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... » Zooming font of RichText to the size of StdFont
Zooming font of RichText to the size of StdFont [message #19666] Sat, 03 January 2009 06:45 Go to next message
Novo is currently offline  Novo
Messages: 761
Registered: December 2006
Contributor
Do I understand correctly that zoom below will make size of the font of RichText equal to the size of StdFont?

Zoom zoom(StdFont().GetHeight(), ScreenDraw(false).GetPixelsPerInch().cy);



Regards,
Novo
Re: Zooming font of RichText to the size of StdFont [message #19677 is a reply to message #19666] Sun, 04 January 2009 15:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11835
Registered: November 2005
Ultimate Member
No. Smile

If I remember well, it should be

Zoom(StdFont().GetHeight(), 100);

for the default font size, which is 100 dots (pixels).

Anyway, result still does not have to be perfect, because final height and requested height are two different things...

Mirek
Re: Zooming font of RichText to the size of StdFont [message #19714 is a reply to message #19677] Wed, 07 January 2009 05:20 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 761
Registered: December 2006
Contributor
Thanks!

ScreenDraw(false).GetPixelsPerInch().cy returns 96 on all my Windows computers.

Actually, zooming looks better in case of 96. In this case letters do not merge with each other.


Regards,
Novo
Re: Zooming font of RichText to the size of StdFont [message #19724 is a reply to message #19714] Wed, 07 January 2009 13:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11835
Registered: November 2005
Ultimate Member
Novo wrote on Tue, 06 January 2009 23:20

Thanks!

ScreenDraw(false).GetPixelsPerInch().cy returns 96 on all my Windows computers.



It is because it is set as screen property. If you set "Large fonts" in windows screen dialog, it changes to 120dpi (AFAIK).

Really, I have said it before, but people for some strange reason put too much emphasis to this basically meaningless value (GetPixelsPerInch for screen). It is really meaningful only for printer.

Mirek
Re: Zooming font of RichText to the size of StdFont [message #19994 is a reply to message #19724] Sun, 08 February 2009 11:46 Go to previous messageGo to next message
Zeth is currently offline  Zeth
Messages: 2
Registered: February 2009
Location: Estonia
Junior Member
GetPixelsPerInch returns 96 even though I have set dpi to 120 in (Desktop) properties -> Settings -> Advanced. I'm using Windows XP. I tried ScreenDraw(false).GetPixelsPerInch().cy and ScreenDraw(false).GetPixelsPerInch().cx
Re: Zooming font of RichText to the size of StdFont [message #20001 is a reply to message #19994] Mon, 09 February 2009 08:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11835
Registered: November 2005
Ultimate Member
Check

void Draw::LoadCaps()

- we are only reading info from GDI. If it returns 96, it is because GDI says 96 (IMO).

However, I still insist that this value is basically useless. I guess Win32 guys think the same Smile

Mirek
Re: Zooming font of RichText to the size of StdFont [message #20006 is a reply to message #20001] Mon, 09 February 2009 09:39 Go to previous messageGo to next message
Zeth is currently offline  Zeth
Messages: 2
Registered: February 2009
Location: Estonia
Junior Member
I've read about it and it seems to be a Windows XP specific problem with GetDeviceCaps always returning 96. I ended up checking my main window size (it isn't resizable):

if(this->GetSize().cx > 690){ //Assume Large font
    DPI = 120;
}
float Multiplier = DPI / 96;


I've attached a small testcase which shows my problem. If you load it with 96 dpi all is ok, but when you change it to use 120dpi then you can see the scrollArea StaticText control is not automatically resized and the buttons are no longer of the same size. Basically all the manually added controls are not resized according to the current dpi. How do you guys handle this?
  • Attachment: Testcase.zip
    (Size: 2.31KB, Downloaded 191 times)

[Updated on: Mon, 09 February 2009 09:51]

Report message to a moderator

Re: Zooming font of RichText to the size of StdFont [message #20049 is a reply to message #20006] Fri, 13 February 2009 15:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11835
Registered: November 2005
Ultimate Member
Zeth wrote on Mon, 09 February 2009 03:39

I've read about it and it seems to be a Windows XP specific problem with GetDeviceCaps always returning 96. I ended up checking my main window size (it isn't resizable):

if(this->GetSize().cx > 690){ //Assume Large font
    DPI = 120;
}
float Multiplier = DPI / 96;


I've attached a small testcase which shows my problem. If you load it with 96 dpi all is ok, but when you change it to use 120dpi then you can see the scrollArea StaticText control is not automatically resized and the buttons are no longer of the same size. Basically all the manually added controls are not resized according to the current dpi. How do you guys handle this?



FontZoom.

Check Ctrl::

static int HorzLayoutZoom(int cx);
static int VertLayoutZoom(int cy);

The basic idea is to query the size of specific text with current default GUI font. Knowing its "default size" (as defined by its size in WinXP with small fonts, but that is hardly relevant) you compute zooming ratio.

Mirek

[Updated on: Fri, 13 February 2009 15:11]

Report message to a moderator

Prompt with non-system dpi for text at first [message #23855 is a reply to message #19666] Fri, 27 November 2009 09:41 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 286
Registered: November 2008
Experienced Member
Hello.
On my system I have 108 dpi instead of 96 dpi by default for fonts.
When I use Prompt function before any TopWindow class in the GUI_APP_MAIN with following test case:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	Zoom z = GetRichTextStdScreenZoom();
	PromptOK(NFormat("This is a text with Zoom(%d, %d)", z.m, z.d));
	z = GetRichTextStdScreenZoom();
	PromptOK(NFormat("This is the same text with Zoom(%d, %d)", z.m, z.d));
}

I have non-system dpi at first activation of the Prompt function.
index.php?t=getfile&id=2013&private=0
index.php?t=getfile&id=2014&private=0
Before introduction of new Drawing system I didn't have this problem, because U++ application was used system dpi.
Current tested revision is 1724.

[Updated on: Fri, 27 November 2009 09:47]

Report message to a moderator

Re: Prompt with non-system dpi for text at first [message #23863 is a reply to message #23855] Fri, 27 November 2009 15:13 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 286
Registered: November 2008
Experienced Member
I found the following solution for my problem:
 int Prompt(Callback1<const String&> WhenLink,
            const char *title, const Image& iconbmp, const char *qtf, bool okcancel,
            const char *button1, const char *button2, const char *button3,
 		   int cx,
 		   Image im1, Image im2, Image im3)
 {
+	int bcy = Ctrl::VertLayoutZoom(24);
+	int bcx = Ctrl::HorzLayoutZoom(72);
 	int fcy = Draw::GetStdFontCy();
 	PromptDlgWnd__ dlg;
 	RichTextCtrl qtfctrl;
 	Icon         icon;
 	qtfctrl.WhenLink = WhenLink;
 	icon.SetImage(iconbmp);
 	Button b1, b2, b3;
 	qtfctrl.SetQTF(String("[G1 ") + qtf, GetRichTextStdScreenZoom());
-	int bcy = Ctrl::VertLayoutZoom(24);
-	int bcx = Ctrl::HorzLayoutZoom(72);
 	if(button1)
 		bcx = max(2 * fcy + GetTextSize(button1, Draw::GetStdFont()).cx, bcx);
 	if(button2)
 		bcx = max(2 * fcy + GetTextSize(button2, Draw::GetStdFont()).cx, bcx);
 	if(button3)
 		bcx = max(2 * fcy + GetTextSize(button3, Draw::GetStdFont()).cx, bcx);

Its just reordering of control flow. So, Ctrl::Csizeinit() can be initialized before GetRichTextStdScreenZoom().
index.php?t=getfile&id=2016&private=0
Re: Prompt with non-system dpi for text at first [message #23870 is a reply to message #23863] Sun, 29 November 2009 23:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11835
Registered: November 2005
Ultimate Member
Thank you for reporting the problem.

I believe even better solution is to put Csizeinit call to GUI_APP_MAIN.

[Updated on: Sun, 29 November 2009 23:32]

Report message to a moderator

Re: Prompt with non-system dpi for text at first [message #23959 is a reply to message #23870] Thu, 10 December 2009 15:52 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 286
Registered: November 2008
Experienced Member
luzr wrote on Sun, 29 November 2009 23:31

Thank you for reporting the problem.

I believe even better solution is to put Csizeinit call to GUI_APP_MAIN.

Thank you for your solution.

Considering new topic I propose following modified solution:
- Make public static SizeInit function to call inlined Csizeinit function.
- Use created SizeInit function in the CtrlCore/Win32Wnd.cpp::InitWin32, CtrlCore/X11App.cpp::InitX11 functions.

Normal diff for 1796 revision:
File: CtrlCore\Ctrl.cpp
770a771,775
> void Ctrl::SizeInit()
> {
> 	Csizeinit();
> }
> 

File: CtrlCore\CtrlCore.h
1328a1329,1330
> 	
> 	static void SizeInit();

File: CtrlCore\Win32Wnd.cpp
288c288
< 	Csizeinit();
---
> 	SizeInit();

File: CtrlCore\X11App.cpp
429c429
< 	Csizeinit();
---
> 	SizeInit();

[Updated on: Thu, 10 December 2009 16:13]

Report message to a moderator

Re: Prompt with non-system dpi for text at first [message #23960 is a reply to message #23959] Thu, 10 December 2009 19:16 Go to previous message
mirek is currently offline  mirek
Messages: 11835
Registered: November 2005
Ultimate Member
Well, I have just removed "inline"...

Mirek
Previous Topic: Extracting StymeManager
Next Topic: RichTextLayoutTracer example improvement
Goto Forum:
  


Current Time: Tue Apr 23 07:02:12 CEST 2019

Total time taken to generate the page: 0.01222 seconds