CairoFontEngine.h 2.19 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 14 15 16 17 18 19 20 21
// Copyright 2003 Glyph & Cog, LLC
// Copyright 2004 Red Hat, Inc
//
//========================================================================

//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// 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
22 23 24 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"

class CairoFont {
public:
38
  static CairoFont *create(GfxFont *gfxFont, XRef *xref, FT_Library lib, GBool useCIDs);
39
  ~CairoFont();
Kristian Høgsberg's avatar
Kristian Høgsberg committed
40

41 42
  GBool matches(Ref &other);
  cairo_font_face_t *getFontFace(void);
43
  unsigned long getGlyph(CharCode code, Unicode *u, int uLen);
Jeff Muizelaar's avatar
Jeff Muizelaar committed
44 45 46
  double getSubstitutionCorrection(GfxFont *gfxFont);

  GBool isSubstitute() { return substitute; }
47
private:
48
  CairoFont(Ref ref, cairo_font_face_t *cairo_font_face, FT_Face face,
Jeff Muizelaar's avatar
Jeff Muizelaar committed
49
      Gushort *codeToGID, int codeToGIDLen, GBool substitute);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
50
  Ref ref;
51
  cairo_font_face_t *cairo_font_face;
52 53
  FT_Face face;

Kristian Høgsberg's avatar
Kristian Høgsberg committed
54 55
  Gushort *codeToGID;
  int codeToGIDLen;
Jeff Muizelaar's avatar
Jeff Muizelaar committed
56 57

  GBool substitute;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
58 59 60 61
};

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

62
#define cairoFontCacheSize 64
Kristian Høgsberg's avatar
Kristian Høgsberg committed
63 64 65 66 67 68 69 70 71 72 73 74

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

class CairoFontEngine {
public:

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

75
  CairoFont *getFont(GfxFont *gfxFont, XRef *xref);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
76 77 78 79

private:
  CairoFont *fontCache[cairoFontCacheSize];
  FT_Library lib;
80
  GBool useCIDs;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
81 82 83
};

#endif