graphics/ font.bi | |
License | Copyright © 2009, FreeBASIC Extended Library Development Group |
ext. gfx.font | |
Functions | |
custom_info | Provides an easy way to load information about a custom draw string font. |
GetTextWidth | Returns the width of a string in a particular draw string font. |
Enumerations | |
FontError | Error values that can be returned by the loadttf function. |
Functions | |
loadttf | Loads a truetype font to a Draw String compatible font buffer, not supported or defined on DOS. |
Copyright © 2009, FreeBASIC Extended Library Development Group
Distributed under the FreeBASIC Extended Library Group license. See accompanying file LICENSE.txt or copy at http://code.google.com- /p- /fb-extended-lib- /wiki- /License
Functions | |
custom_info | Provides an easy way to load information about a custom draw string font. |
GetTextWidth | Returns the width of a string in a particular draw string font. |
Enumerations | |
FontError | Error values that can be returned by the loadttf function. |
Functions | |
loadttf | Loads a truetype font to a Draw String compatible font buffer, not supported or defined on DOS. |
declare function custom_info( byval buf as FB. IMAGE ptr, byref first_ as const string, byref last_ as const string, widths() as const ubyte ) as ext.bool
Provides an easy way to load information about a custom draw string font.
buf | the FB.IMAGE buffer containing your font. |
first_ | string containing the first character your font supports. |
last_ | string containing the last character your font supports. |
widths() | ubyte array containing the width values for each character. |
Returns one of the values defined by ext.bool.
declare function GetTextWidth( byval fnt as const FB. IMAGE ptr, byref xstr as const string ) as uinteger
Returns the width of a string in a particular draw string font.
fnt | FB.IMAGE ptr to the draw string font. |
xstr | the string to return the width of. |
Uinteger containing the pixel width of the specified string in the passed font.
Error values that can be returned by the loadttf function. Not supported or defined on DOS.
declare function loadttf ( byref fontname as Const string, byref img as FB. IMAGE ptr, byval range_lo as integer = 1, byval range_hi as integer = 255, byval font_size as integer = 14, byval colour as uinteger = &HFFFFFF ) as integer
Loads a truetype font to a Draw String compatible font buffer, not supported or defined on DOS.
fontname | string containing the path and filename of the font to load. |
img | un-initialized FB.IMAGE ptr to draw the font on. |
range_lo | the lowest character your font should support. Defaults to 1. |
range_hi | the highest character your font should support. Defaults to 255. |
font_size | requested size of the font in pixels, not exact. Defaults to 14. |
colour | the colour to use when drawing the font, defaults to white or &hFFFFFF. |
Integer value indicating success or failure.
You may use # as a shortcut for the common font directories on Windows and Linux. e.g. “#arial.ttf” on windows expands to “c:/Windows/Fonts/arial.ttf” and on Linux will expand to “/usr/share/fonts/truetype/arial.ttf”. Certain fonts at certain sizes may show some artifacting. We’ve tried to minimize this, but it seems like a feature of freetype and the TrueType standard. Due to the way FreeType loads the font, you will have to use the ALPHA drawing method with Draw String for your font to be displayed properly.
#include once "ext/graphics/font.bi" #include once "fbgfx.bi" using ext dim as FB.IMAGE ptr myFont screenres 320, 240, 32 if gfx.loadttf( "Vera.ttf", myFont ) = 1 then draw string (10,10), "Hello, World!", ,myFont, ALPHA else print "Error loading font." end if imagedestroy myFont
Provides an easy way to load information about a custom draw string font.
declare function custom_info( byval buf as FB. IMAGE ptr, byref first_ as const string, byref last_ as const string, widths() as const ubyte ) as ext.bool
Returns the width of a string in a particular draw string font.
declare function GetTextWidth( byval fnt as const FB. IMAGE ptr, byref xstr as const string ) as uinteger
Loads a truetype font to a Draw String compatible font buffer, not supported or defined on DOS.
declare function loadttf ( byref fontname as Const string, byref img as FB. IMAGE ptr, byval range_lo as integer = 1, byval range_hi as integer = 255, byval font_size as integer = 14, byval colour as uinteger = &HFFFFFF ) as integer