Bug 328837

Summary: Add configurable line height to katepart
Product: [Frameworks and Libraries] frameworks-ktexteditor Reporter: Leonardo <leonardo.guilherme>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: aspotashev, leonardo.guilherme
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Patch that adds a multiplier to line height
Text without a line height multiplier
Text with 1,1 line height multiplier
Comparison of 1.0, 1.1 and 1.2 multipliers
Settings window
Ugly text selection.

Description Leonardo 2013-12-15 16:18:33 UTC
It would be nice if we had the ability to choose the line height of the editor so that text becomes more readable in some fonts.

So I come up with a set of changes that add a new option in the configurations UI to let the user specify a line height multiplier. In the renderer, when setting m_fontHeight, I also multiply it by the chosen value. I am happy with the results (see screenshots).

There's a problem, though: selection gets inconsistent. I know that we let Qt draw the selected text background by passing a list of FormatRanges to it specifying decorations for the selected text. For selected parts that are not text (e.g, when there's whole lines selected), we draw the selection background by ourselves. Qt's text rendering doesn't know of the new height so it doesn't render the selected background in whe whole height, but katepart does so it renders the selection background in the whole height.

I've come up with some ideas: Make Qt's text rendering aware of the new height (I don't think this is going to happen as I searched a lot but couldn't find how to do it) or draw the text background ourselves, but this involves calculations like the selected range, where the characters are, etc, that I don't feel versed enough in kate's code to do that.

So my solution was, when rendering the selected background, use the original font height instead of the multiplied one. It doesn't look very pretty but at least is consistent.

It would be nice if someone helped me fixed the selection in these cases, but, I am happy enough with the results to use it in my day-to-day life.

Reproducible: Always

Steps to Reproduce:
Open Kate
Go to Settings->Configure Kate->Editing
Actual Results:  
No option to change the line height

Expected Results:  
Option to configure the line height or the line height multiplier

Please see patches/screenshots
Comment 1 Leonardo 2013-12-15 16:20:09 UTC
Created attachment 84107 [details]
Patch that adds a multiplier to line height
Comment 2 Leonardo 2013-12-15 16:21:09 UTC
Created attachment 84108 [details]
Text without a line height multiplier
Comment 3 Leonardo 2013-12-15 16:21:48 UTC
Created attachment 84109 [details]
Text with 1,1 line height multiplier
Comment 4 Leonardo 2013-12-15 16:28:14 UTC
Created attachment 84110 [details]
Comparison of 1.0, 1.1 and 1.2 multipliers
Comment 5 Leonardo 2013-12-15 16:28:47 UTC
Created attachment 84111 [details]
Settings window
Comment 6 Leonardo 2013-12-15 16:29:46 UTC
Created attachment 84112 [details]
Ugly text selection.
Comment 7 Bug Janitor Service 2022-03-21 14:53:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/338
Comment 8 Christoph Cullmann 2022-03-22 18:26:15 UTC
Git commit 795a8d568057552b4350f2f73a11443125399ca0 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 22/03/2022 at 18:16.
Pushed by waqar into branch 'master'.

Add support for custom line height

M  +3    -0    src/dialogs/katedialogs.cpp
M  +35   -9    src/dialogs/textareaappearanceconfigwidget.ui
M  +55   -1    src/render/katerenderer.cpp
M  +4    -0    src/render/katerenderer.h
M  +12   -0    src/utils/kateconfig.cpp
M  +9    -0    src/utils/kateconfig.h
M  +8    -6    src/view/kateview.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/795a8d568057552b4350f2f73a11443125399ca0