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