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