1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 23:13:13 -04:00
Files
egui/crates/epaint_default_fonts/fonts/list_fonts.py
Alex Pinkus ae7672e336 Move default fonts to new crate epaint_default_fonts (#4853)
This allows license checking tools to omit the OFL and UFL licenses when
`default_fonts` are turned off.

There was some discussion of versioning on the original issue; I have
chosen to label this version as `0.28.1` to match the other crates.
Happy to adjust the version as needed.

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes <https://github.com/emilk/egui/issues/2321>
* [X] I have followed the instructions in the PR template

---------

Co-authored-by: Alex Pinkus <pinkus@amazon.com>
2024-07-31 09:50:02 +02:00

33 lines
933 B
Python

#!/usr/bin/env python
from fontTools.ttLib import TTFont
from fontTools.unicode import Unicode
from itertools import chain
import sys
ttf = TTFont(sys.argv[1], 0, verbose=0, allowVID=0,
ignoreDecompileErrors=True,
fontNumber=-1)
chars = chain.from_iterable([y + (Unicode[y[0]],)
for y in x.cmap.items()] for x in ttf["cmap"].tables)
all_codepoints = {}
for entry in chars:
codepoint = entry[0]
short_name = entry[1]
long_name = entry[2].lower()
if False:
print(f'(0x{codepoint:02X}, "{short_name}", "{long_name}"),')
else:
name = short_name if long_name == "????" else long_name
# print(f'(0x{codepoint:02X}, "{name}"),')
all_codepoints[codepoint] = name
for codepoint in sorted(all_codepoints.keys()):
name = all_codepoints[codepoint]
print(f'(0x{codepoint:02X}, \'{chr(codepoint)}\', "{name}"),')
ttf.close()