Reputation: 1951
I'm implementing a text editor based on JavaFX. Is it possible to display font ligatures in the same way they work for example in Intellij?
I've found a reference to ligature support in the JavaFX API, but I don't know if this "proves" that there's support.
Upvotes: 8
Views: 444
Reputation: 4380
JavaFX will render required ligatures, but it has no ability to opt in to optional ligatures. The issue tracking adding an API to enable this behaviour is https://bugs.openjdk.org/browse/JDK-8091616.
See also this message from the OpenJFX dev mailing list: https://mail.openjdk.org/pipermail/openjfx-dev/2022-October/036309.html
Upvotes: 0
Reputation: 7255
You can use Tomas Mikula RichTextFX library.
https://github.com/FXMisc/RichTextFX/
You many options here :
1) InlineCssTextArea
uses the
Node#setStyle(String cssStyle)
method to style Text objects of
InlineCssTextArea
and for each word or line you can set a different style using :
InlineCssTextArea.setStyle(from,to,style);
I have extensively used it before to have different fonts and styles inside the same line or lines.
2) StyleClassedTextArea
uses the Node#setStyleClass(String styleClass)
method to style Text
objects. You can define the style classes in your stylesheet.
So let's say that inside your application.css
you have defined 5 different style classes with different fonts. One of them might be...
.red { -fx-fill: red; }
so you can use :
styleClassedTextArea.setStyleClass(from, to, "red");
This renders the text in the range [from, to) in red.
3) For more please check https://github.com/FXMisc/RichTextFX it has detailed description.
Also you can search for more examples on the web.
Upvotes: 4