FontDrawMode
FontDrawMode FontIndex, DrawMode
 
Parameters:

    FontIndex = The index of the font you wish to set the drawmode of
    DrawMode = The rendering method the font use should use with this font.
Returns: NONE
 

      The FontDrawMode command sets lets us change the rendering method a Font uses. Not all font types can react to these changes however, in fact at the time of writing only Compress Raster Fonts can.



[ Draw Modes ]


      Mode 0) = Solid TINT (default)

           This is the default font drawmode, the font colour is tinted with the current INK colour in ARGB forma). The pixels will overwrite the destination pixels. No alpha blending (with the backdrop) is performed. So this method is the fastest option.


      Mode 1) = Alpha Blend to Buffer

           In this mode the font's pixel colours are first tinted with Ink colour (colour in ARGB format), then the resulting pixel is then Alpha blended with the pixel that it was going to overwrite. This mode is best used when drawing to FX or AFX formatted surfaces.


      Mode 2) =Alpha Blend with colour

           In this mode the font's pixel colours are first tinted with Ink colour (colour in ARGB format), then the resulting pixel is then Alpha blended with fixed blend colour. The resulting colour is then written to the destination buffer, so this method will overwrite than destination colour. Use FontBlendColour to set the blend colour.





FACTS:


      * Not all font types can react to DrawMode changes. At the time of writing, only CRF formatted fonts can.





 
Example Source: Download This Example
  // Load the standard windows Arial font
  LoadFont "Arial",1,32,0
  
  // Load the CRF version of this font
  AlphaFont=LoadNewFont("..\../Media/Arial.crf",0,0)
  
  
  
  Dim Colours(1000)
  For lp=0 To GetArrayElements(Colours(),1)
     Colours(lp)=RndRGB()
  Next
  
  
; Set the Blend colour for Font draw mode #2
  FontBlendColour AlphaFont,$ffff0000
  
  
  // Make an fx image the screen of the screen to draw every onto
  
  Screen     =GetFreeImage()
  sw               =GetScreenWidth()
  sh               =GetScreenHeight()
  Screen=NewFXImage(sw,sh)
  
  
  // Set the time when the demo will change the drawmode
  NextDrawmodeChange=Timer()+4000
  
  
  Do
     
     LockBuffer
     RenderToImage Screen
     
     // Clear or shadebox the backdrop
     Select GetFontDrawMode(AlphaFont)
         Case 0
             Cls RGB(0,0,0)
         Case 1
             c1=255
             c2=$304050
             c3=$a0a000
             ShadeBox 0,0,sw,sh,c1,c2,c3,c4
         Case 2
             Cls GetFontBlendColour(AlphaFont)
     EndSelect
     
     // Draw this message to the screen a bunch of times
     SetFont AlphaFont
     Test$="testing Fonttesting Fonttesting Fonttesting Fonttesting Font"
     
     Alevel=AlphaLevel
     Ypos=0
     For lp=0 To 40
        If Ypos<GetScreenHeight()
           Ypos=(lp+1)*25
           Ink Colours(lp) |  ALevel*$1000000
           Text 0,Ypos,test$+Str$(lp)
           ALevel=(ALevel+1And 255
        EndIf
     Next
     UnLockBuffer
     AlphaLevel=(AlphaLevel+1And 255
     
     RenderToScreen
     DrawImage Screen,0,0,false
     
     
     // Display what draw mode the font #2 is using
     SetFont 1
     SetCursor 0,0
     
     Ink $ffffff
     Select GetFontDrawMode(AlphaFont)
         Case 0
             Print "Font DrawMode [0] = Solid Render"
         Case 1
             Print "Font DrawMode [1] = Alpha Blend To Buffer"
         Case 2
             Print "Font DrawMode [2] = Alpha Blend To Colour"
     EndSelect
     
     //
     If KeyState(32Or Timer()>NextDrawModeChange
        D=GetFontDrawMode(AlphaFont)+1
        If d>2 Then D=0
        FontDrawMode AlphaFont,d
        FlushKeys
     NextDrawmodeChange=Timer()+4000
  EndIf
  
  
  
  
  Sync
  Loop
  
  
  
 
Related Info: FontBlendColour | GetFontDrawMode | GetFontHeight | GetFontMaskColour | GetFontName$ | GetFontStatus | GetFontStyle | GetFontType | GetFontWidth | LoadFont | MakeBitmapFont :
 


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