Package ch.rabanti.nanoxlsx4j.styles
Class Font
java.lang.Object
ch.rabanti.nanoxlsx4j.styles.AbstractStyle
ch.rabanti.nanoxlsx4j.styles.Font
- All Implemented Interfaces:
Comparable<AbstractStyle>
Class representing a Font entry. The Font entry is used to define text formatting
- Author:
- Raphael Stoeckli
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum for the font schemestatic enumEnum for the style of the underline property of a stylized textstatic enumEnum for the vertical alignment of the text from baseline -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault font familystatic final StringDefault font family as constantstatic final Font.SchemeValueDefault font schemestatic final floatDefault font sizestatic final StringThe default font name that is declared as Major Font (SeeFont.SchemeValue)static final StringThe default font name that is declared as Minor Font (SeeFont.SchemeValue)static final Font.VerticalAlignValueDefault vertical alignmentstatic final floatMinimum possible font sizestatic final floatMaximum possible font size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Method to copy the current object to a new oneGets the charset of the Font (Default is empty)intGets the font color theme (Default is 1 = Light)Gets the Font color (default is empty)Gets the font family (Default is 2)getName()Gets the font name (Default is Calibri)Gets the font scheme (Default is minor)floatgetSize()Gets the font size.Gets the underline style of the fontGets the alignment of the font (Default is none)inthashCode()Override method to calculate the hash of this componentbooleanisBold()Gets the bold parameter of the fontbooleanGets whether this object is the default fontbooleanisItalic()Gets the italic parameter of the fontbooleanisStrike()Gets whether the font is struck throughvoidsetBold(boolean bold) Sets the bold parameter of the fontvoidsetCharset(String charset) Sets the charset of the Font (Default is empty)voidsetColorTheme(int colorTheme) Sets the font color theme (Default is 1)voidsetColorValue(String colorValue) Sets the color code of the font color.voidSets the font family (Default is 2 = Swiss)voidsetItalic(boolean italic) Sets the italic parameter of the fontvoidSets the font name (Default is Calibri)voidsetScheme(Font.SchemeValue scheme) Sets the Font scheme (Default is minor)voidsetSize(float size) Sets the Font size.voidsetStrike(boolean strike) Sets whether the font is struck throughvoidsetUnderline(Font.UnderlineValue underline) Sets the underline style of the fontvoidsetVerticalAlign(Font.VerticalAlignValue verticalAlign) Sets the Alignment of the font (Default is none)toString()Override toString methodMethods inherited from class ch.rabanti.nanoxlsx4j.styles.AbstractStyle
compareTo, equals, getInternalID, setInternalID
-
Field Details
-
DEFAULT_MAJOR_FONT
The default font name that is declared as Major Font (SeeFont.SchemeValue)- See Also:
-
DEFAULT_MINOR_FONT
The default font name that is declared as Minor Font (SeeFont.SchemeValue)- See Also:
-
DEFAULT_FONT_NAME
Default font family as constant- See Also:
-
DEFAULT_FONT_SCHEME
Default font scheme -
MIN_FONT_SIZE
public static final float MIN_FONT_SIZEMaximum possible font size- See Also:
-
MAX_FONT_SIZE
public static final float MAX_FONT_SIZEMinimum possible font size- See Also:
-
DEFAULT_FONT_SIZE
public static final float DEFAULT_FONT_SIZEDefault font size- See Also:
-
DEFAULT_FONT_FAMILY
Default font family- See Also:
-
DEFAULT_VERTICAL_ALIGN
Default vertical alignment
-
-
Constructor Details
-
Font
public Font()Default constructor
-
-
Method Details
-
isBold
public boolean isBold()Gets the bold parameter of the font- Returns:
- If true, the font is bold
-
setBold
public void setBold(boolean bold) Sets the bold parameter of the font- Parameters:
bold- If true, the font is bold
-
isItalic
public boolean isItalic()Gets the italic parameter of the font- Returns:
- If true, the font is italic
-
setItalic
public void setItalic(boolean italic) Sets the italic parameter of the font- Parameters:
italic- If true, the font is italic
-
isStrike
public boolean isStrike()Gets whether the font is struck through- Returns:
- If true, the font is declared as strike-through
-
setStrike
public void setStrike(boolean strike) Sets whether the font is struck through- Parameters:
strike- If true, the font is declared as strike-through
-
getUnderline
Gets the underline style of the font- API Note:
- If set to
Font.UnderlineValue.noneno underline will be applied (default) - Returns:
- Underline value
-
setUnderline
Sets the underline style of the font- API Note:
- If set to
Font.UnderlineValue.noneno underline will be applied (default) - Parameters:
underline- Underline value
-
getSize
public float getSize()Gets the font size. Valid range is from 1.0 to 409.0- Returns:
- Font size
-
setSize
public void setSize(float size) Sets the Font size. Valid range is from 1 to 409- Parameters:
size- Font size
-
getName
Gets the font name (Default is Calibri)- Returns:
- Font name
-
setName
Sets the font name (Default is Calibri)- API Note:
- Note that the font name is not validated whether it is a valid or existing font. The font name may not exceed more than 31 characters
- Parameters:
name- Font name- Throws:
StyleException- thrown if the name is null or empty.
-
getFamily
Gets the font family (Default is 2)- Returns:
- Font family
-
setFamily
Sets the font family (Default is 2 = Swiss)- Parameters:
family- Font family
-
getColorTheme
public int getColorTheme()Gets the font color theme (Default is 1 = Light)- Returns:
- Font color theme
-
setColorTheme
public void setColorTheme(int colorTheme) Sets the font color theme (Default is 1)- Parameters:
colorTheme- Font color theme- Throws:
StyleException- thrown if the number is below 0
-
getColorValue
Gets the Font color (default is empty)- Returns:
- Font color
-
setColorValue
Sets the color code of the font color. The value is expressed as hex string with the format AARRGGBB. AA (Alpha) is usually FF.
To omit the color, an empty string can be set. Empty is also default.- Parameters:
colorValue- Font color- Throws:
StyleException- thrown if the passed ARGB value is not valid
-
getScheme
Gets the font scheme (Default is minor)- Returns:
- Font scheme
-
setScheme
Sets the Font scheme (Default is minor)- Parameters:
scheme- Font scheme
-
getVerticalAlign
Gets the alignment of the font (Default is none)- Returns:
- Alignment of the font
-
setVerticalAlign
Sets the Alignment of the font (Default is none)- Parameters:
verticalAlign- Alignment of the font
-
getCharset
Gets the charset of the Font (Default is empty)- Returns:
- Charset of the Font
-
setCharset
Sets the charset of the Font (Default is empty)- Parameters:
charset- Charset of the Font
-
isDefaultFont
public boolean isDefaultFont()Gets whether this object is the default font- Returns:
- In true the font is equals the default font
-
toString
Override toString method -
copy
Method to copy the current object to a new one- Specified by:
copyin classAbstractStyle- Returns:
- Copy of the current object without the internal ID
-
hashCode
public int hashCode()Override method to calculate the hash of this component
-