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
  CairoFont(GfxFont *gfxFont, XRef *xref, FT_Library lib,
	    double m11, double m12, double m21, double m22);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
23 24
  ~CairoFont();

25 26 27
  GBool matches(Ref &other, double m11, double m12, double m21, double m22);
  cairo_font_t *getFont(void);
  unsigned long getGlyph(CharCode code, Unicode *u, int uLen);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
28 29 30 31 32 33 34 35 36
  double getSubstitutionCorrection(GfxFont *gfxFont);
private:
  int substIdx;
  Ref ref;
  cairo_font_t *cairo_font;
  FT_Face face;

  Gushort *codeToGID;
  int codeToGIDLen;
37
  double m11, m12, m21, m22;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
38 39 40 41
};

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

42
#define cairoFontCacheSize 64
Kristian Høgsberg's avatar
Kristian Høgsberg committed
43 44 45 46 47 48 49 50 51 52 53 54

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

class CairoFontEngine {
public:

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

55 56
  CairoFont *getFont(GfxFont *gfxFont, XRef *xref,
		     double m11, double m12, double m21, double m22);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
57 58 59 60 61 62 63

private:
  CairoFont *fontCache[cairoFontCacheSize];
  FT_Library lib;
};

#endif