Page 1 of 1
LoadFont returns Arial instead of 0.
Posted: Fri Jun 02, 2023 9:16 am
by AZJIO
If it fails to load the font, then Arial or "Segoe UI" is loaded. I expect a rather old "Courier New" font if no Consolas is found, but not as Arial.
Code: Select all
If LoadFont(0, "Conso111las", 10)
SetGadgetFont(#Combo1, FontID(0))
Else
If LoadFont(0, "Courier New", 10)
SetGadgetFont(#Combo1, FontID(0))
EndIf
EndIf
Re: LoadFont returns Arial instead of 0.
Posted: Fri Jun 02, 2023 9:35 am
by RASHAD
On Windows the font mapper will always attempt to locate a font. If a font name which does not exist such as: "Tim Now Ronin", is used, then the font mapper will attempt to find the closest match. This will be based upon such criteria as: the font name, the font height, the style and so forth. Therefore, the assumption can not be made that a font will not be loaded, due only to an incorrect font name, size, ect...
Re: LoadFont returns Arial instead of 0.
Posted: Fri Jun 02, 2023 9:51 am
by AZJIO
I read this in the help, but I expected that despite the fact that the font is loaded, the function will return 0. If I load the font without "If", then I get the FontID(0) descriptor, but if I check the return flag, then this helps me unload Arial and load another font for index 0. As a result, I can't make protection if Consolas font is missing in WinXP. It remains for me to use WinAPI.
Code: Select all
LoadFont(0, "Conso111las", 10)
SetGadgetFont(#Combo1, FontID(0))
When using WinAPI I get the same result. If the font is incorrect, then I get the "handle" and Arial font.
Code: Select all
hFont = CreateFont_(16, 0, 0, 0, #FW_NORMAL, 0, 0, 0, #DEFAULT_CHARSET, #OUT_DEFAULT_PRECIS, #CLIP_DEFAULT_PRECIS, #PROOF_QUALITY, #DEFAULT_PITCH, @"Consolas")
If hFont
Re: LoadFont returns Arial instead of 0.
Posted: Sat Jun 03, 2023 10:44 am
by Mijikai
I posted a workaround in the german forum mby also interesting:
https://www.purebasic.fr/german/viewtop ... 84#p359884