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:
Kevin Barabash 2015-09-29 22:16:03 -07:00
parent fdbdb28617
commit 6a10237017
3 changed files with 1742 additions and 1728 deletions

View File

@ -6,11 +6,17 @@ import json
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) + ": ")
sys.stdout.write(json.dumps(data[font][glyph], sort_keys=True))
sep = ",\n "
sep = "\n},\n"
sys.stdout.write("\n}};\n");
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 = [data[font][glyph][key] for key in
['depth', 'height', 'italic', 'skew']]
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")

View File

@ -122,11 +122,19 @@ var metrics = {
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
*/
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 = {

File diff suppressed because it is too large Load Diff