Skip to content

Commit

Permalink
Include font assets in hagadias
Browse files Browse the repository at this point in the history
Assets can be accessed by hagadias users by using importlib.resources.

- Move assets into subfolder
- Use pathlib instead of os.path for access
- Update license information
  • Loading branch information
syntaxaire committed Dec 12, 2022
1 parent 994772a commit 0823e19
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ print(gamecodes["class_tiles"]["Horticulturist"])
('creatures/caste_1.bmp', 'g')
```

## License

hagadias is licensed under the terms of the GNU Affero General Public License Version 3.

The included font Source Code Pro is used under the terms of the SIL Open Font License 1.1.

The included file `IBMGRAPH.TXT` is provided by the Unicode Consortium under the terms of the license contained therein.

## Contributing

See `CONTRIBUTING.md`.
Expand Down
File renamed without changes.
Binary file added hagadias/assets/SourceCodePro-Bold.ttf
Binary file not shown.
Binary file added hagadias/assets/SourceCodePro-Semibold.ttf
Binary file not shown.
6 changes: 3 additions & 3 deletions hagadias/helpers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Helper functions for hagadias."""

import itertools
import os
import random
import re
from math import gcd
from pathlib import Path
from typing import Iterator, List, Tuple, Optional

import pefile
Expand All @@ -17,9 +17,9 @@
PALETTE.remove("O") # extradimensional color

# load and store the Code Page 437 to Unicode translation
CP437_MAP_FILE = os.path.join(os.path.dirname(__file__), "IBMGRAPH.TXT")
ASSETS = Path(__file__).parent / "assets"
cp437_conv = {}
with open(CP437_MAP_FILE) as f:
with open(ASSETS / "IBMGRAPH.TXT") as f:
for line in f.readlines():
if not line.startswith("#"):
unicode, cp437, *_ = line.split()
Expand Down
4 changes: 3 additions & 1 deletion hagadias/qudtile.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ class StandInTiles:
transparent pixels, suitable to be colored by QudTile, or can return a pre-colored image.
"""

FONT_SOURCECODEPRO = ImageFont.truetype("helpers/SourceCodePro-Semibold.ttf", 260)
ASSETS = Path(__file__).parent / "assets"
SOURCECODEPRO_FILE = ASSETS / "SourceCodePro-Semibold.ttf"
FONT_SOURCECODEPRO = ImageFont.truetype(str(SOURCECODEPRO_FILE), 260)

_hologram_material_glyph1: Image = None
_hologram_material_glyph2: Image = None
Expand Down

0 comments on commit 0823e19

Please sign in to comment.