Class FallbackFontSet
- java.lang.Object
-
- com.adobe.fontengine.inlineformatting.FallbackFontSet
-
- All Implemented Interfaces:
java.io.Serializable
public final class FallbackFontSet extends java.lang.Object implements java.io.Serializable
A set of fonts indexed byULocale
, typically used for fallback.A
FallbackFontSet
is a set of fonts indexed byULocale
. 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)
andaddFallbackFonts(ULocale, Font[])
methods allow the addition of one or more fonts to a set, for a given locale.The
getFallbackFonts(ULocale)
method returns anIterator
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 theULocale.ROOT
locale.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 localeen_US
are{us1, us2, en1, en2, r1, r2}
in that order, the fallback fonts for the localeen_CA
are{ca1, ca2, en1, en2, r1, r2}
in that order, the fallback fonts for the localeen
are{en1, en2, r1, r2}
in that order, and the fallback fonts for the localeit
are{r1, r2}
in that order.Synchronization
FallbackFontSet
objects are suitably synchronized for use in multiple threads.Serialization
FallbackFontSet
objects can be serialized, provided that they contain only fonts which can be serialized.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FallbackFontSet()
Create an empty FallbackFontSet.FallbackFontSet(FallbackFontSet ffs)
Create a FallbackFontSet by copying an existing one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFallbackFont(ULocale locale, Font font)
Add a font to the setvoid
addFallbackFonts(ULocale locale, Font[] fontsToAdd)
Add each font in an array to the set.boolean
equals(java.lang.Object otherObject)
java.util.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.java.lang.String
toString()
-
-
-
Constructor Detail
-
FallbackFontSet
public FallbackFontSet()
Create an empty FallbackFontSet.
-
FallbackFontSet
public FallbackFontSet(FallbackFontSet ffs)
Create a FallbackFontSet by copying an existing one.
-
-
Method Detail
-
addFallbackFonts
public void addFallbackFonts(ULocale locale, Font[] fontsToAdd)
Add each font in an array to the set.- Parameters:
locale
- the locale for which those fonts are appropriatefontsToAdd
- the fonts to add
-
addFallbackFont
public void addFallbackFont(ULocale locale, Font font)
Add a font to the set- Parameters:
locale
- the locale for which the font is appropriatefont
- the font to add
-
getFallbackFonts
public java.util.Iterator getFallbackFonts(ULocale locale)
Enumerate the fonts for a locale. The fonts forlocale
are enumerated, then the fonts for the fallback locale oflocale
, and so on.
-
equals
public boolean equals(java.lang.Object otherObject)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
isEmpty
public boolean isEmpty()
A test on whether this fontset contains any fonts.- Returns:
- true if the fontset is empty, false otherwise
-
isEmpty
public boolean isEmpty(ULocale locale)
A test on whether this fontset contains any fonts for the given locale.- Parameters:
locale
- the locale to test- Returns:
- true if the fontset has no fonts for the given locale, false otherwise
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-