Skip to content

Commit

Permalink
Bug 1854090 - Omit psnames of fonts with family-name *.tmp from src:l…
Browse files Browse the repository at this point in the history
…ocal() lookups on Windows. r=jwatt, a=dsmith

This is a sad hack, but aims to work around the issue that some
PDF-related software (Acrobat is suspected but not currently confirmed)
is potentially polluting the global font collection with re-encoded
subsets of standard fonts like Arial, but does not munge the psname;
these can then be returned by src:local(...) lookups, which results in
garbled or missing text.

In principle, if such fonts are "installed", Firefox is not wrong to use
them; it's just a badly-configured system. But given that it seems to be
caused by some PDF-handling software, without the user's knowledge, it
seems worth trying to avoid the problem. Simply skipping the psname of
any font with family-name *.tmp is highly unlikely to adversely affect
any real-world content.

Differential Revision: https://phabricator.services.mozilla.com/D191639
  • Loading branch information
jfkthame committed Oct 23, 2023
1 parent 6b31dc6 commit 2bb7ac9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions gfx/thebes/gfxDWriteFontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,11 +1499,18 @@ void gfxDWriteFontList::ReadFaceNamesForFamily(
}

nsAutoCString psname, fullname;
if (NS_SUCCEEDED(gfxFontUtils::ReadCanonicalName(
data, size, gfxFontUtils::NAME_ID_POSTSCRIPT, psname))) {
ToLowerCase(psname);
mLocalNameTable.InsertOrUpdate(
psname, fontlist::LocalFaceRec::InitData(key, i));
// Bug 1854090: don't load PSname if the family name ends with ".tmp",
// as some PDF-related software appears to pollute the font collection
// with spurious re-encoded versions of standard fonts like Arial, fails
// to alter the PSname, and thus can result in garbled rendering because
// the wrong resource may be found via src:local(...).
if (!StringEndsWith(key, ".tmp"_ns)) {
if (NS_SUCCEEDED(gfxFontUtils::ReadCanonicalName(
data, size, gfxFontUtils::NAME_ID_POSTSCRIPT, psname))) {
ToLowerCase(psname);
mLocalNameTable.InsertOrUpdate(
psname, fontlist::LocalFaceRec::InitData(key, i));
}
}
if (NS_SUCCEEDED(gfxFontUtils::ReadCanonicalName(
data, size, gfxFontUtils::NAME_ID_FULL, fullname))) {
Expand Down

0 comments on commit 2bb7ac9

Please sign in to comment.