app/tools/opentype.js
// Parse all the glyphs according to the offsets from the `loca` table.
Parse all the glyphs according to the offsets from the `loca` table.
Parse all the glyphs according to the offsets from the ` loca ` table .
function parseGlyfTable(data, start, loca, font) {
        var glyphs, i, j, offset, nextOffset, glyph,
            component, componentGlyph, transformedPoints;
        glyphs = [];
        for (i = 0; i < loca.length - 1; i += 1) {
            offset = loca[i];
            nextOffset = loca[i + 1];
            if (offset !== nextOffset) {
                glyphs.push(parseGlyph(data, start + offset, i, font));
            } else {
                glyphs.push(new Glyph(font, i));
            }
        }
        for (i = 0; i < glyphs.length; i += 1) {
            glyph = glyphs[i];
            if (glyph.isComposite) {
                for (j = 0; j < glyph.components.length; j += 1) {
                    component = glyph.components[j];
                    componentGlyph = glyphs[component.glyphIndex];
                    if (componentGlyph.points) {
                        transformedPoints = transformPoints(componentGlyph.points, component.dx, component.dy);
                        glyph.points.push.apply(glyph.points, transformedPoints);
                    }
                }
            }
        }
        return glyphs;
    }
function parseGlyfTable ( data , start , loca , font ) { var glyphs , i , j , offset , nextOffset , glyph , component , componentGlyph , transformedPoints ; glyphs = [ ] ; for ( i = 0 ; i < loca . length - 1 ; i += 1 ) { offset = loca [ i ] ; nextOffset = loca [ i + 1 ] ; if ( offset !== nextOffset ) { glyphs . push ( parseGlyph ( data , start + offset , i , font ) ) ; } else { glyphs . push ( new Glyph ( font , i ) ) ; } } for ( i = 0 ; i < glyphs . length ; i += 1 ) { glyph = glyphs [ i ] ; if ( glyph . isComposite ) { for ( j = 0 ; j < glyph . components . length ; j += 1 ) { component = glyph . components [ j ] ; componentGlyph = glyphs [ component . glyphIndex ] ; if ( componentGlyph . points ) { transformedPoints = transformPoints ( componentGlyph . points , component . dx , component . dy ) ; glyph . points . push . apply ( glyph . points , transformedPoints ) ; } } } } return glyphs ; }
Parse all the glyphs according to the offsets from the `loca` table.
Parse all the glyphs according to the offsets from the ` loca ` table .
// The last element of the loca table is invalid. // Go over the glyphs again, resolving the composite glyphs.