sl@0: /* sl@0: * @(#)Features.cpp 1.4 00/03/15 sl@0: * sl@0: * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved sl@0: * sl@0: */ sl@0: sl@0: #include "LETypes.h" sl@0: #include "OpenTypeUtilities.h" sl@0: #include "OpenTypeTables.h" sl@0: #include "Features.h" sl@0: #include "LESwaps.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: const FeatureTable *FeatureListTable::getFeatureTable(le_uint16 featureIndex, LETag *featureTag) const sl@0: { sl@0: if (featureIndex >= SWAPW(featureCount)) { sl@0: return 0; sl@0: } sl@0: sl@0: Offset featureTableOffset = featureRecordArray[featureIndex].featureTableOffset; sl@0: sl@0: *featureTag = SWAPT(featureRecordArray[featureIndex].featureTag); sl@0: sl@0: return (const FeatureTable *) ((char *) this + SWAPW(featureTableOffset)); sl@0: } sl@0: sl@0: /* sl@0: * Note: according to the OpenType Spec. v 1.4, the entries in the Feature sl@0: * List Table are sorted alphabetically by feature tag; however, there seem sl@0: * to be some fonts which have an unsorted list; that's why the binary search sl@0: * is #if 0'd out and replaced by a linear search. sl@0: * sl@0: * Also note: as of ICU 2.6, this method isn't called anyhow... sl@0: */ sl@0: const FeatureTable *FeatureListTable::getFeatureTable(LETag featureTag) const sl@0: { sl@0: #if 0 sl@0: Offset featureTableOffset = sl@0: OpenTypeUtilities::getTagOffset(featureTag, (TagAndOffsetRecord *) featureRecordArray, SWAPW(featureCount)); sl@0: sl@0: if (featureTableOffset == 0) { sl@0: return 0; sl@0: } sl@0: sl@0: return (const FeatureTable *) ((char *) this + SWAPW(featureTableOffset)); sl@0: #else sl@0: int count = SWAPW(featureCount); sl@0: sl@0: for (int i = 0; i < count; i += 1) { sl@0: if (SWAPT(featureRecordArray[i].featureTag) == featureTag) { sl@0: return (const FeatureTable *) ((char *) this + SWAPW(featureRecordArray[i].featureTableOffset)); sl@0: } sl@0: } sl@0: sl@0: return 0; sl@0: #endif sl@0: } sl@0: sl@0: U_NAMESPACE_END