From e982ed30175c370d6bbc70d6df8b0b88f3e28229 Mon Sep 17 00:00:00 2001 From: FriedrichFroebel Date: Sun, 22 Sep 2024 11:25:05 +0200 Subject: [PATCH] do not run on Python 3.8 and improve docs --- .github/workflows/ci.yml | 2 ++ README.md | 2 ++ brother_ql_web/font_helpers.py | 8 +++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 069ea70..f74b37b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,10 +45,12 @@ jobs: - name: install fontra run: python -m pip install .[fontra] + if: ${{ matrix.python != '3.8' }} - name: run tests with fontra run: | python -c "from brother_ql_web.font_helpers import _has_fontra; assert _has_fontra()" python -m unittest discover --verbose --start-directory tests + if: ${{ matrix.python != '3.8' }} - name: run flake8 run: python -m flake8 diff --git a/README.md b/README.md index 7b2f3b3..d63a9b0 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ It's also possible to install it from source for the current interpreter with: In addition to the Python package requirements itself, `fontconfig` should be installed on your system. It's used to identify and inspect fonts on your machine. This package is pre-installed on many Linux distributions. If you're using a Mac, you might want to use [Homebrew](https://brew.sh) to install fontconfig using [`brew install fontconfig`](https://formulae.brew.sh/formula/fontconfig). +If you are not able to install or use `fontconfig` for some reasons, `fontra` is available as a fallback. You can install if using the `fontra` extra. + ### Configuration file Grab a copy of the [example configuration file](https://github.com/FriedrichFroebel/brother_ql_web/blob/master/config.example.json) and adjust it to your needs. You can store this file on your device wherever you want - just make sure to remember the full path as you will have to pass it to the CLI. diff --git a/brother_ql_web/font_helpers.py b/brother_ql_web/font_helpers.py index 1b640f6..6c16697 100644 --- a/brother_ql_web/font_helpers.py +++ b/brother_ql_web/font_helpers.py @@ -19,7 +19,6 @@ def get_fonts(folder: str | None = None) -> dict[str, dict[str, str]]: return _get_fonts_using_fontconfig(folder) - def _get_fonts_using_fontconfig(folder: str | None = None) -> dict[str, dict[str, str]]: fonts: dict[str, dict[str, str]] = defaultdict(dict) if folder: @@ -49,7 +48,6 @@ def _get_fonts_using_fontconfig(folder: str | None = None) -> dict[str, dict[str continue for i in range(len(families)): fonts[families[i]][styles[i]] = path - print(families[i], '|', styles[i], path) # logger.debug("Added this font: %s", (families[i], styles[i], path)) return dict(fonts) @@ -75,6 +73,10 @@ def _get_fonts_using_fontra(folder: str | None = None) -> dict[str, dict[str, st for family in families: styles = fontra.get_font_styles(family, classical=True) for style in styles: - path: str = fontra.get_font(family, style, classical=True).path.absolute().as_posix() + path: str = ( + fontra.get_font(family, style, classical=True) + .path.absolute() + .as_posix() + ) fonts[family][style] = path return dict(fonts)