Merge pull request #15665 from Snuffleupagus/Glyph-category
[api-minor] Initialize the unicode-category *lazily* on the `Glyph`-instance
This commit is contained in:
commit
7e5008f0ff
@ -2775,7 +2775,9 @@ class PartialEvaluator {
|
|||||||
|
|
||||||
for (let i = 0, ii = glyphs.length; i < ii; i++) {
|
for (let i = 0, ii = glyphs.length; i < ii; i++) {
|
||||||
const glyph = glyphs[i];
|
const glyph = glyphs[i];
|
||||||
if (glyph.isInvisibleFormatMark) {
|
const { category } = glyph;
|
||||||
|
|
||||||
|
if (category.isInvisibleFormatMark) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let charSpacing =
|
let charSpacing =
|
||||||
@ -2787,7 +2789,7 @@ class PartialEvaluator {
|
|||||||
}
|
}
|
||||||
let scaledDim = glyphWidth * scale;
|
let scaledDim = glyphWidth * scale;
|
||||||
|
|
||||||
if (glyph.isWhitespace) {
|
if (category.isWhitespace) {
|
||||||
// Don't push a " " in the textContentItem
|
// Don't push a " " in the textContentItem
|
||||||
// (except when it's between two non-spaces chars),
|
// (except when it's between two non-spaces chars),
|
||||||
// it will be done (if required) in next call to
|
// it will be done (if required) in next call to
|
||||||
@ -2815,7 +2817,7 @@ class PartialEvaluator {
|
|||||||
// Must be called after compareWithLastPosition because
|
// Must be called after compareWithLastPosition because
|
||||||
// the textContentItem could have been flushed.
|
// the textContentItem could have been flushed.
|
||||||
const textChunk = ensureTextContentItem();
|
const textChunk = ensureTextContentItem();
|
||||||
if (glyph.isZeroWidthDiacritic) {
|
if (category.isZeroWidthDiacritic) {
|
||||||
scaledDim = 0;
|
scaledDim = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,11 +214,20 @@ class Glyph {
|
|||||||
this.operatorListId = operatorListId;
|
this.operatorListId = operatorListId;
|
||||||
this.isSpace = isSpace;
|
this.isSpace = isSpace;
|
||||||
this.isInFont = isInFont;
|
this.isInFont = isInFont;
|
||||||
|
}
|
||||||
|
|
||||||
const category = getCharUnicodeCategory(unicode);
|
/**
|
||||||
this.isWhitespace = category.isWhitespace;
|
* This property, which is only used by `PartialEvaluator.getTextContent`,
|
||||||
this.isZeroWidthDiacritic = category.isZeroWidthDiacritic;
|
* is purposely made non-serializable.
|
||||||
this.isInvisibleFormatMark = category.isInvisibleFormatMark;
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
get category() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"category",
|
||||||
|
getCharUnicodeCategory(this.unicode),
|
||||||
|
/* nonSerializable = */ true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user