Files
fbclock/tools/fontsize.py
T
2026-07-09 14:15:38 +03:00

26 lines
792 B
Python

import math
# Screen dimensions
screen_width_pixels = 1440
screen_height_pixels = 900
screen_diagonal_inches = 19
# Calculate the aspect ratio dimensions
aspect_ratio = 8 / 5
height_inches = math.sqrt((screen_diagonal_inches**2) / (1 + aspect_ratio**2))
width_inches = aspect_ratio * height_inches
# Calculate PPI (Pixels Per Inch)
ppi_width = screen_width_pixels / width_inches
ppi_height = screen_height_pixels / height_inches
ppi = (ppi_width + ppi_height) / 2 # Average the PPI
# Convert PPI to PPCM (Pixels Per Centimeter)
ppcm = ppi / 2.54
# Determine the pixel size for 1 cm tall characters
font_pixel_height = int(ppcm * 1) # 1 cm
# Output the calculated font size in pixels
print(f"The font size for 1 cm tall characters should be approximately {font_pixel_height} pixels.")