Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Ilya S. Okomin
*/
package org.apache.harmony.awt.gl.font;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Properties;
import java.util.Vector;
import org.apache.harmony.awt.Utils;
import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
import com.google.code.appengine.awt.Font;
import com.google.code.appengine.awt.font.sfntly.SfntlyFontPeer;
import com.google.code.appengine.awt.peer.FontPeer;
public class FontManager {
public static final boolean IS_FONTLIB = false;
/**
* array of font families names
*/
public String[] allFamilies;
public static final String DEFAULT_NAME = IS_FONTLIB ? "DejaVu Sans" : "Default"; /* Default font name */ //$NON-NLS-1$
public static final String DIALOG_NAME = "Dialog"; /* Dialog font name */ //$NON-NLS-1$
/**
* Set of constants applicable to the TrueType 'name' table.
*/
public static final byte FAMILY_NAME_ID = 1; /* Family name identifier */
public static final byte FONT_NAME_ID = 4; /* Full font name identifier */
public static final byte POSTSCRIPT_NAME_ID = 6; /* PostScript name identifier */
public static final short ENGLISH_LANGID = 0x0409; /* English (United States)language identifier */
/**
* Set of constants describing font type.
*/
public static final byte FONT_TYPE_TT = 4; /* TrueType type (TRUETYPE_FONTTYPE) */
public static final byte FONT_TYPE_T1 = 2; /* Type1 type (DEVICE_FONTTYPE) */
public static final byte FONT_TYPE_UNDEF = 0; /* Undefined type */
// logical family types (indices in FontManager.LOGICAL_FONT_NAMES)
static final int DIALOG = 3; // FF_SWISS
static final int SANSSERIF = 1; // FF_SWISS
static final int DIALOGINPUT = 4; // FF_MODERN
static final int MONOSPACED = 2; // FF_MODERN
static final int SERIF = 0; // FF_ROMAN
/**
* FontProperty related constants.
*/
public static final String PLATFORM_FONT_NAME = "PlatformFontName"; //$NON-NLS-1$
public static final String LOGICAL_FONT_NAME = "LogicalFontName"; //$NON-NLS-1$
public static final String COMPONENT_INDEX = "ComponentIndex"; //$NON-NLS-1$
public static final String STYLE_INDEX = "StyleIndex"; //$NON-NLS-1$
public static final String[] FONT_MAPPING_KEYS = {
"LogicalFontName.StyleName.ComponentIndex", "LogicalFontName.ComponentIndex" //$NON-NLS-1$ //$NON-NLS-2$
};
public static final String FONT_CHARACTER_ENCODING = "fontcharset.LogicalFontName.ComponentIndex"; //$NON-NLS-1$
public static final String EXCLUSION_RANGES = "exclusion.LogicalFontName.ComponentIndex"; //$NON-NLS-1$
public static final String FONT_FILE_NAME = "filename.PlatformFontName"; //$NON-NLS-1$
/**
* Available logical font families names.
*/
public static final String[] LOGICAL_FONT_FAMILIES = {
"Serif", "SansSerif", "Monospaced", "Dialog", "DialogInput" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
};
/**
* Available logical font names.
*/
public static final String[] LOGICAL_FONT_NAMES = {
"serif", "serif.plain", "serif.bold", "serif.italic", "serif.bolditalic", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"sansserif", "sansserif.plain", "sansserif.bold", "sansserif.italic", "sansserif.bolditalic", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"monospaced", "monospaced.plain", "monospaced.bold", "monospaced.italic", "monospaced.bolditalic", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"dialog", "dialog.plain", "dialog.bold", "dialog.italic", "dialog.bolditalic", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"dialoginput", "dialoginput.plain", "dialoginput.bold", "dialoginput.italic", "dialoginput.bolditalic" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
};
/**
* Available logical font face names.
*/
public static final String[] LOGICAL_FONT_FACES = {
"Serif", "Serif.plain", "Serif.bold", "Serif.italic", "Serif.bolditalic", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"Sansserif", "Sansserif.plain", "Sansserif.bold", "Sansserif.italic", "Sansserif.bolditalic", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"Monospaced", "Monospaced.plain", "Monospaced.bold", "Monospaced.italic", "Monospaced.bolditalic", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"Dialog", "Dialog.plain", "Dialog.bold", "Dialog.italic", "Dialog.bolditalic", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"Dialoginput", "Dialoginput.plain", "Dialoginput.bold", "Dialoginput.italic", "Dialoginput.bolditalic" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
};
/**
* Set of font style names.
* Font.getStyle() corresponds to indexes in STYLE_NAMES array.
*/
public static final String[] STYLE_NAMES = {
"plain", "bold", "italic", "bolditalic" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
};
/**
* Logical font styles names table where font styles names used
* as the key and the value is the index of this style name.
*/
private static final Hashtable style_keys = new Hashtable(4);
/**
* Initialize font styles keys table.
*/
static {
for (int i = 0; i < STYLE_NAMES.length; i++){
style_keys.put(STYLE_NAMES[i], Integer.valueOf(i));
}
}
/**
* Return font style from the logical style name.
*
* @param lName style name of the logical face
*/
public static int getLogicalStyle(String lName){
Integer value = style_keys.get(lName);
return value != null ? value.intValue(): -1;
}
/**
* Set of possible "os" property values.
*/
public static final String[] OS_VALUES = {
"NT", "98", "2000", "Me", "XP", // For Windows //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"Redhat", "Turbo", "SuSE" // For Linux //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
};
/**
* Set of possible font.property file names.
* Language, Country, Encoding, OS, Version should be replaced with
* the values from current configuration.
*/
public static final String[] FP_FILE_NAMES = {
"/lib/font.properties.Language_Country_Encoding.OSVersion", //$NON-NLS-1$
"/lib/font.properties.Language_Country_Encoding.OS", //$NON-NLS-1$
"/lib/font.properties.Language_Country_Encoding.Version", //$NON-NLS-1$
"/lib/font.properties.Language_Country_Encoding", //$NON-NLS-1$
"/lib/font.properties.Language_Country.OSVersion", //$NON-NLS-1$
"/lib/font.properties.Language_Country.OS", //$NON-NLS-1$
"/lib/font.properties.Language_Country.Version", //$NON-NLS-1$
"/lib/font.properties.Language_Country", //$NON-NLS-1$
"/lib/font.properties.Language_Encoding.OSVersion", //$NON-NLS-1$
"/lib/font.properties.Language_Encoding.OS", //$NON-NLS-1$
"/lib/font.properties.Language_Encoding.Version", //$NON-NLS-1$
"/lib/font.properties.Language_Encoding", //$NON-NLS-1$
"/lib/font.properties.Language.OSVersion", //$NON-NLS-1$
"/lib/font.properties.Language.OS", //$NON-NLS-1$
"/lib/font.properties.Language.Version", //$NON-NLS-1$
"/lib/font.properties.Language", //$NON-NLS-1$
"/lib/font.properties.Encoding.OSVersion", //$NON-NLS-1$
"/lib/font.properties.Encoding.OS", //$NON-NLS-1$
"/lib/font.properties.Encoding.Version", //$NON-NLS-1$
"/lib/font.properties.Encoding", //$NON-NLS-1$
"/lib/font.properties.OSVersion", //$NON-NLS-1$
"/lib/font.properties.OS", //$NON-NLS-1$
"/lib/font.properties.Version", //$NON-NLS-1$
"/lib/font.properties" //$NON-NLS-1$
};
/**
* Table with all available font properties corresponding
* to the current system configuration.
*/
public Hashtable> fProperties = new Hashtable>();
public FontManager() {
if (!IS_FONTLIB) {
allFamilies = getAllFamilies();
/*
* Creating and registering shutdown hook to free resources
* before object is destroyed.
*/
// AccessController.doPrivileged(new PrivilegedAction