Singleton responsible for loading, applying, and scaling custom fonts in the Swing UI. More...
Public Member Functions | |
| int | getCharWidth () |
| Returns the width of a reference character ('W') for grid alignments. | |
| int | getLineHeight () |
| Returns the total line height based on current UI font metrics. | |
| int | getScaledDimension (int basePx) |
| Calculates a scaled dimension based on the current font's line height. | |
| void | initialize () |
| Entry point to load resources and refresh the Look and Feel. | |
Public Attributes | |
| INSTANCE | |
Static Public Attributes | |
| static final double | BASE_LINE_HEIGHT_REFERENCE = 16.0 |
| static final double | BASELINE_CORRECTION_FACTOR = 0.11 |
Private Member Functions | |
| double | calculateVerticalOffset (Font font) |
| Calculates the vertical offset required to center the font baseline. | |
| FontMetrics | getCurrentFontMetrics () |
| Retrieves the current font metrics from UIManager or provides a JRE fallback. | |
| void | loadLucioleFontAsDefaultFont () |
| Loads the Luciole TTF, registers it in the environment, and applies it to UIManager. | |
| void | loadMaterialIconsFont () |
| Loads Material Icons font into the Graphics Environment for icon rendering. | |
Static Private Attributes | |
| static final String | DEFAULT_FONT = "defaultFont" |
| static final JLabel | DUMMY_JLABEL = new JLabel() |
| static final String | FONT_LUCIOLE_PATH = "/font/Luciole-Regular.ttf" |
| static final String | FONT_MATERIAL_ICONS_PATH = "/font/MaterialIcons-Regular.ttf" |
| static final Font | JRE_GUARANTEED_FONT_FALLBACK_FOR_UNIT_TESTS |
Singleton responsible for loading, applying, and scaling custom fonts in the Swing UI.
This manager handles the Luciole and Material Icons fonts. It automatically calculates vertical offsets and scaling ratios to ensure consistent rendering across different operating systems (Windows, Linux) and High-DPI displays.
|
private |
Calculates the vertical offset required to center the font baseline.
*
| font | The font to measure. |
| int fr.softsf.canscan.util.FontManager.getCharWidth | ( | ) |
Returns the width of a reference character ('W') for grid alignments.
|
private |
Retrieves the current font metrics from UIManager or provides a JRE fallback.
| int fr.softsf.canscan.util.FontManager.getLineHeight | ( | ) |
Returns the total line height based on current UI font metrics.
| int fr.softsf.canscan.util.FontManager.getScaledDimension | ( | int | basePx | ) |
Calculates a scaled dimension based on the current font's line height.
This ensures graphical elements (like QR Codes) maintain visual consistency between Windows (HiDPI) and Linux environments.
| basePx | The reference dimension in pixels (e.g., 50px). |
| void fr.softsf.canscan.util.FontManager.initialize | ( | ) |
Entry point to load resources and refresh the Look and Feel.
|
private |
Loads the Luciole TTF, registers it in the environment, and applies it to UIManager.
Includes automated baseline correction via AffineTransform.
|
private |
Loads Material Icons font into the Graphics Environment for icon rendering.
|
static |
|
static |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
| fr.softsf.canscan.util.FontManager.INSTANCE |
|
staticprivate |