From d2e68b68302971a2a47f81ceb4ef27d8ddbe65da Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Wed, 1 Jun 2016 14:37:38 +0300 Subject: [PATCH] 8158302: Handle contextual glyph substitutions Reviewed-by: prr, serb, mschoene --- .../libfontmanager/layout/ContextualGlyphSubstProc.cpp | 5 +++-- .../native/libfontmanager/layout/ContextualGlyphSubstProc.h | 2 +- .../libfontmanager/layout/IndicRearrangementProcessor.cpp | 6 +++--- .../libfontmanager/layout/IndicRearrangementProcessor.h | 2 +- .../native/libfontmanager/layout/LigatureSubstProc.cpp | 3 +-- .../share/native/libfontmanager/layout/LigatureSubstProc.h | 2 +- .../native/libfontmanager/layout/StateTableProcessor.cpp | 3 ++- .../native/libfontmanager/layout/StateTableProcessor.h | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.cpp index 63f7b644fec..9b92060d9e5 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.cpp @@ -46,6 +46,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ContextualGlyphSubstitutionProcessor) ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const LEReferenceTo &morphSubtableHeader, LEErrorCode &success) : StateTableProcessor(morphSubtableHeader, success), entryTable(), contextualGlyphSubstitutionHeader(morphSubtableHeader, success) { + if (LE_FAILURE(success)) return; contextualGlyphSubstitutionHeader.orphan(); substitutionTableOffset = SWAPW(contextualGlyphSubstitutionHeader->substitutionTableOffset); @@ -66,10 +67,10 @@ void ContextualGlyphSubstitutionProcessor::beginStateTable() markGlyph = 0; } -ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index) +ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success) { - LEErrorCode success = LE_NO_ERROR; const ContextualGlyphSubstitutionStateEntry *entry = entryTable.getAlias(index, success); + if (LE_FAILURE(success)) return 0; ByteOffset newState = SWAPW(entry->newStateOffset); le_int16 flags = SWAPW(entry->flags); WordOffset markOffset = SWAPW(entry->markOffset); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.h b/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.h index 136398f7661..7cf15323089 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.h @@ -52,7 +52,7 @@ class ContextualGlyphSubstitutionProcessor : public StateTableProcessor public: virtual void beginStateTable(); - virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index); + virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success); virtual void endStateTable(); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp index 5598349131a..512ec4d527e 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp @@ -63,10 +63,10 @@ void IndicRearrangementProcessor::beginStateTable() lastGlyph = 0; } -ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index) +ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success) { - LEErrorCode success = LE_NO_ERROR; // todo- make a param? - const IndicRearrangementStateEntry *entry = entryTable.getAlias(index,success); + const IndicRearrangementStateEntry *entry = entryTable.getAlias(index, success); + if (LE_FAILURE(success)) return 0; ByteOffset newState = SWAPW(entry->newStateOffset); IndicRearrangementFlags flags = (IndicRearrangementFlags) SWAPW(entry->flags); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h index 42d7a249aa1..593c3188904 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h @@ -52,7 +52,7 @@ class IndicRearrangementProcessor : public StateTableProcessor public: virtual void beginStateTable(); - virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index); + virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success); virtual void endStateTable(); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.cpp index 76131fd2193..111346224e4 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.cpp @@ -67,9 +67,8 @@ void LigatureSubstitutionProcessor::beginStateTable() m = -1; } -ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index) +ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success) { - LEErrorCode success = LE_NO_ERROR; const LigatureSubstitutionStateEntry *entry = entryTable.getAlias(index, success); if (LE_FAILURE(success)) { currGlyph++; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.h b/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.h index 1765a71d674..67bab99a1eb 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.h @@ -54,7 +54,7 @@ class LigatureSubstitutionProcessor : public StateTableProcessor public: virtual void beginStateTable(); - virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index); + virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success); virtual void endStateTable(); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.cpp index f5bef5f3038..2234faf704b 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.cpp @@ -81,6 +81,7 @@ void StateTableProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &suc while (currGlyph <= glyphCount) { if(LE_STATE_PATIENCE_DECR()) break; // patience exceeded. + if (LE_FAILURE(success)) break; ClassCode classCode = classCodeOOB; if (currGlyph == glyphCount) { // XXX: How do we handle EOT vs. EOL? @@ -100,7 +101,7 @@ void StateTableProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &suc EntryTableIndex entryTableIndex = stateArray.getObject((le_uint8)classCode, success); if (LE_FAILURE(success)) { break; } LE_STATE_PATIENCE_CURR(le_int32, currGlyph); - currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex); + currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex, success); LE_STATE_PATIENCE_INCR(currGlyph); } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.h b/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.h index 2e8d7f606b5..e437da73f72 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.h @@ -53,7 +53,7 @@ public: virtual void beginStateTable() = 0; - virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index) = 0; + virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success) = 0; virtual void endStateTable() = 0;