Merge pull request #21073 from Snuffleupagus/TrueType-table-comments

Move some TrueType header comments to the correct lines
This commit is contained in:
Jonas Jenwald 2026-04-10 15:08:24 +02:00 committed by GitHub
commit cb3f956a11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -332,6 +332,15 @@ function safeString16(value) {
return String.fromCharCode((value >> 8) & 0xff, value & 0xff); return String.fromCharCode((value >> 8) & 0xff, value & 0xff);
} }
function ensureInt16(v) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
typeof v === "number" && Math.abs(v) < 2 ** 16,
`ensureInt16: Unexpected input "${v}".`
);
}
}
function isTrueTypeFile(file) { function isTrueTypeFile(file) {
const header = file.peekBytes(4); const header = file.peekBytes(4);
return ( return (
@ -876,8 +885,8 @@ function createOS2Table(properties, charstrings, override) {
string16(properties.capHeight) + // sCapHeight string16(properties.capHeight) + // sCapHeight
string16(0) + // usDefaultChar string16(0) + // usDefaultChar
string16(firstCharIndex || properties.firstChar) + // usBreakChar string16(firstCharIndex || properties.firstChar) + // usBreakChar
"\x00\x03" "\x00\x03" // usMaxContext
); // usMaxContext );
} }
function createPostTable(properties) { function createPostTable(properties) {
@ -891,8 +900,8 @@ function createPostTable(properties) {
"\x00\x00\x00\x00" + // minMemType42 "\x00\x00\x00\x00" + // minMemType42
"\x00\x00\x00\x00" + // maxMemType42 "\x00\x00\x00\x00" + // maxMemType42
"\x00\x00\x00\x00" + // minMemType1 "\x00\x00\x00\x00" + // minMemType1
"\x00\x00\x00\x00" "\x00\x00\x00\x00" // maxMemType1
); // maxMemType1 );
} }
function createPostscriptName(name) { function createPostscriptName(name) {
@ -3281,8 +3290,8 @@ class Font {
"\x00\x11" + // lowestRecPPEM "\x00\x11" + // lowestRecPPEM
"\x00\x00" + // fontDirectionHint "\x00\x00" + // fontDirectionHint
"\x00\x00" + // indexToLocFormat "\x00\x00" + // indexToLocFormat
"\x00\x00" "\x00\x00" // glyphDataFormat
); // glyphDataFormat );
// Horizontal header // Horizontal header
builder.addTable( builder.addTable(
@ -3303,8 +3312,8 @@ class Font {
"\x00\x00" + // -reserved- "\x00\x00" + // -reserved-
"\x00\x00" + // -reserved- "\x00\x00" + // -reserved-
"\x00\x00" + // metricDataFormat "\x00\x00" + // metricDataFormat
string16(numGlyphs) string16(numGlyphs) // Number of HMetrics
); // Number of HMetrics );
// Horizontal metrics // Horizontal metrics
builder.addTable( builder.addTable(
@ -3324,6 +3333,7 @@ class Font {
} else if (cffWidths) { } else if (cffWidths) {
width = Math.ceil(cffWidths[i] || 0); width = Math.ceil(cffWidths[i] || 0);
} }
ensureInt16(width);
data[pos++] = (width >> 8) & 0xff; data[pos++] = (width >> 8) & 0xff;
data[pos++] = width & 0xff; data[pos++] = width & 0xff;
// Use lsb=0, skip redundant assignment. // Use lsb=0, skip redundant assignment.
@ -3336,8 +3346,9 @@ class Font {
// Maximum profile // Maximum profile
builder.addTable( builder.addTable(
"maxp", "maxp",
"\x00\x00\x50\x00" + string16(numGlyphs) // Version number "\x00\x00\x50\x00" + // Version number
); // Num of glyphs string16(numGlyphs) // Num of glyphs
);
// Naming tables // Naming tables
builder.addTable("name", createNameTable(fontName)); builder.addTable("name", createNameTable(fontName));