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