Package com.jalios.jcms.font
Class FontUtil
java.lang.Object
com.jalios.jcms.font.FontUtil
-
Method Summary
Modifier and TypeMethodDescriptionprotected static FontVariantanalyzeVariant(File file, String originalFileName) Analyzes one file and creates a single font variant.protected static intCompares font sources according to their preferred CSS format order.protected static StringescapeIdentifier(String value, String defaultValue) Converts a display name into a stable technical identifier.protected static StringextractFamilyName(String fileName) Extracts a readable font family name from a file name.protected static Stringstatic StringgetExtension(String fileName) Returns the lowercase extension of a file name.static FontFamilystatic PathReturns the directory containing generated font CSS files.static PathReturns the root directory containing local font files.protected static StringgetVariantKey(FontVariant variant) Builds a unique key identifying a variant by weight and style.static StringgetWeightLabel(int weight) Returns a human-readable weight label.protected static booleanisRemoteUrl(String url) protected static voidrebuildFamilyCss(FontFamily family, Path familyDir, Path cssFile) Rebuilds the CSS file for a font family by scanning its storage directory.
-
Method Details
-
getFontCssPath
Returns the directory containing generated font CSS files.- Returns:
- the font CSS directory path
-
getFontLibPath
Returns the root directory containing local font files.- Returns:
- the local font library directory path
-
getWeightLabel
Returns a human-readable weight label.- Parameters:
weight- the CSS font weight- Returns:
- the corresponding display label
-
getFont
-
extractFamilyName
Extracts a readable font family name from a file name.- Parameters:
fileName- the original uploaded file name- Returns:
- the detected readable family name
-
extractWebFontFamily
-
escapeIdentifier
Converts a display name into a stable technical identifier.- Parameters:
value- the display name to convertdefaultValue- Value return if value parameter is empty- Returns:
- a lowercase slug suitable for properties, folders, and CSS class names
-
analyzeVariant
protected static FontVariant analyzeVariant(File file, String originalFileName) throws FontImportException Analyzes one file and creates a single font variant.- Parameters:
file- the physical font fileoriginalFileName- the original or meaningful file name- Returns:
- detected font variant
- Throws:
FontImportException- if the file cannot be analyzed
-
getVariantKey
Builds a unique key identifying a variant by weight and style.- Parameters:
variant- the font variant- Returns:
- a key such as "400.normal" or "700.italic"
-
compareSources
Compares font sources according to their preferred CSS format order.- Parameters:
a- the first font sourceb- the second font source- Returns:
- a negative, zero, or positive value according to source priority
-
isRemoteUrl
-
rebuildFamilyCss
protected static void rebuildFamilyCss(FontFamily family, Path familyDir, Path cssFile) throws FontImportException Rebuilds the CSS file for a font family by scanning its storage directory.- Parameters:
family- the target font familyfamilyDir- the directory containing stored font filescssFile- the generated CSS file- Throws:
FontImportException- if a font file cannot be analyzed
-
getExtension
Returns the lowercase extension of a file name.- Parameters:
fileName- the file name to inspect- Returns:
- the lowercase extension without the dot, or an empty string if missing
-