1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/DeviceTables.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,44 @@
1.4 +/*
1.5 + * @(#)DeviceTables.cpp 1.5 00/03/15
1.6 + *
1.7 + * (C) Copyright IBM Corp. 1998 - 2005 - All Rights Reserved
1.8 + *
1.9 + */
1.10 +
1.11 +#include "LETypes.h"
1.12 +#include "OpenTypeTables.h"
1.13 +#include "DeviceTables.h"
1.14 +#include "LESwaps.h"
1.15 +
1.16 +U_NAMESPACE_BEGIN
1.17 +
1.18 +const le_uint16 DeviceTable::fieldMasks[] = {0x0003, 0x000F, 0x00FF};
1.19 +const le_uint16 DeviceTable::fieldSignBits[] = {0x0002, 0x0008, 0x0080};
1.20 +const le_uint16 DeviceTable::fieldBits[] = { 2, 4, 8};
1.21 +
1.22 +le_int16 DeviceTable::getAdjustment(le_uint16 ppem) const
1.23 +{
1.24 + le_uint16 start = SWAPW(startSize);
1.25 + le_uint16 format = SWAPW(deltaFormat) - 1;
1.26 + le_int16 result = 0;
1.27 +
1.28 + if (ppem >= start && ppem <= SWAPW(endSize)) {
1.29 + le_uint16 sizeIndex = ppem - start;
1.30 + le_uint16 bits = fieldBits[format];
1.31 + le_uint16 count = 16 / bits;
1.32 + le_uint16 word = SWAPW(deltaValues[sizeIndex / count]);
1.33 + le_uint16 fieldIndex = sizeIndex % count;
1.34 + le_uint16 shift = 16 - (bits * (fieldIndex + 1));
1.35 + le_uint16 field = (word >> shift) & fieldMasks[format];
1.36 +
1.37 + result = field;
1.38 +
1.39 + if ((field & fieldSignBits[format]) != 0) {
1.40 + result |= ~ fieldMasks[format];
1.41 + }
1.42 + }
1.43 +
1.44 + return result;
1.45 +}
1.46 +
1.47 +U_NAMESPACE_END