/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
*
* (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
*
*/
#include "LETypes.h"
#include "MorphTables.h"
#include "StateTables.h"
#include "MorphStateTables.h"
#include "SubtableProcessor.h"
#include "StateTableProcessor.h"
#include "LigatureSubstProc.h"
#include "LEGlyphStorage.h"
#include "LESwaps.h"
LigatureSubstitutionProcessor::LigatureSubstitutionProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success)
: StateTableProcessor(morphSubtableHeader, success), ligatureSubstitutionHeader(morphSubtableHeader, success)
{
if(LE_FAILURE(success)) return;
entryTable = LEReferenceToArrayOf<LigatureSubstitutionStateEntry>(stHeader, success, entryTableOffset, LE_UNBOUNDED_ARRAY);
}
{
}
{
m = -1;
}
ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
{
if (flags & lsfSetComponent) {
if (++m >= nComponents) {
m = 0;
}
componentStack[m] = currGlyph;
} else if ( m == -1) {
// bad font- skip this glyph.
currGlyph++;
return newState;
}
if (actionOffset != 0) {
do {
if (m < 0) {
m = nComponents - 1;
}
if (offset != 0) {
LEReferenceToArrayOf<le_int16> offsetTable(stHeader, success, 2 * SignExtend(offset, lafComponentOffsetMask), LE_UNBOUNDED_ARRAY);
if(LE_FAILURE(success)) {
currGlyph++;
LE_DEBUG_BAD_FONT("off end of ligature substitution header");
return newState; // get out! bad font
}
LE_DEBUG_BAD_FONT("preposterous componentGlyph");
currGlyph++;
return newState; // get out! bad font
}
if(mm==nComponents) {
LE_DEBUG_BAD_FONT("exceeded nComponents");
mm--; // don't overrun the stack.
}
i = 0;
} else {
}
}
if(m<0) {
LE_DEBUG_BAD_FONT("m<0")
}
#endif
while (mm >= 0) {
if (++m >= nComponents) {
m = 0;
}
}
}
if (!(flags & lsfDontAdvance)) {
// should handle reverse too!
currGlyph += 1;
}
return newState;
}
{
}