1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/Features.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,61 @@
1.4 +/*
1.5 + * @(#)Features.cpp 1.4 00/03/15
1.6 + *
1.7 + * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
1.8 + *
1.9 + */
1.10 +
1.11 +#include "LETypes.h"
1.12 +#include "OpenTypeUtilities.h"
1.13 +#include "OpenTypeTables.h"
1.14 +#include "Features.h"
1.15 +#include "LESwaps.h"
1.16 +
1.17 +U_NAMESPACE_BEGIN
1.18 +
1.19 +const FeatureTable *FeatureListTable::getFeatureTable(le_uint16 featureIndex, LETag *featureTag) const
1.20 +{
1.21 + if (featureIndex >= SWAPW(featureCount)) {
1.22 + return 0;
1.23 + }
1.24 +
1.25 + Offset featureTableOffset = featureRecordArray[featureIndex].featureTableOffset;
1.26 +
1.27 + *featureTag = SWAPT(featureRecordArray[featureIndex].featureTag);
1.28 +
1.29 + return (const FeatureTable *) ((char *) this + SWAPW(featureTableOffset));
1.30 +}
1.31 +
1.32 +/*
1.33 + * Note: according to the OpenType Spec. v 1.4, the entries in the Feature
1.34 + * List Table are sorted alphabetically by feature tag; however, there seem
1.35 + * to be some fonts which have an unsorted list; that's why the binary search
1.36 + * is #if 0'd out and replaced by a linear search.
1.37 + *
1.38 + * Also note: as of ICU 2.6, this method isn't called anyhow...
1.39 + */
1.40 +const FeatureTable *FeatureListTable::getFeatureTable(LETag featureTag) const
1.41 +{
1.42 +#if 0
1.43 + Offset featureTableOffset =
1.44 + OpenTypeUtilities::getTagOffset(featureTag, (TagAndOffsetRecord *) featureRecordArray, SWAPW(featureCount));
1.45 +
1.46 + if (featureTableOffset == 0) {
1.47 + return 0;
1.48 + }
1.49 +
1.50 + return (const FeatureTable *) ((char *) this + SWAPW(featureTableOffset));
1.51 +#else
1.52 + int count = SWAPW(featureCount);
1.53 +
1.54 + for (int i = 0; i < count; i += 1) {
1.55 + if (SWAPT(featureRecordArray[i].featureTag) == featureTag) {
1.56 + return (const FeatureTable *) ((char *) this + SWAPW(featureRecordArray[i].featureTableOffset));
1.57 + }
1.58 + }
1.59 +
1.60 + return 0;
1.61 +#endif
1.62 +}
1.63 +
1.64 +U_NAMESPACE_END