1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Fixing Type3 text layer creation and character spacing

This commit is contained in:
notmasteryet 2011-12-12 21:32:20 -06:00
parent f56363234f
commit bed87284db
2 changed files with 58 additions and 26 deletions

View file

@ -2101,6 +2101,37 @@ var Font = (function FontClosure() {
return rule;
},
get spaceWidth() {
// trying to estimate space character width
var possibleSpaceReplacements = ['space', 'minus', '1', 'i'];
var width;
for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
var glyphName = possibleSpaceReplacements[i];
// if possible, getting width by glyph name
if (glyphName in this.widths) {
width = this.widths[glyphName];
break;
}
var glyphUnicode = GlyphsUnicode[glyphName];
// finding the charcode via unicodeToCID map
var charcode = 0;
if (this.composite)
charcode = this.unicodeToCID[glyphUnicode];
// ... via toUnicode map
if (!charcode && 'toUnicode' in this)
charcode = this.toUnicode.indexOf(glyphUnicode);
// setting it to unicode if negative or undefined
if (!(charcode > 0))
charcode = glyphUnicode;
// trying to get width via charcode
width = this.widths[charcode];
if (width)
break; // the non-zero width found
}
width = (width || this.defaultWidth) * this.widthMultiplier;
return shadow(this, 'spaceWidth', width);
},
charToGlyph: function fonts_charToGlyph(charcode) {
var unicode, width, codeIRQueue;