Skip to content

Commit

Permalink
Bump east-asian-spacing to 1.3.2
Browse files Browse the repository at this point in the history
* Change `output` to optional, as east-asian-spacing 1.3.2 has a test
  for saving to the same file.
* Switch to use `build_and_save` shorthand.
  • Loading branch information
kojiishi committed Aug 8, 2021
1 parent cbfb343 commit 0d579ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
setup_requires=["setuptools_scm"],
install_requires=[
"east-asian-spacing>=1.3.1",
"east-asian-spacing>=1.3.2",
],
extras_require={
"dev": [
Expand Down
21 changes: 10 additions & 11 deletions src/chws_tool/add_chws.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import pathlib
import sys
import time
import typing
from typing import Optional
from typing import Union

import east_asian_spacing as chws
from chws_tool.config import GoogleFontsConfig
Expand All @@ -29,10 +30,10 @@


async def add_chws_async(
input: typing.Union[str, os.PathLike],
output: typing.Union[str, os.PathLike],
input: Union[str, os.PathLike],
output: Optional[Union[str, os.PathLike]] = None,
**kwargs,
) -> typing.Optional[pathlib.Path]:
) -> Optional[pathlib.Path]:
"""Add OpenType chws/vchw features to a font.
Returns the path of the output font,
Expand All @@ -42,12 +43,10 @@ async def add_chws_async(
`east_asian_spacing.Builder.save()`."""

builder = chws.Builder(input, config=GoogleFontsConfig.default)
await builder.build()
if not builder.has_spacings:
output_path = await builder.build_and_save(output, **kwargs)
if not output_path:
logger.info('Skipped saving due to no changes: "%s"', input)
return None

output_path = builder.save(output, **kwargs)
logger.info("%s ==> %s", input, output_path)

await builder.test()
Expand All @@ -56,10 +55,10 @@ async def add_chws_async(


def add_chws(
input: typing.Union[str, os.PathLike],
output: typing.Union[str, os.PathLike],
input: Union[str, os.PathLike],
output: Optional[Union[str, os.PathLike]] = None,
**kwargs,
) -> typing.Optional[pathlib.Path]:
) -> Optional[pathlib.Path]:
loop = asyncio.get_event_loop()
return loop.run_until_complete(add_chws_async(input, output, **kwargs))

Expand Down

0 comments on commit 0d579ca

Please sign in to comment.