mapotofu 0.1.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.
Files changed (64) hide show
  1. mapotofu-0.1.0/.gitignore +5 -0
  2. mapotofu-0.1.0/LICENSE +202 -0
  3. mapotofu-0.1.0/PKG-INFO +310 -0
  4. mapotofu-0.1.0/README/README_CN.md +280 -0
  5. mapotofu-0.1.0/README/README_JP.md +280 -0
  6. mapotofu-0.1.0/README.md +280 -0
  7. mapotofu-0.1.0/pyproject.toml +60 -0
  8. mapotofu-0.1.0/src/mapotofu/__init__.py +2 -0
  9. mapotofu-0.1.0/src/mapotofu/__main__.py +5 -0
  10. mapotofu-0.1.0/src/mapotofu/assemble.py +429 -0
  11. mapotofu-0.1.0/src/mapotofu/build.py +348 -0
  12. mapotofu-0.1.0/src/mapotofu/charsets.py +145 -0
  13. mapotofu-0.1.0/src/mapotofu/cli.py +85 -0
  14. mapotofu-0.1.0/src/mapotofu/config.py +125 -0
  15. mapotofu-0.1.0/src/mapotofu/cut.py +102 -0
  16. mapotofu-0.1.0/src/mapotofu/fetch.py +74 -0
  17. mapotofu-0.1.0/src/mapotofu/gen_charsets.py +50 -0
  18. mapotofu-0.1.0/src/mapotofu/glyphs.py +142 -0
  19. mapotofu-0.1.0/src/mapotofu/hint.py +248 -0
  20. mapotofu-0.1.0/src/mapotofu/hintcache.py +398 -0
  21. mapotofu-0.1.0/src/mapotofu/instance.py +114 -0
  22. mapotofu-0.1.0/src/mapotofu/layout.py +460 -0
  23. mapotofu-0.1.0/src/mapotofu/man/man1/mapo.1 +1 -0
  24. mapotofu-0.1.0/src/mapotofu/man/man1/mapotofu.1 +1022 -0
  25. mapotofu-0.1.0/src/mapotofu/man/zh_CN/man1/mapo.1 +1 -0
  26. mapotofu-0.1.0/src/mapotofu/man/zh_CN/man1/mapotofu.1 +443 -0
  27. mapotofu-0.1.0/src/mapotofu/manual.py +50 -0
  28. mapotofu-0.1.0/src/mapotofu/meta.py +295 -0
  29. mapotofu-0.1.0/src/mapotofu/package.py +465 -0
  30. mapotofu-0.1.0/src/mapotofu/parts.py +288 -0
  31. mapotofu-0.1.0/src/mapotofu/project.py +42 -0
  32. mapotofu-0.1.0/src/mapotofu/release.py +73 -0
  33. mapotofu-0.1.0/src/mapotofu/shards.py +87 -0
  34. mapotofu-0.1.0/src/mapotofu/slices.py +119 -0
  35. mapotofu-0.1.0/src/mapotofu/sources.py +235 -0
  36. mapotofu-0.1.0/src/mapotofu/stamps.py +137 -0
  37. mapotofu-0.1.0/src/mapotofu/tiers.py +47 -0
  38. mapotofu-0.1.0/src/mapotofu/tools/__init__.py +63 -0
  39. mapotofu-0.1.0/src/mapotofu/tools/change.py +258 -0
  40. mapotofu-0.1.0/src/mapotofu/tools/points.py +117 -0
  41. mapotofu-0.1.0/src/mapotofu/tools/proof.py +143 -0
  42. mapotofu-0.1.0/src/mapotofu/tools/raster.py +145 -0
  43. mapotofu-0.1.0/src/mapotofu/tools/same.py +123 -0
  44. mapotofu-0.1.0/src/mapotofu/tools/sheet.py +113 -0
  45. mapotofu-0.1.0/src/mapotofu/tools/skeleton.py +411 -0
  46. mapotofu-0.1.0/src/mapotofu/tools/specimen.py +94 -0
  47. mapotofu-0.1.0/src/mapotofu/tools/stems.py +138 -0
  48. mapotofu-0.1.0/src/mapotofu/tools/ttf2otf.py +110 -0
  49. mapotofu-0.1.0/src/mapotofu/tools/weights.py +105 -0
  50. mapotofu-0.1.0/src/mapotofu/zones.py +303 -0
  51. mapotofu-0.1.0/tests/__init__.py +0 -0
  52. mapotofu-0.1.0/tests/conftest.py +8 -0
  53. mapotofu-0.1.0/tests/project/mapotofu.toml +141 -0
  54. mapotofu-0.1.0/tests/test_charsets.py +25 -0
  55. mapotofu-0.1.0/tests/test_cli.py +142 -0
  56. mapotofu-0.1.0/tests/test_cut.py +89 -0
  57. mapotofu-0.1.0/tests/test_hintcache.py +61 -0
  58. mapotofu-0.1.0/tests/test_metrics.py +113 -0
  59. mapotofu-0.1.0/tests/test_names.py +111 -0
  60. mapotofu-0.1.0/tests/test_release.py +42 -0
  61. mapotofu-0.1.0/tests/test_stamps.py +38 -0
  62. mapotofu-0.1.0/tests/test_tools.py +178 -0
  63. mapotofu-0.1.0/tests/test_tools_weight.py +122 -0
  64. mapotofu-0.1.0/tests/test_zones.py +62 -0
