Merge pull request #15657 from Snuffleupagus/Glyph-normalizedUnicode
Cache the normalized unicode-value on the `Glyph`-instance
This commit is contained in:
commit
26f6f77db6
@ -51,11 +51,6 @@ import {
|
|||||||
getStdFontMap,
|
getStdFontMap,
|
||||||
getSymbolsFonts,
|
getSymbolsFonts,
|
||||||
} from "./standard_fonts.js";
|
} from "./standard_fonts.js";
|
||||||
import {
|
|
||||||
getNormalizedUnicodes,
|
|
||||||
getUnicodeForGlyph,
|
|
||||||
reverseIfRtl,
|
|
||||||
} from "./unicode.js";
|
|
||||||
import { getTilingPatternIR, Pattern } from "./pattern.js";
|
import { getTilingPatternIR, Pattern } from "./pattern.js";
|
||||||
import { getXfaFontDict, getXfaFontName } from "./xfa_fonts.js";
|
import { getXfaFontDict, getXfaFontName } from "./xfa_fonts.js";
|
||||||
import { IdentityToUnicodeMap, ToUnicodeMap } from "./to_unicode_map.js";
|
import { IdentityToUnicodeMap, ToUnicodeMap } from "./to_unicode_map.js";
|
||||||
@ -75,6 +70,7 @@ import { DecodeStream } from "./decode_stream.js";
|
|||||||
import { getGlyphsUnicode } from "./glyphlist.js";
|
import { getGlyphsUnicode } from "./glyphlist.js";
|
||||||
import { getLookupTableFactory } from "./core_utils.js";
|
import { getLookupTableFactory } from "./core_utils.js";
|
||||||
import { getMetrics } from "./metrics.js";
|
import { getMetrics } from "./metrics.js";
|
||||||
|
import { getUnicodeForGlyph } from "./unicode.js";
|
||||||
import { MurmurHash3_64 } from "../shared/murmurhash3.js";
|
import { MurmurHash3_64 } from "../shared/murmurhash3.js";
|
||||||
import { OperatorList } from "./operator_list.js";
|
import { OperatorList } from "./operator_list.js";
|
||||||
import { PDFImage } from "./image.js";
|
import { PDFImage } from "./image.js";
|
||||||
@ -2293,7 +2289,6 @@ class PartialEvaluator {
|
|||||||
if (includeMarkedContent) {
|
if (includeMarkedContent) {
|
||||||
markedContentData = markedContentData || { level: 0 };
|
markedContentData = markedContentData || { level: 0 };
|
||||||
}
|
}
|
||||||
const NormalizedUnicodes = getNormalizedUnicodes();
|
|
||||||
|
|
||||||
const textContent = {
|
const textContent = {
|
||||||
items: [],
|
items: [],
|
||||||
@ -2839,9 +2834,7 @@ class PartialEvaluator {
|
|||||||
textChunk.prevTransform = getCurrentTextTransform();
|
textChunk.prevTransform = getCurrentTextTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
let glyphUnicode = glyph.unicode;
|
const glyphUnicode = glyph.normalizedUnicode;
|
||||||
glyphUnicode = NormalizedUnicodes[glyphUnicode] || glyphUnicode;
|
|
||||||
glyphUnicode = reverseIfRtl(glyphUnicode);
|
|
||||||
if (saveLastChar(glyphUnicode)) {
|
if (saveLastChar(glyphUnicode)) {
|
||||||
// The two last chars are a non-whitespace followed by a whitespace
|
// The two last chars are a non-whitespace followed by a whitespace
|
||||||
// and then this non-whitespace, so we insert a whitespace here.
|
// and then this non-whitespace, so we insert a whitespace here.
|
||||||
|
@ -35,9 +35,11 @@ import {
|
|||||||
} from "./fonts_utils.js";
|
} from "./fonts_utils.js";
|
||||||
import {
|
import {
|
||||||
getCharUnicodeCategory,
|
getCharUnicodeCategory,
|
||||||
|
getNormalizedUnicodes,
|
||||||
getUnicodeForGlyph,
|
getUnicodeForGlyph,
|
||||||
getUnicodeRangeFor,
|
getUnicodeRangeFor,
|
||||||
mapSpecialUnicodeValues,
|
mapSpecialUnicodeValues,
|
||||||
|
reverseIfRtl,
|
||||||
} from "./unicode.js";
|
} from "./unicode.js";
|
||||||
import { getDingbatsGlyphsUnicode, getGlyphsUnicode } from "./glyphlist.js";
|
import { getDingbatsGlyphsUnicode, getGlyphsUnicode } from "./glyphlist.js";
|
||||||
import {
|
import {
|
||||||
@ -218,6 +220,24 @@ class Glyph {
|
|||||||
this.isZeroWidthDiacritic = category.isZeroWidthDiacritic;
|
this.isZeroWidthDiacritic = category.isZeroWidthDiacritic;
|
||||||
this.isInvisibleFormatMark = category.isInvisibleFormatMark;
|
this.isInvisibleFormatMark = category.isInvisibleFormatMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property, which is only used by `PartialEvaluator.getTextContent`,
|
||||||
|
* is purposely made non-serializable.
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
get normalizedUnicode() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"normalizedUnicode",
|
||||||
|
reverseIfRtl(Glyph._NormalizedUnicodes[this.unicode] || this.unicode),
|
||||||
|
/* nonSerializable = */ true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static get _NormalizedUnicodes() {
|
||||||
|
return shadow(this, "_NormalizedUnicodes", getNormalizedUnicodes());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function int16(b0, b1) {
|
function int16(b0, b1) {
|
||||||
|
@ -498,7 +498,7 @@ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shadow(obj, prop, value) {
|
function shadow(obj, prop, value, nonSerializable = false) {
|
||||||
if (
|
if (
|
||||||
typeof PDFJSDev === "undefined" ||
|
typeof PDFJSDev === "undefined" ||
|
||||||
PDFJSDev.test("!PRODUCTION || TESTING")
|
PDFJSDev.test("!PRODUCTION || TESTING")
|
||||||
@ -510,7 +510,7 @@ function shadow(obj, prop, value) {
|
|||||||
}
|
}
|
||||||
Object.defineProperty(obj, prop, {
|
Object.defineProperty(obj, prop, {
|
||||||
value,
|
value,
|
||||||
enumerable: true,
|
enumerable: !nonSerializable,
|
||||||
configurable: true,
|
configurable: true,
|
||||||
writable: false,
|
writable: false,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user