mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-24 10:08:00 -06:00
M2: a post table version with swapped halves doesn't make a font unusable (#2946)
Vendored hayro-interpret refuses an embedded font whose `post` table version isn't 1.0, 2.0, 2.5 or 3.0 (a guard from pdf.js issue 9462). ScanSoft PDF Create! writes the version of every font it embeds with its 16-bit halves swapped (`00 00 00 03` for 3.0), so those fonts were refused and their text drawn with a substitute: Hebrew came out as Latin look-alikes or not at all. 1.0, 2.0 and 3.0 with swapped halves are now accepted too; any other unknown version is still refused. PdfCraft patch (38) in vendor/README.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RUNQSPVXx3dDBabRZHAnjz
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ffaf312358
commit
b67a8bf268
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+4
-1
@@ -179,11 +179,14 @@ impl OpenTypeFontBlob {
|
||||
let f = FontRef::from_index(data.as_ref().as_ref(), index).ok()?;
|
||||
// Reject fonts with invalid post table version, fixes pdf.js issue 9462. Not sure if there
|
||||
// is a better fix, for some reason skrifa accepts the font which is completely invalid.
|
||||
// PdfCraft patch: also accept 1.0, 2.0 and 3.0 with the two 16-bit halves swapped
|
||||
// (`00 00 00 03` for 3.0), as ScanSoft PDF Create! writes it into every font it embeds
|
||||
// (#2946). Rejecting those fonts drew their text with a substitute that has no such glyphs.
|
||||
let invalid = f.post().is_ok_and(|p| {
|
||||
!matches!(
|
||||
p.version().to_major_minor(),
|
||||
(1, 0) | (2, 0) | (2, 5) | (3, 0)
|
||||
)
|
||||
) && !matches!(p.version().to_be_bytes(), [0, 0, 0, 1..=3])
|
||||
});
|
||||
|
||||
if invalid {
|
||||
|
||||
Reference in New Issue
Block a user