Skip to content

Commit

Permalink
do not run on Python 3.8 and improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedrichFroebel committed Sep 22, 2024
1 parent 7eebba8 commit e982ed3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions brother_ql_web/font_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand All @@ -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)

0 comments on commit e982ed3

Please sign in to comment.