Use an array of values instead of object literals to save space in fontMetricsData.js
Test Plan: make test Reviewers: emily
This commit is contained in:
parent
fdbdb28617
commit
6a10237017
|
@ -6,11 +6,17 @@ import json
|
||||||
data = json.load(sys.stdin)
|
data = json.load(sys.stdin)
|
||||||
sep = "module.exports = {\n"
|
sep = "module.exports = {\n"
|
||||||
for font in sorted(data):
|
for font in sorted(data):
|
||||||
sys.stdout.write(sep + json.dumps(font))
|
sys.stdout.write(sep + json.dumps(font))
|
||||||
sep = ": {\n "
|
sep = ": {\n "
|
||||||
for glyph in sorted(data[font], key=int):
|
for glyph in sorted(data[font], key=int):
|
||||||
sys.stdout.write(sep + json.dumps(glyph) + ": ")
|
sys.stdout.write(sep + json.dumps(glyph) + ": ")
|
||||||
sys.stdout.write(json.dumps(data[font][glyph], sort_keys=True))
|
|
||||||
sep = ",\n "
|
values = [data[font][glyph][key] for key in
|
||||||
sep = "\n},\n"
|
['depth', 'height', 'italic', 'skew']]
|
||||||
sys.stdout.write("\n}};\n");
|
|
||||||
|
values = [value if value != 0.0 else 0 for value in values]
|
||||||
|
|
||||||
|
sys.stdout.write(json.dumps(values))
|
||||||
|
sep = ",\n "
|
||||||
|
sep = "\n},\n"
|
||||||
|
sys.stdout.write("\n}};\n")
|
||||||
|
|
|
@ -122,11 +122,19 @@ var metrics = {
|
||||||
var metricMap = require("./fontMetricsData");
|
var metricMap = require("./fontMetricsData");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is a convience function for looking up information in the
|
* This function is a convenience function for looking up information in the
|
||||||
* metricMap table. It takes a character as a string, and a style
|
* metricMap table. It takes a character as a string, and a style
|
||||||
*/
|
*/
|
||||||
var getCharacterMetrics = function(character, style) {
|
var getCharacterMetrics = function(character, style) {
|
||||||
return metricMap[style][character.charCodeAt(0)];
|
var metrics = metricMap[style][character.charCodeAt(0)];
|
||||||
|
if (metrics) {
|
||||||
|
return {
|
||||||
|
depth: metrics[0],
|
||||||
|
height: metrics[1],
|
||||||
|
italic: metrics[2],
|
||||||
|
skew: metrics[3]
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user