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