public class FontStore extends Object
Font.decode(String)
.
Many languages share the same script. Rather than setting a font spec for many resources with the same language, this class makes it possible to set a font spec for each language.
Thus, the look up hierarchy begins with an exact match for the requested resource. If it does not work the lookup continues in the following order: the specified language's font, the fallback font, and the default font. Of course, if that does not work, use any font that Java thinks is appropriate, but use the size and style of the default font. Since scripts are shared by many languages, this FontStore supports the setting of Language defaults. If the requested language font does not exist a more general one will be provided.
Note: Some languages are represented as transliterations and others have more than one script, which may or may not be supported by a single font.
The GNU General Public License for details.
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFAULT_FONT |
protected static String |
DEFAULT_KEY |
private String |
defaultFont |
private org.crosswire.common.util.PropertyMap |
fontMap |
private URI |
fontStore |
protected static String |
LANG_KEY_PREFIX |
private boolean |
loaded |
private static org.slf4j.Logger |
log
The log stream
|
private String |
storeName |
Constructor and Description |
---|
FontStore(String storeName,
URI fontDir)
Create an new FontStore with the given persistent store.
|
Modifier and Type | Method and Description |
---|---|
String |
getDefaultFont() |
Font |
getFont(String resource,
org.crosswire.common.util.Language lang,
String fallback)
Get a font for the specified resource.
|
protected org.crosswire.common.util.PropertyMap |
getFontMap() |
protected URI |
getFontStore() |
protected String |
getStoreName() |
protected boolean |
isLoaded() |
protected void |
load()
Load the store, if it has not been loaded.
|
protected Font |
obtainFont(String fontSpec) |
void |
resetFont(String key)
Remove the font settings for a given key
|
void |
setDefaultFont(String defaultFont) |
void |
setFont(org.crosswire.common.util.Language lang,
Font font)
Store a font specification for the language.
|
void |
setFont(String resource,
Font font)
Store a font specification for the resource.
|
protected void |
setFontMap(org.crosswire.common.util.PropertyMap fontMap) |
protected void |
setFontStore(URI fontStore) |
protected void |
setLoaded(boolean loaded) |
protected void |
setStoreName(String storeName) |
protected void |
store()
Store the store, if it exists.
|
protected static final String DEFAULT_FONT
protected static final String LANG_KEY_PREFIX
protected static final String DEFAULT_KEY
private String storeName
private String defaultFont
private URI fontStore
private boolean loaded
private org.crosswire.common.util.PropertyMap fontMap
private static final org.slf4j.Logger log
public String getDefaultFont()
public void setDefaultFont(String defaultFont)
defaultFont
- the defaultFont to setpublic void setFont(String resource, Font font)
resource
- the resourcefont
- the fontpublic void setFont(org.crosswire.common.util.Language lang, Font font)
lang
- the languagefont
- the fontpublic void resetFont(String key)
key
- the book initials or language codepublic Font getFont(String resource, org.crosswire.common.util.Language lang, String fallback)
resource
- the name of the resource for whom the font is stored.lang
- the language of the resourcefallback
- the fontspec for the fallback fontprotected String getStoreName()
protected void setStoreName(String storeName)
storeName
- the storeName to setprotected URI getFontStore()
protected void setFontStore(URI fontStore)
fontStore
- the fontStore to setprotected boolean isLoaded()
protected void setLoaded(boolean loaded)
loaded
- the loaded to setprotected org.crosswire.common.util.PropertyMap getFontMap()
protected void setFontMap(org.crosswire.common.util.PropertyMap fontMap)
fontMap
- the fontMap to setprotected void load()
protected void store()