From 9901fcfab51b01acc0ea6614bbb4f9465cab3cd1 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 3 Oct 2016 21:11:51 +0000 Subject: Initial version of PNG font --- pngfont.monkey | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pngfont.monkey (limited to 'pngfont.monkey') 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 -- cgit v1.2.3