CairoFontEngine.h 3.24 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
// 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>
Albert Astals Cid's avatar
Albert Astals Cid committed
20
// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
21
// Copyright (C) 2008 Adrian Johnson <ajohnson@redneon.com>
22 23 24 25
//
// 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
26 27 28 29 30 31 32 33 34 35 36 37 38
//========================================================================

#ifndef CAIROFONTENGINE_H
#define CAIROFONTENGINE_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

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

#include "GfxFont.h"
39
#include "PDFDoc.h"
Kristian Høgsberg's avatar
Kristian Høgsberg committed
40

41 42
class CairoFontEngine;

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

53
  virtual GBool matches(Ref &other, GBool printing);
54
  cairo_font_face_t *getFontFace(void);
55
  unsigned long getGlyph(CharCode code, Unicode *u, int uLen);
56 57 58
  double getSubstitutionCorrection(GfxFont *gfxFont);

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

63
  int *codeToGID;
64
  Guint codeToGIDLen;
65 66

  GBool substitute;
67
  GBool printing;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
68 69 70 71
};

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

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

private:
78
  CairoFreeTypeFont(Ref ref, cairo_font_face_t *cairo_font_face,
79
	    int *codeToGID, Guint codeToGIDLen, GBool substitute);
Adrian Johnson's avatar
Adrian Johnson committed
80 81 82 83
};

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

84 85
class CairoType3Font : public CairoFont {
public:
86 87
  static CairoType3Font *create(GfxFont *gfxFont, PDFDoc *doc,
				CairoFontEngine *fontEngine,
88
				GBool printing);
89 90
  virtual ~CairoType3Font();

91 92
  virtual GBool matches(Ref &other, GBool printing);

93
private:
94
  CairoType3Font(Ref ref, PDFDoc *doc,
95
		 cairo_font_face_t *cairo_font_face,
96
		 int *codeToGID, Guint codeToGIDLen,
97
		 GBool printing);
98
  PDFDoc *doc;
99 100 101 102
};

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

103
#define cairoFontCacheSize 64
Kristian Høgsberg's avatar
Kristian Høgsberg committed
104 105 106 107 108 109 110 111 112 113 114 115

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

class CairoFontEngine {
public:

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

116
  CairoFont *getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
117 118 119 120

private:
  CairoFont *fontCache[cairoFontCacheSize];
  FT_Library lib;
121
  GBool useCIDs;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
122 123 124
};

#endif