1 module des.fonts.base; 2 3 import des.math.linear; 4 import des.il; 5 6 /// 7 class FontException : Exception 8 { 9 /// 10 this( string msg, string file=__FILE__, size_t line=__LINE__ ) @safe pure nothrow 11 { super( msg, file, line ); } 12 } 13 14 /// 15 struct Glyph 16 { 17 /// 18 wstring chars; 19 /// 20 ivec2 pos; 21 /// 22 ivec2 next; 23 /// 24 ivec2 size; 25 } 26 27 /// 28 struct GlyphImage 29 { 30 /// 31 Glyph glyph; 32 /// 33 Image image; 34 } 35 36 /// 37 struct BitmapGlyph 38 { 39 /// 40 Glyph glyph; 41 42 /// offset in font image coords 43 ivec2 offset; 44 } 45 46 /// 47 struct BitmapFont 48 { 49 /// 50 uint height; 51 /// 52 BitmapGlyph[wchar] info; 53 /// 54 Image image; 55 } 56 57 /// 58 struct FontRenderParam 59 { 60 /// 61 enum Flag : ubyte 62 { 63 NONE = 0b0000, /// 64 BOLD = 0b0001, /// 65 ITALIC = 0b0010, /// 66 UNDERLINE = 0b0100, /// 67 STRIKED = 0b1000 /// 68 } 69 70 /// 71 ubyte flag = Flag.NONE; 72 73 /// 74 uint height=14; 75 } 76 77 /// 78 interface FontRender 79 { 80 /// 81 void setParams( in FontRenderParam ); 82 /// 83 GlyphImage renderChar( wchar ); 84 /// 85 BitmapFont generateBitmapFont( wstring ); 86 }