1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import java.awt.Canvas; |
24 |
|
import java.awt.Font; |
25 |
|
import java.awt.FontMetrics; |
26 |
|
|
27 |
|
import org.testng.annotations.BeforeClass; |
28 |
|
import org.testng.annotations.Test; |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 9 |
Complexity Density: 0.45 |
|
30 |
|
public class FontChooserTest |
31 |
|
{ |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
33 |
0 |
@BeforeClass(alwaysRun = true)... |
34 |
|
public void setUpJvOptionPane() |
35 |
|
{ |
36 |
0 |
JvOptionPane.setInteractiveMode(false); |
37 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
38 |
|
} |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 8 |
Complexity Density: 0.44 |
4-
|
|
46 |
0 |
@Test(groups = { "Functional" }, enabled = false)... |
47 |
|
public void dumpInvalidFonts() |
48 |
|
{ |
49 |
0 |
String[] fonts = java.awt.GraphicsEnvironment |
50 |
|
.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); |
51 |
0 |
final Canvas canvas = new Canvas(); |
52 |
0 |
for (int pointSize = 1;; pointSize++) |
53 |
|
{ |
54 |
0 |
System.out.println(System.lineSeparator() |
55 |
|
+ "Plain fonts with sub-pixel width at " + pointSize + "pt:"); |
56 |
0 |
if (pointSize == 1) |
57 |
|
{ |
58 |
0 |
System.out.println("All except:"); |
59 |
|
} |
60 |
0 |
int badCount = 0; |
61 |
0 |
for (String fontname : fonts) |
62 |
|
{ |
63 |
0 |
Font newFont = new Font(fontname, Font.PLAIN, pointSize); |
64 |
0 |
FontMetrics fontm = canvas.getFontMetrics(newFont); |
65 |
0 |
double iw = fontm.getStringBounds("I", null).getWidth(); |
66 |
0 |
final boolean tooSmall = iw < 1d; |
67 |
0 |
if (tooSmall) |
68 |
|
{ |
69 |
0 |
badCount++; |
70 |
|
} |
71 |
0 |
if ((pointSize > 1 && tooSmall) || (pointSize == 1 && !tooSmall)) |
72 |
|
{ |
73 |
0 |
System.out.println(fontname); |
74 |
|
} |
75 |
|
} |
76 |
0 |
if (badCount == 0) |
77 |
|
{ |
78 |
0 |
break; |
79 |
|
} |
80 |
|
} |
81 |
|
} |
82 |
|
|
83 |
|
} |