This tool adds the OpenType
chws, vchw, halt, and vhal
features to OpenType/TrueType fonts when any of these features are missing.
Please see east-asian-spacing for details of these features.
This tool uses the east-asian-spacing package as its core engine, and has following advantages:
To add new fonts to the supported font list, please see the Adding Fonts section below.
You can install this tool by pipx or uv.
pipx install chws-tool
uv tool install chws-tool
Using pip is also supported, but please be aware that, if you install with pip in the global environment, its dependencies may cause conflicts with other packages. If all what you need is the command line tool, pipx or uv can install it globally while still isolating it in a virtual environment.
pip install chws-tool
The following example adds the features to input.otf
and saves it to the build directory.
If the argument is a directory,
the tool expands it to all fonts in the directory recursively.
add-chws input.otf
Use the -o option to change the output directory,
or the --help option for the full list of options.
add-chws input_dir -o output_dir
The following example creates a font with the features
in the "build" directory
if the features are applicable:
import chws_tool
def main():
output_path = chws_tool.add_chws("fonts/input.otf", "build")
if output_path:
print(f"Success! saved to {output_path}")
else:
print("Skipped")
If you prefer to overwrite existing fonts, you can omit the output directory.
import chws_tool
def main():
chws_tool.add_chws("fonts/input.otf")
If your program uses asyncio:
import asyncio
import chws_tool
async def main_async():
output_path = await chws_tool.add_chws_async("fonts/input.otf", "build")
if output_path:
print(f"Success! saved to {output_path}")
else:
print("Skipped")
asyncio.run(main_async())
If you want to clone the repository and install in the editable mode with the development packages, using uv:
git clone https://github.com/googlefonts/chws_tool.git
cd chws_tool
uv sync
. .venv/bin/activate
uv tool install -e .
If you prefer using pip:
git clone https://github.com/googlefonts/chws_tool.git
cd chws_tool
pip install -e '.[dev]'
This package has a built-in list of supported fonts in its config.
Fonts not in the known list are still processed with the default configuration, but this package shows a warning message.
When adding new fonts to the known font list, the following process is recommended:
add-chws with --print-name option can print them.The primary purpose of this process is to find too tight spacings or glyph collisions caused by the kernings.
This tool has heuristic rules to determine the applicability of the spacings using the glyph metrics, but assumes that full-width punctuation glyphs have enough internal spacings according to linguistic conventions as in UAX#50 or in CLREQ. Unfortunately, not all fonts follow the conventions.
To run the visual test:
<script> block of tests/test.html.Here is the check list and tips:
Other controls in the test are not mandatory, but they may be useful in following cases.
Create a new release on github, by creating a new tag with a leading ‘v’ followed by three MAJOR.MINOR.PATCH digits, using semantic versioning.
HTML
52.4%
Python
45.2%
Shell
2.4%
This tool adds the OpenType
chws, vchw, halt, and vhal
features to OpenType/TrueType fonts when any of these features are missing.
Please see east-asian-spacing for details of these features.
This tool uses the east-asian-spacing package as its core engine, and has following advantages:
To add new fonts to the supported font list, please see the Adding Fonts section below.
You can install this tool by pipx or uv.
pipx install chws-tool
uv tool install chws-tool
Using pip is also supported, but please be aware that, if you install with pip in the global environment, its dependencies may cause conflicts with other packages. If all what you need is the command line tool, pipx or uv can install it globally while still isolating it in a virtual environment.
pip install chws-tool
The following example adds the features to input.otf
and saves it to the build directory.
If the argument is a directory,
the tool expands it to all fonts in the directory recursively.
add-chws input.otf
Use the -o option to change the output directory,
or the --help option for the full list of options.
add-chws input_dir -o output_dir
The following example creates a font with the features
in the "build" directory
if the features are applicable:
import chws_tool
def main():
output_path = chws_tool.add_chws("fonts/input.otf", "build")
if output_path:
print(f"Success! saved to {output_path}")
else:
print("Skipped")
If you prefer to overwrite existing fonts, you can omit the output directory.
import chws_tool
def main():
chws_tool.add_chws("fonts/input.otf")
If your program uses asyncio:
import asyncio
import chws_tool
async def main_async():
output_path = await chws_tool.add_chws_async("fonts/input.otf", "build")
if output_path:
print(f"Success! saved to {output_path}")
else:
print("Skipped")
asyncio.run(main_async())
If you want to clone the repository and install in the editable mode with the development packages, using uv:
git clone https://github.com/googlefonts/chws_tool.git
cd chws_tool
uv sync
. .venv/bin/activate
uv tool install -e .
If you prefer using pip:
git clone https://github.com/googlefonts/chws_tool.git
cd chws_tool
pip install -e '.[dev]'
This package has a built-in list of supported fonts in its config.
Fonts not in the known list are still processed with the default configuration, but this package shows a warning message.
When adding new fonts to the known font list, the following process is recommended:
add-chws with --print-name option can print them.The primary purpose of this process is to find too tight spacings or glyph collisions caused by the kernings.
This tool has heuristic rules to determine the applicability of the spacings using the glyph metrics, but assumes that full-width punctuation glyphs have enough internal spacings according to linguistic conventions as in UAX#50 or in CLREQ. Unfortunately, not all fonts follow the conventions.
To run the visual test:
<script> block of tests/test.html.Here is the check list and tips:
Other controls in the test are not mandatory, but they may be useful in following cases.
Create a new release on github, by creating a new tag with a leading ‘v’ followed by three MAJOR.MINOR.PATCH digits, using semantic versioning.
HTML
52.4%
Python
45.2%
Shell
2.4%