提交 a456f1a0 编写于 作者: V vadim

8072490: Better font morphing redux

Reviewed-by: prr, srl, mschoene
上级 fb6199a0
...@@ -188,7 +188,7 @@ public: ...@@ -188,7 +188,7 @@ public:
void addOffset(size_t offset, LEErrorCode &success) { void addOffset(size_t offset, LEErrorCode &success) {
if(hasBounds()) { if(hasBounds()) {
if(offset > fLength) { if(offset >= fLength) {
LE_DEBUG_TR("addOffset off end"); LE_DEBUG_TR("addOffset off end");
success = LE_INDEX_OUT_OF_BOUNDS_ERROR; success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
return; return;
...@@ -203,7 +203,7 @@ public: ...@@ -203,7 +203,7 @@ public:
if(atPtr==NULL) return 0; if(atPtr==NULL) return 0;
if(LE_FAILURE(success)) return LE_UINTPTR_MAX; if(LE_FAILURE(success)) return LE_UINTPTR_MAX;
if((atPtr < fStart) || if((atPtr < fStart) ||
(hasBounds() && (atPtr > fStart+fLength))) { (hasBounds() && (atPtr >= fStart+fLength))) {
LE_DEBUG_TR3("ptrToOffset args out of range: %p", atPtr, 0); LE_DEBUG_TR3("ptrToOffset args out of range: %p", atPtr, 0);
success = LE_INDEX_OUT_OF_BOUNDS_ERROR; success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
return LE_UINTPTR_MAX; return LE_UINTPTR_MAX;
......
...@@ -92,15 +92,18 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp ...@@ -92,15 +92,18 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp
if (actionOffset != 0) { if (actionOffset != 0) {
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, actionOffset); LEReferenceTo<LigatureActionEntry> ap(stHeader, success, actionOffset);
LigatureActionEntry action; LigatureActionEntry action;
le_int32 offset, i = 0; le_int32 offset, i = 0, j = 0;
le_int32 stack[nComponents]; le_int32 stack[nComponents];
le_int16 mm = -1; le_int16 mm = -1;
do { do {
le_uint32 componentGlyph = componentStack[m--]; le_uint32 componentGlyph = componentStack[m--];
if (j++ > 0) {
ap.addObject(success);
}
action = SWAPL(*ap.getAlias()); action = SWAPL(*ap.getAlias());
ap.addObject(success); // ap++
if (m < 0) { if (m < 0) {
m = nComponents - 1; m = nComponents - 1;
......
...@@ -98,7 +98,7 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp ...@@ -98,7 +98,7 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
ap.addObject(ligActionIndex, success); ap.addObject(ligActionIndex, success);
LEReferenceToArrayOf<TTGlyphID> ligatureTable(stHeader, success, ligatureOffset, LE_UNBOUNDED_ARRAY); LEReferenceToArrayOf<TTGlyphID> ligatureTable(stHeader, success, ligatureOffset, LE_UNBOUNDED_ARRAY);
LigatureActionEntry action; LigatureActionEntry action;
le_int32 offset, i = 0; le_int32 offset, i = 0, j = 0;
le_int32 stack[nComponents]; le_int32 stack[nComponents];
le_int16 mm = -1; le_int16 mm = -1;
...@@ -111,6 +111,10 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp ...@@ -111,6 +111,10 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
do { do {
le_uint32 componentGlyph = componentStack[m--]; // pop off le_uint32 componentGlyph = componentStack[m--]; // pop off
if (j++ > 0) {
ap.addObject(success);
}
action = SWAPL(*ap.getAlias()); action = SWAPL(*ap.getAlias());
if (m < 0) { if (m < 0) {
...@@ -144,7 +148,6 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp ...@@ -144,7 +148,6 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
LE_DEBUG_BAD_FONT("m<0") LE_DEBUG_BAD_FONT("m<0")
} }
#endif #endif
ap.addObject(success);
} while (LE_SUCCESS(success) && !(action & lafLast) && (m>=0) ); // stop if last bit is set, or if run out of items } while (LE_SUCCESS(success) && !(action & lafLast) && (m>=0) ); // stop if last bit is set, or if run out of items
while (mm >= 0) { while (mm >= 0) {
......
...@@ -52,8 +52,11 @@ void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &gly ...@@ -52,8 +52,11 @@ void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &gly
le_uint32 chain; le_uint32 chain;
for (chain = 0; LE_SUCCESS(success) && (chain < chainCount); chain += 1) { for (chain = 0; LE_SUCCESS(success) && (chain < chainCount); chain += 1) {
FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags); if (chain > 0) {
le_uint32 chainLength = SWAPL(chainHeader->chainLength); le_uint32 chainLength = SWAPL(chainHeader->chainLength);
chainHeader.addOffset(chainLength, success);
}
FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags);
le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries); le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries);
le_int16 nSubtables = SWAPW(chainHeader->nSubtables); le_int16 nSubtables = SWAPW(chainHeader->nSubtables);
LEReferenceTo<MorphSubtableHeader> subtableHeader = LEReferenceTo<MorphSubtableHeader> subtableHeader =
...@@ -61,7 +64,10 @@ void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &gly ...@@ -61,7 +64,10 @@ void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &gly
le_int16 subtable; le_int16 subtable;
for (subtable = 0; LE_SUCCESS(success) && (subtable < nSubtables); subtable += 1) { for (subtable = 0; LE_SUCCESS(success) && (subtable < nSubtables); subtable += 1) {
if (subtable > 0) {
le_int16 length = SWAPW(subtableHeader->length); le_int16 length = SWAPW(subtableHeader->length);
subtableHeader.addOffset(length, success);
}
SubtableCoverage coverage = SWAPW(subtableHeader->coverage); SubtableCoverage coverage = SWAPW(subtableHeader->coverage);
FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures); FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures);
...@@ -69,10 +75,7 @@ void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &gly ...@@ -69,10 +75,7 @@ void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &gly
if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0 && LE_SUCCESS(success)) { if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0 && LE_SUCCESS(success)) {
subtableHeader->process(subtableHeader, glyphStorage, success); subtableHeader->process(subtableHeader, glyphStorage, success);
} }
subtableHeader.addOffset(length, success);
} }
chainHeader.addOffset(chainLength, success);
} }
} }
......
...@@ -179,12 +179,13 @@ PairPositioningFormat1Subtable::findPairValueRecord(TTGlyphID glyphID, LEReferen ...@@ -179,12 +179,13 @@ PairPositioningFormat1Subtable::findPairValueRecord(TTGlyphID glyphID, LEReferen
LEReferenceTo<PairValueRecord> record(records); LEReferenceTo<PairValueRecord> record(records);
for(le_int32 r = 0; r < recordCount; r += 1) { for(le_int32 r = 0; r < recordCount; r += 1) {
if (r > 0) {
record.addOffset(recordSize, success);
}
if(LE_FAILURE(success)) return LEReferenceTo<PairValueRecord>(); if(LE_FAILURE(success)) return LEReferenceTo<PairValueRecord>();
if (SWAPW(record->secondGlyph) == glyphID) { if (SWAPW(record->secondGlyph) == glyphID) {
return record; return record;
} }
record.addOffset(recordSize, success);
} }
#else #else
#error dead code - not updated. #error dead code - not updated.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册