]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | * @(#)Features.cpp 1.4 00/03/15 | |
3 | * | |
57a6839d | 4 | * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved |
b75a7d8f A |
5 | * |
6 | */ | |
7 | ||
8 | #include "LETypes.h" | |
9 | #include "OpenTypeUtilities.h" | |
10 | #include "OpenTypeTables.h" | |
729e4ab9 | 11 | #include "ICUFeatures.h" |
b75a7d8f A |
12 | #include "LESwaps.h" |
13 | ||
14 | U_NAMESPACE_BEGIN | |
15 | ||
57a6839d | 16 | LEReferenceTo<FeatureTable> FeatureListTable::getFeatureTable(const LETableReference &base, le_uint16 featureIndex, LETag *featureTag, LEErrorCode &success) const |
b75a7d8f | 17 | { |
57a6839d A |
18 | if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) { |
19 | return LEReferenceTo<FeatureTable>(); | |
20 | } | |
b75a7d8f A |
21 | |
22 | Offset featureTableOffset = featureRecordArray[featureIndex].featureTableOffset; | |
23 | ||
24 | *featureTag = SWAPT(featureRecordArray[featureIndex].featureTag); | |
25 | ||
57a6839d | 26 | return LEReferenceTo<FeatureTable>(base, success, SWAPW(featureTableOffset)); |
b75a7d8f A |
27 | } |
28 | ||
57a6839d | 29 | #if 0 |
b75a7d8f A |
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 | } | |
57a6839d | 61 | #endif |
b75a7d8f A |
62 | |
63 | U_NAMESPACE_END |