Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » how get font height
icon5.gif  how get font height [message #22205] Wed, 24 June 2009 12:04 Go to next message
bonami is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
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" Smile

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
Re: how get font height [message #22207 is a reply to message #22206] Wed, 24 June 2009 12:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
P.S.: You might want to consider using

RichTextView::
int GetWidth() const
int GetHeight(int cx) const

instead...
Re: how get font height [message #22219 is a reply to message #22205] Thu, 25 June 2009 09:55 Go to previous messageGo to next message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
i'm afraid i'm still totally confused.
though you answered the relationship between screen and print, points and dots, you still did not mention why Arial(20) makes it fit, and what unit this 20 is in.
I tried RichTextView a; a.SetQTF(str); ...linkSize=a.GetHeight(123/* this value seems to affect nothing*/) //now this value is over 800!while former Arial(20) line gave me 24.
Don't know how to use GetRichTextStdScreenZoom otherwise. I tested 1000/GetRichTextStdScreenZoom() and got over 5300.
Re: how get font height [message #22234 is a reply to message #22219] Fri, 26 June 2009 14:10 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	TopWindow win;
	RichTextCtrl rt;
	String str = "[3A^test^ Graphical introduction]";
	rt = str;
	rt.SetFrame(BlackFrame());
	rt.NoSb();
	win.Add(rt.LeftPos(10, rt.GetWidth() + 2).TopPos(rt.GetHeight(INT_MAX) + 2));
	win.Run();
}


Mirek
icon14.gif  Re: how get font height [message #22267 is a reply to message #22234] Mon, 29 June 2009 04:29 Go to previous message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
OIC. It's auto sized. thank you.
Previous Topic: Inserting text into the current cursor position
Next Topic: Font alignment issues
Goto Forum:
  


Current Time: Thu Mar 28 14:28:43 CET 2024

Total time taken to generate the page: 0.01508 seconds