diff --git a/lib/font/afm.js b/lib/font/afm.js index 610f381..ee5fd28 100644 --- a/lib/font/afm.js +++ b/lib/font/afm.js @@ -103,14 +103,16 @@ udieresis yacute thorn ydieresis\ `.split(/\s+/); class AFMFont { + /** + * @param {string} contents + */ constructor(contents) { - this.contents = contents; this.attributes = {}; this.glyphWidths = {}; this.boundingBoxes = {}; this.kernPairs = {}; - this.parse(); + this.parse(contents); this.bbox = this.attributes['FontBBox'].split(/\s+/).map((e) => +e); this.ascender = +(this.attributes['Ascender'] || 0); @@ -121,9 +123,12 @@ class AFMFont { this.bbox[3] - this.bbox[1] - (this.ascender - this.descender); } - parse() { + /** + * @param {string} contents + */ + parse(contents) { let section = ''; - for (let line of this.contents.split('\n')) { + for (let line of contents.split('\n')) { var match; var a; if ((match = line.match(/^Start(\w+)/))) { @@ -168,6 +173,10 @@ class AFMFont { } } + /** + * @param {string} text + * @returns + */ encodeText(text) { const res = []; for (let i = 0, len = text.length; i < len; i++) {