summaryrefslogtreecommitdiff
path: root/bitmapfont.mod/bitmapfont.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'bitmapfont.mod/bitmapfont.bmx')
-rw-r--r--bitmapfont.mod/bitmapfont.bmx49
1 files changed, 49 insertions, 0 deletions
diff --git a/bitmapfont.mod/bitmapfont.bmx b/bitmapfont.mod/bitmapfont.bmx
index 35feb10..fd70671 100644
--- a/bitmapfont.mod/bitmapfont.bmx
+++ b/bitmapfont.mod/bitmapfont.bmx
@@ -1,3 +1,6 @@
+Rem
+bbdoc: noddybox.bitmapfont
+EndRem
Module noddybox.bitmapfont
ModuleInfo "Framework: Simple Bitmap Font Routines"
@@ -13,6 +16,13 @@ Import brl.Basic
Strict
+Rem
+bbdoc: Defines a bitmap font
+about: The @TBitmapFont object works from BMF Files, which are created using a tool called BitmapFontEd available at
+about: <a href="http://www.noddybox.demon.co.uk/free/index-csharp.html">http://www.noddybox.demon.co.uk/free/index-csharp.html</a><br>
+about: Note that when colours are referenced they simply modify the colours in the font images as @SetColor() would do on a norml image.<br>
+about: When drawing characters the current scale, alpha and rotation settings are applied.
+EndRem
Type TBitmapFont
Const NOCHR=95
@@ -24,6 +34,11 @@ Type TBitmapFont
Field max_width:Int
Field max_height:Int
+ Rem
+ bbdoc: Loads a font from the supplied BMF file.
+ returns: The created font, or null if the BMF file couldn't be loaded.
+ about: The @image_flags are passed onto @CreateImage() when the images for the font are being created.
+ EndRem
Function Load:TBitmapFont(path:String, image_flags:Int)
Local fnt:TBitmapFont
Local str:TStream
@@ -73,6 +88,10 @@ Type TBitmapFont
Return fnt
End Function
+ Rem
+ bbdoc: Draws coloured text.
+ about: Draws @txt at the supplied @x,@y co-ordinates. @red,@green and @blue control the colour.
+ EndRem
Method DrawColoured(txt:String, x:Int, y:Int, red:Int, green:Int, blue:Int)
Local f,r,g,b,c
Local xs#,ys#
@@ -91,10 +110,18 @@ Type TBitmapFont
SetColor(r,g,b)
End Method
+ Rem
+ bbdoc: Draws white text.
+ about: Draws @txt at the supplied @x,@y co-ordinates in white.
+ EndRem
Method Draw(txt:String, x:Int, y:Int)
DrawColoured(txt,x,y,255,255,255)
End Method
+ Rem
+ bbdoc: Draws centred, coloured text.
+ about: Draws @txt centred at the supplied @y co-ordinate. @red,@green and @blue control the colour.
+ EndRem
Method CentreColoured(txt:String, y:Int, red:Int, green:Int, blue:Int)
If is_fixed
DrawColoured(txt,GraphicsWidth()/2-Len(txt)*width[0]/2,y,red,green,blue)
@@ -103,6 +130,10 @@ Type TBitmapFont
EndIf
End Method
+ Rem
+ bbdoc: Draws centred, white text.
+ about: Draws @txt centred at the supplied @y co-ordinate in white.
+ EndRem
Method Centre(txt:String, y:Int)
If is_fixed
DrawColoured(txt,GraphicsWidth()/2-Len(txt)*width[0]/2,y,255,255,255)
@@ -111,6 +142,11 @@ Type TBitmapFont
EndIf
End Method
+ Rem
+ bbdoc: Width of the supplied string.
+ returns: The length of the string @txt in pixels.
+ about: The current scale settings are taken into account.
+ EndRem
Method TextWidth:Int(txt:String)
Local w
Local xs#,ys#
@@ -123,6 +159,11 @@ Type TBitmapFont
Return w
End Method
+ Rem
+ bbdoc: Height of the supplied string.
+ returns: The height of the string @txt in pixels.
+ about: The current scale settings are taken into account.
+ EndRem
Method TextHeight:Int(txt:String)
Local h:Int=0
Local xs#,ys#
@@ -136,10 +177,18 @@ Type TBitmapFont
Return h
End Method
+ Rem
+ bbdoc: Width of the largest character.
+ returns: The width in pixels of the largest character in the font.
+ EndRem
Method MaxWidth:Int()
Return max_width
End Method
+ Rem
+ bbdoc: Height of the largest character.
+ returns: The height in pixels of the largest character in the font.
+ EndRem
Method MaxHeight:Int()
Return max_height
End Method