• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  *******************************************************************************
4  *
5  *   Copyright (C) 1999-2006, International Business Machines
6  *   Corporation and others.  All Rights Reserved.
7  *
8  *******************************************************************************
9  *   file name:  GnomeFontInstance.h
10  *
11  *   created on: 08/30/2001
12  *   created by: Eric R. Mader
13  */
14 
15 #ifndef __GNOMEFONTINSTANCE_H
16 #define __GNOMEFONTINSTANCE_H
17 
18 #include <gnome.h>
19 #include <ft2build.h>
20 #include FT_FREETYPE_H
21 #include FT_GLYPH_H
22 #include <cairo.h>
23 
24 #include "layout/LETypes.h"
25 #include "layout/LEFontInstance.h"
26 
27 #include "RenderingSurface.h"
28 #include "FontTableCache.h"
29 #include "cmaps.h"
30 
31 class GnomeSurface : public RenderingSurface
32 {
33 public:
34     GnomeSurface(GtkWidget *theWidget);
35     virtual ~GnomeSurface();
36 
37     virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count,
38         const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height);
39 
40     GtkWidget *getWidget() const;
41     void setWidget(GtkWidget *theWidget);
42 
43 private:
44     GtkWidget *fWidget;
45     cairo_t   *fCairo;
46 };
47 
48 class GnomeFontInstance : public LEFontInstance, protected FontTableCache
49 {
50  protected:
51     FT_Face fFace;
52 //  FT_Glyph fGlyph;
53 
54     cairo_font_face_t *fCairoFace;
55 
56     le_int32 fPointSize;
57     le_int32 fUnitsPerEM;
58     le_int32 fAscent;
59     le_int32 fDescent;
60     le_int32 fLeading;
61 
62     float fDeviceScaleX;
63     float fDeviceScaleY;
64 
65     CMAPMapper *fMapper;
66 
67     virtual const void *readFontTable(LETag tableTag) const;
68 
69     virtual LEErrorCode initMapper();
70 
71  public:
72     GnomeFontInstance(FT_Library engine, const char *fontPathName, le_int16 pointSize, LEErrorCode &status);
73 
74     virtual ~GnomeFontInstance();
75 
76     virtual const void *getFontTable(LETag tableTag) const;
77 
78     virtual le_int32 getUnitsPerEM() const;
79 
80     virtual le_int32 getAscent() const;
81 
82     virtual le_int32 getDescent() const;
83 
84     virtual le_int32 getLeading() const;
85 
86     virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
87 
88     virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
89 
90     virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
91 
92     float getXPixelsPerEm() const;
93 
94     float getYPixelsPerEm() const;
95 
96     float getScaleFactorX() const;
97 
98     float getScaleFactorY() const;
99 
100     void rasterizeGlyphs(cairo_t *cairo, const LEGlyphID *glyphs, le_int32 glyphCount, const float *positions,
101 				   le_int32 x, le_int32 y) const;
102 };
103 
getWidget()104 inline GtkWidget *GnomeSurface::getWidget() const
105 {
106     return fWidget;
107 }
108 
setWidget(GtkWidget * theWidget)109 inline void GnomeSurface::setWidget(GtkWidget *theWidget)
110 {
111     fWidget = theWidget;
112 }
113 
114 /*
115 inline FT_Instance GnomeFontInstance::getFont() const
116 {
117     return fInstance;
118 }
119 */
120 
getUnitsPerEM()121 inline le_int32 GnomeFontInstance::getUnitsPerEM() const
122 {
123     return fUnitsPerEM;
124 }
125 
getAscent()126 inline le_int32 GnomeFontInstance::getAscent() const
127 {
128     return fAscent;
129 }
130 
getDescent()131 inline le_int32 GnomeFontInstance::getDescent() const
132 {
133     return fDescent;
134 }
135 
getLeading()136 inline le_int32 GnomeFontInstance::getLeading() const
137 {
138     return fLeading;
139 }
140 
mapCharToGlyph(LEUnicode32 ch)141 inline LEGlyphID GnomeFontInstance::mapCharToGlyph(LEUnicode32 ch) const
142 {
143     return fMapper->unicodeToGlyph(ch);
144 }
145 
getXPixelsPerEm()146 inline float GnomeFontInstance::getXPixelsPerEm() const
147 {
148     return (float) fPointSize;
149 }
150 
getYPixelsPerEm()151 inline float GnomeFontInstance::getYPixelsPerEm() const
152 {
153     return  (float) fPointSize;
154 }
155 
getScaleFactorX()156 inline float GnomeFontInstance::getScaleFactorX() const
157 {
158     return fDeviceScaleX;
159 }
160 
getScaleFactorY()161 inline float GnomeFontInstance::getScaleFactorY() const
162 {
163     return fDeviceScaleY;
164 }
165 
166 #endif
167