OutlineConsumerAdapter.java
4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.fontengine.font;
import com.adobe.fontengine.font.Matrix;
import com.adobe.fontengine.font.OutlineConsumer;
import com.adobe.fontengine.font.OutlineConsumer2;
public class OutlineConsumerAdapter
implements OutlineConsumer {
final OutlineConsumer2 dest;
protected boolean contourStarted;
double startX;
double startY;
double currentX;
double currentY;
protected Matrix toEmMatrix = Matrix.IDENTITY_MATRIX;
protected Matrix emToDeviceMatrix = Matrix.IDENTITY_MATRIX;
protected Matrix compositeMatrix = Matrix.IDENTITY_MATRIX;
public OutlineConsumerAdapter(OutlineConsumer2 dest) {
this.dest = dest;
}
public void startOutline() {
this.dest.startOutline();
this.contourStarted = false;
}
public void setMatrix(Matrix m) {
this.setMatrices(m, this.emToDeviceMatrix);
}
public void setEmToPixelMatrix(Matrix m) {
this.setMatrices(this.toEmMatrix, m);
}
protected void setMatrices(Matrix toEmMatrix, Matrix emToDeviceMatrix) {
this.toEmMatrix = toEmMatrix;
this.emToDeviceMatrix = emToDeviceMatrix;
this.compositeMatrix = toEmMatrix.isIdentity() ? emToDeviceMatrix : (emToDeviceMatrix.isIdentity() ? toEmMatrix : toEmMatrix.multiply(emToDeviceMatrix));
}
public void moveto(double x, double y) {
if (this.contourStarted) {
this.dest.line(this.compositeMatrix.applyToXYGetX(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetY(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetX(this.startX, this.startY), this.compositeMatrix.applyToXYGetY(this.startX, this.startY));
this.dest.endContour();
this.contourStarted = false;
}
this.currentX = x;
this.currentY = y;
}
public void lineto(double x2, double y2) {
if (!this.contourStarted) {
this.dest.startContour();
this.contourStarted = true;
this.startX = this.currentX;
this.startY = this.currentY;
}
this.dest.line(this.compositeMatrix.applyToXYGetX(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetY(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetX(x2, y2), this.compositeMatrix.applyToXYGetY(x2, y2));
this.currentX = x2;
this.currentY = y2;
}
public void curveto(double x2, double y2, double x3, double y3) {
if (!this.contourStarted) {
this.dest.startContour();
this.contourStarted = true;
this.startX = this.currentX;
this.startY = this.currentY;
}
this.dest.quadraticCurve(this.compositeMatrix.applyToXYGetX(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetY(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetX(x2, y2), this.compositeMatrix.applyToXYGetY(x2, y2), this.compositeMatrix.applyToXYGetX(x3, y3), this.compositeMatrix.applyToXYGetY(x3, y3));
this.currentX = x3;
this.currentY = y3;
}
public void curveto(double x2, double y2, double x3, double y3, double x4, double y4) {
if (!this.contourStarted) {
this.dest.startContour();
this.contourStarted = true;
this.startX = this.currentX;
this.startY = this.currentY;
}
this.dest.cubicCurve(this.compositeMatrix.applyToXYGetX(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetY(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetX(x2, y2), this.compositeMatrix.applyToXYGetY(x2, y2), this.compositeMatrix.applyToXYGetX(x3, y3), this.compositeMatrix.applyToXYGetY(x3, y3), this.compositeMatrix.applyToXYGetX(x4, y4), this.compositeMatrix.applyToXYGetY(x4, y4));
this.currentX = x4;
this.currentY = y4;
}
public void endOutline() {
if (this.contourStarted) {
if (this.currentX != this.startX || this.currentY != this.startY) {
this.dest.line(this.compositeMatrix.applyToXYGetX(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetY(this.currentX, this.currentY), this.compositeMatrix.applyToXYGetX(this.startX, this.startY), this.compositeMatrix.applyToXYGetY(this.startX, this.startY));
}
this.dest.endContour();
}
this.dest.endOutline();
}
public void endchar() {
}
}