Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kneeboard generation following Pillow update. #3202

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions game/missiongenerator/kneeboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,10 @@
# more information in the comm ladder (the latter of which we should
# probably do), we'll need to split some of this information off into a
# second page.
self.title_font = ImageFont.truetype(
"arial.ttf", 32, layout_engine=ImageFont.LAYOUT_BASIC
)
self.heading_font = ImageFont.truetype(
"arial.ttf", 24, layout_engine=ImageFont.LAYOUT_BASIC
)
self.content_font = ImageFont.truetype(
"arial.ttf", 16, layout_engine=ImageFont.LAYOUT_BASIC
)
self.table_font = ImageFont.truetype(
"resources/fonts/Inconsolata.otf", 20, layout_engine=ImageFont.LAYOUT_BASIC
)
self.title_font = ImageFont.truetype("arial.ttf", 32)
self.heading_font = ImageFont.truetype("arial.ttf", 24)
self.content_font = ImageFont.truetype("arial.ttf", 16)
self.table_font = ImageFont.truetype("resources/fonts/Inconsolata.otf", 20)

Check warning on line 79 in game/missiongenerator/kneeboard.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/kneeboard.py#L76-L79

Added lines #L76 - L79 were not covered by tests
self.draw = ImageDraw.Draw(self.image)
self.page_margin = page_margin
self.x = page_margin
Expand Down Expand Up @@ -116,7 +108,8 @@
)

self.draw.text(self.position, text, font=font, fill=fill)
width, height = self.draw.textsize(text, font=font)
left, top, right, bottom = self.draw.textbbox((0, 0), text, font=font)
height = bottom - top

Check warning on line 112 in game/missiongenerator/kneeboard.py

View check run for this annotation

Codecov / codecov/patch

game/missiongenerator/kneeboard.py#L111-L112

Added lines #L111 - L112 were not covered by tests
self.y += height + self.line_spacing

def title(self, title: str) -> None:
Expand Down Expand Up @@ -330,9 +323,7 @@
self.start_time = start_time
self.dark_kneeboard = dark_kneeboard
self.flight_plan_font = ImageFont.truetype(
"resources/fonts/Inconsolata.otf",
16,
layout_engine=ImageFont.LAYOUT_BASIC,
"resources/fonts/Inconsolata.otf", 16
)

def write(self, path: Path) -> None:
Expand Down
Loading