Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/font/layout/AnchorTables.cpp
38918 views
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
6
* published by the Free Software Foundation. Oracle designates this
7
* particular file as subject to the "Classpath" exception as provided
8
* by Oracle in the LICENSE file that accompanied this code.
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
*
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.
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
38
U_NAMESPACE_BEGIN
39
40
void AnchorTable::getAnchor(const LETableReference &base, LEGlyphID glyphID, const LEFontInstance *fontInstance,
41
LEPoint &anchor, LEErrorCode &success) const
42
{
43
switch(SWAPW(anchorFormat)) {
44
case 1:
45
{
46
LEReferenceTo<Format1AnchorTable> f1(base, success);
47
if (LE_SUCCESS(success)) {
48
f1->getAnchor(f1, fontInstance, anchor, success);
49
}
50
break;
51
}
52
53
case 2:
54
{
55
LEReferenceTo<Format2AnchorTable> f2(base, success);
56
if (LE_SUCCESS(success)) {
57
f2->getAnchor(f2, glyphID, fontInstance, anchor, success);
58
}
59
break;
60
}
61
62
case 3:
63
{
64
LEReferenceTo<Format3AnchorTable> f3(base, success);
65
if (LE_SUCCESS(success)) {
66
f3->getAnchor(f3, fontInstance, anchor, success);
67
}
68
break;
69
}
70
71
default:
72
{
73
// unknown format: just use x, y coordinate, like format 1...
74
LEReferenceTo<Format1AnchorTable> f1(base, success);
75
if (LE_SUCCESS(success)) {
76
f1->getAnchor(f1, fontInstance, anchor, success);
77
}
78
break;
79
}
80
}
81
}
82
83
void Format1AnchorTable::getAnchor(const LEReferenceTo<Format1AnchorTable>& base, const LEFontInstance *fontInstance, LEPoint &anchor, LEErrorCode &success) const
84
{
85
le_int16 x = SWAPW(xCoordinate);
86
le_int16 y = SWAPW(yCoordinate);
87
LEPoint pixels;
88
89
fontInstance->transformFunits(x, y, pixels);
90
fontInstance->pixelsToUnits(pixels, anchor);
91
}
92
93
void Format2AnchorTable::getAnchor(const LEReferenceTo<Format2AnchorTable>& base,
94
LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor
95
, LEErrorCode &success) const
96
{
97
LEPoint point;
98
99
if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) {
100
le_int16 x = SWAPW(xCoordinate);
101
le_int16 y = SWAPW(yCoordinate);
102
103
fontInstance->transformFunits(x, y, point);
104
}
105
106
107
fontInstance->pixelsToUnits(point, anchor);
108
}
109
110
void Format3AnchorTable::getAnchor(const LEReferenceTo<Format3AnchorTable> &base, const LEFontInstance *fontInstance,
111
LEPoint &anchor, LEErrorCode &success) const
112
{
113
le_int16 x = SWAPW(xCoordinate);
114
le_int16 y = SWAPW(yCoordinate);
115
LEPoint pixels;
116
Offset dtxOffset = SWAPW(xDeviceTableOffset);
117
Offset dtyOffset = SWAPW(yDeviceTableOffset);
118
119
fontInstance->transformFunits(x, y, pixels);
120
121
if (dtxOffset != 0) {
122
LEReferenceTo<DeviceTable> dt(base, success, dtxOffset);
123
if (LE_SUCCESS(success)) {
124
le_int16 adjx = dt->getAdjustment(dt, (le_int16) fontInstance->getXPixelsPerEm(), success);
125
pixels.fX += adjx;
126
}
127
}
128
129
if (dtyOffset != 0) {
130
LEReferenceTo<DeviceTable> dt(base, success, dtyOffset);
131
if (LE_SUCCESS(success)) {
132
le_int16 adjy = dt->getAdjustment(dt, (le_int16) fontInstance->getYPixelsPerEm(), success);
133
pixels.fY += adjy;
134
}
135
}
136
137
fontInstance->pixelsToUnits(pixels, anchor);
138
}
139
140
U_NAMESPACE_END
141
142
143