
Summary: The ability to use pre-determined character widths will benefit alternative layout engines such as gagern's canvas layout engine. I would also like to experiment would using CSS transforms to absolutely position each glyph. This diff adds a new make rule, make extended_metrics, which generates metrics that also containing glyph widths. Test Plan: - run `make extended_metrics` - verify that fontMetricsData.js contains entries with 5 numbers instead of 4 Reviewers: emily alpert
27 lines
689 B
Python
27 lines
689 B
Python
#!/usr/bin/env python
|
|
|
|
import sys
|
|
import json
|
|
|
|
props = ['depth', 'height', 'italic', 'skew']
|
|
|
|
if len(sys.argv) > 1:
|
|
if sys.argv[1] == '--width':
|
|
props.append('width')
|
|
|
|
data = json.load(sys.stdin)
|
|
sep = "module.exports = {\n"
|
|
for font in sorted(data):
|
|
sys.stdout.write(sep + json.dumps(font))
|
|
sep = ": {\n "
|
|
for glyph in sorted(data[font], key=int):
|
|
sys.stdout.write(sep + json.dumps(glyph) + ": ")
|
|
|
|
values = [value if value != 0.0 else 0 for value in
|
|
[data[font][glyph][key] for key in props]]
|
|
|
|
sys.stdout.write(json.dumps(values))
|
|
sep = ",\n "
|
|
sep = "\n},\n"
|
|
sys.stdout.write("\n}};\n")
|