author | ihse |
Tue, 22 Oct 2019 09:51:52 +0200 | |
branch | ihse-cflags-rewrite-branch |
changeset 58736 | e878a0b7cff0 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
28996
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
1 |
/* |
46151
5fa789776f7d
8185500: [TESTBUG] Add keywords headful/printer in java/awt and javax tests.
goetz
parents:
28996
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
28996
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
4 |
* |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
8 |
* |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
13 |
* accompanied this code). |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
14 |
* |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
18 |
* |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
21 |
* questions. |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
22 |
*/ |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
23 |
|
46151
5fa789776f7d
8185500: [TESTBUG] Add keywords headful/printer in java/awt and javax tests.
goetz
parents:
28996
diff
changeset
|
24 |
/** |
28996
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
25 |
* @test |
46151
5fa789776f7d
8185500: [TESTBUG] Add keywords headful/printer in java/awt and javax tests.
goetz
parents:
28996
diff
changeset
|
26 |
* @key headful |
28996
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
27 |
* @bug 8064833 |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
28 |
* @summary Test correct font is obtained via famil+style |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
29 |
* @run main HelvLtOblTest |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
30 |
*/ |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
31 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
32 |
import javax.swing.JComponent; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
33 |
import javax.swing.JFrame; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
34 |
import javax.swing.SwingUtilities; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
35 |
import java.awt.Color; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
36 |
import java.awt.Dimension; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
37 |
import java.awt.Font; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
38 |
import java.awt.Graphics; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
39 |
import java.awt.Graphics2D; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
40 |
import java.awt.GraphicsEnvironment; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
41 |
import java.awt.RenderingHints; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
42 |
import java.awt.font.FontRenderContext; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
43 |
import java.awt.font.GlyphVector; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
44 |
import java.awt.image.BufferedImage; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
45 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
46 |
public class HelvLtOblTest extends JComponent { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
47 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
48 |
static Font helvFont = null; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
49 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
50 |
static int[] codes = { 0x23, 0x4a, 0x48, 0x3, 0x4a, 0x55, 0x42, 0x4d, |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
51 |
0x4a, 0x44, 0x3, |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
52 |
0x53, 0x46, 0x45, 0x3, 0x55, 0x46, 0x59, 0x55, }; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
53 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
54 |
static String str = "Big italic red text"; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
55 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
56 |
public static void main(String[] args) throws Exception { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
57 |
String os = System.getProperty("os.name"); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
58 |
if (!os.startsWith("Mac")) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
59 |
return; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
60 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
61 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
62 |
Font[] fonts = ge.getAllFonts(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
63 |
for (int i=0; i<fonts.length; i++) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
64 |
if (fonts[i].getPSName().equals("Helvetica-LightOblique")) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
65 |
helvFont = fonts[i]; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
66 |
break; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
67 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
68 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
69 |
if (helvFont == null) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
70 |
return; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
71 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
72 |
final HelvLtOblTest test = new HelvLtOblTest(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
73 |
SwingUtilities.invokeLater(() -> { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
74 |
JFrame f = new JFrame(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
75 |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
76 |
f.add("Center", test); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
77 |
f.pack(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
78 |
f.setVisible(true); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
79 |
}); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
80 |
test.compareImages(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
81 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
82 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
83 |
public Dimension getPreferredSize() { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
84 |
return new Dimension(400,400); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
85 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
86 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
87 |
public void paintComponent(Graphics g) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
88 |
super.paintComponent(g); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
89 |
Graphics2D g2 = (Graphics2D)g; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
90 |
FontRenderContext frc = new FontRenderContext(null, true, true); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
91 |
Font f = helvFont.deriveFont(Font.PLAIN, 40); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
92 |
System.out.println("font = " +f.getFontName()); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
93 |
GlyphVector gv = f.createGlyphVector(frc, codes); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
94 |
g.setFont(f); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
95 |
g.setColor(Color.white); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
96 |
g.fillRect(0,0,400,400); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
97 |
g.setColor(Color.black); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
98 |
g2.drawGlyphVector(gv, 5,200); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
99 |
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
100 |
RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
101 |
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
102 |
RenderingHints.VALUE_FRACTIONALMETRICS_ON); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
103 |
g2.drawString(str, 5, 250); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
104 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
105 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
106 |
void compareImages() { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
107 |
BufferedImage bi0 = drawText(false); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
108 |
BufferedImage bi1 = drawText(true); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
109 |
compare(bi0, bi1); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
110 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
111 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
112 |
BufferedImage drawText(boolean doGV) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
113 |
int w = 400; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
114 |
int h = 50; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
115 |
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
116 |
Graphics2D g = bi.createGraphics(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
117 |
g.setColor(Color.white); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
118 |
g.fillRect(0,0,w,h); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
119 |
g.setColor(Color.black); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
120 |
Font f = helvFont.deriveFont(Font.PLAIN, 40); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
121 |
g.setFont(f); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
122 |
int x = 5; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
123 |
int y = h - 10; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
124 |
if (doGV) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
125 |
FontRenderContext frc = new FontRenderContext(null, true, true); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
126 |
GlyphVector gv = f.createGlyphVector(frc, codes); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
127 |
g.drawGlyphVector(gv, 5, y); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
128 |
} else { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
129 |
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
130 |
RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
131 |
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
132 |
RenderingHints.VALUE_FRACTIONALMETRICS_ON); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
133 |
g.drawString(str, x, y); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
134 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
135 |
return bi; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
136 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
137 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
138 |
// Need to allow for minimal rounding error, so allow each component |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
139 |
// to differ by 1. |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
140 |
void compare(BufferedImage bi0, BufferedImage bi1) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
141 |
int wid = bi0.getWidth(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
142 |
int hgt = bi0.getHeight(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
143 |
for (int x=0; x<wid; x++) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
144 |
for (int y=0; y<hgt; y++) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
145 |
int rgb0 = bi0.getRGB(x, y); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
146 |
int rgb1 = bi1.getRGB(x, y); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
147 |
if (rgb0 == rgb1) continue; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
148 |
int r0 = (rgb0 & 0xff0000) >> 16; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
149 |
int r1 = (rgb1 & 0xff0000) >> 16; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
150 |
int rdiff = r0-r1; if (rdiff<0) rdiff = -rdiff; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
151 |
int g0 = (rgb0 & 0x00ff00) >> 8; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
152 |
int g1 = (rgb1 & 0x00ff00) >> 8; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
153 |
int gdiff = g0-g1; if (gdiff<0) gdiff = -gdiff; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
154 |
int b0 = (rgb0 & 0x0000ff); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
155 |
int b1 = (rgb1 & 0x0000ff); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
156 |
int bdiff = b0-b1; if (bdiff<0) bdiff = -bdiff; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
157 |
if (rdiff > 1 || gdiff > 1 || bdiff > 1) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
158 |
throw new RuntimeException( |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
159 |
"Images differ at x=" + x + " y="+ y + " " + |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
160 |
Integer.toHexString(rgb0) + " vs " + |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
161 |
Integer.toHexString(rgb1)); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
162 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
163 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
164 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
165 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
166 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
diff
changeset
|
167 |
} |