8146494: Better ligature substitution
Reviewed-by: vadim, mschoene
This commit is contained in:
parent
29aeb05692
commit
11920c3315
@ -71,6 +71,10 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp
|
|||||||
{
|
{
|
||||||
LEErrorCode success = LE_NO_ERROR;
|
LEErrorCode success = LE_NO_ERROR;
|
||||||
const LigatureSubstitutionStateEntry *entry = entryTable.getAlias(index, success);
|
const LigatureSubstitutionStateEntry *entry = entryTable.getAlias(index, success);
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ByteOffset newState = SWAPW(entry->newStateOffset);
|
ByteOffset newState = SWAPW(entry->newStateOffset);
|
||||||
le_uint16 flags = SWAPW(entry->flags);
|
le_uint16 flags = SWAPW(entry->flags);
|
||||||
@ -91,6 +95,10 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp
|
|||||||
|
|
||||||
if (actionOffset != 0) {
|
if (actionOffset != 0) {
|
||||||
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, actionOffset);
|
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, actionOffset);
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph++;
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
LigatureActionEntry action;
|
LigatureActionEntry action;
|
||||||
le_int32 offset, i = 0, j = 0;
|
le_int32 offset, i = 0, j = 0;
|
||||||
le_int32 stack[nComponents];
|
le_int32 stack[nComponents];
|
||||||
@ -101,6 +109,10 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp
|
|||||||
|
|
||||||
if (j++ > 0) {
|
if (j++ > 0) {
|
||||||
ap.addObject(success);
|
ap.addObject(success);
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph++;
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
action = SWAPL(*ap.getAlias());
|
action = SWAPL(*ap.getAlias());
|
||||||
@ -124,9 +136,17 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp
|
|||||||
return newState; // get out! bad font
|
return newState; // get out! bad font
|
||||||
}
|
}
|
||||||
i += SWAPW(offsetTable.getObject(LE_GET_GLYPH(glyphStorage[componentGlyph]), success));
|
i += SWAPW(offsetTable.getObject(LE_GET_GLYPH(glyphStorage[componentGlyph]), success));
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph++;
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
|
|
||||||
if (action & (lafLast | lafStore)) {
|
if (action & (lafLast | lafStore)) {
|
||||||
LEReferenceTo<TTGlyphID> ligatureOffset(stHeader, success, i);
|
LEReferenceTo<TTGlyphID> ligatureOffset(stHeader, success, i);
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph++;
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
TTGlyphID ligatureGlyph = SWAPW(*ligatureOffset.getAlias());
|
TTGlyphID ligatureGlyph = SWAPW(*ligatureOffset.getAlias());
|
||||||
|
|
||||||
glyphStorage[componentGlyph] = LE_SET_GLYPH(glyphStorage[componentGlyph], ligatureGlyph);
|
glyphStorage[componentGlyph] = LE_SET_GLYPH(glyphStorage[componentGlyph], ligatureGlyph);
|
||||||
|
@ -95,6 +95,10 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
|
|||||||
|
|
||||||
if (actionOffset != 0) {
|
if (actionOffset != 0) {
|
||||||
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, ligActionOffset); // byte offset
|
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, ligActionOffset); // byte offset
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph+= dir;
|
||||||
|
return nextStateIndex;
|
||||||
|
}
|
||||||
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;
|
||||||
@ -104,8 +108,8 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
|
|||||||
|
|
||||||
LEReferenceToArrayOf<le_uint16> componentTable(stHeader, success, componentOffset, LE_UNBOUNDED_ARRAY);
|
LEReferenceToArrayOf<le_uint16> componentTable(stHeader, success, componentOffset, LE_UNBOUNDED_ARRAY);
|
||||||
if(LE_FAILURE(success)) {
|
if(LE_FAILURE(success)) {
|
||||||
currGlyph+= dir;
|
currGlyph+= dir;
|
||||||
return nextStateIndex; // get out! bad font
|
return nextStateIndex; // get out! bad font
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -114,6 +118,10 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
|
|||||||
if (j++ > 0) {
|
if (j++ > 0) {
|
||||||
ap.addObject(success);
|
ap.addObject(success);
|
||||||
}
|
}
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph+= dir;
|
||||||
|
return nextStateIndex;
|
||||||
|
}
|
||||||
|
|
||||||
action = SWAPL(*ap.getAlias());
|
action = SWAPL(*ap.getAlias());
|
||||||
|
|
||||||
@ -129,9 +137,17 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
|
|||||||
return nextStateIndex; // get out! bad font
|
return nextStateIndex; // get out! bad font
|
||||||
}
|
}
|
||||||
i += SWAPW(componentTable(LE_GET_GLYPH(glyphStorage[componentGlyph]) + (SignExtend(offset, lafComponentOffsetMask)),success));
|
i += SWAPW(componentTable(LE_GET_GLYPH(glyphStorage[componentGlyph]) + (SignExtend(offset, lafComponentOffsetMask)),success));
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph+= dir;
|
||||||
|
return nextStateIndex;
|
||||||
|
}
|
||||||
|
|
||||||
if (action & (lafLast | lafStore)) {
|
if (action & (lafLast | lafStore)) {
|
||||||
TTGlyphID ligatureGlyph = SWAPW(ligatureTable(i,success));
|
TTGlyphID ligatureGlyph = SWAPW(ligatureTable(i,success));
|
||||||
|
if (LE_FAILURE(success)) {
|
||||||
|
currGlyph+= dir;
|
||||||
|
return nextStateIndex;
|
||||||
|
}
|
||||||
glyphStorage[componentGlyph] = LE_SET_GLYPH(glyphStorage[componentGlyph], ligatureGlyph);
|
glyphStorage[componentGlyph] = LE_SET_GLYPH(glyphStorage[componentGlyph], ligatureGlyph);
|
||||||
if(mm==nComponents) {
|
if(mm==nComponents) {
|
||||||
LE_DEBUG_BAD_FONT("exceeded nComponents");
|
LE_DEBUG_BAD_FONT("exceeded nComponents");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user