GetFontChr
GetFontChr FontIndex, ChrIndex, Xpos, Ypos
 
Parameters:

    FontIndex = The Index of the font you wish to initialize
    ChrIndex = The ASC II index of this character
    Xpos = The Top X coordinate of where it should grab this character
    Ypos = The Top Y coordinate of where it should grab this character
Returns: NONE
 

      The GetFontChr command grabs a block of graphics from the current surface (screen or image) and copies it into a bitmap font. This graphic is then used when the font is drawn. Allowing you to import hand drawn fonts, or create all sorts of wacky ones.



FACTS:


      * GetFontChr will automatically convert the pixel data your grabbing from into whatever the bitmap format this font uses. Including Compressed Raster Fonts, which make take a fraction longer to generate than Video Bitmap or FX bitmap fonts, but they're generally the best option.



Mini Tutorial:


      This example loads the windows true type Arial, and the builds a custom bitmap version of it. In fact this example basically replicates what the MakeBitmapFont does. But this approaches gives you the control and freedom to build or import hand drawn character sets into PB as a custom font.

  
  
; --------------------------------------------------------
; For This example, were going to build a PB Bitmap font
; from the Windows Arial font as an example. Normally you'd
; load a set of pre-drawn characters in and import those...
; --------------------------------------------------------
  
; Load the Windows True Type Font Arial (50 point)
  LoadFont "Arial",2,50,1
  SetFont 2
  
; Set the Width + Height of our custom bitmap font
  ChrWIdth=48
  ChrHeight=55
  
  
  CreateBitmapFont 10,ChrWidth,ChrHeight
  
; Manually Create the characters of our bitmap font
  For lp=Asc(" "To Asc("z")
   ; Draw a random shade box for each chr's backdrop
     ShadeBox xpos+0,0,xpos+Chrwidth,Ypos+ChrHeight,RndRGB(),RndRGB(),0,lp
     
   ; Draw the character and it's shadow
     Ink RGB(32,32,32)
     CenterText xpos+(chrwidth/2)-2,ypos-2,Chr$(lp)
     
     Ink RGB(64,64,64)
     CenterText xpos+(chrwidth/2)-1,ypos-1,Chr$(lp)
     
     Ink RGB(200,240,255)
     CenterText xpos+(chrwidth/2),ypos,Chr$(lp)
     
   ; This the section of screen at position 0x,0y for
   ; This character in font 10
     GetFontChr 10,lp,0,0
  Next
  
; Clear the Screen
  Cls RGB(70,30,50)
  
; Tell PB to use the newly created bitmap font
  SetFont 10
  
; Calc the screen center
  cw=GetScreenWidth()/2
  ch=GetScreenHeight()/2
  
; Display PLayBasic in the center of the screen
  CenterText cw,ch-(chrheight/2),">> PlayBASIC <<"
  
; refresh the screen and wait for a key press
  Sync
  WaitKey
  
  




This example would output.

  
  >> PlayBASIC <<
  

 
Related Info: BlendBitmapFont | CreateBitmapFont | LoadFont | MakeBitmapFont | MakeShadowBitmapFont | SetFont :
 


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