Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the unused Font.prototype.spaceWidth getter (PR 13424 follow-up) #18069

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3289,44 +3289,6 @@ class Font {
return builder.toArray();
}

get spaceWidth() {
// trying to estimate space character width
const possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
let width;
for (const glyphName of possibleSpaceReplacements) {
// if possible, getting width by glyph name
if (glyphName in this.widths) {
width = this.widths[glyphName];
break;
}
const glyphsUnicodeMap = getGlyphsUnicode();
const glyphUnicode = glyphsUnicodeMap[glyphName];
// finding the charcode via unicodeToCID map
let charcode = 0;
if (this.composite && this.cMap.contains(glyphUnicode)) {
charcode = this.cMap.lookup(glyphUnicode);

if (typeof charcode === "string") {
charcode = convertCidString(glyphUnicode, charcode);
}
}
// ... via toUnicode map
if (!charcode && this.toUnicode) {
charcode = this.toUnicode.charCodeOf(glyphUnicode);
}
// setting it to unicode if negative or undefined
if (charcode <= 0) {
charcode = glyphUnicode;
}
// trying to get width via charcode
width = this.widths[charcode];
if (width) {
break; // the non-zero width found
}
}
return shadow(this, "spaceWidth", width || this.defaultWidth);
}

/**
* @private
*/
Expand Down