annotate src/share/native/sun/font/layout/SegmentArrayProcessor2.cpp @ 13703:64b55ae060e8

8227129: Better ligature for subtables Reviewed-by: bae
author mbalao
date Tue, 24 Sep 2019 19:07:02 -0300
parents dbb4e2bdfa9e
children
rev   line source
prr@6934 1 /*
prr@6934 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
prr@6934 3 *
prr@6934 4 * This code is free software; you can redistribute it and/or modify it
prr@6934 5 * under the terms of the GNU General Public License version 2 only, as
prr@6934 6 * published by the Free Software Foundation. Oracle designates this
prr@6934 7 * particular file as subject to the "Classpath" exception as provided
prr@6934 8 * by Oracle in the LICENSE file that accompanied this code.
prr@6934 9 *
prr@6934 10 * This code is distributed in the hope that it will be useful, but WITHOUT
prr@6934 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
prr@6934 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
prr@6934 13 * version 2 for more details (a copy is included in the LICENSE file that
prr@6934 14 * accompanied this code).
prr@6934 15 *
prr@6934 16 * You should have received a copy of the GNU General Public License version
prr@6934 17 * 2 along with this work; if not, write to the Free Software Foundation,
prr@6934 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
prr@6934 19 *
prr@6934 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
prr@6934 21 * or visit www.oracle.com if you need additional information or have any
prr@6934 22 * questions.
prr@6934 23 *
prr@6934 24 */
prr@6934 25
prr@6934 26 /*
prr@6934 27 *
prr@6934 28 * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
prr@6934 29 *
prr@6934 30 */
prr@6934 31
prr@6934 32 #include "LETypes.h"
prr@6934 33 #include "MorphTables.h"
prr@6934 34 #include "SubtableProcessor2.h"
prr@6934 35 #include "NonContextualGlyphSubst.h"
prr@6934 36 #include "NonContextualGlyphSubstProc2.h"
prr@6934 37 #include "SegmentArrayProcessor2.h"
prr@6934 38 #include "LEGlyphStorage.h"
prr@6934 39 #include "LESwaps.h"
prr@6934 40
prr@6934 41 U_NAMESPACE_BEGIN
prr@6934 42
prr@6934 43 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SegmentArrayProcessor2)
prr@6934 44
prr@6934 45 SegmentArrayProcessor2::SegmentArrayProcessor2()
prr@6934 46 {
prr@6934 47 }
prr@6934 48
prr@6936 49 SegmentArrayProcessor2::SegmentArrayProcessor2(const LEReferenceTo<MorphSubtableHeader2> &morphSubtableHeader, LEErrorCode &success)
prr@6936 50 : NonContextualGlyphSubstitutionProcessor2(morphSubtableHeader, success)
prr@6934 51 {
prr@6936 52 const LEReferenceTo<NonContextualGlyphSubstitutionHeader2> header(morphSubtableHeader, success);
prr@6936 53 segmentArrayLookupTable = LEReferenceTo<SegmentArrayLookupTable>(morphSubtableHeader, success, &header->table); // don't parent to 'header' as it is on the stack
prr@6934 54 }
prr@6934 55
prr@6934 56 SegmentArrayProcessor2::~SegmentArrayProcessor2()
prr@6934 57 {
prr@6934 58 }
prr@6934 59
prr@6936 60 void SegmentArrayProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
prr@6934 61 {
mbalao@13703 62 if (LE_FAILURE(success)) return;
mbalao@13703 63
prr@6934 64 const LookupSegment *segments = segmentArrayLookupTable->segments;
prr@6934 65 le_int32 glyphCount = glyphStorage.getGlyphCount();
prr@6934 66 le_int32 glyph;
prr@6934 67
prr@11156 68 if (LE_FAILURE(success)) return;
prr@11156 69
prr@6934 70 for (glyph = 0; glyph < glyphCount; glyph += 1) {
prr@6934 71 LEGlyphID thisGlyph = glyphStorage[glyph];
prr@9052 72 // lookupSegment already range checked by lookupSegment() function.
prr@6936 73 const LookupSegment *lookupSegment = segmentArrayLookupTable->lookupSegment(segmentArrayLookupTable, segments, thisGlyph, success);
prr@6934 74
prr@9052 75 if (lookupSegment != NULL&& LE_SUCCESS(success)) {
prr@6934 76 TTGlyphID firstGlyph = SWAPW(lookupSegment->firstGlyph);
prr@9052 77 TTGlyphID lastGlyph = SWAPW(lookupSegment->lastGlyph);
prr@6934 78 le_int16 offset = SWAPW(lookupSegment->value);
prr@9052 79 TTGlyphID thisGlyphId= LE_GET_GLYPH(thisGlyph);
prr@9052 80 LEReferenceToArrayOf<TTGlyphID> glyphArray(subtableHeader, success, offset, lastGlyph - firstGlyph + 1);
prr@9052 81 if (offset != 0 && thisGlyphId <= lastGlyph && thisGlyphId >= firstGlyph && LE_SUCCESS(success) ) {
prr@9052 82 TTGlyphID newGlyph = SWAPW(glyphArray[thisGlyphId]);
prr@9052 83 glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
prr@6934 84 }
prr@6934 85 }
prr@6934 86 }
prr@6934 87 }
prr@6934 88
prr@6934 89 U_NAMESPACE_END