CairoFontEngine.h 3.12 KB
Newer Older
Kristian Høgsberg's avatar
Kristian Høgsberg committed
1 2 3 4
//========================================================================
//
// CairoFontEngine.h
//
5 6 7 8 9 10 11 12 13
// Copyright 2003 Glyph & Cog, LLC
// Copyright 2004 Red Hat, Inc
//
//========================================================================

//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
14 15 16
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
17 18 19 20 21 22 23 24
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
//
Kristian Høgsberg's avatar
Kristian Høgsberg committed
25 26 27 28 29 30 31 32 33 34 35 36 37
//========================================================================

#ifndef CAIROFONTENGINE_H
#define CAIROFONTENGINE_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

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

#include "GfxFont.h"
38
#include "Catalog.h"
Kristian Høgsberg's avatar
Kristian Høgsberg committed
39

40 41
class CairoFontEngine;

Kristian Høgsberg's avatar
Kristian Høgsberg committed
42 43
class CairoFont {
public:
Adrian Johnson's avatar
Adrian Johnson committed
44 45 46 47 48 49
  CairoFont(Ref ref,
	      cairo_font_face_t *face,
	      Gushort *codeToGID,
	      int codeToGIDLen,
	      GBool substitute);
  virtual ~CairoFont();
Kristian Høgsberg's avatar
Kristian Høgsberg committed
50

51 52
  GBool matches(Ref &other);
  cairo_font_face_t *getFontFace(void);
53
  unsigned long getGlyph(CharCode code, Unicode *u, int uLen);
Jeff Muizelaar's avatar
Jeff Muizelaar committed
54 55 56
  double getSubstitutionCorrection(GfxFont *gfxFont);

  GBool isSubstitute() { return substitute; }
Adrian Johnson's avatar
Adrian Johnson committed
57
protected:
Kristian Høgsberg's avatar
Kristian Høgsberg committed
58
  Ref ref;
59
  cairo_font_face_t *cairo_font_face;
60

Kristian Høgsberg's avatar
Kristian Høgsberg committed
61 62
  Gushort *codeToGID;
  int codeToGIDLen;
Jeff Muizelaar's avatar
Jeff Muizelaar committed
63 64

  GBool substitute;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
65 66 67 68
};

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

Adrian Johnson's avatar
Adrian Johnson committed
69 70 71 72 73 74 75 76 77 78 79 80 81
class CairoFreeTypeFont : public CairoFont {
public:
  static CairoFreeTypeFont *create(GfxFont *gfxFont, XRef *xref, FT_Library lib, GBool useCIDs);
  virtual ~CairoFreeTypeFont();

private:
  CairoFreeTypeFont(Ref ref, cairo_font_face_t *cairo_font_face, FT_Face face,
	    Gushort *codeToGID, int codeToGIDLen, GBool substitute);
  FT_Face face;
};

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

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
class CairoType3Font : public CairoFont {
public:
  static CairoType3Font *create(GfxFont *gfxFont, XRef *xref,
				Catalog *catalog, CairoFontEngine *fontEngine);
  virtual ~CairoType3Font();

private:
  CairoType3Font(Ref ref, XRef *xref, Catalog *catalog,
		 cairo_font_face_t *cairo_font_face,
		 Gushort *codeToGID, int codeToGIDLen);
  XRef *xref;
  Catalog *catalog;
};

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

98
#define cairoFontCacheSize 64
Kristian Høgsberg's avatar
Kristian Høgsberg committed
99 100 101 102 103 104 105 106 107 108 109 110

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

class CairoFontEngine {
public:

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

111
  CairoFont *getFont(GfxFont *gfxFont, XRef *xref, Catalog *catalog);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
112 113 114 115

private:
  CairoFont *fontCache[cairoFontCacheSize];
  FT_Library lib;
116
  GBool useCIDs;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
117 118 119
};

#endif