mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Handle all the whitespaces the same way when creating text chunks
This commit is contained in:
parent
9bb636402a
commit
9dae421a0d
3 changed files with 27 additions and 11 deletions
|
@ -2171,7 +2171,6 @@ class PartialEvaluator {
|
|||
stateManager = stateManager || new StateManager(new TextState());
|
||||
|
||||
const WhitespaceRegexp = /\s/g;
|
||||
const DiacriticRegExp = new RegExp("^\\p{Mn}$", "u");
|
||||
const NormalizedUnicodes = getNormalizedUnicodes();
|
||||
|
||||
const textContent = {
|
||||
|
@ -2572,6 +2571,7 @@ class PartialEvaluator {
|
|||
|
||||
const glyphs = font.charsToGlyphs(chars);
|
||||
const scale = textState.fontMatrix[0] * textState.fontSize;
|
||||
|
||||
for (let i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
const glyph = glyphs[i];
|
||||
let charSpacing =
|
||||
|
@ -2583,13 +2583,12 @@ class PartialEvaluator {
|
|||
}
|
||||
let scaledDim = glyphWidth * scale;
|
||||
|
||||
let glyphUnicode = glyph.unicode;
|
||||
if (
|
||||
glyphUnicode === " " &&
|
||||
glyph.isWhitespace &&
|
||||
(i === 0 ||
|
||||
i + 1 === ii ||
|
||||
glyphs[i - 1].unicode === " " ||
|
||||
glyphs[i + 1].unicode === " " ||
|
||||
glyphs[i - 1].isWhitespace ||
|
||||
glyphs[i + 1].isWhitespace ||
|
||||
extraSpacing)
|
||||
) {
|
||||
// Don't push a " " in the textContentItem
|
||||
|
@ -2612,10 +2611,12 @@ class PartialEvaluator {
|
|||
|
||||
compareWithLastPosition();
|
||||
|
||||
let glyphUnicode = glyph.unicode;
|
||||
|
||||
// Must be called after compareWithLastPosition because
|
||||
// the textContentItem could have been flushed.
|
||||
const textChunk = ensureTextContentItem();
|
||||
if (DiacriticRegExp.test(glyph.unicode)) {
|
||||
if (glyph.isDiacritic) {
|
||||
scaledDim = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue