metricsForChar function

dynamic metricsForChar(
  1. dynamic font,
  2. dynamic chars,
  3. dynamic notFoundMetrics
)

Implementation

function metricsForChar(font, chars, notFoundMetrics) {
    for (let i = 0; i < chars.length; i += 1) {
        const glyphIndex = font.charToGlyphIndex(chars[i]);
        if (glyphIndex > 0) {
            const glyph = font.glyphs.get(glyphIndex);
            return glyph.getMetrics();
        }
    }

    return notFoundMetrics;
}