Skip to content

Commit

Permalink
Merge pull request #123 from simopt-admin/hotfix_font_size
Browse files Browse the repository at this point in the history
Fix extremely small font size on "small" displays
  • Loading branch information
Grochocinski authored Dec 10, 2024
2 parents e9b4dcd + 306cb4b commit c99d1a5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions simopt/gui/toplevel_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ def set_style(self) -> None:
self.style = ttk.Style()
# Configure the default fonts based on screen size
# https://tkinter-docs.readthedocs.io/en/latest/generic/fonts.html
# Scale by width because it's easy to scroll vertically, but scrolling
# horizontally is a pain. This way, the text will always fit on
# the screen.
width = self.winfo_screenwidth()
font_medium = int(width / 200)
height = self.winfo_screenheight()
# If it's wider than 16:9 (like 21:9 or 32:9), use the height to
# calculate the equivalent width
if (width / height) > (16 / 9):
width = height * (16 / 9)
# Otherwise, we're good with just using the width
# Target a 1920x1080 screen
scale = width / 1920

font_medium = int(12 * scale)
if sys.platform == "darwin":
win_to_mac_scaling = 1.375
font_medium = int(font_medium * win_to_mac_scaling)
Expand Down

0 comments on commit c99d1a5

Please sign in to comment.