[JEWEL-830] Fix Editor TextStyle line height #3064
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Swing is not using the font size when computing the base lineHeight, that is then multiplied by the user-set factor (default 1.2). Instead, they use FontMetrics.getHeight(), which computes it as leading + ascent + descent.
This changes the Jewel line height computation for the editor text style to use the same logic. It requires a Graphics2D instance, which is obtained from a Swing BufferedImage on demand, to get the same font metrics as the Swing UI uses.
This gets us a much closer result, but is still not 100% matching. It looks like this introduces a ~10% extra line height in Compose compared to Swing:
I will make a follow-up change when I figure out where in Skia’s line height usage there is a divergence from Swing’s, but for now this is already much better than what we did before.
This change also fixes the Jewel sample plugin.xml so it doesn’t crash at startup when run in the IJP build.