Merge pull request #5898 from stri8ed/master

Extract more accurate glyph heights from type3 fonts
This commit is contained in:
Tim van der Meij 2015-05-13 21:07:17 +02:00
commit b34366d2fc
2 changed files with 13 additions and 0 deletions

View File

@ -956,6 +956,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var tsm = [textState.fontSize * textState.textHScale, 0,
0, textState.fontSize,
0, textState.textRise];
if (font.isType3Font &&
textState.fontMatrix !== FONT_IDENTITY_MATRIX &&
textState.fontSize === 1) {
var glyphHeight = font.bbox[3] - font.bbox[1];
if (glyphHeight > 0) {
glyphHeight = glyphHeight * textState.fontMatrix[3];
tsm[3] *= glyphHeight;
}
}
var trm = textChunk.transform = Util.transform(textState.ctm,
Util.transform(textState.textMatrix, tsm));
if (!font.vertical) {
@ -1639,6 +1650,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// is a tagged pdf. Create a barbebones one to get by.
descriptor = new Dict(null);
descriptor.set('FontName', Name.get(type));
descriptor.set('FontBBox', dict.get('FontBBox'));
} else {
// Before PDF 1.5 if the font was one of the base 14 fonts, having a
// FontDescriptor was not required.

View File

@ -2438,6 +2438,7 @@ var Font = (function FontClosure() {
this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
this.fontMatrix = properties.fontMatrix;
this.bbox = properties.bbox;
this.toUnicode = properties.toUnicode = this.buildToUnicode(properties);