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