cleome 0.3.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.
@@ -0,0 +1,16 @@
1
+ # `@font-face` CSS generation, variable axes, and variant bundling
2
+
3
+ Domain rules for extracting font metadata ([`cleome/metadata.py`](../../src/cleome/metadata.py)), generating `@font-face` stylesheets ([`cleome/css.py`](../../src/cleome/css.py)), and orchestrating cached multi-variant builds ([`cleome/pipeline.py`](../../src/cleome/pipeline.py)) across variable and static fonts.
4
+
5
+ ## Variable and static axis mapping
6
+
7
+ * `extract_font_face_descriptors` and `extract_font_metadata` (`cleome/metadata.py`) extract `font-weight`, `font-stretch`, and `font-style` descriptors from `fvar` axes (`wght`, `wdth`, `ital`, `slnt`) for variable fonts, and from `OS/2` (`usWeightClass`, `usWidthClass`, `fsSelection`) and `post` (`italicAngle`) tables for static fonts.
8
+ * When a variable font includes `ital`, `slnt`, or both axes, `generate_css` (`cleome/css.py`) emits `@font-face` rules for each supported style (`normal`, `italic`, `oblique ...`) pointing to the same `.woff2` slice files. Emit `font-style: normal` only when the font's axis ranges include an upright form (`ital < 0.5` and `0deg` within `slnt`).
9
+
10
+ ## Multi-font variant bundling and content-hashed filenames
11
+
12
+ * `validate_and_compute_variant_suffixes` (`cleome/metadata.py`) validates that bundling multiple font files into one stylesheet shares a common `font-family` name (unless overridden) and a unique `(font-weight, font-stretch, font-style)` descriptor tuple for every emitted rule.
13
+ * Raise a `ValueError` on family mismatches or descriptor collisions rather than auto-numbering colliding variants or filenames (`-2`, `-3`).
14
+ * When bundled variants have different `cmap` coverage, `slice_fonts` (`cleome/pipeline.py`) builds and exports each variant's slices from its own mapped codepoints rather than the cross-font union.
15
+ * When `SliceConfig.filename_hash` is `True` (default), `_subset_single_slice_worker` (`cleome/subsetter.py`) appends an 8-character SHA-256 hex digest of the built `.woff2` bytes (`<slug>(-<variant>)-<slice_id>-<hash8>.woff2`), `_export_woff2_slices_batch` prunes superseded hashes for the built stems, and `_try_load_cached_bundle` (`cleome/pipeline.py`) verifies the on-disk filename hash against the `.woff2` content.
16
+ * `slice_font` and `slice_fonts` (`cleome/pipeline.py`, `--css-out` in `cleome/cli.py`) accept an explicit `css_path` file path so consumers can write the `@font-face` stylesheet outside `out_dir` (such as `src/styles/fonts.css` while `out_dir` is `public/fonts`); `css_filename` and `css_path` are mutually exclusive.
@@ -0,0 +1,20 @@
1
+ # WOFF2 subsetting, OpenType shaping, and slicing tiers
2
+
3
+ Domain rules for `unicode-range` formatting and compaction ([`cleome/urange.py`](../../src/cleome/urange.py)), the 4-tier slicing planner ([`cleome/slicer.py`](../../src/cleome/slicer.py)), and the WOFF2 subsetting pipeline ([`cleome/subsetter.py`](../../src/cleome/subsetter.py)).
4
+
5
+ ## CSS cascade shadowing and range compaction
6
+
7
+ * Cleome orders `@font-face` declarations from lowest priority (Tier 4 rare ideographs and syllables, using 1-token hex ranges) to highest priority (Tier 1 core phonetic blocks and Latin).
8
+ * When compacting `unicode-range` intervals in an earlier tier with `compact_unicode_range` (`cleome/urange.py`), bridge only across unmapped gaps or codepoints shadowed by a higher-priority tier declared later in the stylesheet.
9
+ * Never bridge `unicode-range` tokens across different Unicode planes (such as Plane 2 SIP and Plane 3 TIP).
10
+
11
+ ## Intra-slice OpenType shaping
12
+
13
+ * `fontTools.subset` prunes multi-glyph `GSUB` and `GPOS` lookups (`ccmp`, `mark`, `mkmk`, `liga`, `kern`, `chws`, `vchw`, `ljmo`, `vjmo`, `tjmo`) whenever any participating glyph is absent from the slice.
14
+ * Keep base characters and their combining marks or paired brackets in the same tier and slice (Latin combining marks with `latin`, voiced Kana marks with `kana-core`, Conjoining and Compatibility Hangul Jamo with `hangul-core`, and Bopomofo letters plus tone marks `U+02C7`, `U+02C9-02CB`, `U+02D9` with `cjk-core`) so composition and contextual positioning lookups survive subsetting.
15
+ * Verify changes to character partitioning or subsetting options with HarfBuzz (`uharfbuzz`) shaping assertions before and after slicing.
16
+
17
+ ## UVS and IVS (`cmap` Format 14) handling
18
+
19
+ * Retain `cmap` Format 14 variation selector mappings (both default and non-default UVS and IVS) and their variant glyphs for all base characters included in a slice (`_prepare_uvs_for_slice` in `cleome/subsetter.py`), without leaking standalone variation selector codepoints into the slice's base Format 4 or Format 12 `cmap`.
20
+ * Keep Format 14 sequence retention separate from `patch_uvs_missing_base_cmap` (`cleome/metadata.py`, re-exported by `cleome/subsetter.py`), which recovers characters that upstream fonts mapped in Format 14 but omitted from Format 4 and Format 12.
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ .venv/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .DS_Store
cleome-0.3.0/AGENTS.md ADDED
@@ -0,0 +1,23 @@
1
+ # Cleome
2
+
3
+ Cleome (`cleome`) is a Python (`>= 3.15`) CLI tool and library that inspects Japanese, Korean, and Chinese (`jp`, `kr`, `sc`, `tc`, `hk`) variable and static fonts (`.ttf` / `.otf`) and generates 4-tier `unicode-range` `.woff2` slices and `@font-face` CSS using CSS cascade shadowing and inverted-pyramid frequency granularity.
4
+
5
+ ## Commands
6
+
7
+ * Install dependencies (`uharfbuzz`): `uv sync`
8
+ * Run test suite (`unittest` + HarfBuzz shaping verification, fail-fast): `uv run python -m unittest discover -s tests -v -f`
9
+ * Preview a 4-tier slice plan without writing files (read-only): `uv run cleome plan <font.ttf> [--json]`
10
+ * Build `.woff2` slices and `@font-face` CSS: `uv run cleome build <font.ttf> -o dist/ [--css-out <path.css>] [--no-filename-hash] [--dry-run]`
11
+
12
+ ## Architecture and invariants
13
+
14
+ * **Entrypoint guard (`spawn` / `forkserver`).** Guard runnable scripts and `README.md` or `skills/cleome/SKILL.md` Python examples with `if __name__ == "__main__":`, and pass worker configuration through process pool initializer arguments rather than module globals.
15
+ * **Deterministic, non-destructive font handling.** Open fonts with `recalcTimestamp=False` so repeated builds produce byte-identical `.woff2` files, retain license records (`nameID` `0`, `13`, `14`) in every slice, and never mutate caller-supplied `TTFont` objects in public slicing APIs.
16
+ * **CSS serialization via Stixis.** Delegate `@font-face` AST validation, PEP 750 `Template` (`t"..."`) escaping, and `<urange>` parsing, formatting, and compaction to `stixis` (`SerializationOptions.cleome()`) rather than formatting raw CSS strings by hand.
17
+ * **CLI contract.** `cleome plan` (`src/cleome/cli.py`) is read-only and never creates output directories or imports subsetting workers. Never mix `nargs="*"` or `"+"` optional flags with positional arguments.
18
+ * **Public API sync.** When changing public APIs, CLI flags, or slicing behavior, update [`skills/cleome/SKILL.md`](skills/cleome/SKILL.md), `README.md`, and the relevant guide under `.agents/docs/`.
19
+
20
+ ## Domain guides
21
+
22
+ * Read [.agents/docs/subsetting-and-shaping.md](.agents/docs/subsetting-and-shaping.md) when modifying `unicode-range` compaction (`src/cleome/urange.py`), the 4-tier slicing planner (`src/cleome/slicer.py`), locale detection (`src/cleome/locale.py`), or `fontTools.subset` and `cmap` Format 14 UVS handling (`src/cleome/subsetter.py`).
23
+ * Read [.agents/docs/css-and-metadata.md](.agents/docs/css-and-metadata.md) when modifying OpenType descriptor extraction (`src/cleome/metadata.py`), `@font-face` stylesheet generation (`src/cleome/css.py`), or cached multi-variant bundling (`src/cleome/pipeline.py`).
cleome-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 矢倉 眞隆 (Masataka Yakura)
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.
cleome-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.5
2
+ Name: cleome
3
+ Version: 0.3.0
4
+ Summary: Dynamic unicode-range WOFF2 slicer and @font-face CSS generator for Japanese, Korean, and Chinese web fonts
5
+ Project-URL: Homepage, https://github.com/myakura/cleome
6
+ Project-URL: Repository, https://github.com/myakura/cleome.git
7
+ Project-URL: Issues, https://github.com/myakura/cleome/issues
8
+ Author-email: Masataka Yakura <masataka.yakura@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: cjk,font-face,opentype,subsetting,unicode-range,variable-fonts,webfont,woff2
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.15
17
+ Classifier: Topic :: Internet :: WWW/HTTP
18
+ Classifier: Topic :: Multimedia :: Graphics :: Editors :: Vector-Based
19
+ Classifier: Topic :: Text Processing :: Fonts
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.15
22
+ Requires-Dist: brotli>=1.2.1
23
+ Requires-Dist: fonttools[woff]>=4.67.0
24
+ Requires-Dist: stixis>=0.1.1
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Cleome
28
+
29
+ Cleome is a Python CLI tool and library that slices Japanese, Korean, and Chinese (`JP` / `KR` / `SC` / `TC` / `HK`) variable and static fonts (`.ttf` / `.otf`) into `unicode-range` `.woff2` files and `@font-face` CSS.
30
+
31
+ Cleome inspects a font's `cmap` once and writes deterministic static assets instead of scanning page HTML on every site deploy. You can host the generated `.woff2` chunks and `@font-face` stylesheet directly from Next.js, Astro, Fontsource, or any static CDN. Compared to Google Fonts' static slicing templates, Cleome produces smaller stylesheets and transfers fewer `.woff2` bytes while keeping OpenType layout features, UVS/IVS variation sequences, and variable font axes intact.
32
+
33
+ ---
34
+
35
+
36
+ ## Installation
37
+
38
+ Requires Python `>= 3.15` and [`uv`](https://docs.astral.sh/uv/).
39
+
40
+ ```bash
41
+ # Install as a standalone CLI tool from GitHub
42
+ uv tool install git+https://github.com/myakura/cleome
43
+
44
+ # Or run directly without installing
45
+ uvx --from git+https://github.com/myakura/cleome cleome plan SourceHanSansJP-VF.otf
46
+
47
+ # Or add to a Python project
48
+ uv add git+https://github.com/myakura/cleome
49
+ ```
50
+
51
+ ---
52
+
53
+
54
+ ## CLI usage
55
+
56
+ ```bash
57
+ # Preview the dynamic 4-tier slice plan without writing files (read-only)
58
+ cleome plan SourceHanSansJP-VF.otf
59
+ cleome plan SourceHanSansJP-VF.otf --json
60
+
61
+ # Slice a Variable Font (auto-detects CJK profile; outputs <out-dir>/<slug>.css and <out-dir>/slices/<slug>-*-<hash8>.woff2)
62
+ # Subsequent builds with unchanged inputs/config skip WOFF2 subsetting automatically; pass --force to rebuild
63
+ # Pass --dry-run to validate inputs and output paths without creating directories or writing files
64
+ # Pass --css-out to write the stylesheet to src/styles/ while keeping .woff2 slices in public/fonts/
65
+ # Pass --no-filename-hash when placing slices in a bundler-managed directory that adds its own asset hash
66
+ cleome build SourceHanSansJP-VF.otf -o dist/web
67
+ cleome build SourceHanSansJP-VF.otf -o dist/web --dry-run
68
+ cleome build SourceHanSansJP-VF.otf -o dist/web --force
69
+ cleome build SourceHanSansJP-VF.otf -o public/fonts --url-prefix "/fonts/slices" --css-out src/styles/fonts.css
70
+ cleome build SourceHanSansJP-VF.otf -o src/assets/fonts --no-filename-hash
71
+
72
+ # Explicitly select a CJK slicing profile (auto, jp, kr, sc, tc, hk)
73
+ cleome build SourceHanSansJP-VF.otf --locale jp -o dist/web-jp
74
+ cleome build NotoSansKR-VF.ttf --locale kr -o dist/web-kr
75
+
76
+ # Slice multiple Static Font weights into a single unified @font-face CSS and slices/ directory
77
+ cleome build MyFontJP-Regular.ttf MyFontJP-Bold.ttf -o dist/web-static
78
+
79
+ # Customize CSS font-family, URL prefix, chunk sizes, or retained OpenType layout features
80
+ # Note: --layout-features replaces the entire feature list (default is '*' for all features),
81
+ # so include vertical writing (vert,vrt2,vpal,vhal,vkrn) and composition (ccmp,locl) tags if needed.
82
+ cleome build MyFont-VF.otf -o dist/web \
83
+ --locale jp \
84
+ --family "My Font JP" \
85
+ --slug "my-font-jp" \
86
+ --url-prefix "/assets/fonts/slices" \
87
+ --rare-chunk-size 250 \
88
+ --layout-features "ccmp,locl,kern,mark,mkmk,liga,palt,halt,vpal,vhal,vkrn,vert,vrt2,ruby"
89
+ ```
90
+
91
+ ---
92
+
93
+
94
+ ## Python API usage
95
+
96
+ Call `slice_font` or `slice_fonts` from a build script with either file paths or in-memory `fontTools.ttLib.TTFont` objects. Cleome does not mutate caller-supplied `TTFont` instances.
97
+
98
+ When `workers > 1` (the default), Cleome runs subsetting in a `ProcessPoolExecutor`. On platforms that use `spawn` or `forkserver` (`macOS`, `Windows`, and `Linux` on Python 3.14+), guard top-level scripts with `if __name__ == "__main__":` or pass `workers=1`.
99
+
100
+ ```python
101
+ from pathlib import Path
102
+ from cleome import SliceConfig, slice_font, slice_fonts
103
+
104
+ if __name__ == "__main__":
105
+ # 1. Slice a Variable Font (path or in-memory TTFont; locale="auto" by default)
106
+ result = slice_font(
107
+ "SourceHanSansJP-VF.otf",
108
+ out_dir=Path("dist/web"),
109
+ config=SliceConfig(
110
+ locale="auto", # "auto", "jp", "kr", "sc", "tc", or "hk"
111
+ slices_subdir="slices",
112
+ rare_chunk_size=250,
113
+ ),
114
+ )
115
+ print(f"Generated {result.css_path} and {len(result.built_files)} WOFF2 slices")
116
+
117
+ # 2. Slice multiple Static Font weights into a unified stylesheet
118
+ static_result = slice_fonts(
119
+ [
120
+ "MyFontJP-Regular.ttf",
121
+ "MyFontJP-Bold.ttf",
122
+ ],
123
+ out_dir=Path("dist/web-static"),
124
+ family_name="My Font JP",
125
+ )
126
+ ```
127
+
128
+ ---
129
+
130
+
131
+ ## Development and testing
132
+
133
+ ```bash
134
+ uv sync
135
+ uv run python -m unittest discover -s tests -v -f
136
+ ```
137
+
138
+ ---
139
+
140
+
141
+ ## Documentation
142
+
143
+ * [Hosting and usage guide](docs/hosting-and-usage.md) explains how to deploy generated `<slug>.css` and `.woff2` slices on static hosts, bundlers, and CDNs, configure `--url-prefix` and `--slices-dir`, and set preload, CORS, and `Cache-Control` headers.
144
+ * [Architecture and rationale](docs/architecture-and-rationale.md) explains the 4-tier cascade shadowing design, inverted-pyramid Kanji granularity simulations, OpenType subsetting details, and the issues found in Google Fonts' Japanese delivery.
145
+ * [Chinese and Korean (`KR` / `SC` / `TC` / `HK`) slicing analysis](docs/cjk-slicing-analysis.md) covers Google Fonts' Korean and Chinese (`SC`, `TC`, `HK`) slice templates, ghost `unicode-range` rules, punctuation, Jamo, and Bopomofo splits, and 4-tier simulation results.
146
+
147
+ ---
148
+
149
+
150
+ ## Acknowledgments
151
+
152
+ * [Google Fonts](https://fonts.google.com/) published the production stylesheets, slice definitions (`gfsubsets` / `nam-files`), and corpus frequency data analyzed during this project.
153
+ * [Noto Sans Japanese (`Noto Sans JP`)](https://fonts.google.com/noto/specimen/Noto+Sans+JP) and [Source Han Sans (`源ノ角ゴシック`)](https://github.com/adobe-fonts/source-han-sans) were the primary Japanese typefaces used to test and verify Cleome.
154
+ * [fontTools](https://github.com/fonttools/fonttools) handles OpenType table inspection, `cmap`, `GSUB`, and `GPOS` subsetting (`fontTools.subset`), and WOFF2 packing.
155
+ * [Brotli](https://github.com/google/brotli) compresses and decompresses the WOFF2 streams.
156
+ * [HarfBuzz](https://github.com/harfbuzz/harfbuzz) and [uharfbuzz](https://github.com/harfbuzz/uharfbuzz) verify OpenType glyph shaping, `cmap` Format 14 variation sequences, and combining mark composition (`ccmp`) in the test suite.
157
+ * [Stixis](https://github.com/myakura/stixis) validates and serializes the generated `@font-face` CSS rules and `unicode-range` descriptors.
158
+
159
+ ---
160
+
161
+
162
+ ## License
163
+
164
+ [MIT License](LICENSE)
cleome-0.3.0/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # Cleome
2
+
3
+ Cleome is a Python CLI tool and library that slices Japanese, Korean, and Chinese (`JP` / `KR` / `SC` / `TC` / `HK`) variable and static fonts (`.ttf` / `.otf`) into `unicode-range` `.woff2` files and `@font-face` CSS.
4
+
5
+ Cleome inspects a font's `cmap` once and writes deterministic static assets instead of scanning page HTML on every site deploy. You can host the generated `.woff2` chunks and `@font-face` stylesheet directly from Next.js, Astro, Fontsource, or any static CDN. Compared to Google Fonts' static slicing templates, Cleome produces smaller stylesheets and transfers fewer `.woff2` bytes while keeping OpenType layout features, UVS/IVS variation sequences, and variable font axes intact.
6
+
7
+ ---
8
+
9
+
10
+ ## Installation
11
+
12
+ Requires Python `>= 3.15` and [`uv`](https://docs.astral.sh/uv/).
13
+
14
+ ```bash
15
+ # Install as a standalone CLI tool from GitHub
16
+ uv tool install git+https://github.com/myakura/cleome
17
+
18
+ # Or run directly without installing
19
+ uvx --from git+https://github.com/myakura/cleome cleome plan SourceHanSansJP-VF.otf
20
+
21
+ # Or add to a Python project
22
+ uv add git+https://github.com/myakura/cleome
23
+ ```
24
+
25
+ ---
26
+
27
+
28
+ ## CLI usage
29
+
30
+ ```bash
31
+ # Preview the dynamic 4-tier slice plan without writing files (read-only)
32
+ cleome plan SourceHanSansJP-VF.otf
33
+ cleome plan SourceHanSansJP-VF.otf --json
34
+
35
+ # Slice a Variable Font (auto-detects CJK profile; outputs <out-dir>/<slug>.css and <out-dir>/slices/<slug>-*-<hash8>.woff2)
36
+ # Subsequent builds with unchanged inputs/config skip WOFF2 subsetting automatically; pass --force to rebuild
37
+ # Pass --dry-run to validate inputs and output paths without creating directories or writing files
38
+ # Pass --css-out to write the stylesheet to src/styles/ while keeping .woff2 slices in public/fonts/
39
+ # Pass --no-filename-hash when placing slices in a bundler-managed directory that adds its own asset hash
40
+ cleome build SourceHanSansJP-VF.otf -o dist/web
41
+ cleome build SourceHanSansJP-VF.otf -o dist/web --dry-run
42
+ cleome build SourceHanSansJP-VF.otf -o dist/web --force
43
+ cleome build SourceHanSansJP-VF.otf -o public/fonts --url-prefix "/fonts/slices" --css-out src/styles/fonts.css
44
+ cleome build SourceHanSansJP-VF.otf -o src/assets/fonts --no-filename-hash
45
+
46
+ # Explicitly select a CJK slicing profile (auto, jp, kr, sc, tc, hk)
47
+ cleome build SourceHanSansJP-VF.otf --locale jp -o dist/web-jp
48
+ cleome build NotoSansKR-VF.ttf --locale kr -o dist/web-kr
49
+
50
+ # Slice multiple Static Font weights into a single unified @font-face CSS and slices/ directory
51
+ cleome build MyFontJP-Regular.ttf MyFontJP-Bold.ttf -o dist/web-static
52
+
53
+ # Customize CSS font-family, URL prefix, chunk sizes, or retained OpenType layout features
54
+ # Note: --layout-features replaces the entire feature list (default is '*' for all features),
55
+ # so include vertical writing (vert,vrt2,vpal,vhal,vkrn) and composition (ccmp,locl) tags if needed.
56
+ cleome build MyFont-VF.otf -o dist/web \
57
+ --locale jp \
58
+ --family "My Font JP" \
59
+ --slug "my-font-jp" \
60
+ --url-prefix "/assets/fonts/slices" \
61
+ --rare-chunk-size 250 \
62
+ --layout-features "ccmp,locl,kern,mark,mkmk,liga,palt,halt,vpal,vhal,vkrn,vert,vrt2,ruby"
63
+ ```
64
+
65
+ ---
66
+
67
+
68
+ ## Python API usage
69
+
70
+ Call `slice_font` or `slice_fonts` from a build script with either file paths or in-memory `fontTools.ttLib.TTFont` objects. Cleome does not mutate caller-supplied `TTFont` instances.
71
+
72
+ When `workers > 1` (the default), Cleome runs subsetting in a `ProcessPoolExecutor`. On platforms that use `spawn` or `forkserver` (`macOS`, `Windows`, and `Linux` on Python 3.14+), guard top-level scripts with `if __name__ == "__main__":` or pass `workers=1`.
73
+
74
+ ```python
75
+ from pathlib import Path
76
+ from cleome import SliceConfig, slice_font, slice_fonts
77
+
78
+ if __name__ == "__main__":
79
+ # 1. Slice a Variable Font (path or in-memory TTFont; locale="auto" by default)
80
+ result = slice_font(
81
+ "SourceHanSansJP-VF.otf",
82
+ out_dir=Path("dist/web"),
83
+ config=SliceConfig(
84
+ locale="auto", # "auto", "jp", "kr", "sc", "tc", or "hk"
85
+ slices_subdir="slices",
86
+ rare_chunk_size=250,
87
+ ),
88
+ )
89
+ print(f"Generated {result.css_path} and {len(result.built_files)} WOFF2 slices")
90
+
91
+ # 2. Slice multiple Static Font weights into a unified stylesheet
92
+ static_result = slice_fonts(
93
+ [
94
+ "MyFontJP-Regular.ttf",
95
+ "MyFontJP-Bold.ttf",
96
+ ],
97
+ out_dir=Path("dist/web-static"),
98
+ family_name="My Font JP",
99
+ )
100
+ ```
101
+
102
+ ---
103
+
104
+
105
+ ## Development and testing
106
+
107
+ ```bash
108
+ uv sync
109
+ uv run python -m unittest discover -s tests -v -f
110
+ ```
111
+
112
+ ---
113
+
114
+
115
+ ## Documentation
116
+
117
+ * [Hosting and usage guide](docs/hosting-and-usage.md) explains how to deploy generated `<slug>.css` and `.woff2` slices on static hosts, bundlers, and CDNs, configure `--url-prefix` and `--slices-dir`, and set preload, CORS, and `Cache-Control` headers.
118
+ * [Architecture and rationale](docs/architecture-and-rationale.md) explains the 4-tier cascade shadowing design, inverted-pyramid Kanji granularity simulations, OpenType subsetting details, and the issues found in Google Fonts' Japanese delivery.
119
+ * [Chinese and Korean (`KR` / `SC` / `TC` / `HK`) slicing analysis](docs/cjk-slicing-analysis.md) covers Google Fonts' Korean and Chinese (`SC`, `TC`, `HK`) slice templates, ghost `unicode-range` rules, punctuation, Jamo, and Bopomofo splits, and 4-tier simulation results.
120
+
121
+ ---
122
+
123
+
124
+ ## Acknowledgments
125
+
126
+ * [Google Fonts](https://fonts.google.com/) published the production stylesheets, slice definitions (`gfsubsets` / `nam-files`), and corpus frequency data analyzed during this project.
127
+ * [Noto Sans Japanese (`Noto Sans JP`)](https://fonts.google.com/noto/specimen/Noto+Sans+JP) and [Source Han Sans (`源ノ角ゴシック`)](https://github.com/adobe-fonts/source-han-sans) were the primary Japanese typefaces used to test and verify Cleome.
128
+ * [fontTools](https://github.com/fonttools/fonttools) handles OpenType table inspection, `cmap`, `GSUB`, and `GPOS` subsetting (`fontTools.subset`), and WOFF2 packing.
129
+ * [Brotli](https://github.com/google/brotli) compresses and decompresses the WOFF2 streams.
130
+ * [HarfBuzz](https://github.com/harfbuzz/harfbuzz) and [uharfbuzz](https://github.com/harfbuzz/uharfbuzz) verify OpenType glyph shaping, `cmap` Format 14 variation sequences, and combining mark composition (`ccmp`) in the test suite.
131
+ * [Stixis](https://github.com/myakura/stixis) validates and serializes the generated `@font-face` CSS rules and `unicode-range` descriptors.
132
+
133
+ ---
134
+
135
+
136
+ ## License
137
+
138
+ [MIT License](LICENSE)