wing-font 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wing_font-1.0.0/LICENSE +21 -0
- wing_font-1.0.0/PKG-INFO +118 -0
- wing_font-1.0.0/PYPI.md +99 -0
- wing_font-1.0.0/README.md +673 -0
- wing_font-1.0.0/pyproject.toml +37 -0
- wing_font-1.0.0/setup.cfg +4 -0
- wing_font-1.0.0/tests/test_auto_fit_ascent.py +163 -0
- wing_font-1.0.0/tests/test_bare_base.py +200 -0
- wing_font-1.0.0/tests/test_composite_glyphs.py +235 -0
- wing_font-1.0.0/tests/test_diy_handler.py +139 -0
- wing_font-1.0.0/tests/test_diy_integration.py +287 -0
- wing_font-1.0.0/tests/test_hero_example.py +57 -0
- wing_font-1.0.0/tests/test_ivs_slots.py +109 -0
- wing_font-1.0.0/tests/test_ivs_subset.py +131 -0
- wing_font-1.0.0/tests/test_mark_glyphs.py +249 -0
- wing_font-1.0.0/tests/test_mark_input_handler.py +192 -0
- wing_font-1.0.0/tests/test_mark_strip.py +187 -0
- wing_font-1.0.0/tests/test_multidigit_liga.py +214 -0
- wing_font-1.0.0/tests/test_vertical_metrics.py +161 -0
- wing_font-1.0.0/wing_font.egg-info/PKG-INFO +118 -0
- wing_font-1.0.0/wing_font.egg-info/SOURCES.txt +38 -0
- wing_font-1.0.0/wing_font.egg-info/dependency_links.txt +1 -0
- wing_font-1.0.0/wing_font.egg-info/entry_points.txt +2 -0
- wing_font-1.0.0/wing_font.egg-info/requires.txt +7 -0
- wing_font-1.0.0/wing_font.egg-info/top_level.txt +1 -0
- wing_font-1.0.0/wingfont/__init__.py +10 -0
- wing_font-1.0.0/wingfont/build_glyph.py +1359 -0
- wing_font-1.0.0/wingfont/chain_context_handler.py +694 -0
- wing_font-1.0.0/wingfont/check_cmap_reachability.py +89 -0
- wing_font-1.0.0/wingfont/cli.py +2383 -0
- wing_font-1.0.0/wingfont/csv_parser.py +471 -0
- wing_font-1.0.0/wingfont/diy_handler.py +201 -0
- wing_font-1.0.0/wingfont/fetch.py +123 -0
- wing_font-1.0.0/wingfont/ivs_handler.py +241 -0
- wing_font-1.0.0/wingfont/liga_handler.py +523 -0
- wing_font-1.0.0/wingfont/mark_input_handler.py +124 -0
- wing_font-1.0.0/wingfont/mark_strip_handler.py +232 -0
- wing_font-1.0.0/wingfont/runner.py +463 -0
- wing_font-1.0.0/wingfont/utils.py +735 -0
- wing_font-1.0.0/wingfont/word_liga_handler.py +724 -0
wing_font-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Law Wai Chun
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
wing_font-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wing-font
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Build phonetic-annotation fonts (ruby above each character) from a base font, an annotation font and a character→reading CSV.
|
|
5
|
+
Author: Law Wai Chun
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/chunlaw/wing-font-generator
|
|
8
|
+
Keywords: font,opentype,ruby,annotation,jyutping,pinyin,romanization
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: fonttools==4.55.3
|
|
13
|
+
Requires-Dist: uharfbuzz==0.55.0
|
|
14
|
+
Requires-Dist: brotli>=1.0.9
|
|
15
|
+
Requires-Dist: unicodedata2>=15.1.0
|
|
16
|
+
Provides-Extra: test
|
|
17
|
+
Requires-Dist: pytest; extra == "test"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# wing-font
|
|
21
|
+
|
|
22
|
+
Build OpenType fonts that show each character's pronunciation **above the
|
|
23
|
+
character itself** — Cantonese Jyutping, Mandarin Pinyin, Taiwanese Tâi-lô,
|
|
24
|
+
Japanese furigana and more. The reading is part of the glyph, so it works in
|
|
25
|
+
plain text anywhere a font works (Word, Pages, Canva, browsers). No `<ruby>`
|
|
26
|
+
markup.
|
|
27
|
+
|
|
28
|
+
Pre-built fonts and an in-browser generator: <https://wing-font.chunlaw.io>
|
|
29
|
+
· Source: <https://github.com/chunlaw/wing-font-generator>
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pip install wing-font # Python 3.10+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This gives you the `wing-font` command. The package contains **code only**:
|
|
38
|
+
no fonts and no mapping data. You download those once with `wing-font fetch`.
|
|
39
|
+
|
|
40
|
+
## What you need for one font
|
|
41
|
+
|
|
42
|
+
| Input | What it is | Where it comes from |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| Base font (`-i`) | The font for the characters, e.g. Noto Sans HK | your own `.ttf`, or `wing-font fetch <font file>` |
|
|
45
|
+
| Annotation font (`-a`) | The font for the readings, e.g. Noto Sans (Latin) | your own `.ttf`, or `wing-font fetch <font file>` |
|
|
46
|
+
| Mapping (`-m`) | CSV of `character,reading`, e.g. `行,hang4` | your own CSV, or `wing-font fetch <path>.csv` |
|
|
47
|
+
|
|
48
|
+
## `wing-font fetch` — when and how
|
|
49
|
+
|
|
50
|
+
Use it **once, before your first build**, to download ready-made inputs into a
|
|
51
|
+
folder. Skip it if you bring your own fonts and CSV.
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
wing-font fetch --list # what's available
|
|
55
|
+
wing-font fetch NAME [NAME ...] [--dest DIR] [--force]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- `NAME` ending in `.csv` → a mapping, path relative to
|
|
59
|
+
[`python/mappings/`](https://github.com/chunlaw/wing-font-generator/tree/main/python/mappings)
|
|
60
|
+
in the repo (e.g. `cantonese/canto-lshk.csv`, `mandarin/mandarin-cn.csv`,
|
|
61
|
+
`taiwanese/taigi-tl-toned.csv`, `japanese/japanese-onkun.csv`).
|
|
62
|
+
- Any other `NAME` → a font file from
|
|
63
|
+
[wing-font-hub](https://github.com/chunlaw/wing-font-hub) (all SIL OFL), e.g.
|
|
64
|
+
`NotoSansHK-VariableFont_wght.ttf`, `NotoSerif-Regular.ttf`.
|
|
65
|
+
- Files already downloaded are skipped unless you pass `--force`.
|
|
66
|
+
|
|
67
|
+
## Quick start: Cantonese Jyutping on Noto Sans HK
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
wing-font fetch NotoSansHK-VariableFont_wght.ttf "NotoSans-VariableFont_wdth,wght.ttf" --dest fonts
|
|
71
|
+
wing-font fetch cantonese/canto-lshk.csv --dest mappings
|
|
72
|
+
|
|
73
|
+
wing-font -i fonts/NotoSansHK-VariableFont_wght.ttf \
|
|
74
|
+
-a "fonts/NotoSans-VariableFont_wdth,wght.ttf" --anno-axis wdth=75 \
|
|
75
|
+
-m mappings/canto-lshk.csv \
|
|
76
|
+
-o out/NotoSansHK-Jyutping -opt -as 0.39 -bs 0.70 -y 0.70
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Output: `out/NotoSansHK-Jyutping.ttf` and `.woff2`. Install the `.ttf` and type
|
|
80
|
+
Chinese. Polyphonic characters pick their reading from word context (銀行 →
|
|
81
|
+
hong4, 行人 → hang4). You can also force a reading by typing its number after
|
|
82
|
+
the character (行1, 行2, …).
|
|
83
|
+
|
|
84
|
+
`wing-font --help` lists every option (scales, offsets, annotation below,
|
|
85
|
+
variable-font axes, DIY annotations, …).
|
|
86
|
+
|
|
87
|
+
## Your own language
|
|
88
|
+
|
|
89
|
+
A mapping is a UTF-8 CSV, one row per character or word:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
各,gok3
|
|
93
|
+
銀行,ngan4 hong4
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Pick an annotation font that covers every letter and mark in your readings.
|
|
97
|
+
The full format, and how to add a new script, is in the repo:
|
|
98
|
+
[CONTRIBUTING-mappings.md](https://github.com/chunlaw/wing-font-generator/blob/main/python/mappings/CONTRIBUTING-mappings.md)
|
|
99
|
+
and [AGENTS.md](https://github.com/chunlaw/wing-font-generator/blob/main/AGENTS.md).
|
|
100
|
+
|
|
101
|
+
## From Python
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from wingfont.cli import main
|
|
105
|
+
|
|
106
|
+
main(
|
|
107
|
+
base_font_file="fonts/NotoSansHK-VariableFont_wght.ttf",
|
|
108
|
+
anno_font_file="fonts/NotoSerif-Regular.ttf",
|
|
109
|
+
mapping="mappings/canto-lshk.csv",
|
|
110
|
+
output_prefix="out/NotoSansHK-Jyutping",
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Licences
|
|
115
|
+
|
|
116
|
+
Code: MIT. Fonts you build inherit the licences of the input fonts (SIL OFL
|
|
117
|
+
for everything on wing-font-hub). Each mapping CSV keeps its own data licence.
|
|
118
|
+
See [LICENSES.md](https://github.com/chunlaw/wing-font-generator/blob/main/LICENSES.md).
|
wing_font-1.0.0/PYPI.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# wing-font
|
|
2
|
+
|
|
3
|
+
Build OpenType fonts that show each character's pronunciation **above the
|
|
4
|
+
character itself** — Cantonese Jyutping, Mandarin Pinyin, Taiwanese Tâi-lô,
|
|
5
|
+
Japanese furigana and more. The reading is part of the glyph, so it works in
|
|
6
|
+
plain text anywhere a font works (Word, Pages, Canva, browsers). No `<ruby>`
|
|
7
|
+
markup.
|
|
8
|
+
|
|
9
|
+
Pre-built fonts and an in-browser generator: <https://wing-font.chunlaw.io>
|
|
10
|
+
· Source: <https://github.com/chunlaw/wing-font-generator>
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pip install wing-font # Python 3.10+
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This gives you the `wing-font` command. The package contains **code only**:
|
|
19
|
+
no fonts and no mapping data. You download those once with `wing-font fetch`.
|
|
20
|
+
|
|
21
|
+
## What you need for one font
|
|
22
|
+
|
|
23
|
+
| Input | What it is | Where it comes from |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| Base font (`-i`) | The font for the characters, e.g. Noto Sans HK | your own `.ttf`, or `wing-font fetch <font file>` |
|
|
26
|
+
| Annotation font (`-a`) | The font for the readings, e.g. Noto Sans (Latin) | your own `.ttf`, or `wing-font fetch <font file>` |
|
|
27
|
+
| Mapping (`-m`) | CSV of `character,reading`, e.g. `行,hang4` | your own CSV, or `wing-font fetch <path>.csv` |
|
|
28
|
+
|
|
29
|
+
## `wing-font fetch` — when and how
|
|
30
|
+
|
|
31
|
+
Use it **once, before your first build**, to download ready-made inputs into a
|
|
32
|
+
folder. Skip it if you bring your own fonts and CSV.
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
wing-font fetch --list # what's available
|
|
36
|
+
wing-font fetch NAME [NAME ...] [--dest DIR] [--force]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- `NAME` ending in `.csv` → a mapping, path relative to
|
|
40
|
+
[`python/mappings/`](https://github.com/chunlaw/wing-font-generator/tree/main/python/mappings)
|
|
41
|
+
in the repo (e.g. `cantonese/canto-lshk.csv`, `mandarin/mandarin-cn.csv`,
|
|
42
|
+
`taiwanese/taigi-tl-toned.csv`, `japanese/japanese-onkun.csv`).
|
|
43
|
+
- Any other `NAME` → a font file from
|
|
44
|
+
[wing-font-hub](https://github.com/chunlaw/wing-font-hub) (all SIL OFL), e.g.
|
|
45
|
+
`NotoSansHK-VariableFont_wght.ttf`, `NotoSerif-Regular.ttf`.
|
|
46
|
+
- Files already downloaded are skipped unless you pass `--force`.
|
|
47
|
+
|
|
48
|
+
## Quick start: Cantonese Jyutping on Noto Sans HK
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
wing-font fetch NotoSansHK-VariableFont_wght.ttf "NotoSans-VariableFont_wdth,wght.ttf" --dest fonts
|
|
52
|
+
wing-font fetch cantonese/canto-lshk.csv --dest mappings
|
|
53
|
+
|
|
54
|
+
wing-font -i fonts/NotoSansHK-VariableFont_wght.ttf \
|
|
55
|
+
-a "fonts/NotoSans-VariableFont_wdth,wght.ttf" --anno-axis wdth=75 \
|
|
56
|
+
-m mappings/canto-lshk.csv \
|
|
57
|
+
-o out/NotoSansHK-Jyutping -opt -as 0.39 -bs 0.70 -y 0.70
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Output: `out/NotoSansHK-Jyutping.ttf` and `.woff2`. Install the `.ttf` and type
|
|
61
|
+
Chinese. Polyphonic characters pick their reading from word context (銀行 →
|
|
62
|
+
hong4, 行人 → hang4). You can also force a reading by typing its number after
|
|
63
|
+
the character (行1, 行2, …).
|
|
64
|
+
|
|
65
|
+
`wing-font --help` lists every option (scales, offsets, annotation below,
|
|
66
|
+
variable-font axes, DIY annotations, …).
|
|
67
|
+
|
|
68
|
+
## Your own language
|
|
69
|
+
|
|
70
|
+
A mapping is a UTF-8 CSV, one row per character or word:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
各,gok3
|
|
74
|
+
銀行,ngan4 hong4
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Pick an annotation font that covers every letter and mark in your readings.
|
|
78
|
+
The full format, and how to add a new script, is in the repo:
|
|
79
|
+
[CONTRIBUTING-mappings.md](https://github.com/chunlaw/wing-font-generator/blob/main/python/mappings/CONTRIBUTING-mappings.md)
|
|
80
|
+
and [AGENTS.md](https://github.com/chunlaw/wing-font-generator/blob/main/AGENTS.md).
|
|
81
|
+
|
|
82
|
+
## From Python
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from wingfont.cli import main
|
|
86
|
+
|
|
87
|
+
main(
|
|
88
|
+
base_font_file="fonts/NotoSansHK-VariableFont_wght.ttf",
|
|
89
|
+
anno_font_file="fonts/NotoSerif-Regular.ttf",
|
|
90
|
+
mapping="mappings/canto-lshk.csv",
|
|
91
|
+
output_prefix="out/NotoSansHK-Jyutping",
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Licences
|
|
96
|
+
|
|
97
|
+
Code: MIT. Fonts you build inherit the licences of the input fonts (SIL OFL
|
|
98
|
+
for everything on wing-font-hub). Each mapping CSV keeps its own data licence.
|
|
99
|
+
See [LICENSES.md](https://github.com/chunlaw/wing-font-generator/blob/main/LICENSES.md).
|