summaryrefslogtreecommitdiff
path: root/scripts/layout.py
blob: fbcaa823bc319ba58c5d93abd1fe899e83c64538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Test general health of the fonts."""

import json

from nototools import render

_advance_cache = {}
def get_advances(text, font):
    """Get a list of horizontal advances for text rendered in a font."""
    try:
        return _advance_cache[(text, font)]
    except KeyError:
        pass

    hb_output = render.run_harfbuzz_on_text(text, font, None)
    hb_output = json.loads(hb_output)
    advances = [glyph['ax'] for glyph in hb_output]
    _advance_cache[(text, font)] = advances
    return advances