DrawFontChr
DrawFontChr FontIndex, ChrIndex, Xpos, Ypos, [Transparent=1]
 
Parameters:

    FontIndex = The Index of the font you wish to draw from
    ChrIndex = The ASC II index of this character
    Xpos = The X coordinate of where it should draw this character
    Ypos = The Y coordinate of where it should draw this character
    [Transparent=1] = Draw the character transparent or solid (1=Transparent, 0 = solid)
Returns: NONE
 

      The DrawFontChr command draws a character from a bitmap font to current surface (screen or image).



FACTS:


      * DrawFontChr can not draw (Windows Fonts) to FX images.





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 approach 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 255
   ; 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)
  
  
; Calc the screen center
  cw=GetScreenWidth()/2
  ch=GetScreenHeight()/2
  
; Display PLayBasic in the center of the screen
  CenterText cw,0,"Bitmap Character Set"
  
  
; Set the output coords of the bitmap font  characters
  Xpos=ChrWidth
  Ypos=60
  
  
; Loop from the Space charact the Z charcter.
  For lp=Asc(" "To 255
   ;asc("z")
   ; DRaw this character at this X/Y coord
     DrawFontChr 10,lp,xpos,ypos,false
     
   ; If if the Xpos coord it too wide,
   ; if so it reset it, if not it adds onto the x position
     If Xpos+ChrWIdth>(GetScreenWidth()-ChrWidth)
        Xpos=ChrWidth
        Ypos=Ypos+ChrHeight
     Else
        Xpos=Xpos+ChrWIdth
     EndIf
  Next
  
  
; refresh the screen and wait for a key press
  Sync
  WaitKey
  




This example would output.

  
  no Text output.
  
  

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


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