aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/font/font.h
blob: 8e1f15f25f54cd51fe1bd647c90319b21ad68e9f (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
#ifndef __FONT_H
#define __FONT_H

#include <bfc/ptrlist.h>
#include <bfc/string/StringW.h>

class ifc_canvas;
class svc_font;
class svc_fontMaker;

class FontDef {
  public:
  StringW filename;
  StringW path;
  StringW id;
  int allowmapping;
  int isbitmap;
  int scriptid;
};

class Font {
 public: 
  static void init();

  static svc_font *installTrueTypeFont(const wchar_t *filename, const wchar_t *path, const wchar_t *id, int scriptid, int allowmapping, int isreload);                     // call this to install a new font
  static void installBitmapFont(const wchar_t *filename, const wchar_t *path, const wchar_t *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid, int allowmapping);                       
  static void uninstallAll(int isttfreload=0);
  static void uninstallByScriptId(int scriptid);
  
  static svc_font *requestSkinFont(const wchar_t *id, int *size=NULL, int *gotdefault=NULL);  // call this to get a Font pointer to a font id, pass your size if you have one, so that the mapper can do its job. 
  static void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const wchar_t *txt);
  static int dispatchGetInfo(ifc_canvas *c, const wchar_t *font, int infoid, const wchar_t *txt, int *w, int *h);

  static int useTrueTypeOverride(const wchar_t *txt);
  static const wchar_t *getTrueTypeOverride();
  static int getTrueTypeOverrideScale();
  static int getNumFonts() { return fontlist.getNumItems(); }
  
  static FontDef *enumFontDef(int n) { return fontdefs.enumItem(n); }
  static int getNumFontDefs() { return fontdefs.getNumItems(); }

  static const wchar_t *getFontMapping(const wchar_t *id, int *size);

 private:
  static void deleteFont(svc_font *font);
  static svc_font *newTrueTypeFont();

  static PtrList<svc_font> fontlist;
  static PtrList<FontDef> fontdefs;
  StringW font_id;
  int scriptid;
  static StringW mapping;
};

#endif