Package: chws-tool
chws_toolThis tool adds the OpenTypechws,vchw,halt, andvhalfeatures to OpenType/TrueType fonts when any of these features are missing.
Please seeeast-asian-spacingfor details of these features.This tool uses theeast-asian-spacingpackage as its core engine,
and has following advantages:Simpler API and command line options.Supports CJK fonts atfonts.google.comin its built-inconfig.To add new fonts to the supported font list,
please see theAdding Fontssection below.Installpipinstallchws-toolIf you want to clone and install
in theeditable modewith the development packages:gitclonehttps://github.com/googlefonts/chws_tool.gitcdchws_tool
pipinstall-e'.[dev]'Command Line UsageThe following example adds the features toinput.otfand saves it to thebuilddirectory.
If the argument is a directory,
the tool expands it to all fonts in the directory recursively.add-chwsinput.otfUse the-ooption to change the output directory,
or the--helpoption for the full list of options.add-chwsinput_dir-ooutput_dirAPIThe following example creates a font with the features
in the "build" directory
if the features are applicable:importchws_tooldefmain():output_path=chws_tool.add_chws("fonts/input.otf","build")ifoutput_path:print(f"Success! saved to{output_path}")else:print("Skipped")If you prefer to overwrite existing fonts, you can omit the output directory.importchws_tooldefmain():chws_tool.add_chws("fonts/input.otf")If your program usesasyncio:importasyncioimportchws_toolasyncdefmain_async():output_path=awaitchws_tool.add_chws_async("fonts/input.otf","build")ifoutput_path:print(f"Success! saved to{output_path}")else:print("Skipped")asyncio.run(main_async())Adding FontsThis package has a built-in list of supported fonts in itsconfig.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:Find the font names.
Running theadd-chwswith--print-nameoption can print them.Add them to theconfig.(Optional) Build the font and run theVisual Test.
This step is optional
because this package automatically avoids glyph collisions
by computing glyph outlines.(Optional) Tweak theconfigif needed.Visual TestThe 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 inUAX#50or inCLREQ.
Unfortunately, not all fonts follow the conventions.To run the visual test:Add the test font to the font list
in the top<script>block oftests/test.html.Open it in your browser.Check "Fullwidth", "Upright", and "Hide same size" check boxes.Here is the check list and tips:Find where glyphs are too tight or collide
when the feature is on but look fine without the feature.Quotation marks can collide most often,
especially in vertical flow but sometimes in horizontal flow too."Open+Open" and "Close+Close" are more likely to collide than other pairs.Select glyphs to check how much inks overflow the glyph metrics.Test both horizontal and vertical flows
by flipping the "Vertical" checkbox.Other controls in the test are not mandatory,
but they may be useful in following cases.Uncheck "Hide same size" to see cases where kernings are not applied
by the built-in rules.
They are usually fine.
In most cases, they are because the glyphs are missing,
they are not full-width,
or the pair should not apply for the script of the font.
The test file contaisn code poitns for all East Asian scripts,
but not all code points should apply spacings for all script.The "Language" list does not matter in most cases,
except when the font supports multiple locales,
such as Noto CJK.The "Fullwidth" feature can change glyphs,
but in most cases,
if glyphs look ok with the feature on,
they should be ok with the feature off.The "Upright" feature is only valid in the vertical flow.
You can just check it on,
for the same reason as the "Fullwidth" feature.The "Characters" input fields can change the test cases.
You don't have to change them unless you have specific needs.ReleasingSeehttps://googlefonts.github.io/python#make-a-release.