Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/font/layout/ContextualGlyphSubstProc.cpp
38918 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425/*26*27* (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved28*29*/3031#include "LETypes.h"32#include "MorphTables.h"33#include "StateTables.h"34#include "MorphStateTables.h"35#include "SubtableProcessor.h"36#include "StateTableProcessor.h"37#include "ContextualGlyphSubstProc.h"38#include "LEGlyphStorage.h"39#include "LESwaps.h"4041U_NAMESPACE_BEGIN4243UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ContextualGlyphSubstitutionProcessor)4445ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success)46: StateTableProcessor(morphSubtableHeader, success), entryTable(), contextualGlyphSubstitutionHeader(morphSubtableHeader, success)47{48if (LE_FAILURE(success)) return;49contextualGlyphSubstitutionHeader.orphan();50substitutionTableOffset = SWAPW(contextualGlyphSubstitutionHeader->substitutionTableOffset);515253entryTable = LEReferenceToArrayOf<ContextualGlyphSubstitutionStateEntry>(stateTableHeader, success,54(const ContextualGlyphSubstitutionStateEntry*)(&stateTableHeader->stHeader),55entryTableOffset, LE_UNBOUNDED_ARRAY);56int16Table = LEReferenceToArrayOf<le_int16>(stateTableHeader, success, (const le_int16*)(&stateTableHeader->stHeader),570, LE_UNBOUNDED_ARRAY); // rest of the table as le_int16s58}5960ContextualGlyphSubstitutionProcessor::~ContextualGlyphSubstitutionProcessor()61{62}6364void ContextualGlyphSubstitutionProcessor::beginStateTable()65{66markGlyph = 0;67}6869ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success)70{71const ContextualGlyphSubstitutionStateEntry *entry = entryTable.getAlias(index, success);72if (LE_FAILURE(success)) return 0;73ByteOffset newState = SWAPW(entry->newStateOffset);74le_int16 flags = SWAPW(entry->flags);75WordOffset markOffset = SWAPW(entry->markOffset);76WordOffset currOffset = SWAPW(entry->currOffset);7778if (markOffset != 0 && LE_SUCCESS(success)) {79if (markGlyph < 0 || markGlyph >= glyphStorage.getGlyphCount()) {80success = LE_INDEX_OUT_OF_BOUNDS_ERROR;81return 0;82}83LEGlyphID mGlyph = glyphStorage[markGlyph];84TTGlyphID newGlyph = SWAPW(int16Table.getObject(markOffset + LE_GET_GLYPH(mGlyph), success)); // whew.8586glyphStorage[markGlyph] = LE_SET_GLYPH(mGlyph, newGlyph);87}8889if (currOffset != 0) {90if (currGlyph < 0 || currGlyph >= glyphStorage.getGlyphCount()) {91success = LE_INDEX_OUT_OF_BOUNDS_ERROR;92return 0;93}94LEGlyphID thisGlyph = glyphStorage[currGlyph];95TTGlyphID newGlyph = SWAPW(int16Table.getObject(currOffset + LE_GET_GLYPH(thisGlyph), success)); // whew.9697glyphStorage[currGlyph] = LE_SET_GLYPH(thisGlyph, newGlyph);98}99100if (flags & cgsSetMark) {101markGlyph = currGlyph;102}103104if (!(flags & cgsDontAdvance)) {105// should handle reverse too!106currGlyph += 1;107}108109return newState;110}111112void ContextualGlyphSubstitutionProcessor::endStateTable()113{114}115116U_NAMESPACE_END117118119