-
Bug
-
Resolution: Fixed
-
P4
-
None
-
7u6
Run the following snippet on J2D and some other (ES2, D3D) pipeline
public class FXSwing {
private static void initAndShowGUI() {
String url = "file:///Users/felipe/Documents/fonts/CrashLandingBB.ttf";
final Font jxFont = Font.loadFont(url, 36);
java.awt.Font awtFont = new java.awt.Font(jxFont.getName(), java.awt.Font.PLAIN, 36);
JFrame frame = new JFrame("FX");
final JFXPanel fxPanel = new JFXPanel();
JLabel jlabel = new JLabel("my swing label");
jlabel.setFont(awtFont);
JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, fxPanel, jlabel);
splitter.setBackground(java.awt.Color.WHITE);
splitter.setDividerLocation(300);
frame.add(splitter);
Platform.runLater(new Runnable() {
public void run() {
VBox box = new VBox();
box.setAlignment(Pos.CENTER_LEFT);
Text text = new Text("my jfx text");
text.setFont(jxFont);
box.getChildren().add(text);
Scene scene = new Scene(box, 200, 200, Color.WHITE);
fxPanel.setScene(scene);
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 200);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
initAndShowGUI();
}
});
}
}
The call to java.awt.Font awtFont = new java.awt.Font(jxFont.getName(), java.awt.Font.PLAIN, 36); only creates the "CrashLanding" font on the J2D pipeline.
public class FXSwing {
private static void initAndShowGUI() {
String url = "file:///Users/felipe/Documents/fonts/CrashLandingBB.ttf";
final Font jxFont = Font.loadFont(url, 36);
java.awt.Font awtFont = new java.awt.Font(jxFont.getName(), java.awt.Font.PLAIN, 36);
JFrame frame = new JFrame("FX");
final JFXPanel fxPanel = new JFXPanel();
JLabel jlabel = new JLabel("my swing label");
jlabel.setFont(awtFont);
JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, fxPanel, jlabel);
splitter.setBackground(java.awt.Color.WHITE);
splitter.setDividerLocation(300);
frame.add(splitter);
Platform.runLater(new Runnable() {
public void run() {
VBox box = new VBox();
box.setAlignment(Pos.CENTER_LEFT);
Text text = new Text("my jfx text");
text.setFont(jxFont);
box.getChildren().add(text);
Scene scene = new Scene(box, 200, 200, Color.WHITE);
fxPanel.setScene(scene);
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 200);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
initAndShowGUI();
}
});
}
}
The call to java.awt.Font awtFont = new java.awt.Font(jxFont.getName(), java.awt.Font.PLAIN, 36); only creates the "CrashLanding" font on the J2D pipeline.