]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | |
2 | /* | |
3 | ******************************************************************************* | |
4 | * | |
5 | * Copyright (C) 1999-2003, 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 "freetype/freetype.h" | |
20 | ||
21 | #include "layout/LETypes.h" | |
22 | #include "layout/LEFontInstance.h" | |
23 | ||
24 | #include "RenderingSurface.h" | |
25 | #include "FontTableCache.h" | |
26 | #include "cmaps.h" | |
27 | ||
28 | class GnomeSurface : public RenderingSurface | |
29 | { | |
30 | public: | |
31 | GnomeSurface(GtkWidget *theWidget); | |
32 | virtual ~GnomeSurface(); | |
33 | ||
34 | virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, | |
35 | const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height); | |
36 | ||
37 | GtkWidget *getWidget() const; | |
38 | void setWidget(GtkWidget *theWidget); | |
39 | ||
40 | private: | |
41 | GtkWidget *fWidget; | |
42 | }; | |
43 | ||
44 | class GnomeFontInstance : public LEFontInstance, protected FontTableCache | |
45 | { | |
46 | protected: | |
47 | TT_Face fFace; | |
48 | TT_Instance fInstance; | |
49 | TT_Glyph fGlyph; | |
50 | ||
51 | le_int32 fPointSize; | |
52 | le_int32 fUnitsPerEM; | |
53 | le_int32 fAscent; | |
54 | le_int32 fDescent; | |
55 | le_int32 fLeading; | |
56 | ||
57 | float fDeviceScaleX; | |
58 | float fDeviceScaleY; | |
59 | ||
60 | CMAPMapper *fMapper; | |
61 | ||
62 | virtual const void *readFontTable(LETag tableTag) const; | |
63 | ||
64 | virtual LEErrorCode initMapper(); | |
65 | ||
66 | public: | |
67 | GnomeFontInstance(TT_Engine engine, const TT_Text *fontPathName, le_int16 pointSize, LEErrorCode &status); | |
68 | ||
69 | virtual ~GnomeFontInstance(); | |
70 | ||
71 | TT_Instance getFont() const; | |
72 | ||
73 | virtual const void *getFontTable(LETag tableTag) const; | |
74 | ||
75 | virtual le_int32 getUnitsPerEM() const; | |
76 | ||
77 | virtual le_int32 getAscent() const; | |
78 | ||
79 | virtual le_int32 getDescent() const; | |
80 | ||
81 | virtual le_int32 getLeading() const; | |
82 | ||
83 | virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; | |
84 | ||
85 | virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; | |
86 | ||
87 | virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; | |
88 | ||
89 | float getXPixelsPerEm() const; | |
90 | ||
91 | float getYPixelsPerEm() const; | |
92 | ||
93 | float getScaleFactorX() const; | |
94 | ||
95 | float getScaleFactorY() const; | |
96 | ||
97 | TT_Raster_Map *rasterizeGlyphs(const LEGlyphID *glyphs, le_int32 glyphCount, const le_int32 *dx, const le_int32 *dy, | |
98 | le_int32 &xOffset, le_int32 &yOffset) const; | |
99 | ||
100 | void freeRaster(TT_Raster_Map *raster); | |
101 | }; | |
102 | ||
103 | inline GtkWidget *GnomeSurface::getWidget() const | |
104 | { | |
105 | return fWidget; | |
106 | } | |
107 | ||
108 | inline void GnomeSurface::setWidget(GtkWidget *theWidget) | |
109 | { | |
110 | fWidget = theWidget; | |
111 | } | |
112 | ||
113 | inline TT_Instance GnomeFontInstance::getFont() const | |
114 | { | |
115 | return fInstance; | |
116 | } | |
117 | ||
118 | inline le_int32 GnomeFontInstance::getUnitsPerEM() const | |
119 | { | |
120 | return fUnitsPerEM; | |
121 | } | |
122 | ||
123 | inline le_int32 GnomeFontInstance::getAscent() const | |
124 | { | |
125 | return fAscent; | |
126 | } | |
127 | ||
128 | inline le_int32 GnomeFontInstance::getDescent() const | |
129 | { | |
130 | return fDescent; | |
131 | } | |
132 | ||
133 | inline le_int32 GnomeFontInstance::getLeading() const | |
134 | { | |
135 | return fLeading; | |
136 | } | |
137 | ||
138 | inline LEGlyphID GnomeFontInstance::mapCharToGlyph(LEUnicode32 ch) const | |
139 | { | |
140 | return fMapper->unicodeToGlyph(ch); | |
141 | } | |
142 | ||
143 | inline float GnomeFontInstance::getXPixelsPerEm() const | |
144 | { | |
145 | return (float) fPointSize; | |
146 | } | |
147 | ||
148 | inline float GnomeFontInstance::getYPixelsPerEm() const | |
149 | { | |
150 | return (float) fPointSize; | |
151 | } | |
152 | ||
153 | inline float GnomeFontInstance::getScaleFactorX() const | |
154 | { | |
155 | return fDeviceScaleX; | |
156 | } | |
157 | ||
158 | inline float GnomeFontInstance::getScaleFactorY() const | |
159 | { | |
160 | return fDeviceScaleY; | |
161 | } | |
162 | ||
163 | #endif |