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