CanScan
Loading...
Searching...
No Matches
fr.softsf.canscan.util.FontManager Enum Reference

Singleton responsible for loading and applying custom fonts in the Swing UI. More...

+ Collaboration diagram for fr.softsf.canscan.util.FontManager:

Public Member Functions

int getCharWidth ()
 Returns the reference character width based on 'W'.
 
int getLineHeight ()
 Returns the total line height (ascent + descent + leading).
 
void initialize ()
 Initializes and sets the Luciole font as the default Swing UI font (including scaling/shifting).
 

Public Attributes

 INSTANCE
 

Private Member Functions

FontMetrics getCurrentFontMetrics ()
 Retrieves FontMetrics safely.
 
void loadLucioleFontAsDefaultFont ()
 
void loadMaterialIconsFont ()
 Loads Material Icons (TTF) and registers it in the JVM's Graphics Environment.
 

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 double FONT_SHIFT_DOWN = 2.5
 
static final Font JRE_GUARANTEED_FONT_FALLBACK_FOR_UNIT_TESTS
 

Detailed Description

Singleton responsible for loading and applying custom fonts in the Swing UI.

It loads the Luciole font as the default UIManager font (with vertical adjustment) and registers the Material Icons font for use in specialized UI components. This class is accessed via the INSTANCE enum constant.

Member Function Documentation

◆ getCharWidth()

int fr.softsf.canscan.util.FontManager.getCharWidth ( )

Returns the reference character width based on 'W'.

Uses an internal JLabel context to calculate exact metrics.

Returns
The width of 'W' in pixels.
+ Here is the call graph for this function:

◆ getCurrentFontMetrics()

FontMetrics fr.softsf.canscan.util.FontManager.getCurrentFontMetrics ( )
private

Retrieves FontMetrics safely.

Guarantees non-null return, resolving the Font and relying on client catch blocks for fault tolerance in headless environments.

Returns
The real FontMetrics object.

◆ getLineHeight()

int fr.softsf.canscan.util.FontManager.getLineHeight ( )

Returns the total line height (ascent + descent + leading).

Returns
The line height in pixels.
+ Here is the call graph for this function:

◆ initialize()

void fr.softsf.canscan.util.FontManager.initialize ( )

Initializes and sets the Luciole font as the default Swing UI font (including scaling/shifting).

It also loads and registers the Material Icons font for UI components.

The UI is updated asynchronously on the EDT using SwingUtilities#invokeLater(Runnable) after fonts are loaded.

+ Here is the call graph for this function:

◆ loadLucioleFontAsDefaultFont()

void fr.softsf.canscan.util.FontManager.loadLucioleFontAsDefaultFont ( )
private

◆ loadMaterialIconsFont()

void fr.softsf.canscan.util.FontManager.loadMaterialIconsFont ( )
private

Loads Material Icons (TTF) and registers it in the JVM's Graphics Environment.

The font is then accessible using the family name "Material Icons".

Member Data Documentation

◆ DEFAULT_FONT

final String fr.softsf.canscan.util.FontManager.DEFAULT_FONT = "defaultFont"
staticprivate

◆ DUMMY_JLABEL

final JLabel fr.softsf.canscan.util.FontManager.DUMMY_JLABEL = new JLabel()
staticprivate

◆ FONT_LUCIOLE_PATH

final String fr.softsf.canscan.util.FontManager.FONT_LUCIOLE_PATH = "/font/Luciole-Regular.ttf"
staticprivate

◆ FONT_MATERIAL_ICONS_PATH

final String fr.softsf.canscan.util.FontManager.FONT_MATERIAL_ICONS_PATH = "/font/MaterialIcons-Regular.ttf"
staticprivate

◆ FONT_SHIFT_DOWN

final double fr.softsf.canscan.util.FontManager.FONT_SHIFT_DOWN = 2.5
staticprivate

◆ INSTANCE

fr.softsf.canscan.util.FontManager.INSTANCE

◆ JRE_GUARANTEED_FONT_FALLBACK_FOR_UNIT_TESTS

final Font fr.softsf.canscan.util.FontManager.JRE_GUARANTEED_FONT_FALLBACK_FOR_UNIT_TESTS
staticprivate
Initial value:
=
new Font("Dialog", Font.PLAIN, 12)

The documentation for this enum was generated from the following file: