Example #1
0
EXPORT_C TSize THuiFont::LineExtentsL(const TDesC& aTextString)
	{
	if (aTextString.Length() == 0)
    	{
    	// Zero length strings have extents of zero.
        return TSize(0, 0);
    	}
	
    // Retrieve the CFont object used when rasterizing this text mesh.
	CFont* font = NearestFontL();
    TSize textSize( MeasureBidiTextBoundsWidth(*font, aTextString, CFont::TMeasureTextInput::EFVisualOrder), 
                    font->FontMaxHeight());
    
    const CAknLayoutFont* layoutFont = 0;
    if (CCoeEnv::Static())
        {
        layoutFont = CAknLayoutFont::AsCAknLayoutFontOrNull( font );
        }
    
    if ( layoutFont )
        {
        textSize.iHeight = font->HeightInPixels();
        TInt textPaneHeight = layoutFont->TextPaneHeight();
        TInt textPaneTopToBaseline = layoutFont->TextPaneTopToBaseline();
        
        textSize.iHeight += textPaneHeight - textPaneTopToBaseline;
        textSize.iHeight += KHuiFontVerticalShiftInPixels;
        }
    else
        {
        textSize.iHeight = Max(textSize.iHeight, font->HeightInPixels());
        textSize.iHeight += 3; // the best approximation - fails on big (>=72) fonts
        }
        
    // Return the calculated text size.
    return textSize;
	}