Is it possible to reduce the vertical line spacing in konsole?

Under Settings/Advanced, there is a Line Spacing option but it only goes down to 0 and even at 0 there is considerable space in between lines (i.e., too much of what is commonly referred in typography as leading, the blank vertical spacing between lines of text). I am using the very vertically conservative Inconsolata font, which has minimal vertical spacing compared to Monospace for example, but even with this font there is still way too much spacing between lines at the point size I use (13).

Is there some way to reduce the vertical line spacing further, without having to hack the font itself to compensate? Many editors allow this, but I can't figure out any way to do it in Konsole (below zero), or perhaps all of KDE in general as some sort of system setting.


To anyone interested, I have figured out a way to do this, but it does involve font editing. This should save you hours if not days of googling and frustration , because I know I spent an inordinate amount of time trying to figure all of this out. Please do not be discouraged by the wall of text that are the steps. The entire process takes literally less than five minutes. I've just gone through great lengths to completely spell it out, so that it can take five minutes :) and there is as little ambiguity as possible with regard to what to do and in what sequence.

Here is how you can adjust the vertical line spacing to your heart's content, across all Linux GUI apps:

  1. Download and install FontForge (the package should be called fontforge with yum, apt-get, dnf, or whatever your package manager you use). It's also available in github if you like doing things manually: github install details
  2. Open the font you would like to change (Inconsolata in my case). Note: Before changing a font or even creating a new font, which I highly recommend, copy the old one(s) from /usr/share/fonts/... to ~/.local/share/fonts and make all changes (or new font additions) in your local fonts directory, which as a bonus you will have write privileges to, without the need for root access (to /usr/share/fonts).
  3. OK, back to FontForge, which you can run as: fontforge after installation. Start by opening the font from the .local/share/fonts directory that you copied the original font to. Just type .local/share/fonts assuming you started fontforge from your home directory, and it will take you to that directory. Note that fontforge does not like the ~ character in place of your home directory, so use relative or absolute paths, but do not use ~ when opening the font file. If you have a subdirectory for your font there, just click on that to open it and finally select and open the font itself. Before we change anything else, we should rename the font. From the menu, select Element/Font Info... to open the Font Information dialog. Go to the General category on the lefthand side and let's change the name of the font by putting a suffix after it (e.g., I changed Inconsolata to InconsolataDense80, to indicate that I will be reducing the vertical line spacing (i.e., leading) to 80 percent of its present value). Make sure that you make this change three times for each of the Fontname, Family Name, and Name For Humans fields, respectively.
  4. Next, select the OS/2 category on the left (who would have thunk it???) and on select the Metrics tab at the top.
  5. We will be modifying the HHead Ascent and Descent values, the only two values that affect the vertical spacing on Linux. Good luck figuring this one out on your own. It took me ages to find these proverbial needles in the haystack, diamonds in the rough, your analogy of choice :) !
  6. Be sure to record (e.g., write down) the current values, before you make any changes.
  7. Now to change the vertical spacing, we need to multiply the two values by a factor depending on the amount you want to reduce the vertical spacing by (for me, I used 80% of the current values). You probably want to use the same factor for both for 99% of all cases. If that doesn't work out or causes display artifacting, you can later use different factors to fine tune the individual values as an absolute last resort. Artifacting could also mean that you've reduced the values too much, and by reduce I mean move toward zero (i.e., reduce their magnitudes, their absolute values, since the HHead Descent may be negative, so you will actually be increasing it in a numerical sense if you multiply it by a positive percentage scaling factor).
  8. Set each of the HHead Ascent and Descent to the values you calculated in step 7 (e.g., 80% of their former values is a good start)
  9. We are done with the Font Information dialog, so let's click on the OK button
    1. At this point, let's save our font as a .SDF file, so do a File/Save As... and it should remember the new name of the font you set previously.
    2. Now to apply our changes, we need to (re)generate the font. Select Font/Generate Fonts... from the FontForge menu. If you are dealing with a TrueType font, make sure that TrueType is selected under the font filename. Then click on the Generate button. You may get various Errors Detected which you can safely ignore - click the Generate button on that dialog, if it appears to continue with font generation.
    3. You are good to go at this point, but will need to reset the font cache. Do this by typing fc-cache -v -r.
    4. Open up a new konsole window (the new font or possibly even changes to an existing font will not show in any windows you already have opened).
    5. Select the new font by going to Settings/Edit Current Profile and selecting the Appearance tab. The font selection options are at the settings page. Click Select Font... and you should see your new font listed and be able to select it. The change will be enacted immediately after you click OK.
    6. Congratulations, you are done! If the lines are still too far apart or too close, go back to Step 7 and tweak the HHead Ascent/Descent values to some other multiples of their originals. Don't forget to change (all three) of the font name values to be descriptive of the percentage you multiply by, for future reference and then be sure to save the font under a new file name (and generate it as a new font under the new name, as well). Finally, don't forget to update the font cache and open up a new window to see the effect(s).

I usually do an ls -l or ls -lR before changing the font in Konsole so that I can see the effect on the line spacing between the listed filenames. It is a good idea to have filenames that use ascenders (such as l) and descenders (such as 'y') that are above/below each other, so you can make sure that the lines are not too close and that the ascenders and descenders do not intersect. You can do this easily by creating three files: 'agjpqy','mbdfijlt', and 'zgjpqy'. The first letter of the filenames is just to order the files alphabetically as expected. The rest of the letters contain ascenders, descenders, or both. You can see if they intersect and adjust the vertical spacing of the font accordingly to what subjectively pleases you (reminds me of the story of Goldilocks and the Three Bears).

I hope this helps and saves you a proverbial boatload of time and frustration. Users with OCD will appreciate this the most!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.