|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.crosswire.common.swing.FontStore
public class FontStore
Font Store maintains a persistent, hierarchical store of user font
preferences. A font preference consists of the name of a resource and a font
specification for that resource. The name of the resource may be any unique
value that follows the rules for a property key. The font specification is
the font itself or a string representation of the font that can be turned
into a font with 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.
for license details.
The copyright to this program is held by it's authors.
Field Summary | |
---|---|
protected static String |
DEFAULT_FONT
|
protected static String |
DEFAULT_KEY
|
private String |
defaultFont
|
private 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 Summary | |
---|---|
FontStore(String storeName,
URI fontDir)
Create an new FontStore with the given persistent store. |
Method Summary | |
---|---|
String |
getDefaultFont()
|
Font |
getFont(String resource,
Language lang,
String fallback)
Get a font for the specified resource. |
protected 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(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(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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 PropertyMap fontMap
private static final org.slf4j.Logger log
Constructor Detail |
---|
public FontStore(String storeName, URI fontDir)
storeName
- The name of the store, used as a file name and as a label
inside the fontStore.fontDir
- The location where the fontStore can be stored.Method Detail |
---|
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(Language lang, Font font)
lang
- the languagefont
- the fontpublic void resetFont(String key)
key
- the book initials or language codepublic Font getFont(String resource, 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 font
protected 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 PropertyMap getFontMap()
protected void setFontMap(PropertyMap fontMap)
fontMap
- the fontMap to setprotected void load()
protected void store()
protected Font obtainFont(String fontSpec)
|
Copyright ? 2003-2011 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |