Closed tferr closed 4 months ago
pinging @DevCharly in case they have experienced this elsewhere
I'm actually surprised that ligatures work in Swing 😮
Didn't know TextAttribute.LIGATURES
...
So I tried to enable ligatures in FlatLaf Theme Editor, which uses RSyntaxTextArea, and it works 😮
I think the reason is that FlatLaf Theme Editor uses a subclass of org.fife.ui.rsyntaxtextarea.SyntaxScheme
, which always uses the same font that has the ligatures attribute.
There are several places in SyntaxScheme
where a new font is created using family, style and size, but without attributes. I think the ligature attribute is lost there. E.g.
or
To fix this, and keep the usage of StyleContext.getFont()
, it is probably necessary to additionally invoke font.deriveFont(Map attributes)
to reapply some font attributes of the base font.
Thanks a lot for this. I'm closing it, as this is a reasonable workaround.
I'll reopen this to make the necessary changes in SyntaxScheme
pointed out above. Thanks folks for this!
Fixed in #554 and #559.
JetBrains mono is a much-improved font for coding, featuring many readability features such as coding-specific ligatures. I am not able to use this font properly in RSyntaxTextArea.
Take this snippet that requires FlatLaf and the FlatLaf JetBrains Mono distribution (direct downloadable jars for both dependencies: flatlaf, flatlaf-fonts-jetbrains-mono):
The ligatures do render in JTextArea:
..but not in a RSyntaxTextArea:
Why is that? I could not find any obvious signs that TextAttributes are being overridden in the code base.