/*
**********************************************************************
- * Copyright (C) 1998-2004, International Business Machines
+ * Copyright (C) 1998-2009, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEGlyphStorage)
+LEInsertionCallback::~LEInsertionCallback()
+{
+ // nothing to do...
+}
+
LEGlyphStorage::LEGlyphStorage()
: fGlyphCount(0), fGlyphs(NULL), fCharIndices(NULL), fPositions(NULL),
fAuxData(NULL), fInsertionList(NULL), fSrcIndex(0), fDestIndex(0)
if (fInsertionList == NULL) {
// FIXME: check this for failure?
fInsertionList = new LEInsertionList(rightToLeft);
+ if (fInsertionList == NULL) {
+ LE_DELETE_ARRAY(fCharIndices);
+ fCharIndices = NULL;
+
+ LE_DELETE_ARRAY(fGlyphs);
+ fGlyphs = NULL;
+
+ success = LE_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
}
}
return -1;
}
+ if (fPositions != NULL) {
+ success = LE_INTERNAL_ERROR;
+ return -1;
+ }
+
fPositions = LE_NEW_ARRAY(float, 2 * (fGlyphCount + 1));
if (fPositions == NULL) {
return -1;
}
- fAuxData = LE_NEW_ARRAY(void *, fGlyphCount);
+ if (fAuxData != NULL) {
+ success = LE_INTERNAL_ERROR;
+ return -1;
+ }
+
+ fAuxData = LE_NEW_ARRAY(le_uint32, fGlyphCount);
if (fAuxData == NULL) {
success = LE_MEMORY_ALLOCATION_ERROR;
fCharIndices[glyphIndex] = charIndex;
}
-void LEGlyphStorage::getAuxData(void *auxData[], LEErrorCode &success) const
+void LEGlyphStorage::getAuxData(le_uint32 auxData[], LEErrorCode &success) const
{
if (LE_FAILURE(success)) {
return;
LE_ARRAY_COPY(auxData, fAuxData, fGlyphCount);
}
-void *LEGlyphStorage::getAuxData(le_int32 glyphIndex, LEErrorCode &success) const
+le_uint32 LEGlyphStorage::getAuxData(le_int32 glyphIndex, LEErrorCode &success) const
{
if (LE_FAILURE(success)) {
- return NULL;
+ return 0;
}
if (fAuxData == NULL) {
success = LE_NO_LAYOUT_ERROR;
- return NULL;
+ return 0;
}
if (glyphIndex < 0 || glyphIndex >= fGlyphCount) {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
- return NULL;
+ return 0;
}
return fAuxData[glyphIndex];
}
-void LEGlyphStorage::setAuxData(le_int32 glyphIndex, void *auxData, LEErrorCode &success)
+void LEGlyphStorage::setAuxData(le_int32 glyphIndex, le_uint32 auxData, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
fGlyphCount = newGlyphCount;
}
-// FIXME: add error checking?
+// Move a glyph to a different position in the LEGlyphStorage ( used for Indic v2 processing )
+
+void LEGlyphStorage::moveGlyph(le_int32 fromPosition, le_int32 toPosition, le_uint32 marker )
+{
+
+ LEErrorCode success = LE_NO_ERROR;
+
+ LEGlyphID holdGlyph = getGlyphID(fromPosition,success);
+ le_int32 holdCharIndex = getCharIndex(fromPosition,success);
+ le_uint32 holdAuxData = getAuxData(fromPosition,success);
+
+ if ( fromPosition < toPosition ) {
+ for ( le_int32 i = fromPosition ; i < toPosition ; i++ ) {
+ setGlyphID(i,getGlyphID(i+1,success),success);
+ setCharIndex(i,getCharIndex(i+1,success),success);
+ setAuxData(i,getAuxData(i+1,success),success);
+ }
+ } else {
+ for ( le_int32 i = toPosition ; i > fromPosition ; i-- ) {
+ setGlyphID(i,getGlyphID(i-1,success),success);
+ setCharIndex(i,getCharIndex(i-1,success),success);
+ setAuxData(i,getAuxData(i-1,success),success);
+
+ }
+ }
+
+ setGlyphID(toPosition,holdGlyph,success);
+ setCharIndex(toPosition,holdCharIndex,success);
+ setAuxData(toPosition,holdAuxData | marker,success);
+
+}
+
+// Glue code for existing stable API
LEGlyphID *LEGlyphStorage::insertGlyphs(le_int32 atIndex, le_int32 insertCount)
{
- return fInsertionList->insert(atIndex, insertCount);
+ LEErrorCode ignored = LE_NO_LAYOUT_ERROR;
+ return insertGlyphs(atIndex, insertCount, ignored);
+}
+
+// FIXME: add error checking?
+LEGlyphID *LEGlyphStorage::insertGlyphs(le_int32 atIndex, le_int32 insertCount, LEErrorCode& success)
+{
+ return fInsertionList->insert(atIndex, insertCount, success);
}
le_int32 LEGlyphStorage::applyInsertions()
le_int32 newGlyphCount = fGlyphCount + growAmount;
- fGlyphs = (LEGlyphID *) LE_GROW_ARRAY(fGlyphs, newGlyphCount);
- fCharIndices = (le_int32 *) LE_GROW_ARRAY(fCharIndices, newGlyphCount);
-
- if (fAuxData != NULL) {
- fAuxData = (void **) LE_GROW_ARRAY(fAuxData, newGlyphCount);
+ LEGlyphID *newGlyphs = (LEGlyphID *) LE_GROW_ARRAY(fGlyphs, newGlyphCount);
+ if (newGlyphs == NULL) {
+ // Could not grow the glyph array
+ return fGlyphCount;
+ }
+ fGlyphs = newGlyphs;
+
+ le_int32 *newCharIndices = (le_int32 *) LE_GROW_ARRAY(fCharIndices, newGlyphCount);
+ if (newCharIndices == NULL) {
+ // Could not grow the glyph array
+ return fGlyphCount;
+ }
+ fCharIndices = newCharIndices;
+
+ if (fAuxData != NULL) {
+ le_uint32 *newAuxData = (le_uint32 *) LE_GROW_ARRAY(fAuxData, newGlyphCount);
+ if (newAuxData == NULL) {
+ // could not grow the aux data array
+ return fGlyphCount;
+ }
+ fAuxData = (le_uint32 *)newAuxData;
}
fSrcIndex = fGlyphCount - 1;