1 /*
2 * @(#)Features.cpp 1.4 00/03/15
3 *
4 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
5 *
6 */
7
8 #include "LETypes.h"
9 #include "OpenTypeUtilities.h"
10 #include "OpenTypeTables.h"
11 #include "ICUFeatures.h"
12 #include "LESwaps.h"
13
14 U_NAMESPACE_BEGIN
15
getFeatureTable(const LETableReference & base,le_uint16 featureIndex,LETag * featureTag,LEErrorCode & success) const16 LEReferenceTo<FeatureTable> FeatureListTable::getFeatureTable(const LETableReference &base, le_uint16 featureIndex, LETag *featureTag, LEErrorCode &success) const
17 {
18 if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) {
19 return LEReferenceTo<FeatureTable>();
20 }
21
22 Offset featureTableOffset = featureRecordArray[featureIndex].featureTableOffset;
23
24 *featureTag = SWAPT(featureRecordArray[featureIndex].featureTag);
25
26 return LEReferenceTo<FeatureTable>(base, success, SWAPW(featureTableOffset));
27 }
28
29 #if 0
30 /*
31 * Note: according to the OpenType Spec. v 1.4, the entries in the Feature
32 * List Table are sorted alphabetically by feature tag; however, there seem
33 * to be some fonts which have an unsorted list; that's why the binary search
34 * is #if 0'd out and replaced by a linear search.
35 *
36 * Also note: as of ICU 2.6, this method isn't called anyhow...
37 */
38 const FeatureTable *FeatureListTable::getFeatureTable(LETag featureTag) const
39 {
40 #if 0
41 Offset featureTableOffset =
42 OpenTypeUtilities::getTagOffset(featureTag, (TagAndOffsetRecord *) featureRecordArray, SWAPW(featureCount));
43
44 if (featureTableOffset == 0) {
45 return 0;
46 }
47
48 return (const FeatureTable *) ((char *) this + SWAPW(featureTableOffset));
49 #else
50 int count = SWAPW(featureCount);
51
52 for (int i = 0; i < count; i += 1) {
53 if (SWAPT(featureRecordArray[i].featureTag) == featureTag) {
54 return (const FeatureTable *) ((char *) this + SWAPW(featureRecordArray[i].featureTableOffset));
55 }
56 }
57
58 return 0;
59 #endif
60 }
61 #endif
62
63 U_NAMESPACE_END
64