Home » U++ Library support » RichText,QTF,RTF... » how get font height
how get font height [message #22205] |
Wed, 24 June 2009 12:04 |
|
bonami
Messages: 186 Registered: June 2007 Location: Beijing
|
Experienced Member |
|
|
i have a RichTextCtrl, i want it to be the height of the text on it.
RichTextCtrl rt;
...
String str = "[3A^test^ Graphical introduction]";
rt = str;
typedef const unsigned short screen_size_t;
screen_size_t linkSpace = 10;
screen_size_t linkSize = Arial(20).Info().GetLineHeight();
Add(rt.LeftPos(linkSpace, GetSize().cx - 2 * linkSpace).TopPos(linkSpace, linkSize));
the above code's rt fits. but i wonder how Arial(20) is related to "[3A", whose text should be of 100 dots/12 points. manual cites "points" everywhere, while it seems to mean differently.
[Updated on: Wed, 24 June 2009 12:05] Report message to a moderator
|
|
|
Re: how get font height [message #22206 is a reply to message #22205] |
Wed, 24 June 2009 12:49 |
|
mirek
Messages: 13984 Registered: November 2005
|
Ultimate Member |
|
|
bonami wrote on Wed, 24 June 2009 06:04 | i have a RichTextCtrl, i want it to be the height of the text on it.
RichTextCtrl rt;
...
String str = "[3A^test^ Graphical introduction]";
rt = str;
typedef const unsigned short screen_size_t;
screen_size_t linkSpace = 10;
screen_size_t linkSize = Arial(20).Info().GetLineHeight();
Add(rt.LeftPos(linkSpace, GetSize().cx - 2 * linkSpace).TopPos(linkSpace, linkSize));
the above code's rt fits. but i wonder how Arial(20) is related to "[3A", whose text should be of 100 dots/12 points. manual cites "points" everywhere, while it seems to mean differently.
|
"Points"? I hope it states "dots"
1 dot is defined as pixel of 600dpi printer. This is used "real-world" measure when printing on printer. There is of course relation between dots and points, as point is defined as 1/72 inch, therefore pt = 72 * dot / 600.
Anyway, to display on screen, you need to scale down. In practice, the most convenient is to base the scale on actual default font size (otherwise the text size looks odd).
See GetRichTextStdScreenZoom which defines normal RichText->screen zooming. This is then used as default for RichTextView.
Mirek
|
|
|
|
|
|
|
Goto Forum:
Current Time: Wed Jun 05 05:34:08 CEST 2024
Total time taken to generate the page: 0.01248 seconds
|