svc_fontrender.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #ifndef _svc_fONTRENDER_H
  2. #define _svc_fONTRENDER_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/string/string.h>
  5. #include <api/service/svc_enum.h>
  6. #include <api/service/services.h>
  7. #include <api/service/servicei.h>
  8. class svc_font;
  9. class ifc_canvas;
  10. class NOVTABLE svc_fontRender : public Dispatchable {
  11. public:
  12. static FOURCC getServiceType() { return WaSvc::FONTRENDER; }
  13. // test the type.
  14. int isNamed(const char *renderer_name);
  15. // static methods from Font::
  16. void installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid); // call this to install a new font
  17. void installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid);
  18. void uninstallAll();
  19. void uninstallByScriptId(int scriptid);
  20. svc_font *requestSkinFont(const char *id); // call this to get a Font pointer to a font id
  21. void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt);
  22. int dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h);
  23. int useTrueTypeOverride();
  24. const char *getTrueTypeOverride();
  25. protected:
  26. enum {
  27. ISNAMED,
  28. INSTALLTRUETYPEFONT,
  29. INSTALLBITMAPFONT,
  30. UNINSTALLALL,
  31. UNINSTALLBYSCRIPTID,
  32. REQUESTSKINFONT,
  33. DISPATCHTEXTOUT,
  34. DISPATCHGETINFO,
  35. USETRUETYPEOVERRIDE,
  36. GETTRUETYPEOVERRIDE,
  37. };
  38. };
  39. inline int svc_fontRender::isNamed(const char *renderer_name) {
  40. return _call(ISNAMED, (int)0, renderer_name);
  41. }
  42. inline void svc_fontRender::installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid) {
  43. _voidcall(INSTALLTRUETYPEFONT, filename, path, id, scriptid);
  44. }
  45. inline void svc_fontRender::installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid) {
  46. _voidcall(INSTALLBITMAPFONT, filename, path, id, charwidth, charheight, hspacing, vspacing, scriptid);
  47. }
  48. inline void svc_fontRender::uninstallAll() {
  49. _voidcall(UNINSTALLALL);
  50. }
  51. inline void svc_fontRender::uninstallByScriptId(int scriptid) {
  52. _voidcall(UNINSTALLBYSCRIPTID, scriptid);
  53. }
  54. inline svc_font *svc_fontRender::requestSkinFont(const char *id) {
  55. return _call(REQUESTSKINFONT, (svc_font *)0, id);
  56. }
  57. inline void svc_fontRender::dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt) {
  58. _voidcall(DISPATCHTEXTOUT, c, style, x, y, w, h, txt);
  59. }
  60. inline int svc_fontRender::dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h) {
  61. return _call(DISPATCHGETINFO, (int)0, c, font, infoid, txt, w, h );
  62. }
  63. inline int svc_fontRender::useTrueTypeOverride() {
  64. return _call(USETRUETYPEOVERRIDE, (int)0);
  65. }
  66. inline const char *svc_fontRender::getTrueTypeOverride() {
  67. return _call(GETTRUETYPEOVERRIDE, (const char *)0);
  68. }
  69. // implementor derives from this one
  70. class NOVTABLE svc_fontRenderI : public svc_fontRender {
  71. public:
  72. // test the type
  73. virtual int isNamed(const char *renderer_name) = 0;
  74. // static methods from Font::
  75. virtual void installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid) = 0;
  76. virtual void installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid) = 0;
  77. virtual void uninstallAll() = 0;
  78. virtual void uninstallByScriptId(int scriptid) = 0;
  79. virtual svc_font *requestSkinFont(const char *id) = 0; // call this to get a Font pointer to a font id
  80. virtual void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt) = 0;
  81. virtual int dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h) = 0;
  82. virtual int useTrueTypeOverride() = 0;
  83. virtual const char *getTrueTypeOverride() = 0;
  84. protected:
  85. RECVS_DISPATCH;
  86. };
  87. class FontRenderEnum : public SvcEnumT<svc_fontRender> {
  88. public:
  89. FontRenderEnum(const char *_renderer_name = NULL) : renderer_name(_renderer_name) {}
  90. protected:
  91. virtual int testService(svc_fontRender *svc) {
  92. return (svc->isNamed(renderer_name));
  93. }
  94. private:
  95. String renderer_name;
  96. };
  97. template <class T>
  98. class FontRenderCreator : public waServiceFactoryTSingle<svc_fontRender, T> {};
  99. #endif // _svc_fONTRENDER_H