CairoFontEngine.h 1.44 KB
Newer Older
Kristian Høgsberg's avatar
Kristian Høgsberg committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//========================================================================
//
// CairoFontEngine.h
//
//========================================================================

#ifndef CAIROFONTENGINE_H
#define CAIROFONTENGINE_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

#include "goo/gtypes.h"
#include <cairo-ft.h>

#include "GfxFont.h"

class CairoFont {
public:
21 22 23 24 25
  static CairoFont *create(GfxFont *gfxFont, XRef *xref,
			   FT_Library lib, GBool useCIDs);

  CairoFont *reference() { refcount++; return this; }
  void unreference() { if (--refcount == 0) delete this; }
Kristian Høgsberg's avatar
Kristian Høgsberg committed
26

27 28
  GBool matches(Ref &other);
  cairo_font_face_t *getFontFace(void);
29
  unsigned long getGlyph(CharCode code, Unicode *u, int uLen);
30 31 32 33 34

protected:
  CairoFont(GfxFont *gfxFont, XRef *xref);
  virtual ~CairoFont();

Kristian Høgsberg's avatar
Kristian Høgsberg committed
35
  Ref ref;
36
  XRef *xref;
37
  cairo_font_face_t *cairo_font_face;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
38 39
  Gushort *codeToGID;
  int codeToGIDLen;
40
  int refcount;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
41 42 43 44
};

//------------------------------------------------------------------------

45
#define cairoFontCacheSize 64
Kristian Høgsberg's avatar
Kristian Høgsberg committed
46 47 48 49 50 51 52 53 54 55 56 57

//------------------------------------------------------------------------
// CairoFontEngine
//------------------------------------------------------------------------

class CairoFontEngine {
public:

  // Create a font engine.
  CairoFontEngine(FT_Library libA);
  ~CairoFontEngine();

58
  CairoFont *getFont(GfxFont *gfxFont, XRef *xref);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
59 60 61 62

private:
  CairoFont *fontCache[cairoFontCacheSize];
  FT_Library lib;
63
  GBool useCIDs;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
64 65 66
};

#endif