Convert src/core/cff_font.js to use standard classes

This commit is contained in:
Jonas Jenwald 2021-05-02 16:41:45 +02:00
parent 542ee0d798
commit e803584fe7

View File

@ -17,9 +17,8 @@ import { CFFCompiler, CFFParser } from "./cff_parser.js";
import { SEAC_ANALYSIS_ENABLED, type1FontGlyphMapping } from "./fonts_utils.js";
import { warn } from "../shared/util.js";
const CFFFont = (function CFFFontClosure() {
// eslint-disable-next-line no-shadow
function CFFFont(file, properties) {
class CFFFont {
constructor(file, properties) {
this.properties = properties;
const parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
@ -38,14 +37,15 @@ const CFFFont = (function CFFFontClosure() {
this._createBuiltInEncoding();
}
CFFFont.prototype = {
get numGlyphs() {
return this.cff.charStrings.count;
},
getCharset: function CFFFont_getCharset() {
}
getCharset() {
return this.cff.charset.charset;
},
getGlyphMapping: function CFFFont_getGlyphMapping() {
}
getGlyphMapping() {
const cff = this.cff;
const properties = this.properties;
const charsets = cff.charset.charset;
@ -77,10 +77,11 @@ const CFFFont = (function CFFFontClosure() {
const encoding = cff.encoding ? cff.encoding.encoding : null;
charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
return charCodeToGlyphId;
},
hasGlyphId: function CFFFont_hasGlyphID(id) {
}
hasGlyphId(id) {
return this.cff.hasGlyphId(id);
},
}
/**
* @private
@ -106,10 +107,7 @@ const CFFFont = (function CFFFontClosure() {
if (map.length > 0) {
this.properties.builtInEncoding = map;
}
},
};
return CFFFont;
})();
}
}
export { CFFFont };