I'm using an icon font called IcoMoon. For a particular icon (called menu in IconMoon) it looks blurry in OSX whereas in Windows 7 and Linux it looks sharp.
The code below was run on all three systems and they produced these screen shots:
http://imgur.com/a/hQB3h
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.FlowPane;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class IcoMoonTest1 extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
FlowPane flowPane = new FlowPane();
flowPane.setStyle("-fx-padding: 5;");
Scene scene = new Scene(flowPane, 200, 100);
primaryStage.setScene(scene);
String fontLocation = getClass().getResource("/icomoon.ttf").toExternalForm();
Font.loadFont(fontLocation, 20);
Text menu = new Text("\ue601");
menu.setStyle("-fx-font-family: Icomoon; -fx-font-size: 20; -fx-fill: derive(grey,-30%)");
ToggleButton menuButton = new ToggleButton();
menuButton.setStyle("-fx-padding: 4;");
menuButton.setFocusTraversable(false);
menuButton.setGraphic(menu);
flowPane.getChildren().addAll(menuButton);
primaryStage.show();
}
public static void main(String[] args) {launch(args);}
}
Notice that this code loads the icomoon.ttf font. I can't attach this because I don't have permissions so if you need it please leave an email address I can send it to. Otherwise just go to https://icomoon.io/ click on IcoMoon App in the upper right of the screen, search for menu, select the icon you see in the screen shot above and click on create font and then download both in the bottom right of the screen. You may need to update the char code in the code above with whatever the new font has been generated with.
The code below was run on all three systems and they produced these screen shots:
http://imgur.com/a/hQB3h
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.FlowPane;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class IcoMoonTest1 extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
FlowPane flowPane = new FlowPane();
flowPane.setStyle("-fx-padding: 5;");
Scene scene = new Scene(flowPane, 200, 100);
primaryStage.setScene(scene);
String fontLocation = getClass().getResource("/icomoon.ttf").toExternalForm();
Font.loadFont(fontLocation, 20);
Text menu = new Text("\ue601");
menu.setStyle("-fx-font-family: Icomoon; -fx-font-size: 20; -fx-fill: derive(grey,-30%)");
ToggleButton menuButton = new ToggleButton();
menuButton.setStyle("-fx-padding: 4;");
menuButton.setFocusTraversable(false);
menuButton.setGraphic(menu);
flowPane.getChildren().addAll(menuButton);
primaryStage.show();
}
public static void main(String[] args) {launch(args);}
}
Notice that this code loads the icomoon.ttf font. I can't attach this because I don't have permissions so if you need it please leave an email address I can send it to. Otherwise just go to https://icomoon.io/ click on IcoMoon App in the upper right of the screen, search for menu, select the icon you see in the screen shot above and click on create font and then download both in the bottom right of the screen. You may need to update the char code in the code above with whatever the new font has been generated with.