Skip to content

Commit c9cb51c

Browse files
committed
Rename "Symbol"-named embedded fonts to avoid Windows substitution
Edge on Windows substitutes the system Symbol font for any embedded font whose name table identifies it as "Symbol"/"SymbolMT", ignoring the embedded glyphs and mis-rendering e.g. the bullet character as Greek xi.
1 parent 1cb14a0 commit c9cb51c

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/core/fonts.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3187,9 +3187,23 @@ class Font {
31873187
} else {
31883188
// ... using existing 'name' table as prototype
31893189
const [namePrototype, nameRecords] = readNameTable(tables.name);
3190+
this.psName = namePrototype[0][6] || null;
3191+
3192+
// Edge on Windows substitutes the system Symbol font for any embedded
3193+
// font whose name table identifies it as "Symbol"/"SymbolMT", ignoring
3194+
// the embedded glyphs. Overwrite the family/full/PostScript name
3195+
// entries with the unique `loadedName` so the regenerated name table
3196+
// cannot collide with the system font, mirroring what Firefox does for
3197+
// downloadable @font-face fonts (gfxFontUtils::RenameFont).
3198+
const family = namePrototype[1][1] || namePrototype[0][1] || "";
3199+
if (/^symbol/i.test(family) || /^symbol/i.test(this.psName || "")) {
3200+
for (const id of [1, 4, 6]) {
3201+
namePrototype[0][id] = this.loadedName;
3202+
namePrototype[1][id] = this.loadedName;
3203+
}
3204+
}
31903205

31913206
tables.name.data = createNameTable(name, namePrototype);
3192-
this.psName = namePrototype[0][6] || null;
31933207

31943208
if (!properties.composite) {
31953209
// For TrueType fonts that do not include `ToUnicode` or `Encoding`

0 commit comments

Comments
 (0)