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

FontPeerImpl

public abstract class FontPeerImpl extends Object implements FontPeer
Abstract class for platform dependent peer implementation of the Font class.

Fields Summary
int
ascent
int
descent
int
leading
int
maxAdvance
float
height
int
style
int
size
int
logicalHeight
String
name
String
fontFamilyName
String
faceName
Rectangle2D
maxCharBounds
float
italicAngle
int
numGlyphs
long
pFont
LineMetricsImpl
nlm
String
psName
public char
defaultChar
Default glyph index, that is used, when the desired glyph is unsupported in this Font.
boolean
uniformLM
Uniform LineMetrics flag, that is false for CompositeFont. Default value is true.
int
fontType
Flag of the type of this Font that is indicate is the Font has TrueType or Type1 type. Default value is FONT_TYPE_UNDEF.
private boolean
createdFromStream
Flag if this Font was created from stream, this parameter used in finilize method.
private String
tempFontFileName
FontExtraMetrics
extraMetrix
Constructors Summary
Methods Summary
public abstract booleancanDisplay(char c)
Returns true if this FontPeerImpl can display the specified char

public intcharWidth(char ch)
Returns the advance width of the specified char of this FontPeerImpl. Note, if glyph is absent in the font's glyphset - returned value is the advance of the deafualt glyph. For escape-chars returned width value is 0.

param
ch the char which width is to be returned
return
the advance width of the specified char of this FontPeerImpl

    	Paint p;
    	AndroidGraphics2D g = AndroidGraphics2D.getInstance();
    	if(g == null) {
    		throw new RuntimeException("AndroidGraphics2D not instantiated!");
    	}
   		p = ((AndroidGraphics2D)g).getAndroidPaint();
   		char[] ca = {ch};
   		float[] fa = new float[1];
   		p.getTextWidths(ca, 0, 1, fa);
   		return (int)fa[0];
    
public intcharWidth(int ind)
Returns the advance width of the specified char of this FontPeerImpl.

param
ind the char which width is to be returned
return
the advance width of the specified char of this FontPeerImpl

        return charWidth((char)ind);
    
public abstract voiddispose()
Disposes nesessary resources.

protected voidfinalize()
Sets new font type to the font object.

param
newType new type value

      super.finalize();
      
      dispose();
    
public intgetAscent()
Returns ascent of this font peer.

    	Paint p;
    	AndroidGraphics2D g = AndroidGraphics2D.getInstance();
    	if(g == null) {
    		throw new RuntimeException("AndroidGraphics2D not instantiated!");
    	}
   		p = ((AndroidGraphics2D)g).getAndroidPaint();
   		return (int)p.ascent();
        //return ascent;
    
public abstract GlyphgetDefaultGlyph()
Returns Glyph represeting missing char.

public intgetDescent()
Returns descent of this font peer.

        return descent;
    
public abstract FontExtraMetricsgetExtraMetrics()

public java.lang.StringgetFamily(java.util.Locale l)
Returns family name of the font in specified locale settings.

param
l specified Locale

        return this.getFamily();
    
public java.lang.StringgetFamily()
Returns family name of this FontPeerImpl.

        return fontFamilyName;
    
public longgetFontHandle()
Returns native font handle of this font peer.

        return pFont;
    
public java.lang.StringgetFontName(java.util.Locale l)
Returns face name of the font in specified locale settings.

param
l specified Locale

        return this.getFontName();
    
public java.lang.StringgetFontName()
Returns face name of this FontPeerImpl.

        if (this.fontType == FontManager.FONT_TYPE_T1){
            return this.fontFamilyName;
        }

        return faceName;
    
public intgetFontType()
Returns type of this font.

return
one of constant font type values.

        return fontType;
    
public abstract GlyphgetGlyph(char ch)
Returns Glyph representation of the given char.

param
ch specified char

public Glyph[]getGlyphs(char uFirst, char uLast)
Returns an array of Glyphs that represent characters from the specified Unicode range.

param
uFirst start position in Unicode range
param
uLast end position in Unicode range
return


        char i = uFirst;
        int len = uLast - uFirst;
        ArrayList<Glyph> lst = new ArrayList<Glyph>(len);

        if (size < 0) {
            // awt.09=min range bound value is greater than max range bound
            throw new IllegalArgumentException(Messages.getString("awt.09")); //$NON-NLS-1$
        }

        while (i < uLast) {
            lst.add(this.getGlyph(i));
        }

        return (Glyph[]) lst.toArray();
    
