]> git.saurik.com Git - apple/icu.git/blame - icuSources/samples/layout/GnomeFontInstance.h
ICU-531.48.tar.gz
[apple/icu.git] / icuSources / samples / layout / GnomeFontInstance.h
CommitLineData
b75a7d8f
A
1
2/*
3 *******************************************************************************
4 *
46f4442e 5 * Copyright (C) 1999-2006, International Business Machines
b75a7d8f
A
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>
46f4442e
A
19#include <ft2build.h>
20#include FT_FREETYPE_H
21#include FT_GLYPH_H
22#include <cairo.h>
b75a7d8f
A
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
31class GnomeSurface : public RenderingSurface
32{
33public:
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
43private:
44 GtkWidget *fWidget;
46f4442e 45 cairo_t *fCairo;
b75a7d8f
A
46};
47
48class GnomeFontInstance : public LEFontInstance, protected FontTableCache
49{
50 protected:
46f4442e
A
51 FT_Face fFace;
52// FT_Glyph fGlyph;
53
54 cairo_font_face_t *fCairoFace;
b75a7d8f
A
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:
46f4442e 72 GnomeFontInstance(FT_Library engine, const char *fontPathName, le_int16 pointSize, LEErrorCode &status);
b75a7d8f
A
73
74 virtual ~GnomeFontInstance();
75
b75a7d8f
A
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
46f4442e
A
100 void rasterizeGlyphs(cairo_t *cairo, const LEGlyphID *glyphs, le_int32 glyphCount, const float *positions,
101 le_int32 x, le_int32 y) const;
b75a7d8f
A
102};
103
104inline GtkWidget *GnomeSurface::getWidget() const
105{
106 return fWidget;
107}
108
109inline void GnomeSurface::setWidget(GtkWidget *theWidget)
110{
111 fWidget = theWidget;
112}
113
46f4442e
A
114/*
115inline FT_Instance GnomeFontInstance::getFont() const
b75a7d8f
A
116{
117 return fInstance;
118}
46f4442e 119*/
b75a7d8f
A
120
121inline le_int32 GnomeFontInstance::getUnitsPerEM() const
122{
123 return fUnitsPerEM;
124}
125
126inline le_int32 GnomeFontInstance::getAscent() const
127{
128 return fAscent;
129}
130
131inline le_int32 GnomeFontInstance::getDescent() const
132{
133 return fDescent;
134}
135
136inline le_int32 GnomeFontInstance::getLeading() const
137{
138 return fLeading;
139}
140
141inline LEGlyphID GnomeFontInstance::mapCharToGlyph(LEUnicode32 ch) const
142{
143 return fMapper->unicodeToGlyph(ch);
144}
145
146inline float GnomeFontInstance::getXPixelsPerEm() const
147{
148 return (float) fPointSize;
149}
150
151inline float GnomeFontInstance::getYPixelsPerEm() const
152{
153 return (float) fPointSize;
154}
155
156inline float GnomeFontInstance::getScaleFactorX() const
157{
158 return fDeviceScaleX;
159}
160
161inline float GnomeFontInstance::getScaleFactorY() const
162{
163 return fDeviceScaleY;
164}
165
166#endif