WoopsiGfx 1.4
Nintendo DS 2D Graphics Library
|
00001 /* Contributed by Jeff Laing 00002 * 20080414 00003 */ 00004 00005 #ifndef _PACKED_FONT_BASE_ 00006 #define _PACKED_FONT_BASE_ 00007 00008 #include <nds.h> 00009 #include "fontbase.h" 00010 00011 namespace WoopsiGfx { 00012 00017 class PackedFontBase : public FontBase 00018 { 00019 public: 00033 PackedFontBase( 00034 u8 first, u8 last, 00035 const u16 *glyphData, 00036 const u16 *glyphOffset, 00037 const u8 *glyphWidth, 00038 const u8 height, 00039 const u8 spWidth, 00040 const u8 fontTop, 00041 const u8 fixedWidth = 0) 00042 : 00043 _height(height), 00044 _first(first), _last(last), 00045 _glyphData(glyphData), _glyphOffset(glyphOffset), _glyphWidth(glyphWidth), 00046 _fontWidth(0), _spWidth(spWidth), 00047 _fontTop(fontTop), _widMax(fixedWidth) { }; 00048 00056 inline void setFontWidth(u8 fontWidth) { _fontWidth = (fontWidth && (fontWidth < _widMax)) ? _widMax : fontWidth; }; 00057 00072 virtual s16 drawChar( 00073 MutableBitmapBase* bitmap, 00074 u32 letter, 00075 u16 colour, 00076 s16 x, s16 y, 00077 u16 clipX1, u16 clipY1, u16 clipX2, u16 clipY2); 00078 00094 virtual s16 drawBaselineChar( 00095 MutableBitmapBase* bitmap, 00096 u32 letter, 00097 u16 colour, 00098 s16 x, s16 y, 00099 u16 clipX1, u16 clipY1, u16 clipX2, u16 clipY2) { 00100 return drawChar(bitmap, letter, colour, x, y - getCharTop(y), clipX1, clipY1, clipX2, clipY2); 00101 }; 00102 00108 virtual u16 getStringWidth(const WoopsiString& text) const; 00109 00119 virtual u16 getStringWidth(const WoopsiString& text, s32 startIndex, s32 length) const; 00120 00126 virtual u8 getCharWidth(u32 letter) const; 00127 00133 inline virtual s8 getCharTop(u32 letter) const {return _fontTop;}; 00134 00138 const bool isCharBlank(const u32 letter) const; 00139 00144 inline const u8 getHeight() const { return _height; }; 00145 00151 virtual u8 getCharHeight(u32 letter) const { return _height; }; 00152 00168 virtual void renderChar( 00169 const u16* pixelData, u16 pixelsPerRow, 00170 MutableBitmapBase* bitmap, 00171 u16 colour, 00172 s16 x, s16 y, 00173 u16 clipX1, u16 clipY1, u16 clipX2, u16 clipY2) = 0; 00174 00175 protected: 00176 u8 _height; 00177 u8 _first; 00178 u8 _last; 00179 const u16 *_glyphData; 00180 const u16 *_glyphOffset; 00181 const u8 *_glyphWidth; 00182 u8 _fontWidth; 00183 u8 _spWidth; 00184 u8 _fontTop; 00185 u8 _widMax; 00186 }; 00187 } 00188 00189 #endif