public final class FallbackFontSet extends Object implements Serializable
ULocale, typically used for fallback.
A FallbackFontSet is a set of fonts indexed by ULocale. A
typical use is during formatting of text: if the requested font cannot be
found or does not contain suitable glyphs for a portion of the text being
formatted, the formatter can enumerate the fallback fonts for the locale
of the text until a suitable font is found. Indexing by locale (by opposition
to a flat set) improves the quality of the generated rendering; for example,
some characters are used to write both Japanese and Chinese, but different
shapes are expected.
The addFallbackFont(ULocale, Font) and
addFallbackFonts(ULocale, Font[]) methods allow the addition of one
or more fonts to a set, for a given locale.
The getFallbackFonts(ULocale) method returns an Iterator
which first enumerates the fonts for a locale (in the order in which they
were added), then the fonts for the fallback locale of that locale, and so on
up to the fonts for the ULocale.ROOTlocale.
For example, with a set setup like this:
set.add (new ULocale ("en_US"), us1);
set.add (new ULocale ("en_US"), us2);
set.add (new ULocale ("en_CA"), ca1);
set.add (new ULocale ("en_CA"), ca2);
set.add (new ULocale ("en"), en1);
set.add (new ULocale ("en"), en2);
set.add (ULocale.ROOT, r1);
set.add (ULocale.ROOT, r2);
then the fallback fonts for the locale en_US are
{us1, us2, en1, en2, r1, r2} in that order, the fallback fonts
for the locale en_CA are
{ca1, ca2, en1, en2, r1, r2} in that order, the fallback fonts
for the locale en are {en1, en2, r1, r2} in
that order, and the fallback fonts for the locale it are
{r1, r2} in that order.
FallbackFontSetobjects are suitably synchronized for use in multiple
threads.
FallbackFontSetobjects can be serialized, provided that they contain
only fonts which can be serialized.| Constructor and Description |
|---|
FallbackFontSet()
Create an empty FallbackFontSet.
|
FallbackFontSet(FallbackFontSet ffs)
Create a FallbackFontSet by copying an existing one.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFallbackFont(ULocale locale,
Font font)
Add a font to the set
|
void |
addFallbackFonts(ULocale locale,
Font[] fontsToAdd)
Add each font in an array to the set.
|
boolean |
equals(Object otherObject) |
Iterator |
getFallbackFonts(ULocale locale)
Enumerate the fonts for a locale.
|
int |
hashCode() |
boolean |
isEmpty()
A test on whether this fontset contains any fonts.
|
boolean |
isEmpty(ULocale locale)
A test on whether this fontset contains any fonts for the given locale.
|
String |
toString() |
public FallbackFontSet()
public FallbackFontSet(FallbackFontSet ffs)
public void addFallbackFonts(ULocale locale, Font[] fontsToAdd)
locale - the locale for which those fonts are appropriatefontsToAdd - the fonts to addpublic void addFallbackFont(ULocale locale, Font font)
locale - the locale for which the font is appropriatefont - the font to addpublic Iterator getFallbackFonts(ULocale locale)
locale are enumerated, then the fonts for the
fallback locale of locale, and so on.public boolean isEmpty()
public boolean isEmpty(ULocale locale)
locale - the locale to testCopyright © 2010 - 2020 Adobe. All Rights Reserved