Refactor text extraction / font loading logic

This commit is contained in:
Yury Delendik 2012-09-13 08:09:46 -07:00
parent 6fc70bb2a7
commit e086cf36f4
4 changed files with 98 additions and 144 deletions

View file

@ -782,15 +782,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
x += charWidth;
var glyphUnicode = glyph.unicode === ' ' ? '\u00A0' : glyph.unicode;
var glyphUnicodeLength = glyphUnicode.length;
//reverse an arabic ligature
if (glyphUnicodeLength > 1 &&
isRTLRangeFor(glyphUnicode.charCodeAt(0))) {
for (var ii = glyphUnicodeLength - 1; ii >= 0; ii--)
text.str += glyphUnicode[ii];
} else
text.str += glyphUnicode;
text.length += glyphUnicodeLength;
if (glyphUnicode in NormalizedUnicodes)
glyphUnicode = NormalizedUnicodes[glyphUnicode];
text.str += reverseIfRtl(glyphUnicode);
text.canvasWidth += charWidth;
}
current.x += x * textHScale2;
@ -842,7 +836,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var numFakeSpaces = Math.round(-e / text.geom.spaceWidth);
if (numFakeSpaces > 0) {
text.str += '\u00A0';
text.length++;
}
}
}
@ -856,7 +849,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
text.str += shownText.str;
}
text.canvasWidth += shownText.canvasWidth;
text.length += shownText.length;
}
} else {
error('TJ array element ' + e + ' is not string or num');