restructure fonts data (and update schema)

so we can find data about a font more easily
This commit is contained in:
Koen Lageveen 2019-06-10 11:04:48 +02:00
parent 86255405bb
commit 408a13e47c
3 changed files with 1056 additions and 917 deletions

View File

@ -1,50 +1,58 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type":"array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"alias": {
"type":"string",
"pattern": "^[a-z][a-z0-9-]+$"
},
"name": { "type":"string" },
"author": { "type":"string" },
"description": { "type":"string" },
"year": { "type":"integer" },
"website": {
"type":"string",
"format":"uri"
},
"ligatures": { "type":"boolean" },
"style": {
"type":"string",
"enum": ["serif", "sans"]
},
"rendering": {
"type":"string",
"enum": ["bitmap", "vector"]
},
"variants": {
"type":"array",
"items": {
"type": "string",
"pattern": "^[a-z-]+$"
},
"minItems": 1
}
},
"additionalProperties": false,
"required": [
"alias",
"name",
"author",
"year",
"website",
"ligatures",
"style",
"rendering"
]
}
"$schema": "http://json-schema.org/draft-07/schema#",
"type":"object",
"patternProperties": {
"^[a-z-]*$": {
"$ref": "#/definitions/font"
}
},
"definitions": {
"font": {
"type": "object",
"properties": {
"alias": {
"type":"string",
"pattern": "^[a-z][a-z0-9-]+$"
},
"name": { "type":"string" },
"author": { "type":"string" },
"description": { "type":"string" },
"year": { "type":"integer" },
"website": {
"type":"string",
"format":"uri"
},
"license": { "type":"string" },
"ligatures": { "type":"boolean" },
"style": {
"type":"string",
"enum": ["serif", "sans"]
},
"rendering": {
"type":"string",
"enum": ["bitmap", "vector"]
},
"variants": {
"type":"array",
"items": {
"type": "string",
"pattern": "^([a-z-]+|\\d00)$"
},
"minItems": 1
}
},
"additionalProperties": false,
"required": [
"name",
"author",
"year",
"website",
"ligatures",
"style",
"rendering"
]
}
}
}

1851
fonts.json

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,8 @@ var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
// CodeMirror theme selector
var input = document.getElementById('select-theme');
var font_data = {};
function selectTheme() {
var theme = 'monokai';
@ -31,6 +33,8 @@ function selectFont() {
font = 'input';
}
console.log(font_data[font]);
if (font === 'input') {
$('pre').css({ fontFamily: 'Input Mono, monospace' });
$('textarea').css({ fontFamily: 'Input Mono, monospace' });
@ -96,14 +100,24 @@ function renderSelectList() {
}
$.getJSON('fonts.json', function(data) {
data.sort(function(a, b) {
var fonts = [];
font_data = data;
$.each(font_data, function(k, v) {
var font_props = v;
font_props.alias = k;
fonts.push(v);
});
fonts.sort(function(a, b) {
if (favoritesMap[a.alias] && !favoritesMap[b.alias]) {return -1;}
if (!favoritesMap[a.alias] && favoritesMap[b.alias]) {return 1;}
if (a.name.toLowerCase() < b.name.toLowerCase()) {return -1;}
if (a.name.toLowerCase() > b.name.toLowerCase()) {return 1;}
return 0;
});
$.each(data, function(k, v) {
$.each(fonts, function(k, v) {
var liga_info = '';
var render_info = '';