Skip to content

Commit

Permalink
Specify font SourceHanSerifTC for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-seifert committed Nov 9, 2023
1 parent b6039ce commit 54a6703
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/tests/test_painter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ def test_set_colour_theme(self):
def test_get_text_dimension(self):
painter = PNGPainter(100, 100)
text = "Hello World"
font = "Arial"
font = "../fonts/SourceHanSerifTC-Regular.otf"
font_size = 12
width, height = painter.get_text_dimension(text, font, font_size)
assert width > 0
assert height > 0

def test_get_text_dimension2(self):
painter = PNGPainter(800, 600)
text_width, text_height = painter.get_text_dimension("Hello World", "Arial", 12)
text_width, text_height = painter.get_text_dimension(
"Hello World",
"../fonts/SourceHanSerifTC-Regular.otf",
12,
)
print(f"text_width: {text_width}, text_height: {text_height}")
# Linux returns different text width
assert text_width in [62, 64]
assert text_width in [71, 73]
assert text_height == 11

0 comments on commit 54a6703

Please sign in to comment.