|
||||||||||
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.
for license details.
The copyright to this program is held by it's authors.
Field Summary | |
---|---|
private static String |
DEFAULT_FONT
|
private static String |
DEFAULT_KEY
|
private String |
defaultFont
|
private Properties |
fontMap
|
private URI |
fontStore
|
private static String |
LANG_KEY_PREFIX
|
private boolean |
loaded
|
private static Logger |
log
|
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. |
private void |
load()
Load the store, if it has not been loaded. |
private Font |
obtainFont(String fontSpec)
|
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. |
private 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 |
---|
private static final String DEFAULT_FONT
private String storeName
private String defaultFont
private URI fontStore
private boolean loaded
private Properties fontMap
private static final String LANG_KEY_PREFIX
private static final String DEFAULT_KEY
private static final 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 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
private void load()
private void store()
private Font obtainFont(String fontSpec)
|
Copyright ยจ 2003-2007 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |