Consider a ttf font with both Symbolic and Nonsymbolic flags set with a Differences array in the encoding dict as non-symbolic

It fixes #20232.
This commit is contained in:
Calixte Denizet 2025-09-14 14:46:00 +02:00
parent d77f89026f
commit b6d772d71d
4 changed files with 25 additions and 1 deletions

View File

@ -3661,8 +3661,24 @@ class PartialEvaluator {
if (baseEncodingName) {
properties.defaultEncoding = getEncoding(baseEncodingName);
} else {
const isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
let isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
const isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
// The PDF specs state that the flags Symbolic and Nonsymbolic must be
// mutually exclusive. However, some fonts are marked as both.
// In that case we ignore the Symbolic flag when there is a Differences
// entry (which indicates that the font is used as a non-symbolic
// font).
if (
properties.type === "TrueType" &&
isSymbolicFont &&
isNonsymbolicFont &&
differences.length !== 0
) {
properties.flags &= ~FontFlags.Symbolic;
isSymbolicFont = false;
}
// According to "Table 114" in section "9.6.6.1 General" (under
// "9.6.6 Character Encoding") of the PDF specification, a Nonsymbolic
// font should use the `StandardEncoding` if no encoding is specified.

View File

@ -743,3 +743,4 @@
!tracemonkey_with_editable_annotations.pdf
!bug1980958.pdf
!tracemonkey_annotation_on_page_8.pdf
!issue20232.pdf

BIN
test/pdfs/issue20232.pdf Normal file

Binary file not shown.

View File

@ -13028,5 +13028,12 @@
"md5": "ae4f643ee9bb0fd725277a9d1e0fb1df",
"rounds": 1,
"type": "load"
},
{
"id": "issue20232",
"file": "pdfs/issue20232.pdf",
"md5": "cc53e96a8fd9eafbfbb74de564f37047",
"rounds": 1,
"type": "eq"
}
]