LoadFont()

Syntax

Result = LoadFont(#Font, Name$, YSize [, Flags])
Description
Tries to open the specified font.

Parameters

#Font A number to identify the new font. #PB_Any can be used to auto-generate this number.
Name$ The name of the font to load.
YSize The vertical size of the font in points.
Flags (optional) A combination of the following constants:
  #PB_Font_Bold       : The font will be bold
  #PB_Font_Italic     : The font will be italic
  #PB_Font_Underline  : The font will be underlined (Windows only)
  #PB_Font_StrikeOut  : The font will be strikeout (Windows only)
  #PB_Font_HighQuality: The font will be in high-quality mode (slower) (Windows only)

Return value

Returns nonzero if the font was loaded successfully and zero if not. If #PB_Any was used for the #Font parameter then the generated number is returned on success.

Remarks

If previously another font was loaded with the same #Font number, then this older font will be automatically freed when loading the new one.

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...

Example

  If OpenWindow(0, 0, 0, 270, 160, "Loading font...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If LoadFont(1, "Arial", 24)
      SetGadgetFont(#PB_Default, FontID(1))
      TextGadget(0, 10, 10, 250, 40, "Arial 24")
    EndIf
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf


See Also

FontID(), FreeFont()

Supported OS

All

<- IsFont() - Font Index - RegisterFontFile() ->