]> git.saurik.com Git - apple/icu.git/blob - icuSources/layout/GlyphPositionAdjustments.h
ICU-8.11.1.tar.gz
[apple/icu.git] / icuSources / layout / GlyphPositionAdjustments.h
1 /*
2 *
3 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
4 *
5 */
6
7 #ifndef __GLYPHPOSITIONADJUSTMENTS_H
8 #define __GLYPHPOSITIONADJUSTMENTS_H
9
10 /**
11 * \file
12 * \internal
13 */
14
15 #include "LETypes.h"
16 #include "OpenTypeTables.h"
17
18 U_NAMESPACE_BEGIN
19
20 class LEGlyphStorage;
21 class LEFontInstance;
22
23 class GlyphPositionAdjustments : public UMemory
24 {
25 private:
26 class Adjustment : public UMemory {
27 public:
28
29 inline Adjustment();
30 inline Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff = -1);
31 inline ~Adjustment();
32
33 inline float getXPlacement() const;
34 inline float getYPlacement() const;
35 inline float getXAdvance() const;
36 inline float getYAdvance() const;
37
38 inline le_int32 getBaseOffset() const;
39
40 inline void setXPlacement(float newXPlacement);
41 inline void setYPlacement(float newYPlacement);
42 inline void setXAdvance(float newXAdvance);
43 inline void setYAdvance(float newYAdvance);
44
45 inline void setBaseOffset(le_int32 newBaseOffset);
46
47 inline void adjustXPlacement(float xAdjustment);
48 inline void adjustYPlacement(float yAdjustment);
49 inline void adjustXAdvance(float xAdjustment);
50 inline void adjustYAdvance(float yAdjustment);
51
52 private:
53 float xPlacement;
54 float yPlacement;
55 float xAdvance;
56 float yAdvance;
57
58 le_int32 baseOffset;
59
60 // allow copying of this class because all of its fields are simple types
61 };
62
63 class EntryExitPoint : public UMemory
64 {
65 public:
66 inline EntryExitPoint();
67 inline ~EntryExitPoint();
68
69 inline le_bool isCursiveGlyph() const;
70 inline le_bool baselineIsLogicalEnd() const;
71
72 LEPoint *getEntryPoint(LEPoint &entryPoint) const;
73 LEPoint *getExitPoint(LEPoint &exitPoint) const;
74
75 inline void setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
76 inline void setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
77 inline void setCursiveGlyph(le_bool baselineIsLogicalEnd);
78
79 private:
80 enum EntryExitFlags
81 {
82 EEF_HAS_ENTRY_POINT = 0x80000000L,
83 EEF_HAS_EXIT_POINT = 0x40000000L,
84 EEF_IS_CURSIVE_GLYPH = 0x20000000L,
85 EEF_BASELINE_IS_LOGICAL_END = 0x10000000L
86 };
87
88 le_uint32 fFlags;
89 LEPoint fEntryPoint;
90 LEPoint fExitPoint;
91 };
92
93 le_int32 fGlyphCount;
94 EntryExitPoint *fEntryExitPoints;
95 Adjustment *fAdjustments;
96
97 GlyphPositionAdjustments();
98
99 public:
100 GlyphPositionAdjustments(le_int32 glyphCount);
101 ~GlyphPositionAdjustments();
102
103 inline le_bool hasCursiveGlyphs() const;
104 inline le_bool isCursiveGlyph(le_int32 index) const;
105 inline le_bool baselineIsLogicalEnd(le_int32 index) const;
106
107 const LEPoint *getEntryPoint(le_int32 index, LEPoint &entryPoint) const;
108 const LEPoint *getExitPoint(le_int32 index, LEPoint &exitPoint) const;
109
110 inline float getXPlacement(le_int32 index) const;
111 inline float getYPlacement(le_int32 index) const;
112 inline float getXAdvance(le_int32 index) const;
113 inline float getYAdvance(le_int32 index) const;
114
115 inline le_int32 getBaseOffset(le_int32 index) const;
116
117 inline void setXPlacement(le_int32 index, float newXPlacement);
118 inline void setYPlacement(le_int32 index, float newYPlacement);
119 inline void setXAdvance(le_int32 index, float newXAdvance);
120 inline void setYAdvance(le_int32 index, float newYAdvance);
121
122 inline void setBaseOffset(le_int32 index, le_int32 newBaseOffset);
123
124 inline void adjustXPlacement(le_int32 index, float xAdjustment);
125 inline void adjustYPlacement(le_int32 index, float yAdjustment);
126 inline void adjustXAdvance(le_int32 index, float xAdjustment);
127 inline void adjustYAdvance(le_int32 index, float yAdjustment);
128
129 void setEntryPoint(le_int32 index, LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
130 void setExitPoint(le_int32 index, LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
131 void setCursiveGlyph(le_int32 index, le_bool baselineIsLogicalEnd);
132
133 void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft, const LEFontInstance *fontInstance);
134 };
135
136 inline GlyphPositionAdjustments::Adjustment::Adjustment()
137 : xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0), baseOffset(-1)
138 {
139 // nothing else to do!
140 }
141
142 inline GlyphPositionAdjustments::Adjustment::Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff)
143 : xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv), baseOffset(baseOff)
144 {
145 // nothing else to do!
146 }
147
148 inline GlyphPositionAdjustments::Adjustment::~Adjustment()
149 {
150 // nothing to do!
151 }
152
153 inline float GlyphPositionAdjustments::Adjustment::getXPlacement() const
154 {
155 return xPlacement;
156 }
157
158 inline float GlyphPositionAdjustments::Adjustment::getYPlacement() const
159 {
160 return yPlacement;
161 }
162
163 inline float GlyphPositionAdjustments::Adjustment::getXAdvance() const
164 {
165 return xAdvance;
166 }
167
168 inline float GlyphPositionAdjustments::Adjustment::getYAdvance() const
169 {
170 return yAdvance;
171 }
172
173 inline le_int32 GlyphPositionAdjustments::Adjustment::getBaseOffset() const
174 {
175 return baseOffset;
176 }
177
178 inline void GlyphPositionAdjustments::Adjustment::setXPlacement(float newXPlacement)
179 {
180 xPlacement = newXPlacement;
181 }
182
183 inline void GlyphPositionAdjustments::Adjustment::setYPlacement(float newYPlacement)
184 {
185 yPlacement = newYPlacement;
186 }
187
188 inline void GlyphPositionAdjustments::Adjustment::setXAdvance(float newXAdvance)
189 {
190 xAdvance = newXAdvance;
191 }
192
193 inline void GlyphPositionAdjustments::Adjustment::setYAdvance(float newYAdvance)
194 {
195 yAdvance = newYAdvance;
196 }
197
198 inline void GlyphPositionAdjustments::Adjustment::setBaseOffset(le_int32 newBaseOffset)
199 {
200 baseOffset = newBaseOffset;
201 }
202
203 inline void GlyphPositionAdjustments::Adjustment::adjustXPlacement(float xAdjustment)
204 {
205 xPlacement += xAdjustment;
206 }
207
208 inline void GlyphPositionAdjustments::Adjustment::adjustYPlacement(float yAdjustment)
209 {
210 yPlacement += yAdjustment;
211 }
212
213 inline void GlyphPositionAdjustments::Adjustment::adjustXAdvance(float xAdjustment)
214 {
215 xAdvance += xAdjustment;
216 }
217
218 inline void GlyphPositionAdjustments::Adjustment::adjustYAdvance(float yAdjustment)
219 {
220 yAdvance += yAdjustment;
221 }
222
223 inline GlyphPositionAdjustments::EntryExitPoint::EntryExitPoint()
224 : fFlags(0)
225 {
226 fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fExitPoint.fY = 0;
227 }
228
229 inline GlyphPositionAdjustments::EntryExitPoint::~EntryExitPoint()
230 {
231 // nothing special to do
232 }
233
234 inline le_bool GlyphPositionAdjustments::EntryExitPoint::isCursiveGlyph() const
235 {
236 return (fFlags & EEF_IS_CURSIVE_GLYPH) != 0;
237 }
238
239 inline le_bool GlyphPositionAdjustments::EntryExitPoint::baselineIsLogicalEnd() const
240 {
241 return (fFlags & EEF_BASELINE_IS_LOGICAL_END) != 0;
242 }
243
244 inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)
245 {
246 if (baselineIsLogicalEnd) {
247 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
248 } else {
249 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH);
250 }
251
252 fEntryPoint = newEntryPoint;
253 }
254
255 inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)
256 {
257 if (baselineIsLogicalEnd) {
258 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
259 } else {
260 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH);
261 }
262
263 fExitPoint = newExitPoint;
264 }
265
266 inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(le_bool baselineIsLogicalEnd)
267 {
268 if (baselineIsLogicalEnd) {
269 fFlags |= (EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
270 } else {
271 fFlags |= EEF_IS_CURSIVE_GLYPH;
272 }
273 }
274
275 inline le_bool GlyphPositionAdjustments::isCursiveGlyph(le_int32 index) const
276 {
277 return fEntryExitPoints != NULL && fEntryExitPoints[index].isCursiveGlyph();
278 }
279
280 inline le_bool GlyphPositionAdjustments::baselineIsLogicalEnd(le_int32 index) const
281 {
282 return fEntryExitPoints != NULL && fEntryExitPoints[index].baselineIsLogicalEnd();
283 }
284
285 inline float GlyphPositionAdjustments::getXPlacement(le_int32 index) const
286 {
287 return fAdjustments[index].getXPlacement();
288 }
289
290 inline float GlyphPositionAdjustments::getYPlacement(le_int32 index) const
291 {
292 return fAdjustments[index].getYPlacement();
293 }
294
295 inline float GlyphPositionAdjustments::getXAdvance(le_int32 index) const
296 {
297 return fAdjustments[index].getXAdvance();
298 }
299
300 inline float GlyphPositionAdjustments::getYAdvance(le_int32 index) const
301 {
302 return fAdjustments[index].getYAdvance();
303 }
304
305
306 inline le_int32 GlyphPositionAdjustments::getBaseOffset(le_int32 index) const
307 {
308 return fAdjustments[index].getBaseOffset();
309 }
310
311 inline void GlyphPositionAdjustments::setXPlacement(le_int32 index, float newXPlacement)
312 {
313 fAdjustments[index].setXPlacement(newXPlacement);
314 }
315
316 inline void GlyphPositionAdjustments::setYPlacement(le_int32 index, float newYPlacement)
317 {
318 fAdjustments[index].setYPlacement(newYPlacement);
319 }
320
321 inline void GlyphPositionAdjustments::setXAdvance(le_int32 index, float newXAdvance)
322 {
323 fAdjustments[index].setXAdvance(newXAdvance);
324 }
325
326 inline void GlyphPositionAdjustments::setYAdvance(le_int32 index, float newYAdvance)
327 {
328 fAdjustments[index].setYAdvance(newYAdvance);
329 }
330
331 inline void GlyphPositionAdjustments::setBaseOffset(le_int32 index, le_int32 newBaseOffset)
332 {
333 fAdjustments[index].setBaseOffset(newBaseOffset);
334 }
335
336 inline void GlyphPositionAdjustments::adjustXPlacement(le_int32 index, float xAdjustment)
337 {
338 fAdjustments[index].adjustXPlacement(xAdjustment);
339 }
340
341 inline void GlyphPositionAdjustments::adjustYPlacement(le_int32 index, float yAdjustment)
342 {
343 fAdjustments[index].adjustYPlacement(yAdjustment);
344 }
345
346 inline void GlyphPositionAdjustments::adjustXAdvance(le_int32 index, float xAdjustment)
347 {
348 fAdjustments[index].adjustXAdvance(xAdjustment);
349 }
350
351 inline void GlyphPositionAdjustments::adjustYAdvance(le_int32 index, float yAdjustment)
352 {
353 fAdjustments[index].adjustYAdvance(yAdjustment);
354 }
355
356 inline le_bool GlyphPositionAdjustments::hasCursiveGlyphs() const
357 {
358 return fEntryExitPoints != NULL;
359 }
360
361 U_NAMESPACE_END
362 #endif