1
0

bitmapfont.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef __BITMAPFONT_H
  2. #define __BITMAPFONT_H
  3. #include <api/font/svc_fonti.h>
  4. //#include "font.h"
  5. #include <bfc/platform/platform.h>
  6. #include <bfc/ptrlist.h>
  7. #include <bfc/stack.h>
  8. #include <tataki/bitmap/autobitmap.h>
  9. #include <bfc/string/StringW.h>
  10. class Font;
  11. class BitmapFont : public svc_fontI
  12. {
  13. friend class Font;
  14. public:
  15. virtual void textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased);
  16. virtual void textOut2(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased);
  17. virtual void textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased);
  18. virtual void textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased);
  19. virtual void textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased);
  20. virtual void textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased);
  21. virtual int getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialiased);
  22. virtual int getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialiased);
  23. virtual int getTextHeight2(ifc_canvas *c, int size, int bold, int underline, int italic, int antialiased);
  24. virtual void getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialiased);
  25. virtual int isBitmap();
  26. virtual void setFontBitmap(const wchar_t *name_or_element, const wchar_t *path);
  27. virtual void setFontMetrics(int char_width, int char_height, int hor_spacing, int vert_spacing);
  28. virtual const wchar_t *getFaceName();
  29. virtual void setFontId(const wchar_t *id) { font_id = id; }
  30. virtual const wchar_t *getFontId() { return font_id; }
  31. virtual int getScriptId() { return scriptid; }
  32. virtual void setScriptId(int id) { scriptid = id; }
  33. virtual void setFontFace(const wchar_t *face) {}
  34. virtual int addFontResource(OSFILETYPE f, const wchar_t *name) { return 0; /*failure*/}
  35. virtual int addFontResource2(void *mem, int datalen, const wchar_t *name) { return 0; /*failure*/}
  36. virtual const wchar_t *getFontSvcName() { return L"Bitmap Font"; }
  37. protected:
  38. BitmapFont();
  39. virtual ~BitmapFont();
  40. AutoSkinBitmap *getCharTable();
  41. int getCharWidth();
  42. int getCharHeight();
  43. int getHorizontalSpacing();
  44. int getVerticalSpacing();
  45. void getXYfromChar(wchar_t ic, int *x, int *y);
  46. protected:
  47. StringW font_id;
  48. int scriptid;
  49. private:
  50. AutoSkinBitmap table;
  51. int char_width, char_height, hor_spacing, vert_spacing;
  52. static void do_textOut(BitmapFont *font, ifc_canvas *c, int x, int y, int x2, int y2, const wchar_t *text, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, int style);
  53. static int getWordLength(const wchar_t *p);
  54. static wchar_t *makeLine(const wchar_t *t, BitmapFont *font, int line, int physwidth, int style);
  55. };
  56. #endif