Class FontUtil
- java.lang.Object
-
- net.sf.jasperreports.engine.fonts.FontUtil
-
public final class FontUtil extends Object
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXCEPTION_MESSAGE_KEY_FONT_SET_FAMILY_NOT_FOUND
static String
EXCEPTION_MESSAGE_KEY_NULL_FONT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkAwtFont(String name, boolean ignoreMissingFont)
protected void
collectFontFamilyNames(Collection<String> names)
protected void
collectFontSetNames(Collection<String> names)
static void
copyNonNullOwnProperties(JRFont srcFont, JRFont destFont)
Map<AttributedCharacterIterator.Attribute,Object>
getAttributesWithoutAwtFont(Map<AttributedCharacterIterator.Attribute,Object> attributes, JRFont font)
protected Font
getAwtFont(FontInfo fontInfo, int style, float size, boolean ignoreMissingFont)
Font
getAwtFont(JRFont font, Locale locale)
Returns a java.awt.Font instance by converting a JRFont instance.Font
getAwtFontFromBundles(boolean ignoreCase, String name, int style, float size, Locale locale, boolean ignoreMissingFont)
Font
getAwtFontFromBundles(String name, int style, float size, Locale locale, boolean ignoreMissingFont)
CallsgetAwtFontFromBundles(boolean, String, int, float, Locale, boolean)
with the ignoreCase parameter set to false.Font
getAwtFontFromBundles(AwtFontAttribute fontAttribute, int style, float size, Locale locale, boolean ignoreMissingFont)
String
getExportFontFamily(String name, Locale locale, String exporterKey)
Collection<String>
getFontFamilyNames()
Returns the font family names available through extensions, in alphabetical order.FontInfo
getFontInfo(String name, boolean ignoreCase, Locale locale)
Returns font information containing the font family, font face and font style.FontInfo
getFontInfo(String name, Locale locale)
Returns font information containing the font family, font face and font style, searching for names case sensitive.Collection<String>
getFontNames()
Returns the font names available through extensions, in alphabetical order.FontSetInfo
getFontSetInfo(String name, Locale locale, boolean ignoreMissingFonts)
static FontUtil
getInstance(JasperReportsContext jasperReportsContext)
void
resetThreadMissingFontsCache()
Font
resolveDeserializedFont(Font font)
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_NULL_FONT
public static final String EXCEPTION_MESSAGE_KEY_NULL_FONT
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_FONT_SET_FAMILY_NOT_FOUND
public static final String EXCEPTION_MESSAGE_KEY_FONT_SET_FAMILY_NOT_FOUND
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static FontUtil getInstance(JasperReportsContext jasperReportsContext)
-
copyNonNullOwnProperties
public static void copyNonNullOwnProperties(JRFont srcFont, JRFont destFont)
-
getAttributesWithoutAwtFont
public Map<AttributedCharacterIterator.Attribute,Object> getAttributesWithoutAwtFont(Map<AttributedCharacterIterator.Attribute,Object> attributes, JRFont font)
-
getFontInfo
public FontInfo getFontInfo(String name, boolean ignoreCase, Locale locale)
Returns font information containing the font family, font face and font style.- Parameters:
name
- the font family or font face nameignoreCase
- the flag to specify if family names or face names are searched by ignoring case or notlocale
- the locale- Returns:
- a font info object
-
getFontInfo
public FontInfo getFontInfo(String name, Locale locale)
Returns font information containing the font family, font face and font style, searching for names case sensitive.- Parameters:
name
- the font family or font face namelocale
- the locale- Returns:
- a font info object
-
getFontSetInfo
public FontSetInfo getFontSetInfo(String name, Locale locale, boolean ignoreMissingFonts)
-
getExportFontFamily
public String getExportFontFamily(String name, Locale locale, String exporterKey)
-
getFontFamilyNames
public Collection<String> getFontFamilyNames()
Returns the font family names available through extensions, in alphabetical order.
-
collectFontFamilyNames
protected void collectFontFamilyNames(Collection<String> names)
-
getFontNames
public Collection<String> getFontNames()
Returns the font names available through extensions, in alphabetical order.- Returns:
- the list of font names provided by extensions
-
collectFontSetNames
protected void collectFontSetNames(Collection<String> names)
-
getAwtFontFromBundles
public Font getAwtFontFromBundles(String name, int style, float size, Locale locale, boolean ignoreMissingFont)
CallsgetAwtFontFromBundles(boolean, String, int, float, Locale, boolean)
with the ignoreCase parameter set to false.
-
getAwtFontFromBundles
public Font getAwtFontFromBundles(boolean ignoreCase, String name, int style, float size, Locale locale, boolean ignoreMissingFont)
-
getAwtFont
protected Font getAwtFont(FontInfo fontInfo, int style, float size, boolean ignoreMissingFont)
-
getAwtFontFromBundles
public Font getAwtFontFromBundles(AwtFontAttribute fontAttribute, int style, float size, Locale locale, boolean ignoreMissingFont)
-
resetThreadMissingFontsCache
public void resetThreadMissingFontsCache()
-
checkAwtFont
public void checkAwtFont(String name, boolean ignoreMissingFont)
-
getAwtFont
public Font getAwtFont(JRFont font, Locale locale)
Returns a java.awt.Font instance by converting a JRFont instance. Mostly used in combination with third-party visualization packages such as JFreeChart (for chart themes). Unless the font parameter is null, this method always returns a non-null AWT font, regardless whether it was found in the font extensions or not. This is because we do need a font to draw with and there is no point in raising a font missing exception here, as it is not JasperReports who does the drawing.
-
-