@@ -0,0 +1,5 @@
1
+ /.venv/
2
+ __pycache__/
3
+ .pytest_cache/
4
+ /dist/
5
+ *.part
mapotofu-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,310 @@
1
+ Metadata-Version: 2.5
2
+ Name: mapotofu
3
+ Version: 0.1.0
4
+ Summary: Build CJK composite fonts (CFF2 variable and static CFF, hinted) from a TOML description
5
+ Project-URL: Repository, https://github.com/lutianyu2001/mapotofu
6
+ Project-URL: Issues, https://github.com/lutianyu2001/mapotofu/issues
7
+ Author: Tianyu (Sky) Lu
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: CFF2,CJK,OpenType,font,font-build,variable-font
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Text Processing :: Fonts
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: afdko>=5.0.1
20
+ Requires-Dist: brotli>=1.2.1
21
+ Requires-Dist: cffsubr>=0.4.0
22
+ Requires-Dist: fonttools[lxml,unicode]>=4.68.0
23
+ Requires-Dist: freetype-py>=2.5.1
24
+ Requires-Dist: numpy>=2.5.4
25
+ Requires-Dist: pillow>=13.0.0
26
+ Requires-Dist: scikit-image>=0.26.0
27
+ Requires-Dist: scipy>=1.18.1
28
+ Requires-Dist: uharfbuzz>=0.57.0
29
+ Description-Content-Type: text/markdown
30
+
31
+ # mapotofu
32
+ <p align="right">
33
+ <strong>English</strong> | <a href="https://github.com/lutianyu2001/mapotofu/blob/main/README/README_CN.md">中文</a> | <a href="https://github.com/lutianyu2001/mapotofu/blob/main/README/README_JP.md">日本語</a>
34
+ </p>
35
+
36
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)<br>
37
+ [![CI](https://github.com/lutianyu2001/mapotofu/actions/workflows/ci.yml/badge.svg)](https://github.com/lutianyu2001/mapotofu/actions/workflows/ci.yml)
38
+
39
+ mapotofu is a build program for CJK composite fonts: it merges a CJK font with a Latin font, and optionally CJK italic sources (a regular-script or slanted font drawn as such), into hinted variable and static fonts, from one TOML file per font project.
40
+
41
+ ## Table of Contents
42
+
43
+ - [Overview](#overview)
44
+ - [Features](#features)
45
+ - [Prerequisites](#prerequisites)
46
+ - [Installation](#installation)
47
+ - [Usage](#usage)
48
+ - [Font Project Layout](#font-project-layout)
49
+ - [Configuration](#configuration)
50
+ - [Output Files](#output-files)
51
+ - [Testing](#testing)
52
+ - [Compatibility](#compatibility)
53
+ - [Disclaimer](#disclaimer)
54
+ - [License](#license)
55
+ - [Author](#author)
56
+
57
+ ## Overview
58
+
59
+ A font project is a directory holding a `mapotofu.toml`. mapotofu reads it, downloads the source fonts the project lists, builds every font of every family, region and style in two steps, and packs the result into zip files for a release:
60
+
61
+ 1. **Fonts**: each font is assembled from the sources as an unhinted CFF2 variable font, with the metadata a web package will need.
62
+ 2. **Desktop**: the variable fonts are hinted with otfautohint, the static weights are instanced from them, and both are packaged as standalone OTF files and OTC collections.
63
+
64
+ The CJK part comes from the variable region fonts of Source Han Sans; the Latin part and, when the project gives any, the ideographs and kana of the italics come from the fonts the project names.
65
+
66
+ ## Features
67
+
68
+ - **Variable and static**: CFF2 variable-weight fonts, and static CFF instances of the named weights.
69
+ - **Families**: any of Gothic, UI and Mono.
70
+ - Gothic: curly quotes, the middle dot, the ellipsis and the em dash are full width, in the forms of the region.
71
+ - UI: curly quotes keep their proportional width, as in Latin text.
72
+ - Mono: fixed pitch, Latin and punctuation in half-width cells (a Latin source's `scale` makes it fit).
73
+ - **Regions**: any of SC, TC and J, each with its own glyph forms, language system and local names.
74
+ - **Extensions**: ideographs outside each region's common list go into separate extension fonts, so the main fonts stay small.
75
+ - **Italics**: Latin italics with the upright CJK glyphs, or, for the regions listed in `[fonts.italic_cjk]`, with those of the CJK italic sources; the variable italics switch between their weights along the weight axis (`rvrn`), and each static italic takes the nearest one. A source whose em box differs (such as a narrow font) can be scaled (`scale_x`, `scale_y`) and centred in the full width (`advance`).
76
+ - **Hint cache**: hints are kept per glyph in the project's `hints/`, so each glyph is hinted once and later builds take its hints from there.
77
+ - **Incremental**: work is redone only where what it is made from changed (sources, configuration, code, library versions); an interrupted or failed run is resumed by running it again.
78
+ - **Collections**: fonts of one pool share their glyph tables, which an OTC stores once.
79
+ - **Tools**: `mapo tool` measures, compares, draws and converts fonts (stroke widths and glyph size, how a family changes with weight, the glyphs that change between two weights unlike their kind, whether two fonts have exactly the same glyphs, the same characters in several fonts side by side, every glyph of a font at several weights, the points of an outline, sample lines, TrueType outlines to OTF); the modules behind them can be imported as a Python library.
80
+
81
+ ## Prerequisites
82
+
83
+ - Python ≥3.12
84
+ - [uv](https://docs.astral.sh/uv/)
85
+ - Dependencies, installed with mapotofu: afdko ≥5.0.1 (otfautohint and tx), fontTools ≥4.68.0, cffsubr ≥0.4.0, uharfbuzz ≥0.57.0, brotli ≥1.2.1; for the tools, freetype-py ≥2.5.1, NumPy ≥2.5.4, Pillow ≥13.0.0, scikit-image ≥0.26.0, SciPy ≥1.18.1
86
+ - Memory: subroutinizing a static font takes about 100 times its size. mapotofu records what each job took in `build/memory.json` and starts a job only when that much memory is free.
87
+
88
+ ## Installation
89
+
90
+ ### As a Dependency of the Font Project (Recommended)
91
+
92
+ 1. In the font project (a uv project with a `pyproject.toml`), add mapotofu:
93
+
94
+ ```bash
95
+ uv add mapotofu
96
+ ```
97
+
98
+ 2. Run it from the project:
99
+
100
+ ```bash
101
+ uv run mapo all
102
+ ```
103
+
104
+ Note: a font project that wants the same fonts from the same tag should pin mapotofu to a version, e.g. `uv add "mapotofu==<version>"`.
105
+
106
+ ### As a Tool
107
+
108
+ ```bash
109
+ uvx --from mapotofu mapo all
110
+ ```
111
+
112
+ ### Building from Source
113
+
114
+ ```bash
115
+ git clone https://github.com/lutianyu2001/mapotofu.git
116
+ cd mapotofu
117
+ uv sync
118
+ ```
119
+
120
+ A font project can then take it by path in its `pyproject.toml`:
121
+
122
+ ```toml
123
+ [tool.uv.sources]
124
+ mapotofu = { path = "../mapotofu", editable = true }
125
+ ```
126
+
127
+ ## Usage
128
+
129
+ Run in a font project, i.e. the directory holding `mapotofu.toml` or one below it. `MAPOTOFU_ROOT` names the project when run from elsewhere. `-h`, `--version` and `--man` work in any directory. `mapo` and `mapotofu` are the same command.
130
+
131
+ ```shell
132
+ mapo [-h] [-j N] [--only [KEY ...]] [--man] [--version] STEP
133
+ ```
134
+
135
+ | Step | Description |
136
+ |---------|-------------|
137
+ | `fetch` | Download the sources listed in `sources.toml` into `sources/` |
138
+ | `fonts` | First step: the unhinted variable fonts in `build/fonts/` |
139
+ | `desktop` | Second step: the hinted fonts in `dist/` (OTF, OTC) |
140
+ | `all` | Both steps |
141
+ | `prune-hints` | Drop entries of the hint cache that no font uses any more (after a source changed) |
142
+ | `collections` | Only the OTC collections, from the pooled fonts in `build/pooled/` |
143
+ | `release` | Pack `dist/` into `dist/release/*.zip` by family and region |
144
+
145
+ - `-j, --jobs` (default: 4)
146
+ - Parallel processes; for `desktop`, the pools hinted at once, each over cores/N runs
147
+ - `--only`
148
+ - For `fonts`, `desktop` and `all`: only the pools of these fonts, such as `Gothic-SC-Upright`, or these pools, such as `Italic-SC`
149
+ - `--man`
150
+ - Show the manual (see [Manual](#manual))
151
+ - `--version`
152
+ - Print the version
153
+
154
+ Recommended order for a new project:
155
+
156
+ 1. Download the sources:
157
+
158
+ ```bash
159
+ uv run mapo fetch
160
+ ```
161
+
162
+ 2. Build everything:
163
+
164
+ ```bash
165
+ uv run mapo all
166
+ ```
167
+
168
+ 3. Pack the release:
169
+
170
+ ```bash
171
+ uv run mapo release
172
+ ```
173
+
174
+ *If a run stops (out of memory, interrupted), run the same command again: finished work is kept.*
175
+
176
+ ### Tools
177
+
178
+ `mapo tool NAME` runs one of the tools that come with mapotofu. They take font files and need no font project, so they run in any directory; `mapo tool` lists them and `mapo tool NAME -h` shows the arguments of one.
179
+
180
+ | Tool | Description |
181
+ |---------|-------------|
182
+ | `ttf2otf FONT OUT.otf` | A font with TrueType outlines made into an OTF with PostScript outlines (CFF), subroutinized; the other direction is AFDKO's `otf2ttf` |
183
+ | `points FONT TEXT` | The points of glyphs' outlines as the font stores them: number, x, y, on the curve or off; `--box X0 Y0 X1 Y1` for one part of a glyph |
184
+ | `same FONT FONT` | Whether two fonts have exactly the same glyphs (outlines and advance widths), and which differ: the check that a change left the fonts alone. Exit status 0 if the same, 1 if not |
185
+ | `sheet OUT.png TEXT FONT...` | The same characters in several fonts, a row each, to compare by eye; with `--zoom CHAR X Y WIDTH`, one spot of a glyph in each font instead |
186
+ | `specimen FONT OUT.png` | Sample lines of a font at several weights, shaped as text is |
187
+ | `stems FONT...` | Stroke widths (vertical, horizontal, their ratio) and glyph size of fonts, in units of 1000 per em: which weight of a source matches a master, and what `scale` fits one font to another |
188
+ | `weights FONT FONT...` | How the measures of a family change with weight: the strokes, the width of the ink, the side bearings and the advance of each weight in percent of one of them |
189
+ | `change LIGHT HEAVY` | The glyphs that change between two weights of a font unlike the others of their kind (ink, thick and thin strokes, width, height, advance), the furthest off first: where to look in a weight that was derived from another. `--reference LIGHT HEAVY` takes the spread a kind may have from another family |
190
+ | `proof OUT FONT...` | Every glyph of a font, a cell a font, into `OUT-01.png`, `OUT-02.png`, ...: the weights of a variable font, to see that every glyph interpolates, or two builds |
191
+
192
+ A `FONT` is a file, a face of a collection (`Font.ttc#2`) or a place on the axes of a variable font (`Font[wght].ttf@wght=500`).
193
+
194
+ Example:
195
+
196
+ ```bash
197
+ mapo tool stems <FONT_A> "<FONT_B>@wght=400"
198
+ mapo tool sheet <OUT.png> "永国あA" <FONT_A> "<FONT_B>@wght=400"
199
+ ```
200
+
201
+ The tools are modules of the package `mapotofu.tools`, and their functions can be imported, as can the two modules they are made of: `mapotofu.tools.raster` (fonts opened by such a spec, their glyphs rasterised) and `mapotofu.tools.skeleton` (the skeleton of a glyph as a graph, with the width of its strokes and strokes traced through junctions).
202
+
203
+ ```python
204
+ from mapotofu.tools.raster import FontSource
205
+ from mapotofu.tools.stems import font_stems
206
+
207
+ print(font_stems(FontSource("<FONT>")))
208
+ ```
209
+
210
+ ### Manual
211
+
212
+ `man mapo` (or `man mapotofu`) is the whole manual, in English and in Chinese: the steps and options, and every key of `mapotofu.toml` and `sources.toml`, with a complete example. mapotofu installs it into its environment, so `man` finds it wherever that environment's `bin` is on `PATH`, as under `uv run`:
213
+
214
+ ```bash
215
+ uv run man mapo
216
+ ```
217
+
218
+ `mapo --man` shows the same page from anywhere: in the pager, in the language of the locale.
219
+
220
+ ## Font Project Layout
221
+
222
+ | Path | Contents |
223
+ |------|----------|
224
+ | `mapotofu.toml` | The fonts' configuration (see [Configuration](#configuration)) |
225
+ | `sources.toml` | Where the source fonts are downloaded from, with their SHA-256 |
226
+ | `data/common-<region>.txt` | The common ideographs of each region, one hexadecimal code point per line (`#` starts a comment); the others go into the extension fonts |
227
+ | `hints/` | The hint cache, and the list of glyphs left unhinted; source data, to be committed |
228
+ | `OFL.txt` | The fonts' license; `release` packs nothing without it |
229
+ | `sources/`, `build/`, `dist/` | Downloaded sources, intermediate files and output; not committed |
230
+
231
+ `sources.toml` lists zip archives, with the members to take, and single files:
232
+
233
+ ```toml
234
+ [[archive]]
235
+ url = "<URL of a zip file>"
236
+ sha256 = "<SHA-256 of the file>"
237
+ members = { "<path inside the zip>" = "<name under sources/>" }
238
+
239
+ [[file]]
240
+ url = "<URL of a font file>"
241
+ sha256 = "<SHA-256 of the file>"
242
+ ```
243
+
244
+ ## Configuration
245
+
246
+ `mapotofu.toml` has four tables. Which one a change is in decides how much is built again:
247
+
248
+ | Table | Holds | Changing it |
249
+ |-------|-------|-------------|
250
+ | `[fonts]` | Regions, families, the weight axis and its masters, the CJK, Latin and (optional) CJK italic sources | Builds the fonts anew |
251
+ | `[meta]` | Version, designer, copyright, license, vendor ID, named weights, family and style names | Only finalizes the built fonts again |
252
+ | `[hints]` | Where the hint cache keeps the hints of each source's glyphs | Second step only |
253
+ | `[package]` | The name of the collections and their zips | Second step only |
254
+
255
+ The manual explains every key and has a complete example (see [Manual](#manual)); `tests/project/mapotofu.toml` is a full configuration with comments.
256
+
257
+ ## Output Files
258
+
259
+ | Path | Contents |
260
+ |------|----------|
261
+ | `build/fonts/*.otf`, `*.json` | First step: unhinted variable fonts sharing a glyph pool, and their metadata |
262
+ | `dist/variable/*.otf` | Hinted CFF2 variable fonts, upright and italic |
263
+ | `dist/static/*.otf` | Static CFF fonts of the named weights |
264
+ | `dist/otc/*.otc` | Collections, variable and static |
265
+ | `dist/release/*.zip` | The release: a `-VF.zip` and a `-static.zip` for each family and region, and the collections; each carries `OFL.txt` |
266
+
267
+ Note: fonts made from other fonts are Modified Versions of them. With sources under the SIL Open Font License, the result must be released under it too, and its names must not use the sources' Reserved Font Names (Source Han Sans reserves "Source").
268
+
269
+ ## Testing
270
+
271
+ ```bash
272
+ uv run pytest
273
+ ```
274
+
275
+ The tests run on `tests/project`, which builds nothing. Tests on built fonts belong to the font project.
276
+
277
+ ## Compatibility
278
+
279
+ Tested on:
280
+
281
+ - Ubuntu 24.04.4 LTS, 32 cores, 32 GB of memory
282
+ - Python 3.12.3, afdko 5.0.1, fontTools 4.68.0, cffsubr 0.4.0, uharfbuzz 0.57.0
283
+ - Source Han Sans 2.005R
284
+ - GitHub Actions `ubuntu-latest`, one pool per job
285
+
286
+ ## Disclaimer
287
+
288
+ This project is not affiliated with, endorsed by, or sponsored by Adobe Inc. Adobe and Source are either registered trademarks or trademarks of Adobe in the United States and/or other countries and are referenced here solely for descriptive purposes.
289
+
290
+ ## License
291
+
292
+ Copyright 2026 Tianyu (Sky) Lu
293
+
294
+ The entire repository is licensed under the Apache License, Version 2.0
295
+ (the "License"); you may not use any file in this repository except in
296
+ compliance with the License. You may obtain a copy of the License at
297
+
298
+ ```plaintext
299
+ http://www.apache.org/licenses/LICENSE-2.0
300
+ ```
301
+
302
+ Unless required by applicable law or agreed to in writing, software
303
+ distributed under the License is distributed on an "AS IS" BASIS,
304
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
305
+ See the License for the specific language governing permissions and
306
+ limitations under the License.
307
+
308
+ ## Author
309
+
310
+ Tianyu (Sky) Lu