Package com.oorian.css
Class Font
java.lang.Object
com.oorian.css.Font
Mutable configuration class for CSS font properties.
The Font class provides a convenient way to configure multiple font properties (family, size, weight, style, variant) as a single object. It can be constructed from individual values or parsed from a CSS string.
System Font Keywords:
CAPTION- Font for captioned controls (buttons, drop-downs)ICON- Font for icon labelsMENU- Font for menusMESSAGE_BOX- Font for dialog boxesSMALL_CAPTION- Font for small captionsSTATUS_BAR- Font for status bars
Usage:
Font font = new Font(FontFamily.ARIAL, 14, FontWeight.BOLD);
element.setFont(font);
// Or parse from CSS string
Font parsed = new Font("font-family: Arial; font-size: 14pt");
- Since:
- 2012
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem font for captioned controls.static final StringSystem font for icon labels.static final StringInherits font from parent element.static final StringSets font to default value.static final StringSystem font for menus.static final StringSystem font for dialog boxes.static final StringSystem font for small captions.static final StringSystem font for status bars. -
Constructor Summary
ConstructorsConstructorDescriptionFont()Constructs a Font with default inherited values.Font(FontFamily family, float size) Constructs a Font with the specified FontFamily and size in points.Font(FontFamily family, float size, FontWeight weight) Constructs a Font with FontFamily, size in points, and FontWeight.Font(FontFamily family, String size) Constructs a Font with the specified FontFamily enum and size.Constructs a Font by parsing a CSS font string.Constructs a Font with the specified family and size in points.Constructs a Font with the specified family and size.Constructs a Font with family, size, and weight as strings. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringReturns the font family name.final StringgetSize()Returns the font size with units.final StringgetStyle()Returns the font style value.final StringReturns the font variant value.final StringReturns the font weight value.final voidsetFamily(FontFamily family) Sets the font family from a FontFamily enum.final voidSets the font family by name.final voidsetSize(float size) Sets the font size in points.final voidSets the font size with units.final voidSets the font style from a FontStyle enum.final voidSets the font style by value string.final voidsetVariant(FontVariant variant) Sets the font variant from a FontVariant enum.final voidsetVariant(String variant) Sets the font variant by value string.final voidsetWeight(FontWeight weight) Sets the font weight from a FontWeight enum.final voidSets the font weight by value string.toString()Returns the CSS representation of this font configuration.
-
Field Details
-
INHERIT
Inherits font from parent element.- See Also:
-
INITIAL
Sets font to default value.- See Also:
-
CAPTION
System font for captioned controls.- See Also:
-
ICON
System font for icon labels.- See Also:
-
MENU
System font for menus.- See Also:
-
MESSAGE_BOX
System font for dialog boxes.- See Also:
-
SMALL_CAPTION
System font for small captions.- See Also:
-
STATUS_BAR
System font for status bars.- See Also:
-
-
Constructor Details
-
Font
public Font()Constructs a Font with default inherited values. -
Font
Constructs a Font with the specified family and size.- Parameters:
family- the font family namesize- the font size with units
-
Font
Constructs a Font with the specified FontFamily enum and size.- Parameters:
family- the font family enum valuesize- the font size with units
-
Font
Constructs a Font with the specified family and size in points.- Parameters:
family- the font family namesize- the font size in points
-
Font
Constructs a Font with the specified FontFamily and size in points.- Parameters:
family- the font family enum valuesize- the font size in points
-
Font
Constructs a Font with family, size, and weight as strings.- Parameters:
family- the font family namesize- the font size with unitsweight- the font weight value
-
Font
Constructs a Font with FontFamily, size in points, and FontWeight.- Parameters:
family- the font family enum valuesize- the font size in pointsweight- the font weight enum value
-
Font
Constructs a Font by parsing a CSS font string.Parses semicolon-separated CSS properties like "font-family: Arial; font-size: 14pt; font-weight: bold".
- Parameters:
css- the CSS font property string to parse
-
-
Method Details
-
setFamily
Sets the font family by name.- Parameters:
family- the font family name
-
setFamily
Sets the font family from a FontFamily enum.- Parameters:
family- the font family enum value
-
setSize
Sets the font size with units.- Parameters:
size- the font size with units
-
setSize
public final void setSize(float size) Sets the font size in points.- Parameters:
size- the font size in points
-
setWeight
Sets the font weight by value string.- Parameters:
weight- the font weight value
-
setWeight
Sets the font weight from a FontWeight enum.- Parameters:
weight- the font weight enum value
-
setStyle
Sets the font style by value string.- Parameters:
style- the font style value
-
setStyle
Sets the font style from a FontStyle enum.- Parameters:
style- the font style enum value
-
setVariant
Sets the font variant by value string.- Parameters:
variant- the font variant value
-
setVariant
Sets the font variant from a FontVariant enum.- Parameters:
variant- the font variant enum value
-
getFamily
Returns the font family name.- Returns:
- the font family
-
getSize
Returns the font size with units.- Returns:
- the font size
-
getWeight
Returns the font weight value.- Returns:
- the font weight
-
getVariant
Returns the font variant value.- Returns:
- the font variant
-
getStyle
Returns the font style value.- Returns:
- the font style
-
toString
Returns the CSS representation of this font configuration.
-