1

I have a problem making the text italic to the Arabic texts, It does not work, I also tried different types of fonts, but none of them works, Here is the code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;


public class JavafxApp extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        var pane = new AnchorPane();
        var text = new Text("عربي English");
        text.setLayoutX(50);
        text.setLayoutY(100);
        text.setStyle("-fx-font-style: italic; -fx-font-size: 18; -fx-font- 
        family : Simplified Arabic;");
        pane.getChildren().add(text);
        var scene = new Scene(pane, 200, 200);
        primaryStage.setScene(scene);
        primaryStage.show();

    }
}

result,

Any suggestions? I would be grateful

1 Answers1

1

Your issue is, most probably you don't have an ITALIC version of your font in your windows fonts folder, Because JavaFX does not have support for synthesizing bold or italic fonts when no font of that style is present

See long-standing RFE: JDK-8091064 & JDK-8130526

Simply That means you need to have italic font in your font family

Akila
  • 1,258
  • 2
  • 16
  • 25
  • 1
    If so, this means that other programs must encounter the same problem as Microsoft Word, But Microsoft Word does not have this problem – Saif Al Basrawi May 08 '18 at 05:50
  • @SaifAlBasrawi indeed, Microsoft word internally synthesizing fonts while JavaFX doesn't, see comments in [JDK-8127134](https://bugs.openjdk.java.net/browse/JDK-8127134) – Akila May 08 '18 at 05:58