mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
Better spacing in text layer.
This commit is contained in:
parent
bc33ae2fc4
commit
fa46b73c47
3 changed files with 57 additions and 58 deletions
|
@ -1397,16 +1397,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
var x = 0, i;
|
||||
for (i = 0; i < glyphsLength; ++i) {
|
||||
var glyph = glyphs[i];
|
||||
if (glyph === null) {
|
||||
// word break
|
||||
x += fontDirection * wordSpacing;
|
||||
continue;
|
||||
} else if (isNum(glyph)) {
|
||||
if (isNum(glyph)) {
|
||||
x += spacingDir * glyph * fontSize / 1000;
|
||||
continue;
|
||||
}
|
||||
|
||||
var restoreNeeded = false;
|
||||
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
|
||||
var character = glyph.fontChar;
|
||||
var accent = glyph.accent;
|
||||
var scaledX, scaledY, scaledAccentX, scaledAccentY;
|
||||
|
@ -1450,7 +1447,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
}
|
||||
}
|
||||
|
||||
var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
|
||||
var charWidth = width * widthAdvanceScale + spacing * fontDirection;
|
||||
x += charWidth;
|
||||
|
||||
if (restoreNeeded) {
|
||||
|
@ -1495,18 +1492,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
|
||||
for (i = 0; i < glyphsLength; ++i) {
|
||||
glyph = glyphs[i];
|
||||
if (glyph === null) {
|
||||
// word break
|
||||
this.ctx.translate(wordSpacing, 0);
|
||||
current.x += wordSpacing * textHScale;
|
||||
continue;
|
||||
} else if (isNum(glyph)) {
|
||||
if (isNum(glyph)) {
|
||||
spacingLength = spacingDir * glyph * fontSize / 1000;
|
||||
this.ctx.translate(spacingLength, 0);
|
||||
current.x += spacingLength * textHScale;
|
||||
continue;
|
||||
}
|
||||
|
||||
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
|
||||
var operatorList = font.charProcOperatorList[glyph.operatorListId];
|
||||
if (!operatorList) {
|
||||
warn('Type3 character \"' + glyph.operatorListId +
|
||||
|
@ -1521,7 +1514,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
this.restore();
|
||||
|
||||
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
||||
width = transformed[0] * fontSize + charSpacing;
|
||||
width = transformed[0] * fontSize + spacing;
|
||||
|
||||
ctx.translate(width, 0);
|
||||
current.x += width * textHScale;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue