svc_font.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #ifndef _SVC_FONT_H
  2. #define _SVC_FONT_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/std_file.h>
  5. #include <stdio.h>
  6. #include <api/service/services.h>
  7. //#include <api/service/servicei.h>
  8. class ifc_canvas;
  9. #ifdef _WIN32
  10. enum
  11. {
  12. STDFONT_LEFT = DT_LEFT,
  13. STDFONT_RIGHT = DT_RIGHT,
  14. STDFONT_CENTER = DT_CENTER,
  15. };
  16. #else
  17. #warning TODO: find good values for these
  18. enum
  19. {
  20. STDFONT_RIGHT = 1,
  21. STDFONT_CENTER = 2,
  22. STDFONT_LEFT = 4,
  23. };
  24. #endif
  25. class NOVTABLE svc_font : public Dispatchable
  26. {
  27. public:
  28. static FOURCC getServiceType() { return WaSvc::FONTRENDER; }
  29. 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 antialias); // abstract interface
  30. void textOut(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 antialias);
  31. 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 antialias);
  32. 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 antialias);
  33. 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 antialias);
  34. 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 antialias);
  35. int getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias);
  36. int getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias);
  37. int getTextHeight(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias);
  38. void getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias);
  39. void setFontId(const wchar_t *id);
  40. const wchar_t *getFontId();
  41. const wchar_t *getFaceName();
  42. int isBitmap();
  43. int getScriptId();
  44. void setScriptId(int id);
  45. void setFontFace(const wchar_t *face);
  46. int addFontResource(HANDLE f, const wchar_t *name);
  47. int addFontResource2(void *mem, int datalen, const wchar_t *name);
  48. const wchar_t *getFontSvcName();
  49. protected:
  50. enum {
  51. TEXTOUT,
  52. TEXTOUT2,
  53. TEXTOUTELLIPSED,
  54. TEXTOUTWRAPPED,
  55. TEXTOUTWRAPPEDPATHED,
  56. TEXTOUTCENTERED,
  57. GETTEXTWIDTH,
  58. GETTEXTHEIGHT,
  59. GETTEXTHEIGHT2,
  60. GETTEXTEXTENT,
  61. SETFONTID,
  62. GETFONTID,
  63. GETFACENAME_, // GETFACENAME is taken in win32
  64. ISBITMAP,
  65. GETSCRIPTID,
  66. SETSCRIPTID,
  67. SETFONTFACE,
  68. ADDFONTRESOURCE,
  69. ADDFONTRESOURCE2,
  70. GETFONTSVCNAME,
  71. };
  72. };
  73. inline void svc_font::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 antialias)
  74. {
  75. _voidcall(TEXTOUT, c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, antialias);
  76. }
  77. inline void svc_font::textOut(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 antialias)
  78. {
  79. _voidcall(TEXTOUT2, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias);
  80. }
  81. inline void svc_font::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 antialias)
  82. {
  83. _voidcall(TEXTOUTELLIPSED, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias);
  84. }
  85. inline void svc_font::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 antialias)
  86. {
  87. _voidcall(TEXTOUTWRAPPED, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias);
  88. }
  89. inline void svc_font::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 antialias)
  90. {
  91. _voidcall(TEXTOUTWRAPPEDPATHED, c, x, y, w, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias);
  92. }
  93. inline void svc_font::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 antialias)
  94. {
  95. _voidcall(TEXTOUTCENTERED, c, r, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias);
  96. }
  97. inline int svc_font::getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias)
  98. {
  99. return _call(GETTEXTWIDTH, (int)0, c, text, size, bold, underline, italic, antialias);
  100. }
  101. inline int svc_font::getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias) {
  102. return _call(GETTEXTHEIGHT, (int)0, c, text, size, bold, underline, italic, antialias);
  103. }
  104. inline int svc_font::getTextHeight(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias) {
  105. return _call(GETTEXTHEIGHT, (int)0, c, size, bold, underline, italic, antialias);
  106. }
  107. inline void svc_font::getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias) {
  108. _voidcall(GETTEXTEXTENT, c, text, w, h, size, bold, underline, italic, antialias);
  109. }
  110. inline void svc_font::setFontId(const wchar_t *id) {
  111. _voidcall(SETFONTID, id);
  112. }
  113. inline const wchar_t *svc_font::getFontId()
  114. {
  115. return _call(GETFONTID, (const wchar_t *)0);
  116. }
  117. inline const wchar_t *svc_font::getFaceName()
  118. {
  119. return _call(GETFACENAME_, (const wchar_t *)0);
  120. }
  121. inline int svc_font::isBitmap() {
  122. return _call(ISBITMAP, (int)0);
  123. }
  124. inline int svc_font::getScriptId() {
  125. return _call(GETSCRIPTID, (int)0);
  126. }
  127. inline void svc_font::setScriptId(int id) {
  128. _voidcall(SETSCRIPTID, id);
  129. }
  130. inline void svc_font::setFontFace(const wchar_t *face)
  131. {
  132. _voidcall(SETFONTFACE, face);
  133. }
  134. inline int svc_font::addFontResource(HANDLE f, const wchar_t *name) {
  135. return _call(ADDFONTRESOURCE, (int)0, f, name);
  136. }
  137. inline int svc_font::addFontResource2(void *mem, int datalen, const wchar_t *name) {
  138. return _call(ADDFONTRESOURCE2, (int)0, mem, datalen, name);
  139. }
  140. inline const wchar_t *svc_font::getFontSvcName() {
  141. return _call(GETFONTSVCNAME, (const wchar_t *)0);
  142. }
  143. #endif // _SVC_FONT_H