equal
deleted
inserted
replaced
|
1 /* |
|
2 * @(#)DeviceTables.cpp 1.5 00/03/15 |
|
3 * |
|
4 * (C) Copyright IBM Corp. 1998 - 2005 - All Rights Reserved |
|
5 * |
|
6 */ |
|
7 |
|
8 #include "LETypes.h" |
|
9 #include "OpenTypeTables.h" |
|
10 #include "DeviceTables.h" |
|
11 #include "LESwaps.h" |
|
12 |
|
13 U_NAMESPACE_BEGIN |
|
14 |
|
15 const le_uint16 DeviceTable::fieldMasks[] = {0x0003, 0x000F, 0x00FF}; |
|
16 const le_uint16 DeviceTable::fieldSignBits[] = {0x0002, 0x0008, 0x0080}; |
|
17 const le_uint16 DeviceTable::fieldBits[] = { 2, 4, 8}; |
|
18 |
|
19 le_int16 DeviceTable::getAdjustment(le_uint16 ppem) const |
|
20 { |
|
21 le_uint16 start = SWAPW(startSize); |
|
22 le_uint16 format = SWAPW(deltaFormat) - 1; |
|
23 le_int16 result = 0; |
|
24 |
|
25 if (ppem >= start && ppem <= SWAPW(endSize)) { |
|
26 le_uint16 sizeIndex = ppem - start; |
|
27 le_uint16 bits = fieldBits[format]; |
|
28 le_uint16 count = 16 / bits; |
|
29 le_uint16 word = SWAPW(deltaValues[sizeIndex / count]); |
|
30 le_uint16 fieldIndex = sizeIndex % count; |
|
31 le_uint16 shift = 16 - (bits * (fieldIndex + 1)); |
|
32 le_uint16 field = (word >> shift) & fieldMasks[format]; |
|
33 |
|
34 result = field; |
|
35 |
|
36 if ((field & fieldSignBits[format]) != 0) { |
|
37 result |= ~ fieldMasks[format]; |
|
38 } |
|
39 } |
|
40 |
|
41 return result; |
|
42 } |
|
43 |
|
44 U_NAMESPACE_END |