mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-29 15:47:57 +02:00
[api-minor] Initialize the unicode-category *lazily* on the Glyph
-instance
The purpose of this patch is twofold: - Initialize the unicode-category data *lazily* during text-extraction, since this is completely unused during general parsing/rendering. - Stop exposing this data in the API, since it's unused on the main-thread and it seems like it was *accidentally* included. Obviously these changes are API-observable, but hopefully no user is depending on this. Furthermore, it's trivial for a user to re-create this unicode-category data manually with a regular expression (from the exposed `unicode` property).
This commit is contained in:
parent
26f6f77db6
commit
c8868a1c7a
2 changed files with 18 additions and 7 deletions
|
@ -214,11 +214,20 @@ class Glyph {
|
|||
this.operatorListId = operatorListId;
|
||||
this.isSpace = isSpace;
|
||||
this.isInFont = isInFont;
|
||||
}
|
||||
|
||||
const category = getCharUnicodeCategory(unicode);
|
||||
this.isWhitespace = category.isWhitespace;
|
||||
this.isZeroWidthDiacritic = category.isZeroWidthDiacritic;
|
||||
this.isInvisibleFormatMark = category.isInvisibleFormatMark;
|
||||
/**
|
||||
* This property, which is only used by `PartialEvaluator.getTextContent`,
|
||||
* is purposely made non-serializable.
|
||||
* @type {Object}
|
||||
*/
|
||||
get category() {
|
||||
return shadow(
|
||||
this,
|
||||
"category",
|
||||
getCharUnicodeCategory(this.unicode),
|
||||
/* nonSerializable = */ true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue