2
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
5506
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
2
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
*
|
|
28 |
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
|
|
29 |
*
|
|
30 |
*/
|
|
31 |
|
|
32 |
#include "LETypes.h"
|
|
33 |
#include "LEFontInstance.h"
|
|
34 |
#include "DeviceTables.h"
|
|
35 |
#include "AnchorTables.h"
|
|
36 |
#include "LESwaps.h"
|
|
37 |
|
3935
|
38 |
U_NAMESPACE_BEGIN
|
|
39 |
|
2
|
40 |
void AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance,
|
|
41 |
LEPoint &anchor) const
|
|
42 |
{
|
|
43 |
switch(SWAPW(anchorFormat)) {
|
|
44 |
case 1:
|
|
45 |
{
|
|
46 |
const Format1AnchorTable *f1 = (const Format1AnchorTable *) this;
|
|
47 |
|
|
48 |
f1->getAnchor(fontInstance, anchor);
|
|
49 |
break;
|
|
50 |
}
|
|
51 |
|
|
52 |
case 2:
|
|
53 |
{
|
|
54 |
const Format2AnchorTable *f2 = (const Format2AnchorTable *) this;
|
|
55 |
|
|
56 |
f2->getAnchor(glyphID, fontInstance, anchor);
|
|
57 |
break;
|
|
58 |
}
|
|
59 |
|
|
60 |
case 3:
|
|
61 |
{
|
|
62 |
const Format3AnchorTable *f3 = (const Format3AnchorTable *) this;
|
|
63 |
|
|
64 |
f3->getAnchor(fontInstance, anchor);
|
|
65 |
break;
|
|
66 |
}
|
|
67 |
|
|
68 |
default:
|
|
69 |
// unknown format: just use x, y coordinate, like format 1...
|
|
70 |
const Format1AnchorTable *f1 = (const Format1AnchorTable *) this;
|
|
71 |
|
|
72 |
f1->getAnchor(fontInstance, anchor);
|
|
73 |
break;
|
|
74 |
}
|
|
75 |
}
|
|
76 |
|
|
77 |
void Format1AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
|
|
78 |
{
|
|
79 |
le_int16 x = SWAPW(xCoordinate);
|
|
80 |
le_int16 y = SWAPW(yCoordinate);
|
|
81 |
LEPoint pixels;
|
|
82 |
|
|
83 |
fontInstance->transformFunits(x, y, pixels);
|
|
84 |
|
|
85 |
fontInstance->pixelsToUnits(pixels, anchor);
|
|
86 |
}
|
|
87 |
|
|
88 |
void Format2AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor) const
|
|
89 |
{
|
|
90 |
LEPoint point;
|
|
91 |
|
|
92 |
if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) {
|
|
93 |
le_int16 x = SWAPW(xCoordinate);
|
|
94 |
le_int16 y = SWAPW(yCoordinate);
|
|
95 |
|
|
96 |
fontInstance->transformFunits(x, y, point);
|
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
fontInstance->pixelsToUnits(point, anchor);
|
|
101 |
}
|
|
102 |
|
|
103 |
void Format3AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
|
|
104 |
{
|
|
105 |
le_int16 x = SWAPW(xCoordinate);
|
|
106 |
le_int16 y = SWAPW(yCoordinate);
|
|
107 |
LEPoint pixels;
|
|
108 |
Offset dtxOffset = SWAPW(xDeviceTableOffset);
|
|
109 |
Offset dtyOffset = SWAPW(yDeviceTableOffset);
|
|
110 |
|
|
111 |
fontInstance->transformFunits(x, y, pixels);
|
|
112 |
|
|
113 |
if (dtxOffset != 0) {
|
|
114 |
const DeviceTable *dtx = (const DeviceTable *) ((char *) this + dtxOffset);
|
|
115 |
le_int16 adjx = dtx->getAdjustment((le_int16) fontInstance->getXPixelsPerEm());
|
|
116 |
|
|
117 |
pixels.fX += adjx;
|
|
118 |
}
|
|
119 |
|
|
120 |
if (dtyOffset != 0) {
|
|
121 |
const DeviceTable *dty = (const DeviceTable *) ((char *) this + dtyOffset);
|
|
122 |
le_int16 adjy = dty->getAdjustment((le_int16) fontInstance->getYPixelsPerEm());
|
|
123 |
|
|
124 |
pixels.fY += adjy;
|
|
125 |
}
|
|
126 |
|
|
127 |
fontInstance->pixelsToUnits(pixels, anchor);
|
|
128 |
}
|
3935
|
129 |
|
|
130 |
U_NAMESPACE_END
|
|
131 |
|