Page 1 of 2
Font Problem with 5.72
Posted: Mon Apr 06, 2020 10:53 am
by infratec
I just starting using 5.72 in production. But when I compile the programs, I run into a font problem:
Code:
Code: Select all
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: Select all
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.
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 10:59 am
by BarryG
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?
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 11:09 am
by infratec
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:
If you have the time, you can adjust all of my programs

Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 11:29 am
by infratec
It looks like 5.72 uses Segoe UI 9
I get the same result when I use
Code: Select all
LoadFont(0, "Segoe UI", 9)
SetGadgetFont(#PB_Default, FontID(0))
But which font is used by 5.71 ?
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 12:38 pm
by infratec
Found this:
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: Select all
LoadFont(0, "Tahoma", 9)
SetGadgetFont(#PB_Default, FontID(0))
It is still not the right font.
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 12:40 pm
by infratec
Btw.:
Since GetStockObject_() should not be used ...
Code: Select all
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

See here:
https://docs.microsoft.com/de-de/window ... i-logfonta
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 1:03 pm
by Little John
@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 ...
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 1:06 pm
by infratec
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: Select all
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.
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 2:40 pm
by kenmo
Everything is. You didn't kow enough.
Come on, let's not be rude.
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
https://www.purebasic.fr/english/viewto ... =4&t=73895
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:
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.
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 2:43 pm
by IdeasVacuum
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?
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 2:54 pm
by IdeasVacuum
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.
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 3:49 pm
by infratec
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?
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)
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 5:58 pm
by kenmo
It was not rude
OK, maybe I misread your tone. No worries.
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.
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().
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.
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.
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 8:37 pm
by chi
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/viewto ... 65#p547765)
I'm not gonna say it... not gonna say it...
I told you so
... 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.
Re: Font Problem with 5.72
Posted: Mon Apr 06, 2020 10:50 pm
by infratec
@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.
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.