os/textandloc/fontservices/textshaperplugin/IcuSource/layout/GlyphPositionAdjustments.h
First public contribution.
3 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
7 #ifndef __GLYPHPOSITIONADJUSTMENTS_H
8 #define __GLYPHPOSITIONADJUSTMENTS_H
16 #include "OpenTypeTables.h"
23 class GlyphPositionAdjustments : public UMemory
26 class Adjustment : public UMemory {
30 inline Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff = -1);
33 inline float getXPlacement() const;
34 inline float getYPlacement() const;
35 inline float getXAdvance() const;
36 inline float getYAdvance() const;
38 inline le_int32 getBaseOffset() const;
40 inline void setXPlacement(float newXPlacement);
41 inline void setYPlacement(float newYPlacement);
42 inline void setXAdvance(float newXAdvance);
43 inline void setYAdvance(float newYAdvance);
45 inline void setBaseOffset(le_int32 newBaseOffset);
47 inline void adjustXPlacement(float xAdjustment);
48 inline void adjustYPlacement(float yAdjustment);
49 inline void adjustXAdvance(float xAdjustment);
50 inline void adjustYAdvance(float yAdjustment);
60 // allow copying of this class because all of its fields are simple types
63 class EntryExitPoint : public UMemory
66 inline EntryExitPoint();
67 inline ~EntryExitPoint();
69 inline le_bool isCursiveGlyph() const;
70 inline le_bool baselineIsLogicalEnd() const;
72 LEPoint *getEntryPoint(LEPoint &entryPoint) const;
73 LEPoint *getExitPoint(LEPoint &exitPoint) const;
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);
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
94 EntryExitPoint *fEntryExitPoints;
95 Adjustment *fAdjustments;
97 GlyphPositionAdjustments();
100 GlyphPositionAdjustments(le_int32 glyphCount);
101 ~GlyphPositionAdjustments();
103 inline le_bool hasCursiveGlyphs() const;
104 inline le_bool isCursiveGlyph(le_int32 index) const;
105 inline le_bool baselineIsLogicalEnd(le_int32 index) const;
107 const LEPoint *getEntryPoint(le_int32 index, LEPoint &entryPoint) const;
108 const LEPoint *getExitPoint(le_int32 index, LEPoint &exitPoint) const;
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;
115 inline le_int32 getBaseOffset(le_int32 index) const;
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);
122 inline void setBaseOffset(le_int32 index, le_int32 newBaseOffset);
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);
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);
133 void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft, const LEFontInstance *fontInstance);
136 inline GlyphPositionAdjustments::Adjustment::Adjustment()
137 : xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0), baseOffset(-1)
139 // nothing else to do!
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)
145 // nothing else to do!
148 inline GlyphPositionAdjustments::Adjustment::~Adjustment()
153 inline float GlyphPositionAdjustments::Adjustment::getXPlacement() const
158 inline float GlyphPositionAdjustments::Adjustment::getYPlacement() const
163 inline float GlyphPositionAdjustments::Adjustment::getXAdvance() const
168 inline float GlyphPositionAdjustments::Adjustment::getYAdvance() const
173 inline le_int32 GlyphPositionAdjustments::Adjustment::getBaseOffset() const
178 inline void GlyphPositionAdjustments::Adjustment::setXPlacement(float newXPlacement)
180 xPlacement = newXPlacement;
183 inline void GlyphPositionAdjustments::Adjustment::setYPlacement(float newYPlacement)
185 yPlacement = newYPlacement;
188 inline void GlyphPositionAdjustments::Adjustment::setXAdvance(float newXAdvance)
190 xAdvance = newXAdvance;
193 inline void GlyphPositionAdjustments::Adjustment::setYAdvance(float newYAdvance)
195 yAdvance = newYAdvance;
198 inline void GlyphPositionAdjustments::Adjustment::setBaseOffset(le_int32 newBaseOffset)
200 baseOffset = newBaseOffset;
203 inline void GlyphPositionAdjustments::Adjustment::adjustXPlacement(float xAdjustment)
205 xPlacement += xAdjustment;
208 inline void GlyphPositionAdjustments::Adjustment::adjustYPlacement(float yAdjustment)
210 yPlacement += yAdjustment;
213 inline void GlyphPositionAdjustments::Adjustment::adjustXAdvance(float xAdjustment)
215 xAdvance += xAdjustment;
218 inline void GlyphPositionAdjustments::Adjustment::adjustYAdvance(float yAdjustment)
220 yAdvance += yAdjustment;
223 inline GlyphPositionAdjustments::EntryExitPoint::EntryExitPoint()
226 fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fEntryPoint.fY = 0;
229 inline GlyphPositionAdjustments::EntryExitPoint::~EntryExitPoint()
231 // nothing special to do
234 inline le_bool GlyphPositionAdjustments::EntryExitPoint::isCursiveGlyph() const
236 return (fFlags & EEF_IS_CURSIVE_GLYPH) != 0;
239 inline le_bool GlyphPositionAdjustments::EntryExitPoint::baselineIsLogicalEnd() const
241 return (fFlags & EEF_BASELINE_IS_LOGICAL_END) != 0;
244 inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)
246 if (baselineIsLogicalEnd) {
247 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
249 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH);
252 fEntryPoint = newEntryPoint;
255 inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)
257 if (baselineIsLogicalEnd) {
258 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
260 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH);
263 fExitPoint = newExitPoint;
266 inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(le_bool baselineIsLogicalEnd)
268 if (baselineIsLogicalEnd) {
269 fFlags |= (EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
271 fFlags |= EEF_IS_CURSIVE_GLYPH;
275 inline le_bool GlyphPositionAdjustments::isCursiveGlyph(le_int32 index) const
277 return fEntryExitPoints != NULL && fEntryExitPoints[index].isCursiveGlyph();
280 inline le_bool GlyphPositionAdjustments::baselineIsLogicalEnd(le_int32 index) const
282 return fEntryExitPoints != NULL && fEntryExitPoints[index].baselineIsLogicalEnd();
285 inline float GlyphPositionAdjustments::getXPlacement(le_int32 index) const
287 return fAdjustments[index].getXPlacement();
290 inline float GlyphPositionAdjustments::getYPlacement(le_int32 index) const
292 return fAdjustments[index].getYPlacement();
295 inline float GlyphPositionAdjustments::getXAdvance(le_int32 index) const
297 return fAdjustments[index].getXAdvance();
300 inline float GlyphPositionAdjustments::getYAdvance(le_int32 index) const
302 return fAdjustments[index].getYAdvance();
306 inline le_int32 GlyphPositionAdjustments::getBaseOffset(le_int32 index) const
308 return fAdjustments[index].getBaseOffset();
311 inline void GlyphPositionAdjustments::setXPlacement(le_int32 index, float newXPlacement)
313 fAdjustments[index].setXPlacement(newXPlacement);
316 inline void GlyphPositionAdjustments::setYPlacement(le_int32 index, float newYPlacement)
318 fAdjustments[index].setYPlacement(newYPlacement);
321 inline void GlyphPositionAdjustments::setXAdvance(le_int32 index, float newXAdvance)
323 fAdjustments[index].setXAdvance(newXAdvance);
326 inline void GlyphPositionAdjustments::setYAdvance(le_int32 index, float newYAdvance)
328 fAdjustments[index].setYAdvance(newYAdvance);
331 inline void GlyphPositionAdjustments::setBaseOffset(le_int32 index, le_int32 newBaseOffset)
333 fAdjustments[index].setBaseOffset(newBaseOffset);
336 inline void GlyphPositionAdjustments::adjustXPlacement(le_int32 index, float xAdjustment)
338 fAdjustments[index].adjustXPlacement(xAdjustment);
341 inline void GlyphPositionAdjustments::adjustYPlacement(le_int32 index, float yAdjustment)
343 fAdjustments[index].adjustYPlacement(yAdjustment);
346 inline void GlyphPositionAdjustments::adjustXAdvance(le_int32 index, float xAdjustment)
348 fAdjustments[index].adjustXAdvance(xAdjustment);
351 inline void GlyphPositionAdjustments::adjustYAdvance(le_int32 index, float yAdjustment)
353 fAdjustments[index].adjustYAdvance(yAdjustment);
356 inline le_bool GlyphPositionAdjustments::hasCursiveGlyphs() const
358 return fEntryExitPoints != NULL;