FontChrWidth
FontChrWidth FontIndex, Chracter, Width
 
Parameters:

    FontIndex = The Index of the font you wish to alter
    Chracter = The character you wish to change
    Width = The newWwidth of this character
Returns: NONE
 

      FontChrWidth() changes the width of an individual character within a bitmap font.



FACTS:


      * FontChrWidth does not change the physical bitmap size of the character. Only it's spacing when drawn. Allowing some chr's to be thinner than others.




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 command does. But this approaches gives you the control and freedom to build or import your own 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 Ariel (50 point)
  myFont=LoadNewFont("Arial",50,1)
  
; Change to this font
  SetFont MyFont
  
; Set the Width + Height of oru custom font
  ChrWIdth=48
  ChrHeight=48
  
  
  MyBitMapFont=NewBitmapFont(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,255,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 My BitMapFont
     GetFontChr MyBitMapFont,lp,0,0
     
   ; Double the Characters Width
     FontChrWidth MyBitMapFont, lp, GetFontChrWidth(MyBitmapFont,lp)*2
     
  Next
  
; Clear the Screen
  Cls RGB(0,0,0)
  
; Tell PB to use the newly created bitmap font
  SetFont MyBitmapFont
  
; Calc the screen center
  cw=GetScreenWidth()/2
  ch=GetScreenHeight()/2
  
; Display PLayBasic in the center of the screen
  CenterText cw,ch-(chrheight/2),">> Hello <<"
  
; refresh the screen and wait for a key press
  Sync
  WaitKey
  
  




This example would output.

  
  >> Hello <<
  

 
Related Info: GetTextHeight | GetTextWidth | LoadFont | NewBitmapFont | SetFont :
 


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