Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kojiishi committed Jul 18, 2021
1 parent a32fd07 commit f30427e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pip install -e '.[dev]'

[editable mode]: https://pip.pypa.io/en/stable/cli/pip_install/#install-editable

## Usage
## Command Line Usage

The following example adds the features to `input.otf`
and saves it to the `build` directory.
Expand Down Expand Up @@ -68,18 +68,20 @@ asyncio.run(main_async())
## Adding Fonts
[adding fonts]: #adding-fonts

This tool has a built-in list of supported fonts in its [config],
and ignores fonts not in the list for the following reasons:
* The tool needs to know the language of the font
because the spacing rules vary by the language.
* Fonts may have glyphs
that require tweaking code points to adjust spacing pairs.
This package has a built-in list of supported fonts in its [config].
The list indicates these fonts passed the [visual test],
with possibly tweaked configurations.

When adding new fonts, the following process is recommended:
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:

1. Find the font names.
Running the `add-chws` with `--dump-name` option can print them.
2. Add them to the [config] with the appropriate language.
2. Add them to the [config].
3. Build the font and run the [Visual Test].
4. Tweak the [config] if needed.

Expand Down
14 changes: 9 additions & 5 deletions src/chws_tool/add_chws.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ async def add_chws(
return output_path


def _dump_font_names(inputs):
for input in inputs:
font = chws.Font.load(input)
fonts = font.fonts_in_collection if font.is_collection else (font,)
for font in fonts:
print(font.debug_name(1))


async def main_async() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("inputs", nargs="+")
Expand All @@ -83,11 +91,7 @@ async def main_async() -> None:
inputs = chws.Builder.expand_paths(args.inputs)

if args.dump_name:
for input in inputs:
font = chws.Font.load(input)
fonts = font.fonts_in_collection if font.is_collection else (font,)
for font in fonts:
print(font.debug_name(1))
_dump_font_names(inputs)
return

args.output.mkdir(exist_ok=True, parents=True)
Expand Down
2 changes: 1 addition & 1 deletion src/chws_tool/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def for_font_name(

# Ignore unknown fonts.
# We prefer manual visual check over relying on heuristic rules.
logger.warning('Not a known font, run with the default config: "%s"', name)
logger.warning('Not a known font, using the default config: "%s"', name)
return self


Expand Down

0 comments on commit f30427e

Please sign in to comment.