diff options
author | Ian C <ianc@noddybox.co.uk> | 2016-10-03 21:11:51 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2016-10-03 21:11:51 +0000 |
commit | 9901fcfab51b01acc0ea6614bbb4f9465cab3cd1 (patch) | |
tree | fd69dc97949aa5b051a3877082ea1dec693a80ce | |
parent | aaf20e130f62d8f3558f1e28178df57ed9e8aec1 (diff) |
-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 |