gui.utils.utils_fonts
- File:
EuljiroBible/gui/utils/utils_fonts.py
- Author:
Benjamin Jaedon Choi - https://github.com/saintbenjamin
- Affiliated Church:
The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]
- Address:
The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea
- Telephone:
+82-2-2266-3070
- E-mail:
euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)
- License:
MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.
Provides utility functions for managing fonts across the GUI and overlay in EuljiroBible.
- gui.utils.utils_fonts.create_app_font(family, size, weight_value)[source]
Create a QFont instance from the given font configuration.
This helper converts an integer weight into a
QFont.Weightsafely, falling back toQFont.Weight.Normalif the value is invalid.- Parameters:
family (str) – Font family name (e.g.,
"Noto Sans").size (int) – Font point size.
weight_value (int) – Integer weight value compatible with
QFont.Weight(e.g.,50,75).
- Returns:
Configured font instance with antialias preference enabled.
- Return type:
QFont
- gui.utils.utils_fonts.load_application_settings(app)[source]
Load persisted application font settings and apply them to QApplication.
This function reads the settings JSON file and applies the saved font family, size, and weight to the given
QApplicationinstance.Failure behavior:
If loading or parsing fails, a GUI-safe error dialog is shown via
handle_exceptionand the application continues (Qt default font remains).
- Parameters:
app (QApplication) – The QApplication instance to configure.
- Returns:
None
- gui.utils.utils_fonts.apply_font_to_children(widget, font)[source]
Apply a font recursively to a widget and all of its descendants.
This is used to ensure consistent font appearance across widgets that do not automatically update after
QApplication.setFont()on some platforms.- Parameters:
widget (QWidget) – Root widget to apply the font to.
font (QFont) – Font to apply.
- Returns:
None
- gui.utils.utils_fonts.apply_main_font_to_app(font_family, font_size, font_weight, root_widget)[source]
Persist and apply the main UI font across the application.
This function: - Persists the font configuration via
ConfigManager.save_font. - Updates the global QApplication font. - Recursively applies the font to all children ofroot_widget.- Parameters:
font_family (str) – Font family name.
font_size (int) – Font point size.
font_weight (QFont.Weight | int) – Font weight. Expected to be compatible with
QFont.setWeight().root_widget (QWidget) – Root widget whose descendants should receive the font.
- Returns:
None
- gui.utils.utils_fonts.apply_overlay_font(widget_overlay, settings)[source]
Apply overlay font settings to an existing overlay widget.
Note
WidgetOverlay.apply_settings()already reads from configuration and applies font + colors + sizing logic. This helper sets a base font first and then delegates the full refresh toapply_settings().- Parameters:
widget_overlay (WidgetOverlay | None) – Overlay instance to update.
settings (dict) – Settings dictionary expected to contain: -
display_font_family(str) -display_font_size(int) -display_font_weight(int or QFont.Weight)
- Returns:
None