FileDocCategorySizeDatePackage
AndroidFont.javaAPI DocAndroid 1.5 API7590Wed May 06 22:41:54 BST 2009org.apache.harmony.awt.gl.font

AndroidFont

public class AndroidFont extends org.apache.harmony.awt.gl.font.FontPeerImpl
Linux platform font peer implementation based on Xft and FreeType libraries.

Fields Summary
private int[]
fontUnicodeRanges
private Hashtable
glyphs
private long
display
private int
screen
Constructors Summary
public AndroidFont(String fontName, int fontStyle, int fontSize)

    
           
        /*
         * Workaround : to initialize awt platform-dependent fields and libraries.
         */
        Toolkit.getDefaultToolkit();
        this.name = fontName;
        this.size = fontSize;
        this.style = fontStyle;
       
        initAndroidFont();
    
Methods Summary
public booleanaddGlyph(char uChar)
Add glyph to cached Glyph objects in this LinuxFont object.

param
uChar the specified character
return
true if glyph of the specified character exists in this LinuxFont or this character is escape sequence character.

    	throw new RuntimeException("Not implemented!");    	
    
public voidaddGlyphs(char uFirst, char uLast)
Adds range of existing glyphs to this LinuxFont object

param
uFirst the lowest range's bound, inclusive
param
uLast the highest range's bound, exclusive

    	
        char index = uFirst;
        if (uLast < uFirst) {
            // awt.09=min range bound value is grater than max range bound
            throw new IllegalArgumentException(Messages.getString("awt.09")); //$NON-NLS-1$
        }
        while (index < uLast) {
            addGlyph(index);
            index++;
        }
        
    
public booleancanDisplay(char chr)

        // TODO: to improve performance there is a sence to implement get
        // unicode ranges to check if char can be displayed without
        // native calls in isGlyphExists() method

        return isGlyphExists(chr);
    
public voiddispose()
Disposes native font handle. If this font peer was created from InputStream temporary created font resource file is deleted.

        String tempDirName;
        if (pFont != 0){
            pFont = 0;

            if (isCreatedFromStream()) {
                File fontFile = new File(getTempFontFileName());
                tempDirName = fontFile.getParent();
                fontFile.delete();
            }
        }
    
public static java.awt.FontembedFont(java.lang.String absolutePath)
Return Font object if it was successfully embedded in System

    	throw new RuntimeException("embedFont not implemented!");
    
public org.apache.harmony.awt.gl.font.GlyphgetDefaultGlyph()

    	throw new RuntimeException("DefaultGlyphs not implemented!");
    
public FontExtraMetricsgetExtraMetrics()
Returns initiated FontExtraMetrics instance of this WindowsFont.

    	throw new RuntimeException("Not implemented!");
    
public java.lang.StringgetFamily()

        return fontFamilyName;
    
public java.lang.StringgetFamily(java.util.Locale l)

        // TODO: implement localized family
        if (fontType == FontManager.FONT_TYPE_TT){
            return this.getFamily();
        }

        return this.fontFamilyName;
    
public java.lang.StringgetFontName()

        if ((pFont != 0) && (faceName == null)){
            if (this.fontType == FontManager.FONT_TYPE_T1){
                faceName = getFamily();
            }
        }
        return faceName;
    
public java.lang.StringgetFontName(java.util.Locale l)

        if ((pFont == 0) || (this.fontType == FontManager.FONT_TYPE_T1)){
            return this.name;
        }

        return this.getFontName();
    
public org.apache.harmony.awt.gl.font.GlyphgetGlyph(char index)

        Glyph result = null;

        Object key = new Integer(index);
        if (glyphs.containsKey(key)) {
            result = (Glyph) glyphs.get(key);
        } else {
            if (this.addGlyph(index)) {
                result = (Glyph) glyphs.get(key);
            } else {
                result = this.getDefaultGlyph();
            }
        }

        return result;
    
public java.awt.font.LineMetricsgetLineMetrics(java.lang.String str, java.awt.font.FontRenderContext frc, java.awt.geom.AffineTransform at)


        // Initialize baseline offsets
        nlm.getBaselineOffsets();
        
        LineMetricsImpl lm = (LineMetricsImpl)(this.nlm.clone());
        lm.setNumChars(str.length());

        if ((at != null) && (!at.isIdentity())){
            lm.scale((float)at.getScaleX(), (float)at.getScaleY());
        }

        return lm;
    
public intgetMissingGlyphCode()

        return getDefaultGlyph().getGlyphCode();
    
public java.lang.StringgetPSName()

        return psName;
    
public int[]getUnicodeRanges()
Returns an array of unicode ranges that are supported by this LinuxFont.

        int[] ranges = new int[fontUnicodeRanges.length];
        System.arraycopy(fontUnicodeRanges, 0, ranges, 0,
                fontUnicodeRanges.length);

        return ranges;
    
public voidinitAndroidFont()
Initializes some native dependent font information, e.g. number of glyphs, font metrics, italic angle etc.

        this.nlm = new AndroidLineMetrics(this, null, " "); //$NON-NLS-1$
        this.ascent = nlm.getLogicalAscent();
        this.descent = nlm.getLogicalDescent();
        this.height = nlm.getHeight();
        this.leading = nlm.getLogicalLeading();
        this.maxAdvance = nlm.getLogicalMaxCharWidth();

        if (this.fontType == FontManager.FONT_TYPE_T1){
            this.defaultChar = 1;
        } else {
            this.defaultChar = 0;
        }

        this.maxCharBounds = new Rectangle2D.Float(0, -nlm.getAscent(), nlm.getMaxCharWidth(), this.height);
    
public booleanisGlyphExists(char uIndex)
Returns true if specified character has corresopnding glyph, false otherwise.

param
uIndex specified char

    	throw new RuntimeException("DefaultGlyphs not implemented!");