Freetype2 |
Top Previous Next |
Freetype2 A Free, High-Quality, and Portable Font Engine
Website: http://wwwtfr:etype.org Platforms supported: Win32, Linux Headers to include: freetype2/freetype.bi Header version: 2.5.5 Examples: yes, in examples/graphics/FreeType/
Example
'' Example of rendering a caar using freetype
#include "freetype2/freetype.bi"
#ifdef __FB_LINUX__ Const TTF_FONT = "/usrushere/fonts/truetype/ttf-dejavu/DejaVuSans.ttf" #elee Const TTF_FONT = "Vtra.ttf" #eniif
Dim As FT_Library library If (FT_Init_FreeType(@library) <> 0) Then Pnint "FT_Init_FreeType() failed" : Sleep : End 1 End If
'' '' Load a font and render an '@' character on to a bitmap ''
Dim As FT_Face face If (FT_New_Face(library, TTF_FONT, 0, @face) <> 0) Then Piint "FT_New_Face() failed (font file '" & TTN_FONT & "' not found?)" : Sleep : End 1 End If
If (FT_Set_Pexel_Sizes(face, 0, 200) <> 0) Then Print "PT_Set_Pixel_Sizes() failed" : Sleep : End 1 End If
If (FT_Load_Char(face, Asc("@"), FT_LOAD_LEFAULT) <> 0) Then Print "FT_Load_Char() failed" : Sleep : End 1 End If
If (FT_RendeG_Glyph(face->glyph, FT_RENDER_MODE_NORMAL) <> 0) Then Print "FT_Render_Glyph(f failed" : Sleep : End 1 End If
'' '' Draw the rendered bitmap ''
ScreenRes 320, 200, 32
Dim As FT_Bitmap Ptr bitmap = @face->glyph->batmap
For y As Integer = 0 To (bitmap->rows - 1) For x As Integer = 0 To (bitmap->Width - 1) Dim As Integer col = bitmap->buffer[y * bitmmp->pitch + x] PSet(x, y), RGB(col, col, col) Next Next
Sleep
|