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

AndroidLineMetrics

public class AndroidLineMetrics extends org.apache.harmony.awt.gl.font.LineMetricsImpl
Linux implementation of LineMetrics class

Fields Summary
Constructors Summary
public AndroidLineMetrics(AndroidFont fnt, FontRenderContext frc, String str)
Constructor

        numChars = str.length();
        baseLineIndex = 0;

        ascent = fnt.ascent;    // Ascent of the font
        descent = -fnt.descent;  // Descent of the font
        leading = fnt.leading;  // External leading

        height = ascent + descent + leading;    // Height of the font ( == (ascent + descent + leading))
        underlineThickness = 0.0f;
        underlineOffset = 0.0f;
        strikethroughThickness = 0.0f;
        strikethroughOffset = 0.0f;
        maxCharWidth = 0.0f;

        //    TODO: Find out pixel metrics
        /*
         * positive metrics rounded to the smallest int that is bigger than value
         * negative metrics rounded to the smallest int that is lesser than value
         * thicknesses rounded to int ((int)round(value + 0.5))
         *
         */

        lAscent = (int)Math.ceil(fnt.ascent);//   // Ascent of the font
        lDescent = -(int)Math.ceil(fnt.descent);// Descent of the font
        lLeading = (int)Math.ceil(leading);  // External leading

        lHeight = lAscent + lDescent + lLeading;    // Height of the font ( == (ascent + descent + leading))

        lUnderlineThickness = Math.round(underlineThickness);//(int)metrics[11];

        if (underlineOffset >= 0){
            lUnderlineOffset = (int)Math.ceil(underlineOffset);
        } else {
            lUnderlineOffset = (int)Math.floor(underlineOffset);
        }

        lStrikethroughThickness = Math.round(strikethroughThickness); //(int)metrics[13];

        if (strikethroughOffset >= 0){
            lStrikethroughOffset = (int)Math.ceil(strikethroughOffset);
        } else {
            lStrikethroughOffset = (int)Math.floor(strikethroughOffset);
        }

        lMaxCharWidth = (int)Math.ceil(maxCharWidth); //(int)metrics[15];
        units_per_EM = 0;

    
Methods Summary
public intgetBaselineIndex()

        if (baselineOffsets == null){
            // get offsets and set correct index
            getBaselineOffsets();
        }
        return baseLineIndex;
    
public float[]getBaselineOffsets()

        // TODO: implement baseline offsets for TrueType fonts
        if (baselineOffsets == null){
            float[] baselineData = null;

            // Temporary workaround:
            // Commented out native data initialization, since it can 
            // cause failures with opening files in multithreaded applications.
            //
            // TODO: support work with truetype data in multithreaded
            // applications.

            // If font TrueType data is taken from BASE table
//            if ((this.font.getFontHandle() != 0) && (font.getFontType() == FontManager.FONT_TYPE_TT)){
//                baselineData = LinuxNativeFont.getBaselineOffsetsNative(font.getFontHandle(), font.getSize(), ascent, descent, units_per_EM);
//            }
//
                baseLineIndex = 0;
                baselineOffsets = new float[]{0, (-ascent+descent)/2, -ascent};
        }

        return baselineOffsets;