Skip to content

Commit b920f1e

Browse files
committed
SwingJS fixes
1 parent 761bdd3 commit b920f1e

File tree

7 files changed

+28
-7
lines changed

7 files changed

+28
-7
lines changed
85.9 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200219170133
1+
20200220124544
85.9 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200219170133
1+
20200220124544
85.9 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/test/Test_Font.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package test;
22

33
import java.awt.Font;
4+
import java.awt.Graphics2D;
5+
import java.awt.font.FontRenderContext;
6+
import java.awt.font.LineMetrics;
47

8+
import javax.swing.JFrame;
59
import javax.swing.JLabel;
610

711
/**
@@ -14,16 +18,32 @@ public class Test_Font extends Test_ {
1418
public static void main(String[] args) {
1519

1620
JLabel c = new JLabel("testing");
21+
JFrame f = new JFrame();
22+
f.pack();
23+
Graphics2D g = (Graphics2D) f.getGraphics();
24+
FontRenderContext frc = g.getFontRenderContext();
25+
g.dispose();
1726
for (int i = 6; i < 20; i++) {
18-
System.out.println(c.getFontMetrics(new Font(Font.DIALOG, Font.PLAIN, i)));
19-
System.out.println(c.getFontMetrics(new Font(Font.SERIF, Font.PLAIN, i)));
20-
System.out.println(c.getFontMetrics(new Font(Font.SANS_SERIF, Font.PLAIN, i)));
21-
System.out.println(c.getFontMetrics(new Font(Font.MONOSPACED, Font.PLAIN, i)));
27+
show(frc, Font.DIALOG, Font.PLAIN, i);
28+
show(frc, Font.SERIF, Font.PLAIN, i);
29+
show(frc, Font.SANS_SERIF, Font.PLAIN, i);
30+
show(frc, Font.MONOSPACED, Font.PLAIN, i);
2231
}
2332

2433

2534

2635
System.out.println("Test_Font OK");
2736
}
2837

38+
private static void show(FontRenderContext frc, String name, int style, int size) {
39+
Font f=new Font(name, style, size);
40+
LineMetrics lm = f.getLineMetrics("X", frc);
41+
42+
System.out.println(size + " so=" + lm.getStrikethroughOffset()
43+
+ " st="+ lm.getStrikethroughThickness() + "/" + (size/4f)
44+
+ " uo=" + lm.getUnderlineOffset()
45+
+ " ut= " + lm.getUnderlineThickness()
46+
);
47+
}
48+
2949
}

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10698,7 +10698,7 @@ if (J2S && J2S._version) return;
1069810698
* or a message in System.err will be generated by Clazz.setTVer(ver).
1069910699
*
1070010700
*/
10701-
var VERSION = "3.2.7";
10701+
var VERSION = "3.2.8";
1070210702

1070310703

1070410704
jQuery || alert("Note -- jQuery is required, but it's not defined.");
@@ -13871,6 +13871,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1387113871

1387213872
// Google closure compiler cannot handle Clazz.new or Clazz.super
1387313873

13874+
// BH 2020.02.18 2.3.8-v2 upgrades String, Integer, ClassLoader, Package, various Exceptions
1387413875
// BH 2020.02.12 3.2.8-v1 new Throwable().getStackTrace() should not include j2sClazz methods
1387513876
// BH 2020.02.02 3.2.7-v5 fixes array.getClass().getName() and getArrayClass() for short -- should be [S, not [H, for Java
1387613877
// BH 2019.12.29 3.2.6 fixes Float.parseFloat$S("NaN") [and Double]

0 commit comments

Comments
 (0)