From f9373a8fc5ceed7aae0f99495f744fd5d99c52a0 Mon Sep 17 00:00:00 2001 From: Jannis Klose <69921578+janni1288@users.noreply.github.com> Date: Fri, 24 Jul 2026 08:20:48 +0200 Subject: [PATCH] [FIX] base_fontawesome_web_editor: fix icon to image conversion FontAwesome >= 6.7.2 declares icon glyphs via the --fa custom property instead of the classic content CSS declaration. Odoo core's fontToImg() still expects content: to extract the glyph, causing a crash. Synthesize a content declaration from --fa when present. --- .../static/src/js/wysiwyg/fonts.esm.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/base_fontawesome_web_editor/static/src/js/wysiwyg/fonts.esm.js b/base_fontawesome_web_editor/static/src/js/wysiwyg/fonts.esm.js index 881a78b136a..329d5368ab6 100644 --- a/base_fontawesome_web_editor/static/src/js/wysiwyg/fonts.esm.js +++ b/base_fontawesome_web_editor/static/src/js/wysiwyg/fonts.esm.js @@ -45,9 +45,26 @@ patch(fonts, { data.selector += ", " + match[0]; data.names.push(match[1]); } else { + let css = cssText.replace(/(^.*\{\s*)|(\s*\}\s*$)/g, ""); + // FontAwesome >= 6.7.2 declares the icon's glyph via the --fa + // custom property instead of a classic `content` declaration. + // Odoo core's fontToImg() still parses `content: "..."` to + // extract the glyph, so synthesize one from --fa when it's + // the only declaration available. If the codepoint can't be + // parsed (e.g. unsupported --fa format), skip silently rather + // than crash; that icon just won't be convertible to an image. + if (!/content:/.test(css)) { + const faMatch = css.match(/--fa:\s*["']\\([0-9a-fA-F]+)["']/); + if (faMatch) { + const codePoint = parseInt(faMatch[1], 16); + if (Number.isFinite(codePoint)) { + css += ` content: "${String.fromCodePoint(codePoint)}";`; + } + } + } data = { selector: match[0], - css: cssText.replace(/(^.*\{\s*)|(\s*\}\s*$)/g, ""), + css: css, names: [match[1]], }; }