Spaces:
Running
Running
Download pipeline/subset.py from Ethscriptions/tz: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/spaces/Ethscriptions/tz/resolve/main/pipeline/subset.py
- Command line
-
hf download hf://spaces/Ethscriptions/tz/pipeline/subset.py
-
curl -L -o subset.py https://huggingface.co/spaces/Ethscriptions/tz/resolve/main/pipeline/subset.py
1.61 kB
| import os, glob, subprocess, sys | |
| src='/workspaces/frontend/src' | |
| chars=set() | |
| for p in glob.glob(src+'/**/*.*',recursive=True): | |
| if p.endswith(('.ts','.tsx','.json','.css')): | |
| chars|=set(open(p,encoding='utf-8').read()) | |
| chars|=set(open('/workspaces/space/奥德彪语录.md',encoding='utf-8').read()) | |
| ascii_=''.join(chr(i) for i in range(32,127)) | |
| chars|=set(ascii_)|set(',。;:?!、“”‘’「」『』《》()—…·№→↘←↑↓●▌❚∞×÷+-=%/') | |
| text=''.join(sorted(c for c in chars if c.isprintable())) | |
| open('/tmp/tools/charset.txt','w',encoding='utf-8').write(text) | |
| print('chars',len(text)) | |
| out='/workspaces/frontend/public/fonts'; os.makedirs(out,exist_ok=True) | |
| F='/tmp/fonts/' | |
| jobs=[('NotoSerifSC[wght].ttf','NotoSerifSC.woff2',True),('NotoSansSC[wght].ttf','NotoSansSC.woff2',True), | |
| ('MaShanZheng-Regular.ttf','MaShanZheng.woff2',True),('ZhiMangXing-Regular.ttf','ZhiMangXing.woff2',True), | |
| ('BebasNeue-Regular.ttf','BebasNeue.woff2',False),('CormorantGaramond[wght].ttf','CormorantGaramond.woff2',False), | |
| ('CormorantGaramond-Italic[wght].ttf','CormorantGaramondItalic.woff2',False),('SpaceMono-Regular.ttf','SpaceMono.woff2',False)] | |
| for a,b,cjk in jobs: | |
| args=['/tmp/venv/bin/pyftsubset',F+a,'--flavor=woff2','--output-file='+out+'/'+b,'--layout-features=*','--no-hinting'] | |
| if cjk: args.append('--text-file=/tmp/tools/charset.txt') | |
| else: args.append('--unicodes=U+0020-007E,U+00A0-00FF,U+2010-2027,U+2030-205E,U+2116,U+2190-21FF,U+25CF,U+221E,U+00D7') | |
| subprocess.run(args,check=True) | |
| print(b, os.path.getsize(out+'/'+b)//1024,'KB') | |