Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/font/layout/Features.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*28* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved29*30*/3132#include "LETypes.h"33#include "OpenTypeUtilities.h"34#include "OpenTypeTables.h"35#include "ICUFeatures.h"36#include "LESwaps.h"3738U_NAMESPACE_BEGIN3940LEReferenceTo<FeatureTable> FeatureListTable::getFeatureTable(const LETableReference &base, le_uint16 featureIndex, LETag *featureTag, LEErrorCode &success) const41{42LEReferenceToArrayOf<FeatureRecord>43featureRecordArrayRef(base, success, featureRecordArray, SWAPW(featureCount));4445if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) {46success = LE_INDEX_OUT_OF_BOUNDS_ERROR;47return LEReferenceTo<FeatureTable>();48}4950Offset featureTableOffset = featureRecordArray[featureIndex].featureTableOffset;5152*featureTag = SWAPT(featureRecordArray[featureIndex].featureTag);5354return LEReferenceTo<FeatureTable>(base, success, SWAPW(featureTableOffset));55}5657#if 058/*59* Note: according to the OpenType Spec. v 1.4, the entries in the Feature60* List Table are sorted alphabetically by feature tag; however, there seem61* to be some fonts which have an unsorted list; that's why the binary search62* is #if 0'd out and replaced by a linear search.63*64* Also note: as of ICU 2.6, this method isn't called anyhow...65*/66const FeatureTable *FeatureListTable::getFeatureTable(LETag featureTag) const67{68#if 069Offset featureTableOffset =70OpenTypeUtilities::getTagOffset(featureTag, (TagAndOffsetRecord *) featureRecordArray, SWAPW(featureCount));7172if (featureTableOffset == 0) {73return 0;74}7576return (const FeatureTable *) ((char *) this + SWAPW(featureTableOffset));77#else78int count = SWAPW(featureCount);7980for (int i = 0; i < count; i += 1) {81if (SWAPT(featureRecordArray[i].featureTag) == featureTag) {82return (const FeatureTable *) ((char *) this + SWAPW(featureRecordArray[i].featureTableOffset));83}84}8586return 0;87#endif88}89#endif9091U_NAMESPACE_END929394