aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/service/svcs/svc_fontrender.h
blob: a377e76c106d250c47b299a8d3f63c2d08de7ca7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef _svc_fONTRENDER_H
#define _svc_fONTRENDER_H

#include <bfc/dispatch.h>
#include <bfc/string/string.h>
#include <api/service/svc_enum.h>
#include <api/service/services.h>
#include <api/service/servicei.h>

class svc_font;
class ifc_canvas;

class NOVTABLE svc_fontRender : public Dispatchable {
public:
  static FOURCC getServiceType() { return WaSvc::FONTRENDER; }

  // test the type.
  int isNamed(const char *renderer_name);

  // static methods from Font::
  void installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid);                     // call this to install a new font
  void installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid);                       
  void uninstallAll();
  void uninstallByScriptId(int scriptid);
  svc_font *requestSkinFont(const char *id);                                                      // call this to get a Font pointer to a font id
  void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt);
  int dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h);
  int useTrueTypeOverride();
  const char *getTrueTypeOverride();


protected:
  enum {
    ISNAMED,
    INSTALLTRUETYPEFONT,
    INSTALLBITMAPFONT,
    UNINSTALLALL,
    UNINSTALLBYSCRIPTID,
    REQUESTSKINFONT,
    DISPATCHTEXTOUT,
    DISPATCHGETINFO,
    USETRUETYPEOVERRIDE,
    GETTRUETYPEOVERRIDE,
  };
};


inline int svc_fontRender::isNamed(const char *renderer_name) {
  return _call(ISNAMED, (int)0, renderer_name);
}

inline void svc_fontRender::installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid) {
  _voidcall(INSTALLTRUETYPEFONT, filename, path, id, scriptid);
}

inline void svc_fontRender::installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid) {
  _voidcall(INSTALLBITMAPFONT, filename, path, id, charwidth, charheight, hspacing, vspacing, scriptid);
}

inline void svc_fontRender::uninstallAll() {
  _voidcall(UNINSTALLALL);
}

inline void svc_fontRender::uninstallByScriptId(int scriptid) {
  _voidcall(UNINSTALLBYSCRIPTID, scriptid);
}

inline svc_font *svc_fontRender::requestSkinFont(const char *id) {
  return _call(REQUESTSKINFONT, (svc_font *)0, id);
}

inline void svc_fontRender::dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt) {
  _voidcall(DISPATCHTEXTOUT, c, style, x, y, w, h, txt);
}

inline int svc_fontRender::dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h) {
  return _call(DISPATCHGETINFO, (int)0, c, font, infoid, txt, w, h  );
}

inline int svc_fontRender::useTrueTypeOverride() {
  return _call(USETRUETYPEOVERRIDE, (int)0);
}

inline const char *svc_fontRender::getTrueTypeOverride() {
  return _call(GETTRUETYPEOVERRIDE, (const char *)0);
}

// implementor derives from this one
class NOVTABLE svc_fontRenderI : public svc_fontRender {
public:

  // test the type
  virtual int isNamed(const char *renderer_name) = 0;

  // static methods from Font::
  virtual void installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid) = 0;
  virtual void installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid) = 0;
  virtual void uninstallAll() = 0;
  virtual void uninstallByScriptId(int scriptid) = 0;
  virtual svc_font *requestSkinFont(const char *id) = 0;                                                      // call this to get a Font pointer to a font id
  virtual void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt) = 0;
  virtual int dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h) = 0;
  virtual int useTrueTypeOverride() = 0;
  virtual const char *getTrueTypeOverride() = 0;


protected:
  RECVS_DISPATCH;
};

class FontRenderEnum : public SvcEnumT<svc_fontRender> {
public:
  FontRenderEnum(const char *_renderer_name = NULL) : renderer_name(_renderer_name) {}
protected:
  virtual int testService(svc_fontRender *svc) {
    return (svc->isNamed(renderer_name));
  }
private:
  String renderer_name;
};

template <class T>
class FontRenderCreator : public waServiceFactoryTSingle<svc_fontRender, T> {};


#endif // _svc_fONTRENDER_H