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... » Using Qtf forgets control font
Using Qtf forgets control font [message #16677] Mon, 07 July 2008 14:04 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I have a simple test case here to illustrate the problem. I have a layout with two labels, and both have their label set to the same text, only the second one gets a "\1" prepended to enable Qtf and allow word wrapping.

The second label will forget the font that it's supposed to use, and thus, under Linux, with the current font problems, will simply not display anything since the font that the Qtf defaults to does not have the character. A workaround could be to give the font name again in the Qtf, but shouldn't this "forgetting" be fixed? I'll try to figure out what this would imply.
  • Attachment: Test.zip
    (Size: 1.24KB, Downloaded 653 times)
Re: Using Qtf forgets control font [message #16678 is a reply to message #16677] Mon, 07 July 2008 15:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
If you use QTF in label, font is ignored. (-> a feature, not a bug Smile

Mirek
Re: Using Qtf forgets control font [message #16680 is a reply to message #16678] Mon, 07 July 2008 16:53 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Mon, 07 July 2008 16:30

If you use QTF in label, font is ignored. (-> a feature, not a bug Smile

Mirek

Strange feature. A little counter-productive, but I guess I can compensate with extra Qtf. I tried something like this:
lblKun.SetFont(f).SetText("\1[!" + f.GetFaceName() + "! [3 " + ToUtf8(Join(kanji_.KunReading, EntrySeparator)) + "]]"); 

only to find out that using [3 ...] for 12 points is different from the StdFont height. Is there a function that takes a font height and return the Qtf magical number needed to obtain that size?

And is there a Qtf tag to disable font antialliasing? I couldn't find one.

Or even better, is there another way to enable word-wrapping.
Re: Using Qtf forgets control font [message #16699 is a reply to message #16680] Mon, 07 July 2008 22:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Mon, 07 July 2008 10:53

luzr wrote on Mon, 07 July 2008 16:30

If you use QTF in label, font is ignored. (-> a feature, not a bug Smile

Mirek

Strange feature. A little counter-productive, but I guess I can compensate with extra Qtf. I tried something like this:
lblKun.SetFont(f).SetText("\1[!" + f.GetFaceName() + "! [3 " + ToUtf8(Join(kanji_.KunReading, EntrySeparator)) + "]]"); 

only to find out that using for 12 points is different from the StdFont height. Is there a function that takes a font height and return the Qtf magical number needed to obtain that size?


[/quote]

Unfortunately, things are a little bit more complicated (as usual). QTF is basically "physical unit format" (intended to be eventually printed). The unit is "dot" - 1/600 of inch. However, for screen displaying, there is zooming coeficient that is derived from Font-zoom.

Font "numbers" are tables of dots, but you can express the font height if you prepend it with '+', like "[+80 ...".

Mirek

[Updated on: Mon, 07 July 2008 22:51]

Report message to a moderator

Re: Using Qtf forgets control font [message #16711 is a reply to message #16699] Tue, 08 July 2008 13:47 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Sorry, but Qtf is more trouble than it's worth. I'll fork label and rewrite Paint so that it uses manual word-wrapping.
Re: Using Qtf forgets control font [message #16715 is a reply to message #16711] Tue, 08 July 2008 14:38 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
cbpporter wrote on Tue, 08 July 2008 13:47

Sorry, but Qtf is more trouble than it's worth. I'll fork label and rewrite Paint so that it uses manual word-wrapping.


I can't agree. QTF is one of the most useful features.
Re: Using Qtf forgets control font [message #16718 is a reply to message #16715] Tue, 08 July 2008 15:28 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
zsolt wrote on Tue, 08 July 2008 15:38

cbpporter wrote on Tue, 08 July 2008 13:47

Sorry, but Qtf is more trouble than it's worth. I'll fork label and rewrite Paint so that it uses manual word-wrapping.


I can't agree. QTF is one of the most useful features.

I'm sure it is really useful in printing and quick fancy formated outputs. Yet it can not handle a simple thing like "take all the formating info out of that font and use it". Maybe if we define some kind of a mechanism similar to the one that allows the usage of picture inside Qtf (which is a great feature BTW)...
Re: Using Qtf forgets control font [message #17815 is a reply to message #16718] Fri, 29 August 2008 21:09 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I'm trying to implement something regarding DPI/Font to Qtf and I need to determine screen DPI. Something like Draw::GetPixelsPerInch seems a good place to start, but first of all I can only call it on a Draw instance, and even if I do, I get a failed assert regarding IsDrawing. Using it on ScreenInfo also seemed like a good idea, but I can't use it or find it's definition. All I can find is about 6 such declarations scattered around:
Draw& ScreenInfo();


Also, could someone point me in the direction where GUI scaling is done, so I can understand the way sizes scale with higher DPI. Is it CurDPI / 72 * intended size or something similar?
Re: Using Qtf forgets control font [message #17818 is a reply to message #17815] Fri, 29 August 2008 22:39 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Also, WindXP is quite helpful in giving you this handy tip:
Quote:

If your screen resolution makes items too small to view comfortably, you can increase the DPI to compensate.

Is it just me, or is this statement completely backwards. Why would increasing the DPI make any text larger. That doesn't make any sense to me Laughing. Am I missing something?
Re: Using Qtf forgets control font [message #17832 is a reply to message #17818] Sat, 30 August 2008 13:43 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I think I understand now. When you are printing on paper, the size of an inch is constant. Thus increasing DPI, makes text smaller.

But on screen, DPI is considered PPI and the pixel size for a resolution is considered constant. By altering DPI, you actually change the size of an inch. So by increasing DPI, you increase the "virtual" inch size, and thus text gets larger.
Re: Using Qtf forgets control font [message #17833 is a reply to message #17832] Sat, 30 August 2008 14:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sat, 30 August 2008 07:43

I think I understand now. When you are printing on paper, the size of an inch is constant. Thus increasing DPI, makes text smaller.

But on screen, DPI is considered PPI and the pixel size for a resolution is considered constant. By altering DPI, you actually change the size of an inch. So by increasing DPI, you increase the "virtual" inch size, and thus text gets larger.


Smile Welcome to the real world.

That is why I keep saying that points and DPI for screen are largely irrelevant. What only matters is zoom ratio.

Mirek
Re: Using Qtf forgets control font [message #17835 is a reply to message #17833] Sat, 30 August 2008 14:10 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Sat, 30 August 2008 15:05


Smile Welcome to the real world.


Thank you Smile!

Quote:


That is why I keep saying that points and DPI for screen are largely irrelevant. What only matters is zoom ratio.


Still, there are still two issues left:
1. Even though DPI is irrelevant for screens, and computations are wrong, I still want to use the same computations as the rest of the world. My size x font from U++ must be pixel-by-pixel identical to the same font in Notepad or a window title bar.
2. I still need to know how to use ScreenInfo and GetPixelsPerInch.
Re: Using Qtf forgets control font [message #17836 is a reply to message #17835] Sat, 30 August 2008 14:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sat, 30 August 2008 08:10


Still, there are still two issues left:
1. Even though DPI is irrelevant for screens, and computations are wrong, I still want to use the same computations as the rest of the world. My size x font from U++ must be pixel-by-pixel identical to the same font in Notepad or a window title bar.



Definitely. It is. That is what Ctrl::FontZoom is for.

Quote:


2. I still need to know how to use ScreenInfo and GetPixelsPerInch.


Sure. What is the problem?

Mirek
Re: Using Qtf forgets control font [message #17842 is a reply to message #17836] Sat, 30 August 2008 22:08 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Sat, 30 August 2008 15:53

Definitely. It is. That is what Ctrl::FontZoom is for.


I can't find Ctrl::FontZoom.

And:
Quote:

Something like Draw::GetPixelsPerInch seems a good place to start, but first of all I can only call it on a Draw instance, and even if I do, I get a failed assert regarding IsDrawing. Using it on ScreenInfo also seemed like a good idea, but I can't use it or find it's definition. All I can find is about 6 such declarations scattered around
Re: Using Qtf forgets control font [message #17849 is a reply to message #17842] Sun, 31 August 2008 10:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Sorry, "FontZoom" is "general term". The methods are

Ctrl::

	static const char *GetZoomText();
	static void SetZoomSize(Size sz, Size bsz = Size(0, 0));
	static int  HorzLayoutZoom(int cx);
	static int  VertLayoutZoom(int cy);
	static Size LayoutZoom(int cx, int cy);
	static Size LayoutZoom(Size sz);
	static void NoLayoutZoom();
	static void GetZoomRatio(Size& m, Size& d);

	static int  HZoom(int cx)                            { return HorzLayoutZoom(cx); }


The idea behind this is that there is some basic font size. All dialog layouts are designed with this basic font size in mind - and these are units shown in layout designer.

Then there is "GetZoomText" - a standard text whose size is known in basic font size (by basic font we consider here the "normal font" used for most texts in GUI).

Then, when U++ app is started, the same text is measured in host platform "normal GUI font" and this new size / "standard size" is taken as "FontZoom ratio".

This is the best solution I was able to invent... In practice, it works pretty well.

Mirek
Re: Using Qtf forgets control font [message #17851 is a reply to message #17849] Sun, 31 August 2008 10:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I had to deprecate ScreenInfo, as it is inherently MT unsafe... Sad

You should be able to get the same thing using

ScreenDraw info(true);

Mirek
Re: Using Qtf forgets control font [message #17853 is a reply to message #17849] Sun, 31 August 2008 13:39 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Sun, 31 August 2008 11:46

Sorry, "FontZoom" is "general term". The methods are
The idea behind this is that there is some basic font size. All dialog layouts are designed with this basic font size in mind - and these are units shown in layout designer.

Then there is "GetZoomText" - a standard text whose size is known in basic font size (by basic font we consider here the "normal font" used for most texts in GUI).

Then, when U++ app is started, the same text is measured in host platform "normal GUI font" and this new size / "standard size" is taken as "FontZoom ratio".

This is the best solution I was able to invent... In practice, it works pretty well.


OK, basically you have Csize where you get the current size using StdFont of the zoom text, and Dsize, which is initialized with a hardcoded measurement of the same text and same font under what you consider zoom 1:1 zoom ration. And you use their ration to adjust positions.

Then you must know what which font StdFont() is Razz.

I also noticed that max between Csize and Dsize. This probably explains why when I lowered my PPI and I go really small text, the layout was not shrunk, but when I increase PPI, layouts grow..

Quote:


I had to deprecate ScreenInfo, as it is inherently MT unsafe...

You should be able to get the same thing using

ScreenDraw info(true);


ScreenDraw worked fine. Thank you! Actually, I was getting the assert because I used PromptOK in a Paint method. I shouldn't have done that.

Can I use ScreenDraw to draw on the screen as with Win API GetDC(0)? If yes, then probably I should extract the info I need at application startup and then discard the ScreenDraw instance.

I think I have everything that I need to add HeightPt() and GetHeightPt() to Font.

Also, except font antialiasing, is there any other missing tag from Qtf that is present in a font description?

[Updated on: Thu, 04 September 2008 05:03]

Report message to a moderator

Re: Using Qtf forgets control font [message #17872 is a reply to message #17853] Mon, 01 September 2008 13:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Sun, 31 August 2008 07:39



Can I use ScreenDraw to draw on the screen as with Win API GetDC(0)?



That is ScreenDraw with "false". "true" means "information context" - read only.

Quote:


If yes, then probably I should extract the info I need at application startup and then discard the ScreenDraw instance.



Yep.

Quote:


Also, except font antialiasing, is there any other missing tag from Qtf that is present in a font description?



IMO, no. In fact, "antialiasing" request sort of surprised me... OTOH, why not, there might be a use for it.

Mirek
Re: Using Qtf forgets control font [message #17876 is a reply to message #17872] Mon, 01 September 2008 14:46 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Mon, 01 September 2008 14:37


IMO, no. In fact, "antialiasing" request sort of surprised me... OTOH, why not, there might be a use for it.


There are some CJK fonts under Linux which are completely unreadable with anti-aliasing, unless you use huge font size, where anti-aliasing doesn't really help in general. Also, since U++ kind of forces you to use Qtf for formated display, I think it makes no sense for it not to support all attributes of font.
Re: Using Qtf forgets control font [message #17949 is a reply to message #17876] Thu, 04 September 2008 05:08 Go to previous messageGo to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I added HeightPt to Font. Or should it be HeightPoints now, so to not overuse abbreviations? If it will be accepted I'll add the possibility to choose the sizing unit to TheIDE's font properties dialog from the layout designer so that I can set up all my layouts to use points. If not, I'll leave it as it is because it is too much effort to maintain a TheIDE fork.
Previous Topic: Print Preview function for RichText/RichEdit
Next Topic: Is there a way to do page of pages, i.e., Page 2 of 5 in Report?
Goto Forum:
  


Current Time: Thu Mar 28 15:26:35 CET 2024

Total time taken to generate the page: 0.01086 seconds