-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Util function to generate char unicode map #201
Milestone
Comments
Hi @mhamid3d thank you for the feedback! I think you are right, at least a mention in the docs should be done. The function handling this probably could use the code used in the import re
import json
import urllib.request
def create_font_charmap(font_name, font_css_url):
req = urllib.request.urlopen(font_css_url)
if req.status != 200:
raise Exception('Failed to download CSS Charmap')
rawcss = req.read().decode()
req.close()
charmap = {}
pattern = '^\.ph-(.+):before {\s*content: "(.+)";\s*}$'
data = re.findall(pattern, rawcss, re.MULTILINE)
for name, key in data:
key = key.replace('\\', '0x')
name = name.lower()
charmap[name] = key
with open(f'{font_name}-charmap.json', 'w') as fp:
json.dump(charmap, fp, indent=4, sort_keys=True) Let us know if you want to work on this! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be nice to have a utility to generate the char map since it's required to load additional fonts. Although, if this adds too many dependencies, maybe a mention in the docs to what method was used to generate the precompiled ones.
The text was updated successfully, but these errors were encountered: