Browse Source

Merge pull request #2167 from jviereck/textLayer-whitespaces

Tune whitespace insertion
Yury Delendik 13 years ago
parent
commit
5cf5ef357f
  1. 11
      src/evaluator.js

11
src/evaluator.js

@ -510,6 +510,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
getTextContent: function partialEvaluatorGetIRQueue( getTextContent: function partialEvaluatorGetIRQueue(
stream, resources, state) { stream, resources, state) {
var bidiTexts; var bidiTexts;
var kSpaceFactor = 0.35;
var kMultipleSpaceFactor = 1.5;
if (!state) { if (!state) {
bidiTexts = []; bidiTexts = [];
@ -551,8 +553,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
if (typeof items[j] === 'string') { if (typeof items[j] === 'string') {
chunk += fontCharsToUnicode(items[j], font); chunk += fontCharsToUnicode(items[j], font);
} else if (items[j] < 0 && font.spaceWidth > 0) { } else if (items[j] < 0 && font.spaceWidth > 0) {
var numFakeSpaces = Math.round(-items[j] / font.spaceWidth); var fakeSpaces = -items[j] / font.spaceWidth;
if (numFakeSpaces > 0) { if (fakeSpaces > kMultipleSpaceFactor) {
fakeSpaces = Math.round(fakeSpaces);
while (fakeSpaces--) {
chunk += ' ';
}
} else if (fakeSpaces > kSpaceFactor) {
chunk += ' '; chunk += ' ';
} }
} }

Loading…
Cancel
Save