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

« back to all changes in this revision

Viewing changes to source/layout/AnchorTables.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
 
 * @(#)AnchorTables.cpp 1.6 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 "LEFontInstance.h"
10
 
#include "DeviceTables.h"
11
 
#include "AnchorTables.h"
12
 
#include "LESwaps.h"
13
 
 
14
 
U_NAMESPACE_BEGIN
15
 
 
16
 
void AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance,
17
 
                            LEPoint &anchor) const
18
 
{
19
 
    switch(SWAPW(anchorFormat)) {
20
 
    case 1:
21
 
    {
22
 
        const Format1AnchorTable *f1 = (const Format1AnchorTable *) this;
23
 
 
24
 
        f1->getAnchor(fontInstance, anchor);
25
 
        break;
26
 
    }
27
 
 
28
 
    case 2:
29
 
    {
30
 
        const Format2AnchorTable *f2 = (const Format2AnchorTable *) this;
31
 
 
32
 
        f2->getAnchor(glyphID, fontInstance, anchor);
33
 
        break;
34
 
    }
35
 
 
36
 
    case 3:
37
 
    {
38
 
        const Format3AnchorTable *f3 = (const Format3AnchorTable *) this;
39
 
 
40
 
        f3->getAnchor(fontInstance, anchor);
41
 
        break;
42
 
    }
43
 
 
44
 
    default:
45
 
        break;
46
 
    }
47
 
}
48
 
 
49
 
void Format1AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
50
 
{
51
 
    le_int16 x = SWAPW(xCoordinate);
52
 
    le_int16 y = SWAPW(yCoordinate);
53
 
    LEPoint pixels;
54
 
 
55
 
    fontInstance->transformFunits(x, y, pixels);
56
 
 
57
 
    fontInstance->pixelsToUnits(pixels, anchor);
58
 
}
59
 
 
60
 
void Format2AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor) const
61
 
{
62
 
    LEPoint point;
63
 
 
64
 
    if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) {
65
 
        le_int16 x = SWAPW(xCoordinate);
66
 
        le_int16 y = SWAPW(yCoordinate);
67
 
 
68
 
        fontInstance->transformFunits(x, y, point);
69
 
    }
70
 
 
71
 
 
72
 
    fontInstance->pixelsToUnits(point, anchor);
73
 
}
74
 
 
75
 
void Format3AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
76
 
{
77
 
    le_int16 x = SWAPW(xCoordinate);
78
 
    le_int16 y = SWAPW(yCoordinate);
79
 
    LEPoint pixels;
80
 
    Offset dtxOffset = SWAPW(xDeviceTableOffset);
81
 
    Offset dtyOffset = SWAPW(yDeviceTableOffset);
82
 
 
83
 
    fontInstance->transformFunits(x, y, pixels);
84
 
 
85
 
    if (dtxOffset != 0) {
86
 
        const DeviceTable *dtx = (const DeviceTable *) ((char *) this + dtxOffset);
87
 
        le_int16 adjx = dtx->getAdjustment((le_int16) fontInstance->getXPixelsPerEm());
88
 
 
89
 
        pixels.fX += adjx;
90
 
    }
91
 
 
92
 
    if (dtyOffset != 0) {
93
 
        const DeviceTable *dty = (const DeviceTable *) ((char *) this + dtyOffset);
94
 
        le_int16 adjy = dty->getAdjustment((le_int16) fontInstance->getYPixelsPerEm());
95
 
 
96
 
        pixels.fY += adjy;
97
 
    }
98
 
 
99
 
    fontInstance->pixelsToUnits(pixels, anchor);
100
 
}
101
 
 
102
 
U_NAMESPACE_END
103