Skip to content

Commit

Permalink
Offset is used in buildTextGeometry only
Browse files Browse the repository at this point in the history
  • Loading branch information
kalley committed Oct 16, 2015
1 parent d819506 commit 85fa33c
Showing 1 changed file with 7 additions and 30 deletions.
37 changes: 7 additions & 30 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1136,38 +1136,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var prevChar = j > 0 ? items[j - 1] : null;
offset = isNum(prevChar) ? items[j - 1] / 1000 : 0;
buildTextGeometry(items[j], textChunk, offset);
} else {
// PDF Specification 5.3.2 states:
// The number is expressed in thousandths of a unit of text
// space.
// This amount is subtracted from the current horizontal or
// vertical coordinate, depending on the writing mode.
// In the default coordinate system, a positive adjustment
// has the effect of moving the next glyph painted either to
// the left or down by the given amount.
var val = items[j] * textState.fontSize / 1000;
if (textState.font.vertical) {
offset = val * textState.textMatrix[3];
textState.translateTextMatrix(0, offset);
// Value needs to be added to height to paint down.
textChunk.height += offset;
} else {
offset = val * textState.textHScale *
textState.textMatrix[0];
textState.translateTextMatrix(offset, 0);
// Value needs to be subtracted from width to paint left.
textChunk.width -= offset;
}
if (items[j] < 0 && textState.font.spaceWidth > 0) {
var fakeSpaces = -items[j] / textState.font.spaceWidth;
if (fakeSpaces > MULTI_SPACE_FACTOR) {
fakeSpaces = Math.round(fakeSpaces);
while (fakeSpaces--) {
textChunk.str.push(' ');
}
} else if (fakeSpaces > SPACE_FACTOR) {
} else if (items[j] < 0 && textState.font.spaceWidth > 0) {
var fakeSpaces = -items[j] / textState.font.spaceWidth;
if (fakeSpaces > MULTI_SPACE_FACTOR) {
fakeSpaces = Math.round(fakeSpaces);
while (fakeSpaces--) {
textChunk.str.push(' ');
}
} else if (fakeSpaces > SPACE_FACTOR) {
textChunk.str.push(' ');
}
}
}
Expand Down

0 comments on commit 85fa33c

Please sign in to comment.