LoadFont() never return zero

Just starting out? Need help? Post your questions and find answers here.
auraes
New User
New User
Posts: 4
Joined: Mon Jan 23, 2017 9:23 am

LoadFont() never return zero

Post by auraes »

Hi,
If the font was not loaded successfully, LoadFont() returns nonzero instead of zero.

Code: Select all

If OpenWindow(0, 0, 0, 270, 160, "Loading font...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  r = LoadFont(1, "", 24)
  Debug r
  r = LoadFont(#PB_Any, "", 24)
  Debug r
  
  r = LoadFont(1, "anything", 24)
  Debug r
  r = LoadFont(#PB_Any, "anything", 24)
  Debug r
  
  r = LoadFont(1, "Arial", 24)
  Debug r
  r = LoadFont(#PB_Any, "Arial", 24)
  Debug r
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
PureBasic 5.51 (Windows - x64)
PureBasic 5.51 (Linux - x64)
Fred
Administrator
Administrator
Posts: 18344
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: LoadFont() never return zero

Post by Fred »

This is documented, it's the way Windows works:

Code: Select all

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... 
auraes
New User
New User
Posts: 4
Joined: Mon Jan 23, 2017 9:23 am

Re: LoadFont() never return zero

Post by auraes »

Thank you.
I get the same thing under Linux (Lubuntu 16.04.1 LTS, 64-bit)
So, LoadFont() and IsFont() never seem to return zero... Why not !?
I'll take a look at RegisterFontFile() to be sure to have the good Font.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: LoadFont() never return zero

Post by Dude »

auraes wrote:LoadFont() and IsFont() never seem to return zero... Why not !?
Fred just told you why. :)
Post Reply