Skip to content

Commit

Permalink
fix: revert font generation
Browse files Browse the repository at this point in the history
  • Loading branch information
feram18 committed Oct 6, 2022
1 parent cdcf144 commit c57c0f3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 19 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Log Files
*.log*

# Generated Fonts
assets/fonts/*.pbm
assets/fonts/*.pil

# Submodules
rpi-rgb-led-matrix/*

Expand Down
Binary file added assets/fonts/tom-thumb.pbm
Binary file not shown.
Binary file added assets/fonts/tom-thumb.pil
Binary file not shown.
2 changes: 1 addition & 1 deletion config/layout/w64h32.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"font": "tom-thumb",
"font": "assets/fonts/tom-thumb.pil",
"standings": {
"constructors": {
"row_height": 8,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@pytest.mark.skipif(not sys.platform.startswith('linux'), reason='Requires Linux')
class TestUtils:
def setup_method(self):
self.font = utils.load_font('tom-thumb')
self.font = utils.load_font('assets/fonts/tom-thumb.bdf')

def test_read_json(self, caplog):
caplog.clear()
Expand Down
16 changes: 3 additions & 13 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,15 @@ def read_json(filename: str) -> dict:
logging.error(f"Couldn't find file at {filename}")


def load_font(name: str) -> ImageFont:
def load_font(path: str) -> ImageFont:
"""
Return ImageFont object from given font name
:param name: Font name
:param path: Font path
:return: font: ImageFont object
"""
path = f'{FONTS_DIR}/{name}.pil'
if os.path.isfile(path):
return ImageFont.load(path)

path = f'{FONTS_DIR}/{name}.bdf'
if os.path.isfile(path):
return load_font(convert_font(path))

path = f'{LIB_FONTS_DIR}/{name}.bdf'
if os.path.isfile(path):
return load_font(convert_font(path))

logging.error(f"Couldn't find font {name}.")
logging.error(f"Couldn't find font {path}.")


def convert_font(filename: str) -> str:
Expand Down

0 comments on commit c57c0f3

Please sign in to comment.