Fields Summary |
---|
boolean | NOT_IMP |
public String[] | allFamiliesarray of font families names |
public static final String | DEFAULT_NAME |
public static final String | DIALOG_NAME |
public static final byte | FAMILY_NAME_IDSet of constants applicable to the TrueType 'name' table. |
public static final byte | FONT_NAME_ID |
public static final byte | POSTSCRIPT_NAME_ID |
public static final short | ENGLISH_LANGID |
public static final byte | FONT_TYPE_TTSet of constants describing font type. |
public static final byte | FONT_TYPE_T1 |
public static final byte | FONT_TYPE_UNDEF |
static final int | DIALOG |
static final int | SANSSERIF |
static final int | DIALOGINPUT |
static final int | MONOSPACED |
static final int | SERIF |
public static final String | PLATFORM_FONT_NAMEFontProperty related constants. |
public static final String | LOGICAL_FONT_NAME |
public static final String | COMPONENT_INDEX |
public static final String | STYLE_INDEX |
public static final String[] | FONT_MAPPING_KEYS |
public static final String | FONT_CHARACTER_ENCODING |
public static final String | EXCLUSION_RANGES |
public static final String | FONT_FILE_NAME |
public static final String[] | LOGICAL_FONT_FAMILIESAvailable logical font families names. |
public static final String[] | LOGICAL_FONT_NAMESAvailable logical font names. |
public static final String[] | LOGICAL_FONT_FACESAvailable logical font face names. |
public static final String[] | STYLE_NAMESSet of font style names.
Font.getStyle() corresponds to indexes in STYLE_NAMES array. |
private static final Hashtable | style_keysLogical font styles names table where font styles names used
as the key and the value is the index of this style name. |
public static final String[] | OS_VALUESSet of possible "os" property values. |
public static final String[] | FP_FILE_NAMESSet of possible font.property file names.
Language, Country, Encoding, OS, Version should be replaced with
the values from current configuration. |
public Hashtable | fPropertiesTable with all available font properties corresponding
to the current system configuration. |
public static final int | EMPTY_FONTS_CAPACITYMaximum number of unreferenced font peers to keep. |
Hashtable | tableLCIDLocale - Language ID hash table. |
public Hashtable | fontsTableHash table that contains FontPeers instances. |
public ReferenceQueue | queueReferenceQueue for HashMapReference objects to check
if they were collected by garbage collector. |
public static final FontManager | instSingleton instance |
Methods Summary |
---|
public abstract java.awt.peer.FontPeer | createDefaultFont(int style, int size)Returns new default font peer with "Default" name for the parameters
specified. This method must be overridden by subclasses implementations.
|
private java.awt.peer.FontPeer | createFontPeer(java.lang.String name, int style, int size, int logicalIndex)Returns instance of font peer (logical or physical) according to the
specified parameters.
FontPeer peer;
if (logicalIndex != -1){
peer = createLogicalFontPeer(name, style, size);
}else {
peer = createPhysicalFontPeer(name, style, size);
}
return peer;
|
public java.lang.String | createLogicalFace(java.lang.String family, int styleIndex)Returns logical face name corresponding to the logical
family name and style of the font.
return family + "." + STYLE_NAMES[styleIndex]; //$NON-NLS-1$
|
private java.awt.peer.FontPeer | createLogicalFontPeer(java.lang.String faceName, int style, int size)Returns new logical font peer for the parameters specified using font
properties.
String family = getFamilyFromLogicalFace(faceName);
FontProperty[] fps = getFontProperties(family.toLowerCase() + "." + style); //$NON-NLS-1$
if (fps != null){
int numFonts = fps.length;
FontPeerImpl[] physicalFonts = new FontPeerImpl[numFonts];
for (int i = 0; i < numFonts; i++){
FontProperty fp = fps[i];
String name = fp.getName();
int fpStyle = fp.getStyle();
String key = name.concat(String.valueOf(fpStyle)).
concat(String.valueOf(size));
HashMapReference hmr = fontsTable.get(key);
if (hmr != null) {
physicalFonts[i] = (FontPeerImpl)hmr.get();
}
if (physicalFonts[i] == null){
physicalFonts[i] = (FontPeerImpl)createPhysicalFontPeer(name, fpStyle, size);
fontsTable.put(key, new HashMapReference(key, physicalFonts[i], queue));
}
if (physicalFonts[i] == null){
physicalFonts[i] = (FontPeerImpl)getDefaultFont(style, size);
}
}
return new CompositeFont(family, faceName, style, size, fps, physicalFonts);
}
// if there is no property for this logical font - default font is to be
// created
FontPeerImpl peer = (FontPeerImpl)getDefaultFont(style, size);
return peer;
|
public abstract java.awt.peer.FontPeer | createPhysicalFontPeer(java.lang.String name, int style, int size)Returns new physical font peer for the parameters specified using font properties
This method must be overridden by subclasses implementations.
|
public abstract java.lang.String[] | getAllFamilies()
|
public abstract java.awt.Font[] | getAllFonts()
|
public java.awt.peer.FontPeer | getDefaultFont(int style, int size)Returns default font peer class with "Default" name that is usually
used when font with specified font names and style doesn't exsist
on a system.
updateFontsTable();
FontPeer peer = null;
String key = DEFAULT_NAME.concat(String.valueOf(style)).
concat(String.valueOf(size));
HashMapReference hmr = fontsTable.get(key);
if (hmr != null) {
peer = hmr.get();
}
if (peer == null) {
peer = createDefaultFont(style, size);
((FontPeerImpl)peer).setFamily(DEFAULT_NAME);
((FontPeerImpl)peer).setPSName(DEFAULT_NAME);
((FontPeerImpl)peer).setFontName(DEFAULT_NAME);
fontsTable.put(key, new HashMapReference(key, peer, queue));
}
return peer;
|
public int | getFaceIndex(java.lang.String faceName)Returns index of face name from the array of face names available in
this GraphicsEnvironment or -1 if no face name was found. Default return
value is -1, method must be overridden by FontManager implementation.
return -1;
|
public java.lang.String | getFamily(int index)Returns family with index specified from the array of family names available in
this GraphicsEnvironment.
return allFamilies[index];
|
public java.lang.String | getFamilyFromLogicalFace(java.lang.String faceName)Returns family name for logical face names as a parameter.
int pos = faceName.indexOf("."); //$NON-NLS-1$
if (pos == -1){
return faceName;
}
return faceName.substring(0, pos);
|
public int | getFamilyIndex(java.lang.String familyName)Returns index of family name from the array of family names available in
this GraphicsEnvironment or -1 if no family name was found.
for (int i=0; i<allFamilies.length; i++ ){
if (familyName.equalsIgnoreCase(allFamilies[i])){
return i;
}
}
return -1;
|
public java.awt.peer.FontPeer | getFontPeer(java.lang.String fontName, int _fontStyle, int size)Returns platform-dependent Font peer created from the specified
Font object from the table with cached FontPeers instances.
Note, this method checks whether FontPeer with specified parameters
exists in the table with cached FontPeers' instances. If there is no needed
instance - it is created and cached.
updateFontsTable();
FontPeer peer = null;
String key;
String name;
int fontStyle = _fontStyle;
int logicalIndex = getLogicalFaceIndex(fontName);
if (logicalIndex != -1){
name = getLogicalFaceFromFont(fontStyle, logicalIndex);
fontStyle = getStyleFromLogicalFace(name);
key = name.concat(String.valueOf(size));
} else {
name = fontName;
key = name.concat(String.valueOf(fontStyle)).
concat(String.valueOf(size));
}
HashMapReference hmr = fontsTable.get(key);
if (hmr != null) {
peer = hmr.get();
}
if (peer == null) {
peer = createFontPeer(name, fontStyle, size, logicalIndex);
if (peer == null){
peer = getFontPeer(DIALOG_NAME, fontStyle, size);
}
fontsTable.put(key, new HashMapReference(key, peer, queue));
}
return peer;
|
public FontProperty[] | getFontProperties(java.lang.String fpName)Returns an array of FontProperties from the properties file
with the specified property name "logical face.style". E.g.
"dialog.2" corresponds to the font family Dialog with bold style.
Vector<FontProperty> props = fProperties.get(fpName);
if (props == null){
return null;
}
int size = props.size();
if (size == 0){
return null;
}
FontProperty[] fps = new FontProperty[size];
for (int i=0; i < fps.length; i++){
fps[i] = props.elementAt(i);
}
return fps;
|
public static java.io.File | getFontPropertyFile()Returns File object with font properties. It's name obtained using current
system configuration properties and locale settings. If no appropriate
file is found method returns null.
File file = null;
String javaHome = System.getProperty("java.home"); //$NON-NLS-1$
Locale l = Locale.getDefault();
String language = l.getLanguage();
String country = l.getCountry();
String fileEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
String os = System.getProperty("os.name"); //$NON-NLS-1$
int i = 0;
// OS names from system properties don't match
// OS identifiers used in font.property files
for (; i < OS_VALUES.length; i++){
if (os.endsWith(OS_VALUES[i])){
os = OS_VALUES[i];
break;
}
}
if (i == OS_VALUES.length){
os = null;
}
String version = System.getProperty("os.version"); //$NON-NLS-1$
String pathname;
for (i = 0; i < FP_FILE_NAMES.length; i++){
pathname = FP_FILE_NAMES[i];
if (os != null){
pathname = pathname.replaceFirst("OS", os); //$NON-NLS-1$
}
pathname = javaHome + pathname;
pathname = pathname.replaceAll("Language", language). //$NON-NLS-1$
replaceAll("Country", country). //$NON-NLS-1$
replaceAll("Encoding", fileEncoding). //$NON-NLS-1$
replaceAll("Version", version); //$NON-NLS-1$
file = new File(pathname);
if (file.exists()){
break;
}
}
return file.exists() ? file : null;
|
public static org.apache.harmony.awt.gl.font.FontManager | getInstance()Gets singleton instance of FontManager
return inst;
|
public java.lang.Short | getLCID(java.util.Locale l)Return language Id from LCID hash corresponding to the specified locale
if (this.tableLCID.size() == 0){
initLCIDTable();
}
return tableLCID.get(l.toString());
|
public java.lang.String | getLogicalFaceFromFont(int fontStyle, int logicalIndex)Returns face name of the logical font, which is the result
of specified font style and face style union.
int style = 0;
String name = LOGICAL_FONT_FACES[logicalIndex];
int pos = name.indexOf("."); //$NON-NLS-1$
if (pos == -1){
return createLogicalFace(name, fontStyle);
}
String styleName = name.substring(pos+1);
name = name.substring(0, pos);
// appending font style to the face style
style = fontStyle | getLogicalStyle(styleName);
return createLogicalFace(name, style);
|
public static int | getLogicalFaceIndex(java.lang.String fontName)Returns index of the font name in array of font names or -1 if
this font is not logical.
for (int i=0; i<LOGICAL_FONT_NAMES.length; i++ ){
if (LOGICAL_FONT_NAMES[i].equalsIgnoreCase(fontName)){
return i;
}
}
return -1;
|
public static int | getLogicalStyle(java.lang.String lName)Return font style from the logical style name.
for (int i = 0; i < STYLE_NAMES.length; i++){
style_keys.put(STYLE_NAMES[i], Integer.valueOf(i));
}
Integer value = style_keys.get(lName);
return value != null ? value.intValue(): -1;
|
public static java.util.Properties | getProperties(java.io.File file)Returns Properties from the properties file or null if
there is an error with FileInputStream processing.
Properties props = null;
FileInputStream fis = null;
try{
fis = new FileInputStream(file);
props = new Properties();
props.load(fis);
} catch (Exception e){
System.out.println(e);
}
return props;
|
public int | getStyleFromLogicalFace(java.lang.String name)Function returns style value from logical face name.
int style;
int pos = name.indexOf("."); //$NON-NLS-1$
if (pos == -1){
return Font.PLAIN;
}
String styleName = name.substring(pos+1);
style = getLogicalStyle(styleName);
return style;
|
public java.io.File | getTempFontFile()Returns File object, created in a directory
according to the System, where JVM is being ran.
In Linux case we use ".fonts" directory (for fontconfig purpose),
where font file from the stream will be stored, hence in LinuxFontManager this
method is overridden.
In Windows case we use Windows temp directory (default implementation)
//???AWT
/*
File fontFile = File.createTempFile("jFont", ".ttf"); //$NON-NLS-1$ //$NON-NLS-2$
fontFile.deleteOnExit();
return fontFile;
*/
if(NOT_IMP)
throw new NotImplementedException("getTempFontFile not Implemented");
return null;
|
public abstract void | initLCIDTable()Platform-dependent LCID table init.
|
public boolean | isFamilyExist(java.lang.String familyName)Returns true if specified family name is available in this
GraphicsEnvironment.
return (getFamilyIndex(familyName) != -1);
|
public static int[] | parseIntervals(java.lang.String exclusionString)Returns an array of integer range values
if the parameter exclusionString has format:
Range
Range [, exclusionString]
Range:
Char-Char
Char:
HexDigit HexDigit HexDigit HexDigit
Method returns null if the specified string is null.
int[] results = null;
if (exclusionString == null){
return null;
}
String[] intervals = exclusionString.split(","); //$NON-NLS-1$
if (intervals != null){
int num = intervals.length;
if (num > 0){
results = new int[intervals.length << 1];
for (int i = 0; i < intervals.length; i++){
String ranges[] = intervals[i].split("-"); //$NON-NLS-1$
results[i*2] = Integer.parseInt(ranges[0], 16);
results[i*2+1] = Integer.parseInt(ranges[1], 16);
}
}
}
return results;
|
private void | updateFontsTable()Removes keys from the Hashtable with font peers which corresponding
HashMapReference objects were garbage collected.
HashMapReference r;
//???AWT
//while ((r = (HashMapReference)queue.poll()) != null) {
// fontsTable.remove(r.getKey());
//}
|