It is currently Sun Jan 24, 2021 10:37 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 10:53 am 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5209
Location: Germany
I just starting using 5.72 in production. But when I compile the programs, I run into a font problem:

Image

Code:
Code:
OpenWindow(0, 100, 200, 195, 50, Str(#PB_Compiler_Version), #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)

TextGadget(1, 10, 10, 100, 20, "WQFE_-Oo0123456789", #PB_Text_Border)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow


That's very, very bad.

Maybe I can fix it with
Code:
SetGadgetFont(#PB_Default, FontId(xxx))

But for that I need to know the used font from 5.71
And .. this would be only a quick hack.


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 10:59 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1208
infratec wrote:
That's very, very bad.

What is? I don't even know what's supposed to be wrong, other than a slightly different font? Both texts are clipped in the textbox, so it can't be that. What's wrong?


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 11:09 am 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5209
Location: Germany
Everything is. You didn't kow enough.

This was only an example to show that there is something different.
Which should not be.

In the 'real world' it results in:

Image

If you have the time, you can adjust all of my programs :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 11:29 am 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5209
Location: Germany
It looks like 5.72 uses Segoe UI 9

I get the same result when I use
Code:
LoadFont(0, "Segoe UI", 9)
SetGadgetFont(#PB_Default, FontID(0))


But which font is used by 5.71 ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 12:38 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5209
Location: Germany
Found this:
Quote:

DEFAULT_GUI_FONT

Default font for user interface objects such as menus and dialog boxes. It is not recommended that you use DEFAULT_GUI_FONT or SYSTEM_FONT to obtain the font used by dialogs and windows; for more information, see the remarks section.

The default font is Tahoma.


But if I try
Code:
LoadFont(0, "Tahoma", 9)
SetGadgetFont(#PB_Default, FontID(0))

It is still not the right font.


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 12:40 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5209
Location: Germany
Btw.:

Since GetStockObject_() should not be used ...
Code:
Structure tagNONCLIENTMETRICS
  cbSize.i
  iBorderWidth.i
  iScrollWidth.i
  iScrollHeight.i
  iCaptionWidth.i
  iCaptionHeight.i
  lfCaptionFont.LOGFONT
  iSmCaptionWidth.i
  iSmCaptionHeight.i
  lfSmCaptionFont.LOGFONT
  iMenuWidth.i
  iMenuHeight.i
  lfMenuFont.LOGFONT
  lfStatusFont.LOGFONT
  lfMessageFont.LOGFONT
  iPaddedBorderWidth.i
EndStructure


Define NONCLIENTMETRICS.tagNONCLIENTMETRICS

NONCLIENTMETRICS\cbSize = SizeOf(tagNONCLIENTMETRICS)

If SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(tagNONCLIENTMETRICS), @NONCLIENTMETRICS, 0)
  Debug "Caption    : " + PeekS(@NONCLIENTMETRICS\lfCaptionFont\lfFaceName) + " " + Str(NONCLIENTMETRICS\lfCaptionFont\lfHeight)
  Debug "SmCaption  : " + PeekS(@NONCLIENTMETRICS\lfSmCaptionFont\lfFaceName) + " " + Str(NONCLIENTMETRICS\lfCaptionFont\lfHeight)
  Debug "MenuFont   : " + PeekS(@NONCLIENTMETRICS\lfMenuFont\lfFaceName) + " " + Str(NONCLIENTMETRICS\lfCaptionFont\lfHeight)
  Debug "StatusFont : " + PeekS(@NONCLIENTMETRICS\lfStatusFont\lfFaceName) + " " + Str(NONCLIENTMETRICS\lfCaptionFont\lfHeight)
  Debug "MessageFont: " + PeekS(@NONCLIENTMETRICS\lfMessageFont\lfFaceName) + " " + Str(NONCLIENTMETRICS\lfCaptionFont\lfHeight)
EndIf

Returns everywhere Segoe UI -12 on my Win10.
But I don't know why I have to use the PeekS(), it is a unicode string :!:

The -12 is not a bug :wink:
See here: https://docs.microsoft.com/de-de/window ... i-logfonta


Last edited by infratec on Mon Apr 06, 2020 1:27 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 1:03 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3967
Location: Berlin, Germany
@infratec:

As far as I recall, on Windows the standard gadget font in PB was previously MS Shell Dlg, 8 pt.
As you wrote, now in PB 5.72 it seems to be Segoe UI, 9 pt.
Unfortunately, this change is not even officially documented anywhere ...

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 1:06 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5209
Location: Germany
Yes, it was MS Shell Dlg, 8 pt.

which is ...

Microsoft Sans Serif, 8pt
(outside of Japan)

Found this here:
https://bugreports.qt.io/browse/QTBUG-58610
Then jump to
https://docs.microsoft.com/en-us/window ... hell-dlg-2

This results in
Code:
CompilerIf #PB_Compiler_OS = #PB_OS_Windows And #PB_Compiler_Version > 571
  Define DefaultFontEarlierPB572.i
  DefaultFontEarlierPB572 = LoadFont(#PB_Any, "Microsoft Sans Serif", 8)
  SetGadgetFont(#PB_Default, FontID(DefaultFontEarlierPB572))
CompilerEndIf


Which is for me a temporary fix, until Fred gives a comment about this behaviour.


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 2:40 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1869
Quote:
Everything is. You didn't kow enough.

Come on, let's not be rude.

Quote:
This was only an example to show that there is something different. Which should not be.


5.72 is now using Microsoft's recommended way of getting the system font. It changed on purpose. Long discussion here viewtopic.php?f=4&t=73895

Quote:
Which is for me a temporary fix, until Fred gives a comment about this behaviour.

Fred gave a one-line suggestion for the old behavior in that thread:
Quote:
That said if you absolutely want to use it, just use SetGadgetFont(#PB_Default, GetStockObject_(#DEFAULT_GUI_FONT)) before any gadget creation and it will be used.



Anyway, if your GUI doesn't handle variations in font size, then there's already potential for issues because users' DPI and fonts can vary... I'm trying to be better about it myself.

_________________
On GitHub: PB Includes - IDE Tools - Color Themes - IDE Branches - TabBarGadget Mods


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 2:43 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6282
Location: Wales, UK
Well surely the reason Microsoft has moved on with fonts is for better legibility on modern monitors. I expect Fred is just in that flow. How good is Segoe with Unicode compared to MS Shell Dialog?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 2:54 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6282
Location: Wales, UK
I agree with Kenmo 100% re font size, dpi etc.

I encounter many programs and website forms that do not cater for different languages properly - Anything that takes text input from Users should be generously sized. If in doubt, oversized is better than undersized.

Not long ago, I struggled to send some important kit to Germany - The Royal Mail service had an online form with text boxes that were simply not long enough for the address!

I signed-up for a TV service and their software can't take my full name (as requested) and this has led to billing errors because their records show two names - Christopher and Christophe.

Developer oversights like these can cost a fortune.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 3:49 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5209
Location: Germany
It was not rude, it was the answer to his question:
BarryG wrote:
What is? I don't even know what's supposed to be wrong, other than a slightly different font? Both texts are clipped in the textbox, so it can't be that. What's wrong?



Quote:
5.72 is now using Microsoft's recommended way of getting the system font. It changed on purpose. Long discussion here viewtopic.php?f=4&t=73895

Is this written in a change log at anouncements?
How many members were involved in this discussion?

The topic is total different and I don't read all topics.
So I didn't know this. (And I think many others too)

GetStockObject() should not be used to get the font according to Microsoft.

And without registry hacks it is not possible that a user can change the default font which is used by a program.

Such a change can be done from 5.xx to 6.xx but not from 5.71 to 5.72 and with no 'official' information about this. (my opinion)


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 5:58 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1869
Quote:
It was not rude

OK, maybe I misread your tone. No worries.

Quote:
Is this written in a change log at anouncements?

That thread is in the list of changes for 5.72. Yes I know it's not convenient to read through every linked thread, though.

Quote:
GetStockObject() should not be used to get the font according to Microsoft.

Exactly, that's why it was considered a bug and was "fixed" in 5.72 by changing the default method. 5.71 was using GetStockObject().

Quote:
And without registry hacks it is not possible that a user can change the default font which is used by a program.

Did Fred's snippet not work for you? Should behave exactly like 5.71.

Quote:
Such a change can be done from 5.xx to 6.xx but not from 5.71 to 5.72 and with no 'official' information about this. (my opinion)

I agree with you that it should be made clearer. It's a change that visually affects our compiled programs.

_________________
On GitHub: PB Includes - IDE Tools - Color Themes - IDE Branches - TabBarGadget Mods


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 8:37 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 770
Location: Linz, Austria
chi wrote:
About changing PB's default font: I still prefer "Microsoft Sans Serif" over "Segoe UI" because it's a little bit lighter, more subtle. But, of course, the main reason is: I'm used to it and I can design my apps on any OS from Win2000 to Win10 and it will look the same. Also, if we change to Segoe, a lot of UI elements have to be adjusted... That's just my opinion.
(https://www.purebasic.fr/english/viewtopic.php?p=547765#p547765)
I'm not gonna say it... not gonna say it... I told you so :oops:

... but I can understand the reason why it was changed and in the long run it was a good decision (IMHO). If you really don't like the new font, or you don't want to adjust your UI, you can always replace the new default font with Microsoft Sans Serif.

_________________
Et cetera is my worst enemy


Top
 Profile  
Reply with quote  
 Post subject: Re: Font Problem with 5.72
PostPosted: Mon Apr 06, 2020 10:50 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5209
Location: Germany
@chi

That is what I have done now.
But this 'hint' should be given from the PB Team.

@Kenmo
You agree that GetStockObject() should not be used any longer, but the workarround you also agree to it
uses exactly this. It is a bit conflicting. :wink:

All what 'we normal users' need is an official statement how to fix this behaviour without using the not recommended
GetStockObject() version. Like I did now.
But it is now at a place were not all users will see and notice it.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye