mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Add hasp_font_create.py
This commit is contained in:
parent
ce4df6d810
commit
d5f385eaad
274
src/font/encodings.json
Normal file
274
src/font/encodings.json
Normal file
@ -0,0 +1,274 @@
|
||||
{
|
||||
"ascii": {
|
||||
"cpp": "src/font/ascii/robotocondensed_regular_{}_ascii.cpp",
|
||||
"size": [
|
||||
12,
|
||||
14,
|
||||
16,
|
||||
20,
|
||||
22,
|
||||
24,
|
||||
26,
|
||||
28,
|
||||
32,
|
||||
36,
|
||||
38,
|
||||
40,
|
||||
44,
|
||||
48
|
||||
],
|
||||
"textfont": "src/font/roboto/RobotoCondensed-Regular.ttf",
|
||||
"iconfont": "src/font/materialdesignicons-webfont.ttf",
|
||||
"chars": {
|
||||
"ASCII range": "0x20-0x7E",
|
||||
"Non-breaking space": "0xA0",
|
||||
"Pound sign": "0xA3",
|
||||
"Degree symbol": "0xB0",
|
||||
"Plus-minus sign": "0xB1",
|
||||
"Superscript two": "0xB2",
|
||||
"Superscript three": "0xB3",
|
||||
"Micro sign": "0xB5",
|
||||
"Multiplication sign": "0xD7",
|
||||
"Division sign": "0xF7",
|
||||
"Bullet Symbol": "0x2022",
|
||||
"Euro Symbol": "0x20AC"
|
||||
}
|
||||
},
|
||||
"latin1": {
|
||||
"cpp": "src/font/latin1/robotocondensed_regular_{}_latin1.cpp",
|
||||
"size": [
|
||||
12,
|
||||
14,
|
||||
16,
|
||||
20,
|
||||
22,
|
||||
24,
|
||||
26,
|
||||
28,
|
||||
32,
|
||||
36,
|
||||
38,
|
||||
40,
|
||||
44,
|
||||
48
|
||||
],
|
||||
"textfont": "src/font/roboto/RobotoCondensed-Regular.ttf",
|
||||
"iconfont": "src/font/materialdesignicons-webfont.ttf",
|
||||
"chars": {
|
||||
"ASCII range": "0x20-0x7E",
|
||||
"Non-breaking space": "0xA0",
|
||||
"Inverted exclamation mark": "0xA1",
|
||||
"Pound sign": "0xA3",
|
||||
"Degree symbol": "0xB0",
|
||||
"Plus-minus sign": "0xB1",
|
||||
"Superscript two": "0xB2",
|
||||
"Superscript three": "0xB3",
|
||||
"Micro sign": "0xB5",
|
||||
"Inverted question mark": "0xBF",
|
||||
"Capital A with grave": "0xC0",
|
||||
"Capital A with acute": "0xC1",
|
||||
"Capital A with circumflex": "0xC2",
|
||||
"Capital A with tilde": "0xC3",
|
||||
"Capital A with diaeresis": "0xC4",
|
||||
"Capital A with ring above": "0xC5",
|
||||
"Capital AE": "0xC6",
|
||||
"Capital C with cedilla": "0xC7",
|
||||
"Capital E with grave": "0xC8",
|
||||
"Capital E with acute": "0xC9",
|
||||
"Capital E with circumflex": "0xCA",
|
||||
"Capital E with diaeresis": "0xCB",
|
||||
"Capital I with grave": "0xCC",
|
||||
"Capital I with acute": "0xCD",
|
||||
"Capital I with circumflex": "0xCE",
|
||||
"Capital I with diaeresis": "0xCF",
|
||||
"Capital Eth": "0xD0",
|
||||
"Capital N with tilde": "0xD1",
|
||||
"Capital O with grave": "0xD2",
|
||||
"Capital O with acute": "0xD3",
|
||||
"Capital O with circumflex": "0xD4",
|
||||
"Capital O with tilde": "0xD5",
|
||||
"Capital O with diaeresis": "0xD6",
|
||||
"Multiplication sign": "0xD7",
|
||||
"Capital O with stroke": "0xD8",
|
||||
"Capital U with grave": "0xD9",
|
||||
"Capital U with acute": "0xDA",
|
||||
"Capital U with circumflex": "0xDB",
|
||||
"Capital U with diaeresis": "0xDC",
|
||||
"Capital Y with acute": "0xDD",
|
||||
"Capital Thorn": "0xDE",
|
||||
"Small sharp S": "0xDF",
|
||||
"Small A with grave": "0xE0",
|
||||
"Small A with acute": "0xE1",
|
||||
"Small A with circumflex": "0xE2",
|
||||
"Small A with tilde": "0xE3",
|
||||
"Small A with diaeresis": "0xE4",
|
||||
"Small A with ring above": "0xE5",
|
||||
"Small AE": "0xE6",
|
||||
"Small C with cedilla": "0xE7",
|
||||
"Small E with grave": "0xE8",
|
||||
"Small E with acute": "0xE9",
|
||||
"Small E with circumflex": "0xEA",
|
||||
"Small E with diaeresis": "0xEB",
|
||||
"Small I with grave": "0xEC",
|
||||
"Small I with acute": "0xED",
|
||||
"Small I with circumflex": "0xEE",
|
||||
"Small I with diaeresis": "0xEF",
|
||||
"Small Eth": "0xF0",
|
||||
"Small N with tilde": "0xF1",
|
||||
"Small O with grave": "0xF2",
|
||||
"Small O with acute": "0xF3",
|
||||
"Small O with circumflex": "0xF4",
|
||||
"Small O with tilde": "0xF5",
|
||||
"Small O with diaeresis": "0xF6",
|
||||
"Division sign": "0xF7",
|
||||
"Small O with stroke": "0xF8",
|
||||
"Small U with grave": "0xF9",
|
||||
"Small U with acute": "0xFA",
|
||||
"Small U with circumflex": "0xFB",
|
||||
"Small U with diaeresis": "0xFC",
|
||||
"Small Y with acute": "0xFD",
|
||||
"Small Thorn": "0xFE",
|
||||
"Small Y with diaeresis": "0xFF",
|
||||
"G with breve": "0x011E-0x011F",
|
||||
"Capital I with dot above": "0x0130",
|
||||
"Small dotless I": "0x0131",
|
||||
"Ligature OE": "0x0152-0x0153",
|
||||
"S with cedilla": "0x015E-0x015F",
|
||||
"S with caron": "0x0160-0x0161",
|
||||
"Z with caron": "0x017D-0x017E",
|
||||
"Capital Letter Sharp S": "0x1E9E",
|
||||
"Bullet Symbol": "0x2022",
|
||||
"Euro Symbol": "0x20AC"
|
||||
}
|
||||
},
|
||||
"latin2": {
|
||||
"cpp": "src/font/latin2/robotocondensed_regular_{}_latin2.cpp",
|
||||
"size": [
|
||||
12,
|
||||
14,
|
||||
16,
|
||||
20,
|
||||
22,
|
||||
24,
|
||||
26,
|
||||
28,
|
||||
32,
|
||||
36,
|
||||
38,
|
||||
40,
|
||||
44,
|
||||
48
|
||||
],
|
||||
"textfont": "src/font/roboto/RobotoCondensed-Regular.ttf",
|
||||
"iconfont": "src/font/materialdesignicons-webfont.ttf",
|
||||
"chars": {
|
||||
"ASCII range": "0x20-0x7E",
|
||||
"Non-breaking space": "0xA0",
|
||||
"Pound sign": "0xA3",
|
||||
"Degree symbol": "0xB0",
|
||||
"Plus-minus sign": "0xB1",
|
||||
"Superscript two": "0xB2",
|
||||
"Superscript three": "0xB3",
|
||||
"Micro sign": "0xB5",
|
||||
"Capital A with acute": "0xC1",
|
||||
"Capital A with circumflex": "0xC2",
|
||||
"Capital A with diaeresis": "0x00C4",
|
||||
"Capital E with acute": "0xC9",
|
||||
"Capital E with diaeresis": "0x00CB",
|
||||
"Capital I with acute": "0xCD",
|
||||
"Capital I with circumflex": "0xCE",
|
||||
"Capital O with acute": "0xD3",
|
||||
"Capital O with circumflex": "0x00D4",
|
||||
"Capital O with diaeresis": "0xD6",
|
||||
"Multiplication sign": "0xD7",
|
||||
"Capital U with acute": "0xDA",
|
||||
"Capital U with diaeresis": "0xDC",
|
||||
"Capital Y with acute": "0xDD",
|
||||
"Small A with acute": "0xE1",
|
||||
"Small A with circumflex": "0xE2",
|
||||
"Small A with diaeresis": "0x00E4",
|
||||
"Small E with acute": "0xE9",
|
||||
"Small I with acute": "0xED",
|
||||
"Small I with circumflex": "0xEE",
|
||||
"Small O with acute": "0xF3",
|
||||
"Small O with circumflex": "0x00F4",
|
||||
"Small O with diaeresis": "0xF6",
|
||||
"Division sign": "0xF7",
|
||||
"Small U with acute": "0xFA",
|
||||
"Small U with diaeresis": "0xFC",
|
||||
"Small Y with acute": "0x00FD",
|
||||
"A with breve": "0x0102-0x0103",
|
||||
"A with ogonek": "0x0104-0x0105",
|
||||
"C with acute": "0x0106-0x0107",
|
||||
"C with caron": "0x010C-0x010D",
|
||||
"D with caron": "0x010E-0x010F",
|
||||
"D with stroke": "0x0110-0x0111",
|
||||
"E with breve": "0x0114-0x0115",
|
||||
"E with ogonek": "0x0118-0x0119",
|
||||
"E with caron": "0x011A-0x011B",
|
||||
"L with acute": "0x0139-0x013A",
|
||||
"L with caron": "0x013D-0x013E",
|
||||
"L with stroke": "0x0141-0x0142",
|
||||
"N with acute": "0x0143-0x0144",
|
||||
"N with caron": "0x0147-0x0148",
|
||||
"O with double acute": "0x0150-0x0151",
|
||||
"Capital R with acute": "0x0154-0x0155",
|
||||
"R with caron": "0x0158-0x0159",
|
||||
"S with acute": "0x015A-0x015B",
|
||||
"S with cedilla": "0x015E-0x015F",
|
||||
"S with caron": "0x0160-0x0161",
|
||||
"T with cedilla": "0x0162-0x0163",
|
||||
"T with caron": "0x0164-0X0165",
|
||||
"U with ring above": "0x016E-0x016F",
|
||||
"U with double acute": "0x0170-0x0171",
|
||||
"Z with acute": "0x0179-0x017A",
|
||||
"Z with dot above": "0x017B-0x017C",
|
||||
"Z with caron": "0x017D-0x017E",
|
||||
// "Serbo-Croatian Digraphs": "0x01C4-0x01CC", // Usually written as separate letters
|
||||
"A with Caron": "0x01CD-0x01CE",
|
||||
"HR-SL-RO letters": "0x0200-0x021B",
|
||||
"Bullet Symbol": "0x2022",
|
||||
"Euro Symbol": "0x20AC"
|
||||
}
|
||||
},
|
||||
"cyrillic": {
|
||||
"cpp": "src/font/cyrillic/robotocondensed_regular_{}_cyrillic.cpp",
|
||||
"size": [
|
||||
12,
|
||||
14,
|
||||
16,
|
||||
20,
|
||||
22,
|
||||
24,
|
||||
26,
|
||||
28,
|
||||
32,
|
||||
36,
|
||||
38,
|
||||
40,
|
||||
44,
|
||||
48
|
||||
],
|
||||
"textfont": "src/font/roboto/RobotoCondensed-Regular.ttf",
|
||||
"iconfont": "src/font/materialdesignicons-webfont.ttf",
|
||||
"chars": {
|
||||
"ASCII range": "0x20-0x7E",
|
||||
"Non-breaking space": "0xA0",
|
||||
"Pound sign": "0xA3",
|
||||
"0xA7": "0xA7",
|
||||
"0xAD": "0xAD",
|
||||
"Degree symbol": "0xB0",
|
||||
"Plus-minus sign": "0xB1",
|
||||
"Superscript two": "0xB2",
|
||||
"Superscript three": "0xB3",
|
||||
"Micro sign": "0xB5",
|
||||
"Multiplication sign": "0xD7",
|
||||
"Division sign": "0xF7",
|
||||
"Cyrillic extensions 1": "0x0400-0x040F",
|
||||
"Basic Cyrillic alphabet": "0x0410-0x044F",
|
||||
"Cyrillic extensions 2": "0x0450-0x045F",
|
||||
"Bullet Symbol": "0x2022",
|
||||
"Euro Symbol": "0x20AC"
|
||||
}
|
||||
}
|
||||
}
|
5564
src/font/md-icons.json
Normal file
5564
src/font/md-icons.json
Normal file
File diff suppressed because it is too large
Load Diff
65
tools/hasp_font_create.py
Normal file
65
tools/hasp_font_create.py
Normal file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3.6
|
||||
|
||||
import argparse
|
||||
from argparse import RawTextHelpFormatter
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import jsmin
|
||||
from jsmin import jsmin
|
||||
|
||||
# with open("src/custom/fonts.json") as f:
|
||||
# fonts = json.load(f)
|
||||
# print(fonts)
|
||||
|
||||
with open("src/font/encodings.json") as js_file:
|
||||
minified = jsmin(js_file.read())
|
||||
fonts = json.loads(minified)
|
||||
print(fonts)
|
||||
|
||||
with open("src/font/md-icons.json") as js_file:
|
||||
minified = jsmin(js_file.read())
|
||||
icons = json.loads(minified)
|
||||
print(icons)
|
||||
|
||||
symbol_list = []
|
||||
for (code, desc) in icons["icons"].items():
|
||||
if code != "0":
|
||||
symbol_list.append('"{}"'.format(str(code)))
|
||||
|
||||
symbols = ",".join(symbol_list)
|
||||
print(symbols)
|
||||
|
||||
compr = "--no-kerning"
|
||||
bpp = 3
|
||||
size = 16
|
||||
shift = int("0xE2000", base=0)
|
||||
|
||||
for (item, data) in fonts.items():
|
||||
for size in data["size"]:
|
||||
output = data["cpp"].format(size)
|
||||
chars = []
|
||||
for (desc, char) in data["chars"].items():
|
||||
chars.append(char)
|
||||
|
||||
cmd = "lv_font_conv {} --bpp {} --size {} --font {} -r {} --font {} -r {} --format bin -o {} --format lvgl".format(
|
||||
compr,
|
||||
bpp,
|
||||
size,
|
||||
data["textfont"],
|
||||
",".join(chars),
|
||||
icons["iconfont"],
|
||||
symbols,
|
||||
output,
|
||||
)
|
||||
os.system(cmd)
|
||||
|
||||
with open(output, "r", encoding="utf8") as f:
|
||||
contents = f.readlines()
|
||||
|
||||
contents[13] = contents[13].replace(" 1", " 0 // default to off")
|
||||
contents.insert(0, "/* clang-format off */\n") # Add c-lang directive
|
||||
|
||||
with open(output, "w", encoding="utf8") as f:
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
Loading…
x
Reference in New Issue
Block a user