15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 /*
27 *
28 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
29 *
30 */
31
32 #ifndef __GLYPHPOSITIONADJUSTMENTS_H
33 #define __GLYPHPOSITIONADJUSTMENTS_H
34
35 #include "LETypes.h"
36 #include "OpenTypeTables.h"
37
38 class LEGlyphStorage;
39 class LEFontInstance;
40
41 class GlyphPositionAdjustments
42 {
43 private:
44 class Adjustment {
45 public:
46
47 inline Adjustment();
48 inline Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff = -1);
49 inline ~Adjustment();
50
51 inline float getXPlacement() const;
52 inline float getYPlacement() const;
53 inline float getXAdvance() const;
54 inline float getYAdvance() const;
55
56 inline le_int32 getBaseOffset() const;
57
58 inline void setXPlacement(float newXPlacement);
59 inline void setYPlacement(float newYPlacement);
60 inline void setXAdvance(float newXAdvance);
61 inline void setYAdvance(float newYAdvance);
62
63 inline void setBaseOffset(le_int32 newBaseOffset);
64
65 inline void adjustXPlacement(float xAdjustment);
66 inline void adjustYPlacement(float yAdjustment);
67 inline void adjustXAdvance(float xAdjustment);
68 inline void adjustYAdvance(float yAdjustment);
69
70 private:
71 float xPlacement;
72 float yPlacement;
73 float xAdvance;
74 float yAdvance;
75
76 le_int32 baseOffset;
77
78 // allow copying of this class because all of its fields are simple types
79 };
80
81 class EntryExitPoint
82 {
83 public:
84 inline EntryExitPoint();
85 inline ~EntryExitPoint();
86
87 inline le_bool isCursiveGlyph() const;
88 inline le_bool baselineIsLogicalEnd() const;
89
90 LEPoint *getEntryPoint(LEPoint &entryPoint) const;
91 LEPoint *getExitPoint(LEPoint &exitPoint) const;
92
93 inline void setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
94 inline void setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
95 inline void setCursiveGlyph(le_bool baselineIsLogicalEnd);
96
97 private:
98 enum EntryExitFlags
99 {
100 EEF_HAS_ENTRY_POINT = 0x80000000L,
101 EEF_HAS_EXIT_POINT = 0x40000000L,
102 EEF_IS_CURSIVE_GLYPH = 0x20000000L,
103 EEF_BASELINE_IS_LOGICAL_END = 0x10000000L
104 };
105
106 le_uint32 fFlags;
107 LEPoint fEntryPoint;
108 LEPoint fExitPoint;
109 };
110
111 le_int32 fGlyphCount;
112 EntryExitPoint *fEntryExitPoints;
127
128 inline float getXPlacement(le_int32 index) const;
129 inline float getYPlacement(le_int32 index) const;
130 inline float getXAdvance(le_int32 index) const;
131 inline float getYAdvance(le_int32 index) const;
132
133 inline le_int32 getBaseOffset(le_int32 index) const;
134
135 inline void setXPlacement(le_int32 index, float newXPlacement);
136 inline void setYPlacement(le_int32 index, float newYPlacement);
137 inline void setXAdvance(le_int32 index, float newXAdvance);
138 inline void setYAdvance(le_int32 index, float newYAdvance);
139
140 inline void setBaseOffset(le_int32 index, le_int32 newBaseOffset);
141
142 inline void adjustXPlacement(le_int32 index, float xAdjustment);
143 inline void adjustYPlacement(le_int32 index, float yAdjustment);
144 inline void adjustXAdvance(le_int32 index, float xAdjustment);
145 inline void adjustYAdvance(le_int32 index, float yAdjustment);
146
147 void setEntryPoint(le_int32 index, LEPoint &newEntryPoint,
148 le_bool baselineIsLogicalEnd);
149 void setExitPoint(le_int32 index, LEPoint &newExitPoint,
150 le_bool baselineIsLogicalEnd);
151 void setCursiveGlyph(le_int32 index, le_bool baselineIsLogicalEnd);
152
153 void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft,
154 const LEFontInstance *fontInstance);
155 };
156
157 inline GlyphPositionAdjustments::Adjustment::Adjustment()
158 : xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0), baseOffset(-1)
159 {
160 // nothing else to do!
161 }
162
163 inline GlyphPositionAdjustments::Adjustment::Adjustment(float xPlace, float yPlace,
164 float xAdv, float yAdv, le_int32 baseOff)
165 : xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv),
166 baseOffset(baseOff)
167 {
168 // nothing else to do!
169 }
170
171 inline GlyphPositionAdjustments::Adjustment::~Adjustment()
172 {
173 // nothing to do!
174 }
175
176 inline float GlyphPositionAdjustments::Adjustment::getXPlacement() const
177 {
178 return xPlacement;
179 }
180
181 inline float GlyphPositionAdjustments::Adjustment::getYPlacement() const
182 {
183 return yPlacement;
184 }
185
186 inline float GlyphPositionAdjustments::Adjustment::getXAdvance() const
229 }
230
231 inline void GlyphPositionAdjustments::Adjustment::adjustYPlacement(float yAdjustment)
232 {
233 yPlacement += yAdjustment;
234 }
235
236 inline void GlyphPositionAdjustments::Adjustment::adjustXAdvance(float xAdjustment)
237 {
238 xAdvance += xAdjustment;
239 }
240
241 inline void GlyphPositionAdjustments::Adjustment::adjustYAdvance(float yAdjustment)
242 {
243 yAdvance += yAdjustment;
244 }
245
246 inline GlyphPositionAdjustments::EntryExitPoint::EntryExitPoint()
247 : fFlags(0)
248 {
249 fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fEntryPoint.fY = 0;
250 }
251
252 inline GlyphPositionAdjustments::EntryExitPoint::~EntryExitPoint()
253 {
254 // nothing special to do
255 }
256
257 inline le_bool GlyphPositionAdjustments::EntryExitPoint::isCursiveGlyph() const
258 {
259 return (fFlags & EEF_IS_CURSIVE_GLYPH) != 0;
260 }
261
262 inline le_bool GlyphPositionAdjustments::EntryExitPoint::baselineIsLogicalEnd() const
263 {
264 return (fFlags & EEF_BASELINE_IS_LOGICAL_END) != 0;
265 }
266
267 inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(
268 LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)
269 {
270 if (baselineIsLogicalEnd) {
271 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH |
272 EEF_BASELINE_IS_LOGICAL_END);
273 } else {
274 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH);
275 }
276
277 fEntryPoint = newEntryPoint;
278 }
279
280 inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(
281 LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)
282 {
283 if (baselineIsLogicalEnd) {
284 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH |
285 EEF_BASELINE_IS_LOGICAL_END);
286 } else {
287 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH);
288 }
289
290 fExitPoint = newExitPoint;
291 }
292
293 inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(
294 le_bool baselineIsLogicalEnd)
295 {
296 if (baselineIsLogicalEnd) {
297 fFlags |= (EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
298 } else {
299 fFlags |= EEF_IS_CURSIVE_GLYPH;
300 }
301 }
302
303 inline le_bool GlyphPositionAdjustments::isCursiveGlyph(le_int32 index) const
304 {
305 return fEntryExitPoints != NULL && fEntryExitPoints[index].isCursiveGlyph();
306 }
307
308 inline le_bool GlyphPositionAdjustments::baselineIsLogicalEnd(le_int32 index) const
309 {
310 return fEntryExitPoints != NULL && fEntryExitPoints[index].baselineIsLogicalEnd();
311 }
312
313 inline float GlyphPositionAdjustments::getXPlacement(le_int32 index) const
314 {
369 inline void GlyphPositionAdjustments::adjustYPlacement(le_int32 index, float yAdjustment)
370 {
371 fAdjustments[index].adjustYPlacement(yAdjustment);
372 }
373
374 inline void GlyphPositionAdjustments::adjustXAdvance(le_int32 index, float xAdjustment)
375 {
376 fAdjustments[index].adjustXAdvance(xAdjustment);
377 }
378
379 inline void GlyphPositionAdjustments::adjustYAdvance(le_int32 index, float yAdjustment)
380 {
381 fAdjustments[index].adjustYAdvance(yAdjustment);
382 }
383
384 inline le_bool GlyphPositionAdjustments::hasCursiveGlyphs() const
385 {
386 return fEntryExitPoints != NULL;
387 }
388
389 #endif
|
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 /*
27 *
28 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
29 *
30 */
31
32 #ifndef __GLYPHPOSITIONADJUSTMENTS_H
33 #define __GLYPHPOSITIONADJUSTMENTS_H
34
35 /**
36 * \file
37 * \internal
38 */
39
40 #include "LETypes.h"
41 #include "OpenTypeTables.h"
42
43 U_NAMESPACE_BEGIN
44
45 class LEGlyphStorage;
46 class LEFontInstance;
47
48 class GlyphPositionAdjustments : public UMemory
49 {
50 private:
51 class Adjustment : public UMemory {
52 public:
53
54 inline Adjustment();
55 inline Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff = -1);
56 inline ~Adjustment();
57
58 inline float getXPlacement() const;
59 inline float getYPlacement() const;
60 inline float getXAdvance() const;
61 inline float getYAdvance() const;
62
63 inline le_int32 getBaseOffset() const;
64
65 inline void setXPlacement(float newXPlacement);
66 inline void setYPlacement(float newYPlacement);
67 inline void setXAdvance(float newXAdvance);
68 inline void setYAdvance(float newYAdvance);
69
70 inline void setBaseOffset(le_int32 newBaseOffset);
71
72 inline void adjustXPlacement(float xAdjustment);
73 inline void adjustYPlacement(float yAdjustment);
74 inline void adjustXAdvance(float xAdjustment);
75 inline void adjustYAdvance(float yAdjustment);
76
77 private:
78 float xPlacement;
79 float yPlacement;
80 float xAdvance;
81 float yAdvance;
82
83 le_int32 baseOffset;
84
85 // allow copying of this class because all of its fields are simple types
86 };
87
88 class EntryExitPoint : public UMemory
89 {
90 public:
91 inline EntryExitPoint();
92 inline ~EntryExitPoint();
93
94 inline le_bool isCursiveGlyph() const;
95 inline le_bool baselineIsLogicalEnd() const;
96
97 LEPoint *getEntryPoint(LEPoint &entryPoint) const;
98 LEPoint *getExitPoint(LEPoint &exitPoint) const;
99
100 inline void clearEntryPoint();
101 inline void clearExitPoint();
102 inline void setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
103 inline void setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
104 inline void setCursiveGlyph(le_bool baselineIsLogicalEnd);
105
106 private:
107 enum EntryExitFlags
108 {
109 EEF_HAS_ENTRY_POINT = 0x80000000L,
110 EEF_HAS_EXIT_POINT = 0x40000000L,
111 EEF_IS_CURSIVE_GLYPH = 0x20000000L,
112 EEF_BASELINE_IS_LOGICAL_END = 0x10000000L
113 };
114
115 le_uint32 fFlags;
116 LEPoint fEntryPoint;
117 LEPoint fExitPoint;
118 };
119
120 le_int32 fGlyphCount;
121 EntryExitPoint *fEntryExitPoints;
136
137 inline float getXPlacement(le_int32 index) const;
138 inline float getYPlacement(le_int32 index) const;
139 inline float getXAdvance(le_int32 index) const;
140 inline float getYAdvance(le_int32 index) const;
141
142 inline le_int32 getBaseOffset(le_int32 index) const;
143
144 inline void setXPlacement(le_int32 index, float newXPlacement);
145 inline void setYPlacement(le_int32 index, float newYPlacement);
146 inline void setXAdvance(le_int32 index, float newXAdvance);
147 inline void setYAdvance(le_int32 index, float newYAdvance);
148
149 inline void setBaseOffset(le_int32 index, le_int32 newBaseOffset);
150
151 inline void adjustXPlacement(le_int32 index, float xAdjustment);
152 inline void adjustYPlacement(le_int32 index, float yAdjustment);
153 inline void adjustXAdvance(le_int32 index, float xAdjustment);
154 inline void adjustYAdvance(le_int32 index, float yAdjustment);
155
156 void clearEntryPoint(le_int32 index);
157 void clearExitPoint(le_int32 index);
158 void setEntryPoint(le_int32 index, LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
159 void setExitPoint(le_int32 index, LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
160 void setCursiveGlyph(le_int32 index, le_bool baselineIsLogicalEnd);
161
162 void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft, const LEFontInstance *fontInstance);
163 };
164
165 inline GlyphPositionAdjustments::Adjustment::Adjustment()
166 : xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0), baseOffset(-1)
167 {
168 // nothing else to do!
169 }
170
171 inline GlyphPositionAdjustments::Adjustment::Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff)
172 : xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv), baseOffset(baseOff)
173 {
174 // nothing else to do!
175 }
176
177 inline GlyphPositionAdjustments::Adjustment::~Adjustment()
178 {
179 // nothing to do!
180 }
181
182 inline float GlyphPositionAdjustments::Adjustment::getXPlacement() const
183 {
184 return xPlacement;
185 }
186
187 inline float GlyphPositionAdjustments::Adjustment::getYPlacement() const
188 {
189 return yPlacement;
190 }
191
192 inline float GlyphPositionAdjustments::Adjustment::getXAdvance() const
235 }
236
237 inline void GlyphPositionAdjustments::Adjustment::adjustYPlacement(float yAdjustment)
238 {
239 yPlacement += yAdjustment;
240 }
241
242 inline void GlyphPositionAdjustments::Adjustment::adjustXAdvance(float xAdjustment)
243 {
244 xAdvance += xAdjustment;
245 }
246
247 inline void GlyphPositionAdjustments::Adjustment::adjustYAdvance(float yAdjustment)
248 {
249 yAdvance += yAdjustment;
250 }
251
252 inline GlyphPositionAdjustments::EntryExitPoint::EntryExitPoint()
253 : fFlags(0)
254 {
255 fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fExitPoint.fY = 0;
256 }
257
258 inline GlyphPositionAdjustments::EntryExitPoint::~EntryExitPoint()
259 {
260 // nothing special to do
261 }
262
263 inline le_bool GlyphPositionAdjustments::EntryExitPoint::isCursiveGlyph() const
264 {
265 return (fFlags & EEF_IS_CURSIVE_GLYPH) != 0;
266 }
267
268 inline le_bool GlyphPositionAdjustments::EntryExitPoint::baselineIsLogicalEnd() const
269 {
270 return (fFlags & EEF_BASELINE_IS_LOGICAL_END) != 0;
271 }
272
273 inline void GlyphPositionAdjustments::EntryExitPoint::clearEntryPoint()
274 {
275 fFlags &= ~EEF_HAS_ENTRY_POINT;
276 }
277
278 inline void GlyphPositionAdjustments::EntryExitPoint::clearExitPoint()
279 {
280 fFlags &= ~EEF_HAS_EXIT_POINT;
281 }
282
283 inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)
284 {
285 if (baselineIsLogicalEnd) {
286 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
287 } else {
288 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH);
289 }
290
291 fEntryPoint = newEntryPoint;
292 }
293
294 inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)
295 {
296 if (baselineIsLogicalEnd) {
297 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
298 } else {
299 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH);
300 }
301
302 fExitPoint = newExitPoint;
303 }
304
305 inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(le_bool baselineIsLogicalEnd)
306 {
307 if (baselineIsLogicalEnd) {
308 fFlags |= (EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
309 } else {
310 fFlags |= EEF_IS_CURSIVE_GLYPH;
311 }
312 }
313
314 inline le_bool GlyphPositionAdjustments::isCursiveGlyph(le_int32 index) const
315 {
316 return fEntryExitPoints != NULL && fEntryExitPoints[index].isCursiveGlyph();
317 }
318
319 inline le_bool GlyphPositionAdjustments::baselineIsLogicalEnd(le_int32 index) const
320 {
321 return fEntryExitPoints != NULL && fEntryExitPoints[index].baselineIsLogicalEnd();
322 }
323
324 inline float GlyphPositionAdjustments::getXPlacement(le_int32 index) const
325 {
380 inline void GlyphPositionAdjustments::adjustYPlacement(le_int32 index, float yAdjustment)
381 {
382 fAdjustments[index].adjustYPlacement(yAdjustment);
383 }
384
385 inline void GlyphPositionAdjustments::adjustXAdvance(le_int32 index, float xAdjustment)
386 {
387 fAdjustments[index].adjustXAdvance(xAdjustment);
388 }
389
390 inline void GlyphPositionAdjustments::adjustYAdvance(le_int32 index, float yAdjustment)
391 {
392 fAdjustments[index].adjustYAdvance(yAdjustment);
393 }
394
395 inline le_bool GlyphPositionAdjustments::hasCursiveGlyphs() const
396 {
397 return fEntryExitPoints != NULL;
398 }
399
400 U_NAMESPACE_END
401 #endif
|