diff options
Diffstat (limited to 'pngfont.monkey')
-rw-r--r-- | pngfont.monkey | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pngfont.monkey b/pngfont.monkey new file mode 100644 index 0000000..aaa0aad --- /dev/null +++ b/pngfont.monkey @@ -0,0 +1,35 @@ +' +' 2D Fixed-width PNG font +' +Strict + +Import mojo + +Class TNoddyboxPNGFont + +Private + Field img:Image + Field char_width:Int + Field charmap:String + +Public + + Method New(filename:String, chars:String, width:Int) + char_width = width + charmap = chars + img = LoadImage(filename, chars.Length()) + End Method + + Method Draw:Void(x:Int, y:Int, s:String) + For Local f:Int = 0 To s.Length() - 1 + Local i:Int = charmap.Find(s[f..f+1]) + + If i > -1 + DrawImage(img, x, y, i) + Endif + + x += char_width + Next + End Method + +End Class
\ No newline at end of file |