Run this sample program :
"
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class FontIssue extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Label label = new Label("this is a test");
label.setStyle("-fx-font-family: Arial;");
Label label2 = new Label("this is a test");
label2.setStyle("-fx-font-family: Arial; -fx-font-style:italic;");
Label label3 = new Label("this is a test");
label3.setStyle("-fx-font-family: Algerian;");
Label label4 = new Label("this is a test");
label4.setStyle("-fx-font-family: Algerian; -fx-font-style:italic;");
VBox box = new VBox();
box.getChildren().addAll(label, label2, label3, label4);
Scene scene = new Scene(box);
stage.setScene(scene);
stage.show();
}
}
"
As you can see, the Algerian font is not rendered in Italic. I've checked inside my Windows font and I don't have the Italic font.
Now Excel and my navigator are rendering this font properly in Italic so they are synthesizing them somehow and I understood that JavaFX could do the same.
"
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class FontIssue extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Label label = new Label("this is a test");
label.setStyle("-fx-font-family: Arial;");
Label label2 = new Label("this is a test");
label2.setStyle("-fx-font-family: Arial; -fx-font-style:italic;");
Label label3 = new Label("this is a test");
label3.setStyle("-fx-font-family: Algerian;");
Label label4 = new Label("this is a test");
label4.setStyle("-fx-font-family: Algerian; -fx-font-style:italic;");
VBox box = new VBox();
box.getChildren().addAll(label, label2, label3, label4);
Scene scene = new Scene(box);
stage.setScene(scene);
stage.show();
}
}
"
As you can see, the Algerian font is not rendered in Italic. I've checked inside my Windows font and I don't have the Italic font.
Now Excel and my navigator are rendering this font properly in Italic so they are synthesizing them somehow and I understood that JavaFX could do the same.
- duplicates
-
JDK-8091064 Implement synthetic font styling
- Open