|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.taco.i18n.gui.FontUtilities
public class FontUtilities
Utility functions for getting fonts appropriate for locales.
Nested Class Summary | |
---|---|
static class |
FontUtilities.DefaultFontMapper
A default implementation of IFontMapper . |
static interface |
FontUtilities.IFontMapper
|
Field Summary | |
---|---|
protected static java.awt.Font |
_DEFAULT_SERIF_FONT
A prototypical font for the current platform used to determine if the current platform can display characters in different locales. |
protected static java.util.Map |
_localeToFontsMap
A map from locale to arrays of fonts that that can display characters in the locale, made plain and one-point. |
Constructor Summary | |
---|---|
FontUtilities()
|
Method Summary | |
---|---|
static void |
adjustFontsForLocale(java.awt.Component component,
java.util.Locale locale)
Call adjustFontsForLocale( . |
static javax.swing.border.Border |
adjustFontsForLocale(java.util.Locale oldLocale,
javax.swing.border.Border border,
java.util.Locale locale,
FontUtilities.IFontMapper fontMapper)
Return a border that may be adjusted so that it can display characters in the argument locale. |
static void |
adjustFontsForLocale(java.util.Locale oldLocale,
java.awt.Component component,
java.util.Locale locale,
boolean recurse,
FontUtilities.IFontMapper fontMapper)
Adjust the font for the component and its border so that it can display characters of locale . |
static java.awt.Font[] |
getFontsForLocale(java.util.Locale locale)
Return an array of fonts that can display characters for the argument locale. |
static boolean |
isCompatible(java.awt.Font font,
java.util.Locale locale)
Return true if the argument font can display characters in the argument locale. |
static boolean |
usesChineseCharacters(java.util.Locale locale)
Return true if Chinese characters are used in the argument locale. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.util.Map _localeToFontsMap
protected static final java.awt.Font _DEFAULT_SERIF_FONT
Constructor Detail |
---|
public FontUtilities()
Method Detail |
---|
public static final java.awt.Font[] getFontsForLocale(java.util.Locale locale)
Return an array of fonts that can display characters for the argument locale. Otherwise, consult the cached map from locale to fonts. If an entry exists, return it. Otherwise, scan all fonts on the system for fonts capable of displaying characters in the argument locale. If no font that can display characters for the locale can be found, return an empty array. The returned array is a clone of the array stored by this class, so it may be modified.
This method tests if a font can display characters of a locale by seeing if it can display the locale's display name, in the argument locale.
public static void adjustFontsForLocale(java.awt.Component component, java.util.Locale locale) throws java.awt.FontFormatException
adjustFontsForLocale(Locale.getDefault()
,
component, locale, true, DefaultFontMapper.instance)
.
java.awt.FontFormatException
public static void adjustFontsForLocale(java.util.Locale oldLocale, java.awt.Component component, java.util.Locale locale, boolean recurse, FontUtilities.IFontMapper fontMapper) throws java.awt.FontFormatException
locale
. If recursive
is
true
, adjust fonts for any components contained by
component, recursively, unless a component is an instance of
IFontAdjustedOnLocaleChange
. If the font of
component
needs to be adjusted, do so whether or not it is
an instance of IFontAdjustedOnLocaleChange
.
oldLocale
- The current locale of the component. May by
null
if unknown.component
- The component to modify.locale
- The target locale for the component.recurse
- If true, adjust fonts for all contained components,
recursively.fontMapper
- The strategy for transforming original fonts to new
ones.
java.awt.FontFormatException
- if no fonts can be found to display
characters in the target locale.public static javax.swing.border.Border adjustFontsForLocale(java.util.Locale oldLocale, javax.swing.border.Border border, java.util.Locale locale, FontUtilities.IFontMapper fontMapper) throws java.awt.FontFormatException
oldLocale
- The current locale of the border. May by
null
if unknown.border
- The border to .locale
- The target locale for the border.fontMapper
- The strategy for transforming original fonts to new
ones.
java.awt.FontFormatException
- Thrown if no fonts can be found to display
characters in the target locale.public static final boolean isCompatible(java.awt.Font font, java.util.Locale locale)
public static boolean usesChineseCharacters(java.util.Locale locale)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |