mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Remove the invisible format marks from the text chunks
- it aims to fix issue #9186.
This commit is contained in:
parent
88236e1163
commit
e1d3a3b414
7 changed files with 99 additions and 14 deletions
|
@ -2561,6 +2561,9 @@ class PartialEvaluator {
|
|||
|
||||
for (let i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
const glyph = glyphs[i];
|
||||
if (glyph.isInvisibleFormatMark) {
|
||||
continue;
|
||||
}
|
||||
let charSpacing =
|
||||
textState.charSpacing + (i + 1 === ii ? extraSpacing : 0);
|
||||
|
||||
|
@ -2601,7 +2604,7 @@ class PartialEvaluator {
|
|||
// Must be called after compareWithLastPosition because
|
||||
// the textContentItem could have been flushed.
|
||||
const textChunk = ensureTextContentItem();
|
||||
if (glyph.isDiacritic) {
|
||||
if (glyph.isZeroWidthDiacritic) {
|
||||
scaledDim = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,8 @@ class Glyph {
|
|||
|
||||
const category = getCharUnicodeCategory(unicode);
|
||||
this.isWhitespace = category.isWhitespace;
|
||||
this.isDiacritic = category.isDiacritic;
|
||||
this.isZeroWidthDiacritic = category.isZeroWidthDiacritic;
|
||||
this.isInvisibleFormatMark = category.isInvisibleFormatMark;
|
||||
}
|
||||
|
||||
matchesForCache(
|
||||
|
|
|
@ -1640,12 +1640,13 @@ function reverseIfRtl(chars) {
|
|||
return buf.join("");
|
||||
}
|
||||
|
||||
const SpecialCharRegExp = new RegExp("^(\\s)|(\\p{Mn})$", "u");
|
||||
const SpecialCharRegExp = new RegExp("^(\\s)|(\\p{Mn})|(\\p{Cf})$", "u");
|
||||
function getCharUnicodeCategory(char) {
|
||||
const groups = char.match(SpecialCharRegExp);
|
||||
return {
|
||||
isWhitespace: !!(groups && groups[1]),
|
||||
isDiacritic: !!(groups && groups[2]),
|
||||
isZeroWidthDiacritic: !!(groups && groups[2]),
|
||||
isInvisibleFormatMark: !!(groups && groups[3]),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue