Quince/tools/icons.py
astar76 7a4266b034 Quince: a Material You video player on mpv
libmpv render API into an egui/glow texture, floating controls with a wavy
seek bar and morphing play button, track/speed/chapter menus, playlist and
adjust sheets, settings, open link, previews, smoke-test harness.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 17:56:15 -06:00

32 lines
2.1 KiB
Python

import sys
from fontTools.ttLib import TTFont
from fontTools.varLib import instancer
from fontTools import subset
src="/usr/share/fonts/TTF/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf"
names="""play_arrow pause skip_next skip_previous fast_forward fast_rewind replay_10 forward_10 volume_up volume_down volume_mute volume_off
fullscreen fullscreen_exit block subtitles subtitles_off music_note queue_music playlist_play playlist_add settings tune more_vert folder_open file_open link movie close add delete check
chevron_right chevron_left expand_more expand_less speed aspect_ratio rotate_right rotate_left zoom_in zoom_out photo_camera repeat repeat_one shuffle bookmarks history keyboard info palette
video_settings closed_caption drag_indicator crop flip brightness_6 contrast timer sync restart_alt stop remove clear_all video_file language light_mode dark_mode brightness_auto animation
text_fields format_size vertical_align_bottom visibility visibility_off graphic_eq equalizer swap_vert slow_motion_video memory terminal public sort search open_in_new hearing
arrow_back arrow_forward low_priority radio_button_checked radio_button_unchecked check_circle error warning content_copy sync_alt splitscreen frame_source picture_in_picture_alt hd
""".split()
f=TTFont(src)
cmap=f.getBestCmap()
rev={}
for cp,g in cmap.items():
if 0xe000<=cp<=0xf8ff or cp>0xffff: rev.setdefault(g,cp)
out=[];missing=[]
for n in names:
if n in rev: out.append((n,rev[n]))
else: missing.append(n)
print("missing",missing,file=sys.stderr)
cps=[c for _,c in out]
for fill,fn in ((0,"symbols.ttf"),(1,"symbols-fill.ttf")):
v=TTFont(src)
v=instancer.instantiateVariableFont(v,{"FILL":fill,"wght":400,"GRAD":0,"opsz":24})
opts=subset.Options(); opts.layout_features=[]; opts.notdef_outline=True; opts.name_IDs=["*"]
s=subset.Subsetter(opts); s.populate(unicodes=cps); s.subset(v)
v.save(sys.argv[1]+"/"+fn)
with open(sys.argv[2],"w") as w:
w.write("//! Material Symbols Rounded codepoints (subset in assets/symbols*.ttf, made by tools/icons.py).\n#![allow(dead_code)]\n\n")
for n,c in out: w.write(f'pub const {n.upper()}: &str = "\\u{{{c:x}}}";\n')