diff options
author | Roozbeh Pournader <roozbeh@google.com> | 2015-01-07 11:45:20 -0800 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk@google.com> | 2015-04-16 12:16:24 -0700 |
commit | 0fd852f5cb306362f44a89686356bbad47da93d9 (patch) | |
tree | 7c0359d0194316428510020d5333f6fb8d089ca8 /scripts/layout.py | |
parent | 94a70f1b9f0407dfe335f70dbfd3a73bbb26afc0 (diff) |
Move get_advances to a new layout module.
Diffstat (limited to 'scripts/layout.py')
-rw-r--r-- | scripts/layout.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/layout.py b/scripts/layout.py new file mode 100644 index 0000000..fbcaa82 --- /dev/null +++ b/scripts/layout.py @@ -0,0 +1,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 + |