mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
Add a build step to generate extended metrics that additionally contain glyph widths
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
This commit is contained in:
@@ -87,22 +87,25 @@ def main():
|
||||
continue
|
||||
name = names.pop()
|
||||
|
||||
height = depth = italic = skew = 0
|
||||
height = depth = italic = skew = width = 0
|
||||
glyph = glyf[name]
|
||||
if glyph.numberOfContours:
|
||||
height = glyph.yMax
|
||||
depth = -glyph.yMin
|
||||
width = glyph.xMax - glyph.xMin
|
||||
if base_char:
|
||||
base_char_str = str(ord(base_char))
|
||||
base_metrics = start_json[font][base_char_str]
|
||||
italic = base_metrics["italic"]
|
||||
skew = base_metrics["skew"]
|
||||
width = base_metrics["width"]
|
||||
|
||||
start_json[font][str(code)] = {
|
||||
"height": height / unitsPerEm,
|
||||
"depth": depth / unitsPerEm,
|
||||
"italic": italic,
|
||||
"skew": skew,
|
||||
"width": width
|
||||
}
|
||||
|
||||
sys.stdout.write(
|
||||
|
Reference in New Issue
Block a user