lib/parse/glyf.js
function parseGlyfTable(data, start, loca) {
    var glyphs, i, j, offset, nextOffset, glyph,
        component, componentGlyph, transformedPoints;
    glyphs = [];
    // The last element of the loca table is invalid.
    for (i = 0; i < loca.length - 1; i += 1) {
        offset = loca[i];
        nextOffset = loca[i + 1];
//        console.log('pg: ', offset, nextOffset);
        if (offset !== nextOffset) {
            glyphs.push(parseGlyph(data,  i, start + offset));
        } else {
            glyphs.push(new Glyph(i));
        }
    }
//    console.log(start);
    // Go over the glyphs again, resolving the composite glyphs.
    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);
                    glyph.points = glyph.points.concat(transformedPoints);
                }
            }
        }
        glyph.path = getPath(glyph.points);
    }
    return glyphs;
}
function parseGlyfTable(data, start, loca) {
    var glyphs, i, j, offset, nextOffset, glyph,
        component, componentGlyph, transformedPoints;
    glyphs = [];
    // The last element of the loca table is invalid.
    for (i = 0; i < loca.length - 1; i += 1) {
        offset = loca[i];
        nextOffset = loca[i + 1];
//        console.log('pg: ', offset, nextOffset);
        if (offset !== nextOffset) {
            glyphs.push(parseGlyph(data,  i, start + offset));
        } else {
            glyphs.push(new Glyph(i));
        }
    }
//    console.log(start);
    // Go over the glyphs again, resolving the composite glyphs.
    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);
                    glyph.points = glyph.points.concat(transformedPoints);
                }
            }
        }
        glyph.path = getPath(glyph.points);
    }
    return glyphs;
}
function parseGlyfTable ( data , start , loca ) { var glyphs , i , j , offset , nextOffset , glyph , component , componentGlyph , transformedPoints ; glyphs = [ ] ; // The last element of the loca table is invalid. for ( i = 0 ; i < loca . length - 1 ; i += 1 ) { offset = loca [ i ] ; nextOffset = loca [ i + 1 ] ; //        console.log('pg: ', offset, nextOffset); if ( offset !== nextOffset ) { glyphs . push ( parseGlyph ( data , i , start + offset ) ) ; } else { glyphs . push ( new Glyph ( i ) ) ; } } //    console.log(start); // Go over the glyphs again, resolving the composite glyphs. 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 ) ; glyph . points = glyph . points . concat ( transformedPoints ) ; } } } glyph . path = getPath ( glyph . points ) ; } 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 .