better sanity check in interpolator
[dd2d.git] / d2dfont.d
blob05e7a120b658babf08b1751c4968809cd94105c3
1 module d2dfont is aliced;
2 private:
4 import arsd.color;
5 import iv.stream;
7 import glutils;
8 import console;
9 import wadarc;
11 import d2dgfx;
14 // ////////////////////////////////////////////////////////////////////////// //
15 public __gshared D2DImage[256] smfont;
16 //public __gshared D2DImage fftest;
19 public void loadSmFont () {
20 foreach (ubyte cc; 0..256) {
21 try {
22 import std.string : format;
23 smfont[cc] = new D2DImage("fonts/stcf/stcfnx%02x.vga".format(cc));
24 smfont[cc].createGLTex;
25 } catch (Exception) {
26 //conwriteln("no char with code ", cc);
29 //fftest = new D2DImage("fonts/stbf/stbf_x61.vga");
30 //fftest = new D2DImage("tilegfx/comp03_1.vga");
31 //fftest.createGLTex;
35 public void smDrawText (int x, int y, const(char)[] str) {
36 foreach (char ch; str) {
37 if (ch == ' ') { x += 6; continue; }
38 auto img = smfont.ptr[cast(ubyte)ch];
39 if (img is null) {
40 // try uppercase letter
41 ch = koi8upper(ch);
42 img = smfont.ptr[cast(ubyte)ch];
43 if (img is null) continue;
45 drawAtXY(img.tex, x-img.sx, y-img.sy);
46 x += img.width;