3 * (C) Copyright IBM Corp. 1998-2007 - 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 clearEntryPoint();
76 inline void clearExitPoint();
77 inline void setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
78 inline void setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
79 inline void setCursiveGlyph(le_bool baselineIsLogicalEnd);
84 EEF_HAS_ENTRY_POINT = 0x80000000L,
85 EEF_HAS_EXIT_POINT = 0x40000000L,
86 EEF_IS_CURSIVE_GLYPH = 0x20000000L,
87 EEF_BASELINE_IS_LOGICAL_END = 0x10000000L
96 EntryExitPoint *fEntryExitPoints;
97 Adjustment *fAdjustments;
99 GlyphPositionAdjustments();
102 GlyphPositionAdjustments(le_int32 glyphCount);
103 ~GlyphPositionAdjustments();
105 inline le_bool hasCursiveGlyphs() const;
106 inline le_bool isCursiveGlyph(le_int32 index) const;
107 inline le_bool baselineIsLogicalEnd(le_int32 index) const;
109 const LEPoint *getEntryPoint(le_int32 index, LEPoint &entryPoint) const;
110 const LEPoint *getExitPoint(le_int32 index, LEPoint &exitPoint) const;
112 inline float getXPlacement(le_int32 index) const;
113 inline float getYPlacement(le_int32 index) const;
114 inline float getXAdvance(le_int32 index) const;
115 inline float getYAdvance(le_int32 index) const;
117 inline le_int32 getBaseOffset(le_int32 index) const;
119 inline void setXPlacement(le_int32 index, float newXPlacement);
120 inline void setYPlacement(le_int32 index, float newYPlacement);
121 inline void setXAdvance(le_int32 index, float newXAdvance);
122 inline void setYAdvance(le_int32 index, float newYAdvance);
124 inline void setBaseOffset(le_int32 index, le_int32 newBaseOffset);
126 inline void adjustXPlacement(le_int32 index, float xAdjustment);
127 inline void adjustYPlacement(le_int32 index, float yAdjustment);
128 inline void adjustXAdvance(le_int32 index, float xAdjustment);
129 inline void adjustYAdvance(le_int32 index, float yAdjustment);
131 void clearEntryPoint(le_int32 index);
132 void clearExitPoint(le_int32 index);
133 void setEntryPoint(le_int32 index, LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
134 void setExitPoint(le_int32 index, LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
135 void setCursiveGlyph(le_int32 index, le_bool baselineIsLogicalEnd);
137 void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft, const LEFontInstance *fontInstance);
140 inline GlyphPositionAdjustments::Adjustment::Adjustment()
141 : xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0), baseOffset(-1)
143 // nothing else to do!
146 inline GlyphPositionAdjustments::Adjustment::Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff)
147 : xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv), baseOffset(baseOff)
149 // nothing else to do!
152 inline GlyphPositionAdjustments::Adjustment::~Adjustment()
157 inline float GlyphPositionAdjustments::Adjustment::getXPlacement() const
162 inline float GlyphPositionAdjustments::Adjustment::getYPlacement() const
167 inline float GlyphPositionAdjustments::Adjustment::getXAdvance() const
172 inline float GlyphPositionAdjustments::Adjustment::getYAdvance() const
177 inline le_int32 GlyphPositionAdjustments::Adjustment::getBaseOffset() const
182 inline void GlyphPositionAdjustments::Adjustment::setXPlacement(float newXPlacement)
184 xPlacement = newXPlacement;
187 inline void GlyphPositionAdjustments::Adjustment::setYPlacement(float newYPlacement)
189 yPlacement = newYPlacement;
192 inline void GlyphPositionAdjustments::Adjustment::setXAdvance(float newXAdvance)
194 xAdvance = newXAdvance;
197 inline void GlyphPositionAdjustments::Adjustment::setYAdvance(float newYAdvance)
199 yAdvance = newYAdvance;
202 inline void GlyphPositionAdjustments::Adjustment::setBaseOffset(le_int32 newBaseOffset)
204 baseOffset = newBaseOffset;
207 inline void GlyphPositionAdjustments::Adjustment::adjustXPlacement(float xAdjustment)
209 xPlacement += xAdjustment;
212 inline void GlyphPositionAdjustments::Adjustment::adjustYPlacement(float yAdjustment)
214 yPlacement += yAdjustment;
217 inline void GlyphPositionAdjustments::Adjustment::adjustXAdvance(float xAdjustment)
219 xAdvance += xAdjustment;
222 inline void GlyphPositionAdjustments::Adjustment::adjustYAdvance(float yAdjustment)
224 yAdvance += yAdjustment;
227 inline GlyphPositionAdjustments::EntryExitPoint::EntryExitPoint()
230 fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fExitPoint.fY = 0;
233 inline GlyphPositionAdjustments::EntryExitPoint::~EntryExitPoint()
235 // nothing special to do
238 inline le_bool GlyphPositionAdjustments::EntryExitPoint::isCursiveGlyph() const
240 return (fFlags & EEF_IS_CURSIVE_GLYPH) != 0;
243 inline le_bool GlyphPositionAdjustments::EntryExitPoint::baselineIsLogicalEnd() const
245 return (fFlags & EEF_BASELINE_IS_LOGICAL_END) != 0;
248 inline void GlyphPositionAdjustments::EntryExitPoint::clearEntryPoint()
250 fFlags &= ~EEF_HAS_ENTRY_POINT;
253 inline void GlyphPositionAdjustments::EntryExitPoint::clearExitPoint()
255 fFlags &= ~EEF_HAS_EXIT_POINT;
258 inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)
260 if (baselineIsLogicalEnd) {
261 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
263 fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH);
266 fEntryPoint = newEntryPoint;
269 inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)
271 if (baselineIsLogicalEnd) {
272 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
274 fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH);
277 fExitPoint = newExitPoint;
280 inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(le_bool baselineIsLogicalEnd)
282 if (baselineIsLogicalEnd) {
283 fFlags |= (EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
285 fFlags |= EEF_IS_CURSIVE_GLYPH;
289 inline le_bool GlyphPositionAdjustments::isCursiveGlyph(le_int32 index) const
291 return fEntryExitPoints != NULL && fEntryExitPoints[index].isCursiveGlyph();
294 inline le_bool GlyphPositionAdjustments::baselineIsLogicalEnd(le_int32 index) const
296 return fEntryExitPoints != NULL && fEntryExitPoints[index].baselineIsLogicalEnd();
299 inline float GlyphPositionAdjustments::getXPlacement(le_int32 index) const
301 return fAdjustments[index].getXPlacement();
304 inline float GlyphPositionAdjustments::getYPlacement(le_int32 index) const
306 return fAdjustments[index].getYPlacement();
309 inline float GlyphPositionAdjustments::getXAdvance(le_int32 index) const
311 return fAdjustments[index].getXAdvance();
314 inline float GlyphPositionAdjustments::getYAdvance(le_int32 index) const
316 return fAdjustments[index].getYAdvance();
320 inline le_int32 GlyphPositionAdjustments::getBaseOffset(le_int32 index) const
322 return fAdjustments[index].getBaseOffset();
325 inline void GlyphPositionAdjustments::setXPlacement(le_int32 index, float newXPlacement)
327 fAdjustments[index].setXPlacement(newXPlacement);
330 inline void GlyphPositionAdjustments::setYPlacement(le_int32 index, float newYPlacement)
332 fAdjustments[index].setYPlacement(newYPlacement);
335 inline void GlyphPositionAdjustments::setXAdvance(le_int32 index, float newXAdvance)
337 fAdjustments[index].setXAdvance(newXAdvance);
340 inline void GlyphPositionAdjustments::setYAdvance(le_int32 index, float newYAdvance)
342 fAdjustments[index].setYAdvance(newYAdvance);
345 inline void GlyphPositionAdjustments::setBaseOffset(le_int32 index, le_int32 newBaseOffset)
347 fAdjustments[index].setBaseOffset(newBaseOffset);
350 inline void GlyphPositionAdjustments::adjustXPlacement(le_int32 index, float xAdjustment)
352 fAdjustments[index].adjustXPlacement(xAdjustment);
355 inline void GlyphPositionAdjustments::adjustYPlacement(le_int32 index, float yAdjustment)
357 fAdjustments[index].adjustYPlacement(yAdjustment);
360 inline void GlyphPositionAdjustments::adjustXAdvance(le_int32 index, float xAdjustment)
362 fAdjustments[index].adjustXAdvance(xAdjustment);
365 inline void GlyphPositionAdjustments::adjustYAdvance(le_int32 index, float yAdjustment)
367 fAdjustments[index].adjustYAdvance(yAdjustment);
370 inline le_bool GlyphPositionAdjustments::hasCursiveGlyphs() const
372 return fEntryExitPoints != NULL;