File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -103,14 +103,16 @@ udieresis yacute thorn ydieresis\
103
103
` . split ( / \s + / ) ;
104
104
105
105
class AFMFont {
106
+ /**
107
+ * @param {string } contents
108
+ */
106
109
constructor ( contents ) {
107
- this . contents = contents ;
108
110
this . attributes = { } ;
109
111
this . glyphWidths = { } ;
110
112
this . boundingBoxes = { } ;
111
113
this . kernPairs = { } ;
112
114
113
- this . parse ( ) ;
115
+ this . parse ( contents ) ;
114
116
115
117
this . bbox = this . attributes [ 'FontBBox' ] . split ( / \s + / ) . map ( ( e ) => + e ) ;
116
118
this . ascender = + ( this . attributes [ 'Ascender' ] || 0 ) ;
@@ -121,9 +123,12 @@ class AFMFont {
121
123
this . bbox [ 3 ] - this . bbox [ 1 ] - ( this . ascender - this . descender ) ;
122
124
}
123
125
124
- parse ( ) {
126
+ /**
127
+ * @param {string } contents
128
+ */
129
+ parse ( contents ) {
125
130
let section = '' ;
126
- for ( let line of this . contents . split ( '\n' ) ) {
131
+ for ( let line of contents . split ( '\n' ) ) {
127
132
var match ;
128
133
var a ;
129
134
if ( ( match = line . match ( / ^ S t a r t ( \w + ) / ) ) ) {
@@ -168,6 +173,10 @@ class AFMFont {
168
173
}
169
174
}
170
175
176
+ /**
177
+ * @param {string } text
178
+ * @returns
179
+ */
171
180
encodeText ( text ) {
172
181
const res = [ ] ;
173
182
for ( let i = 0 , len = text . length ; i < len ; i ++ ) {
You can’t perform that action at this time.
0 commit comments