(font, glyph, code)
| 3248 | // The encoding is described in the Type 2 Charstring Format |
| 3249 | // https://www.microsoft.com/typography/OTSPEC/charstr2.htm |
| 3250 | function parseCFFCharstring(font, glyph, code) { |
| 3251 | var c1x; |
| 3252 | var c1y; |
| 3253 | var c2x; |
| 3254 | var c2y; |
| 3255 | var p = new path.Path(); |
| 3256 | var stack = []; |
| 3257 | var nStems = 0; |
| 3258 | var haveWidth = false; |
| 3259 | var width = font.defaultWidthX; |
| 3260 | var open = false; |
| 3261 | var x = 0; |
| 3262 | var y = 0; |
| 3263 | |
| 3264 | function newContour(x, y) { |
| 3265 | if (open) { |
| 3266 | p.closePath(); |
| 3267 | } |
| 3268 | |
| 3269 | p.moveTo(x, y); |
| 3270 | open = true; |
| 3271 | } |
| 3272 | |
| 3273 | function parseStems() { |
| 3274 | var hasWidthArg; |
| 3275 | |
| 3276 | // The number of stem operators on the stack is always even. |
| 3277 | // If the value is uneven, that means a width is specified. |
| 3278 | hasWidthArg = stack.length % 2 !== 0; |
| 3279 | if (hasWidthArg && !haveWidth) { |
| 3280 | width = stack.shift() + font.nominalWidthX; |
| 3281 | } |
| 3282 | |
| 3283 | nStems += stack.length >> 1; |
| 3284 | stack.length = 0; |
| 3285 | haveWidth = true; |
| 3286 | } |
| 3287 | |
| 3288 | function parse(code) { |
| 3289 | var b1; |
| 3290 | var b2; |
| 3291 | var b3; |
| 3292 | var b4; |
| 3293 | var codeIndex; |
| 3294 | var subrCode; |
| 3295 | var jpx; |
| 3296 | var jpy; |
| 3297 | var c3x; |
| 3298 | var c3y; |
| 3299 | var c4x; |
| 3300 | var c4y; |
| 3301 | |
| 3302 | var i = 0; |
| 3303 | while (i < code.length) { |
| 3304 | var v = code[i]; |
| 3305 | i += 1; |
| 3306 | switch (v) { |
| 3307 | case 1: // hstem |
no test coverage detected