Browse Source

Fix for descent calculation while reading font hhea headers

Preetham Mysore 9 years ago
parent
commit
be1e12dbcb
  1. 9
      src/core/fonts.js
  2. 1
      test/pdfs/.gitignore
  3. BIN
      test/pdfs/zero_descent.pdf
  4. 8
      test/test_manifest.json

9
src/core/fonts.js

@ -723,6 +723,11 @@ var Font = (function FontClosure() {
return (b0 << 8) + b1; return (b0 << 8) + b1;
} }
function signedInt16(b0, b1) {
var value = (b0 << 8) + b1;
return value & (1 << 15) ? value - 0x10000 : value;
}
function int32(b0, b1, b2, b3) { function int32(b0, b1, b2, b3) {
return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3; return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
} }
@ -2240,9 +2245,9 @@ var Font = (function FontClosure() {
var metricsOverride = { var metricsOverride = {
unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]), unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
yMax: int16(tables['head'].data[42], tables['head'].data[43]), yMax: int16(tables['head'].data[42], tables['head'].data[43]),
yMin: int16(tables['head'].data[38], tables['head'].data[39]) - 0x10000, yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]), ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
descent: int16(tables['hhea'].data[6], tables['hhea'].data[7]) - 0x10000 descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
}; };
// PDF FontDescriptor metrics lie -- using data from actual font. // PDF FontDescriptor metrics lie -- using data from actual font.

1
test/pdfs/.gitignore vendored

@ -222,3 +222,4 @@
!annotation-squiggly.pdf !annotation-squiggly.pdf
!annotation-highlight.pdf !annotation-highlight.pdf
!annotation-fileattachment.pdf !annotation-fileattachment.pdf
!zero_descent.pdf

BIN
test/pdfs/zero_descent.pdf

Binary file not shown.

8
test/test_manifest.json

@ -2823,5 +2823,13 @@
"rounds": 1, "rounds": 1,
"lastPage": 1, "lastPage": 1,
"type": "load" "type": "load"
},
{ "id": "zero_descent",
"file": "pdfs/zero_descent.pdf",
"md5": "32805ab28be1d0e91d27d9742c66eccf",
"link": false,
"rounds": 1,
"lastPage": 1,
"type": "text"
} }
] ]

Loading…
Cancel
Save