LoadFont
LoadFont Filename$, FontIndex, [Size=0], [StyleFlag=0], [Format=-1]
 
Parameters:

    Filename$ = The Filename of the font you wish to load
    FontIndex = The index identifier of this font
    [Size=0] = The size of this font
    [StyleFlag=0] = Style flags Bold, Italics, Underline
    [Format=-1] = The format of this font
Returns: NONE
 

      LoadFont can load either standard windows font (true type or bitmap), or PlayBASIC's very own CRF (Compressed Raster Font) format.

      Compressed Raster Fonts (CRF's for short) were added to PlayBASIC V1.64 as a global font solution. CRF's are a form of bitmap font, that can be drawn onto any surface and include Alpha Channel support (Anti Aliasing).

      You can convert fonts to CRF format both internally (MakeBitmapFont) or by using the PlayFONT tool (See PlayBASIC Forums/Web Site).


[ StyleFlags ]
0 = Normal style
1 = Bold
2 = Itelics
3 = Combined Bold + Italics
4 = Underline
5 = Bold + Underline
6 = Italics+ Underline
7 = Bold + Italics + UnderLine


[ Format Flags ]
-1 = True Type (default)
2= Video Bitmap Font
4= FX Bitmap Font
8= Compressed Raster Font



      Using the format parameter you can get PlayBASIC load a windows font and convert to one another format while loading.




FACTS:


      * By default, PlayBASIC loads the "Courier New" as font #1. Since this is a windows font, you shouldn't rely upon the appearance of this font across different editions of the Windows. If this is important to you then we recommend converting your required font to CRF format (See SaveFont or use PlayFont) , which will be identical on all systems.

      * Not all windows fonts can be loaded!

      * If you try and load that doesn't exist, or can't be loaded. Windows will automatically attempt to find a closest match as it can. This font will be loaded in it's place.

      * Windows True Type / Bitmaps Fonts will be automatically converted to a CRF when drawing text to FX/AFX formatted surfaces.

      * PlayBASIC CRF fonts can be rendered to any surface format and depth and support alpha channel.

      * CRF fonts can be loaded from memory (rather than from disc) by replacing the filename with the address and & character.. eg LoadFont "&"+Str$(AddressInMemory), Index, Size,Flags They can also be automatically loaded from memory when attached as a resource. See #AddResource





Mini Tutorial: - Loading a Windows Font


      This example displays a message in the default font, then loads a second Windows font as the current font and displays a second message.

  
  
; Display a message in the PB default font
  Print "This text is displayed in the normal font"
  
; Load the "Arial" font as font 2, size 24, in the normal style
  LoadFont "Arial",2,24,0
  
; Set Font 2 at the current font.
  SetFont 2
  
; Display a message in the PB default font
  Print "This text is displayed in the Ariel font"
  
; Display the screen and wait for a key to be pressed
  Sync
  WaitKey
  




This example would output.

  
  This Text is displayed in the normal font
  This Text is displayed in the Ariel font
  





Mini Tutorial: - Loading a Compressed Raster Font (.CRF format)


      This example displays a message in the default font, then loads a second Windows font as the current font and displays a second message.

      Unlike Windows fonts, compressed raster fonts can be located anywhere, so you should give the LoadFont command the full location and filename of the file. The Size and Style parameters aren't relavent when loading CRF's.


  
  
; Display a message in the PB default font
  Print "This text is displayed in the normal font"
  
; Load the "Arial" font as font 2, size 24, in the normal style
  LoadFont "Arial",2,24,0
  
; Set Font 2 at the current font.
  SetFont 2
  
; Display a message in the PB default font
  Print "This text is displayed in the Ariel font"
  
; Display the screen and wait for a key to be pressed
  Sync
  WaitKey
  







 
Example Source: Download This Example
  // Load a Windows arial font into font #1 (replacing the default font)
  LoadFont "Arial",1,32,0
  
  
  SetFont 1
  Print "Windows Arial Font Rendering To PLayBasic Screen"
  
  
  // Load a pre converted CRF version of the courier new font in PB as font #2
  LoadFont "..\../Media/Courier New.crf",2,0,0
  
  SetFont 2
  Print "PlayBASIC CRF Font Rendering To PlayBASIC Screen"
  
  
  Print "Press Space"
  
  Sync
  WaitKey
  WaitNoKey
  
  
  
  
  // Create FX IMage
  Screen=NewFXImage(800,400)
  
  // Redirect all rendering to the FX image
  RenderToImage Screen
  Cls RGB(40,50,60)
  
  
  //  Since PlayBASIC V`1.64L, Windows fonts are internally converted to CRF
  // when you try and draw to a FX or AFX formatted image.
  SetFont 1
  Print "Windows Arial Font Rendering To PlayBASIC Screen"
  
  // Render our CRF font to the FX surface..  No worries mate !
  SetFont 2
  Print "PlayBASIC CRF Font Rendering To PlayBASIC Screen"
  
  
  // draw the FX screen to main display
  RenderToScreen
  DrawImage Screen,0,0,false
  
  
  Sync
  WaitKey
  
 
Related Info: CreateBitmapFont | CreateFXFont | DeleteFont | GetFontStatus | GetFreeFont | LoadNewFont | MakeBitmapFont | PrepareFXFont :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com