public Glyph[]getGlyphs(char[] chars)
Returns an array of Glyphs representing given array of chars.

param
chars specified array of chars

        if (chars == null){
            return null;
        }

        Glyph[] result = new Glyph[chars.length];

        for (int i = 0; i < chars.length; i++) {
            result[i] = this.getGlyph(chars[i]);
        }
        return result;
    
public Glyph[]getGlyphs(java.lang.String str)
Returns an array of Glyphs representing given string.

param
str specified string

        char[] chars = str.toCharArray();
        return this.getGlyphs(chars);
    
public floatgetHeight()
Returns height of this font peer.

        return height;
    
public floatgetItalicAngle()
Returns tangens of the italic angle of this FontPeerImpl. If the FontPeerImpl has TrueType font type, italic angle value can be calculated as (CharSlopeRun / CharSlopeRise) in terms of GDI.

        return italicAngle;
    
public intgetLeading()
Returns leading of this font peer.

        return leading;
    
public abstract java.awt.font.LineMetricsgetLineMetrics(java.lang.String str, java.awt.font.FontRenderContext frc, java.awt.geom.AffineTransform at)
Returns LineMetrics object with specified parameters

param
str specified String
param
frc specified render context
param
at specified affine transform
return

public java.awt.font.LineMetricsgetLineMetrics()
Returns cached LineMetrics object of this font peer.

        return nlm;
    
public intgetLogicalHeight()
Returns height of this font peer in pixels.

        return logicalHeight;
    
public java.awt.geom.Rectangle2DgetMaxCharBounds(java.awt.font.FontRenderContext frc)
Returns the bounds of the largest char in this FontPeerImpl in specified render context.

param
frc specified FontRenderContext

        return maxCharBounds;
    
public abstract intgetMissingGlyphCode()
Returns code of the missing glyph.

public java.lang.StringgetName()
Returns font name.

        return name;
    
public intgetNumGlyphs()
Returns the number of glyphs in this FontPeerImpl.

        return  numGlyphs;
    
public abstract java.lang.StringgetPSName()
Returns postscript name of the font.

public intgetSize()
Returns font size.

        return size;
    
public intgetStyle()
Returns font style.

        return style;
    
public java.lang.StringgetTempFontFileName()
Returns font file name of this font.

        return this.tempFontFileName;
    
public booleanhasUniformLineMetrics()
Returns true if this font peer has uniform line metrics.

        return uniformLM;
    
public booleanisCreatedFromStream()
Returns true, if this font peer was created from InputStream, false otherwise. In case of creating fonts from InputStream some font peer implementations may need to free temporary resources.

        return this.createdFromStream;
    
public voidsetCreatedFromStream(boolean value)
Sets createdFromStream flag to the specified parameter. If parameter is true it means font peer was created from InputStream.

param
value true, if font peer was created from InputStream

        this.createdFromStream = value;
    
public voidsetFamily(java.lang.String familyName)
Sets family name of the font in specified locale settings.

        this.fontFamilyName = familyName;
    
public voidsetFontFileName(java.lang.String value)
Sets font file name of this font to the specified one.

param
value String representing font file name

        this.tempFontFileName = value;
    
public voidsetFontName(java.lang.String fontName)
Sets font name of the font in specified locale settings.

        this.faceName = fontName;
    
public voidsetFontType(int newType)
Sets new font type to the font object.

param
newType new type value

        if (newType == FontManager.FONT_TYPE_T1 || newType == FontManager.FONT_TYPE_TT){
            fontType = newType;
        }
    
public voidsetLogicalHeight(int newHeight)
Sets height of this font peer in pixels to the given value.

param
newHeight new height in pixels value

        logicalHeight = newHeight;
    
public voidsetPSName(java.lang.String name)
Set postscript name of the font to the specified parameter.


       
    
                              
            

                 
       
    
	//private Graphics2D g = ((AndroidGraphicsFactory)Toolkit.getDefaultToolkit().getGraphicsFactory()).getGraphics2D();
    //private Graphics2D g = AndroidGraphics2D.getInstance();

                     
       
        this.psName = name;