| 4353 | |
| 4354 | // Parse the coordinate data for a glyph. |
| 4355 | function parseGlyphCoordinate(p, flag, previousValue, shortVectorBitMask, sameBitMask) { |
| 4356 | var v; |
| 4357 | if ((flag & shortVectorBitMask) > 0) { |
| 4358 | // The coordinate is 1 byte long. |
| 4359 | v = p.parseByte(); |
| 4360 | // The `same` bit is re-used for short values to signify the sign of the value. |
| 4361 | if ((flag & sameBitMask) === 0) { |
| 4362 | v = -v; |
| 4363 | } |
| 4364 | |
| 4365 | v = previousValue + v; |
| 4366 | } else { |
| 4367 | // The coordinate is 2 bytes long. |
| 4368 | // If the `same` bit is set, the coordinate is the same as the previous coordinate. |
| 4369 | if ((flag & sameBitMask) > 0) { |
| 4370 | v = previousValue; |
| 4371 | } else { |
| 4372 | // Parse the coordinate as a signed 16-bit delta value. |
| 4373 | v = previousValue + p.parseShort(); |
| 4374 | } |
| 4375 | } |
| 4376 | |
| 4377 | return v; |
| 4378 | } |
| 4379 | |
| 4380 | // Parse a TrueType glyph. |
| 4381 | function parseGlyph(glyph, data, start) { |