mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 10:15:37 +02:00
Refactor text extraction / font loading logic
This commit is contained in:
parent
6fc70bb2a7
commit
e086cf36f4
4 changed files with 98 additions and 144 deletions
|
@ -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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue