How to draw text at the centre of a rectangle ?
Is there any way to know the length of my text ?
I am thinking if my text's length is lX, I can calculate the start position's x coordinate as (Rectangle.length - lX) / 2 .
How to draw text at the centre of a rectangle ?
Is there any way to know the length of my text ?
I am thinking if my text's length is lX, I can calculate the start position's x coordinate as (Rectangle.length - lX) / 2 .
For drawing some text center justified in a box you can do like this:
You can use CFont::TextWidthInPixels() function.Code:gc.DrawText(KExampleText, box, baseline, CGraphicsContext::ECenter, margin);
TInt TextWidthInPixels(const TDesC &aText) const;
Description
Gets the width in pixels of the specified descriptor when displayed in this font.
you can alaign it to the center, just check the gc functions that can be used for text drawing, also check CFont for functionality foe the text lenght checkings.