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
Re: Using Qtf forgets control font [message #18033 is a reply to message #17949] Sun, 07 September 2008 13:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 03 September 2008 23:08

I added HeightPt to Font. Or should it be HeightPoints now, so to not overuse abbreviations?



Ehm, after all these posts about points being meaningless for screen? Smile

On what device that point is defined?

Quote:


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.



That's Pandora's box, believe me.

Mirek
Re: Using Qtf forgets control font [message #18037 is a reply to message #18033] Sun, 07 September 2008 14:08 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
luzr wrote on Sun, 07 September 2008 14:35


Ehm, after all these posts about points being meaningless for screen? Smile


Well my problem is simple. I have Font selection dialog. User chooses size 16 for example. In U++ size is in pixels. User chooses size 16 in different program. Size is in points. User complains that I have bug with font sizes Sad. After a simple investigation, it seems that this is what is needed to get same size:
Font& Font::HeightPt(int pt)
{
    height = pt * sScreenPPI / 72;
    return *this;
}

Not extensively tested, but seems to generate pixel perfect matches.

Quote:


That's Pandora's box, believe me.


I'll assume that you don't want it opened. Anyway, after all other task are done, the property browser could also be improved and (dare I say it) made more like the Delphi/VS one.

PS: something is messed up with Assist/Navigate.. in SVN. All items appear about 15 times.
Re: Using Qtf forgets control font [message #18040 is a reply to message #18037] Sun, 07 September 2008 20:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
cbpporter wrote on Sun, 07 September 2008 08:08

luzr wrote on Sun, 07 September 2008 14:35


Ehm, after all these posts about points being meaningless for screen? Smile


Well my problem is simple. I have Font selection dialog. User chooses size 16 for example. In U++ size is in pixels. User chooses size 16 in different program. Size is in points. User complains that I have bug with font sizes Sad. After a simple investigation, it seems that this is what is needed to get same size:
Font& Font::HeightPt(int pt)
{
    height = pt * sScreenPPI / 72;
    return *this;
}

Not extensively tested, but seems to generate pixel perfect matches.



That is certainly reasonable requirement, but makes me really wonder whether you need a method for this.

IMO, simple function (PointsToPixels) would be enough.

Mirek
Re: Using Qtf forgets control font [message #18056 is a reply to message #18040] Tue, 09 September 2008 02:15 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
luzr wrote on Sun, 07 September 2008 21:47


IMO, simple function (PointsToPixels) would be enough.


I guess a simple function will do too. I used a method to ease the transition from pixels to points.
int PointsToPixels(int points)
{
	static int screenPPI = ScreenDraw(false).GetPixelsPerInch().cy;
	return points * screenPPI / 72;
}


Normally this would mean a lot of extra typing to replace the sizes of all GUI elements. I guess I'll have to use styles.
Re: Using Qtf forgets control font [message #18057 is a reply to message #18056] Tue, 09 September 2008 03:14 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
I'm afraid that double return values are needed for such conversions. Otherwise I get rounding errors when I'm trying to build Qtf as in the example.

Edit: or maybe a conversion table.
  • Attachment: FontSize.rar
    (Size: 1.26KB, Downloaded 211 times)

[Updated on: Tue, 09 September 2008 05:28]

Report message to a moderator

Re: Using Qtf forgets control font [message #18061 is a reply to message #18057] Tue, 09 September 2008 08:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
cbpporter wrote on Mon, 08 September 2008 21:14

I'm afraid that double return values are needed for such conversions. Otherwise I get rounding errors when I'm trying to build Qtf as in the example.

Edit: or maybe a conversion table.


Well, to the API it goes always as integer (in Win32 and X11). Means that you can do rounding in the function.

Mirek
Re: Using Qtf forgets control font [message #18087 is a reply to message #18061] Wed, 10 September 2008 06:07 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
I tested under Win and rounding seems OK but must be done in all conversion functions. Must test under Linux too.

I noticed that for testing purposes is is a fair assessment to consider StdFont as Arial. Does this apply to X11 also? And if for some strange reason the only font that I have is Wingdings, will StdFont default to Wingdings? Smile
Re: Using Qtf forgets control font [message #18088 is a reply to message #18087] Wed, 10 September 2008 08:08 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
cbpporter wrote on Wed, 10 September 2008 07:07

Must test under Linux too.


It appears that ScreenDraw is not defined under Linux. Now do you understand why I think that a cross platform framework like U++ should do everything in it's power to stop users from using system dependent functionality.

We need a cross platform way of getting screen PPI and hide ScreenDraw better.
Re: Using Qtf forgets control font [message #18113 is a reply to message #18087] Wed, 10 September 2008 20:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 10 September 2008 00:07

I tested under Win and rounding seems OK but must be done in all conversion functions. Must test under Linux too.

I noticed that for testing purposes is is a fair assessment to consider StdFont as Arial.



Nope, I Win32 it is taken from the system, in XP it is Tahoma (in older Win, it is MS Sans Serif).

Quote:


Does this apply to X11 also?



It is also taken in X11. Anyway, in X11, "system" font usually is the same font chosen for "Arial".

Quote:


And if for some strange reason the only font that I have is Wingdings, will StdFont default to Wingdings? Smile



If Wingdings are set as system font, then yes:)

However, you would not be able to start U++ app without "three basic fonts" - Arial, Roman, Courier. On Win32 they are required. (and on X11, equivalents are always defined in fontconfig).

Mirek
Re: Using Qtf forgets control font [message #18118 is a reply to message #18113] Wed, 10 September 2008 21:27 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
luzr wrote on Wed, 10 September 2008 21:46


Nope, I Win32 it is taken from the system, in XP it is Tahoma (in older Win, it is MS Sans Serif).


I assumed that because I had a qtf with arial and one without any font specified and they were the same. It seems than not specifying font in qtf makes it use Arial, not StdFont.
Re: Using Qtf forgets control font [message #18121 is a reply to message #18118] Wed, 10 September 2008 22:02 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
I no longer understand what's going on.

I have the test up similar to what I uploaded and everything works fine. I choose the size in points, covert to pixels, and everything has correct proportions. I am using a layout.

Then I copy paste the code to my real application, and the text is suddenly too large. My already zoomed text gets zoomed again. The only difference is that the layout that contains the Label is added as s frame with a splitter. If I disable font zooming I get correct results. Why is that frame zoomed, when other layouts are not?
Re: Using Qtf forgets control font [message #18123 is a reply to message #18113] Thu, 11 September 2008 06:56 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
luzr wrote on Wed, 10 September 2008 21:46


Nope, I Win32 it is taken from the system, in XP it is Tahoma (in older Win, it is MS Sans Serif).


That is not true on my XP.
See screenshot.
First line is Tahoma from Notepad, second is Stdfont, third is Tahoma from U++ app.

index.php?t=getfile&id=1365&private=0
  • Attachment: Tahoma.PNG
    (Size: 0.75KB, Downloaded 757 times)
Re: Using Qtf forgets control font [message #18129 is a reply to message #18123] Fri, 12 September 2008 08:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
Well, strange.

The critical question however is: Is the U++ font the same as in other apps? (Since I have fixed the issue couple of years ago, I never seen incorrect font on any windows version I have ever seen U++ app running).

It is possible that your "normal" font is even different. Maybe it is CJK version of Win32?

Anyway, the critical piece of code starts at line 173 of Draw/DrawTextWin32.cpp. Perhaps you can add

DUMP(ncm.lfMenuFont.lfFaceName)

before SetStdFont to see what is going on.

Mirek
Re: Using Qtf forgets control font [message #18134 is a reply to message #18129] Fri, 12 September 2008 11:15 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
Well the font is "Tahoma". I had problems determining what is wrong until I noticed that it depends on the application you're compiling. My test application works fine in regard to fonts.

But my real application has two problems:
1. Even though StdFont is Tahoma, I have a SplitterFrame with a layout in it where StdFont is not Tahoma somehow.
2. That layout uses bigger font zooming. Normally I have consistent font zooming, but something is wrong here.

And these two problems are IMO closely related. Somehow StdFont gets wacky and causes font zooming to increase, since the font that is used instead of Tahoma is larger.

But I think this problem is specific to me and I somehow introduced a bug somewhere while messing around with fonts. Another hint is that from some point one, all my logs start to have a progressive indentation, and some extra rtiming have started to appear. I really need to debug this.

PS: I came to the conclusion that OpenOffice is a poor model to test fonts against. The fact that it is not so specific too Windows shows, and there are often subtle differences when compared to native font rendering. so my new model is Notepad Razz.

PS:
Quote:


Anyway, the critical piece of code starts at line 173 of Draw/DrawTextWin32.cpp


You know, you could have pointed me here all those times that I asked how do you get the name of StdFont Smile. By reviewing that code I now finally understand how font stuff is determined. Better late than never!
Re: Using Qtf forgets control font [message #18142 is a reply to message #18134] Fri, 12 September 2008 17:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
cbpporter wrote on Fri, 12 September 2008 05:15

Well the font is "Tahoma". I had problems determining what is wrong until I noticed that it depends on the application you're compiling. My test application works fine in regard to fonts.

But my real application has two problems:
1. Even though StdFont is Tahoma, I have a SplitterFrame with a layout in it where StdFont is not Tahoma somehow.
2. That layout uses bigger font zooming. Normally I have consistent font zooming, but something is wrong here.



I would like to check some testcase to find out what is going wrong...

Mirek
Re: Using Qtf forgets control font [message #18160 is a reply to message #18142] Sat, 13 September 2008 19:19 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
I finally found the bug. It is really stupid actually. My fault.

I spent almost two hours removing classes and files one by one so that I could create a small test package. The bug just wouldn't go away, even when all I had were two classes with 5 lines each, just doing some simple layouting.

Then I found it! My bottom frame class was in it's own file and somewhere in that .cpp between function definitions was a:
ScreenDraw info(true);

That little line than must have been left over form earlier testing caused all the exaggerated font zooming. It is really funny actually, if you don't consider the time went into investigating this.

Anyway, false alarm. Need to be more careful with such dangerous thing like ScreenDraw. Now I can get back to solving my real font issues, like finding a replacement for ScreenDraw for starters.
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: Tue Aug 20 14:57:38 CEST 2019

Total time taken to generate the page: 0.01386 seconds