MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / parseCFFCharset

Function parseCFFCharset

libraries/p5.js:3174–3213  ·  view source on GitHub ↗
(data, start, nGlyphs, strings)

Source from the content-addressed store, hash-verified

3172// This function will return a list of glyph names.
3173// See Adobe TN #5176 chapter 13, "Charsets".
3174function parseCFFCharset(data, start, nGlyphs, strings) {
3175 var i;
3176 var sid;
3177 var count;
3178 var parser = new parse.Parser(data, start);
3179
3180 // The .notdef glyph is not included, so subtract 1.
3181 nGlyphs -= 1;
3182 var charset = ['.notdef'];
3183
3184 var format = parser.parseCard8();
3185 if (format === 0) {
3186 for (i = 0; i < nGlyphs; i += 1) {
3187 sid = parser.parseSID();
3188 charset.push(getCFFString(strings, sid));
3189 }
3190 } else if (format === 1) {
3191 while (charset.length <= nGlyphs) {
3192 sid = parser.parseSID();
3193 count = parser.parseCard8();
3194 for (i = 0; i <= count; i += 1) {
3195 charset.push(getCFFString(strings, sid));
3196 sid += 1;
3197 }
3198 }
3199 } else if (format === 2) {
3200 while (charset.length <= nGlyphs) {
3201 sid = parser.parseSID();
3202 count = parser.parseCard16();
3203 for (i = 0; i <= count; i += 1) {
3204 charset.push(getCFFString(strings, sid));
3205 sid += 1;
3206 }
3207 }
3208 } else {
3209 throw new Error('Unknown charset format ' + format);
3210 }
3211
3212 return charset;
3213}
3214
3215// Parse the CFF encoding data. Only one encoding can be specified per font.
3216// See Adobe TN #5176 chapter 12, "Encodings".

Callers 1

parseCFFTableFunction · 0.85

Calls 1

getCFFStringFunction · 0.85

Tested by

no test coverage detected