~ubuntu-branches/ubuntu/gutsy/icu/gutsy-updates

« back to all changes in this revision

Viewing changes to source/layout/DeviceTables.cpp

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2005-11-19 11:29:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20051119112931-vcizkrp10tli4enw
Tags: 3.4-3
Explicitly build with g++ 3.4.  The current ICU fails its test suite
with 4.0 but not with 3.4.  Future versions should work properly with
4.0.

Show diffs side-by-side

added added

removed removed

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