Lazarus

Using the Lazarus IDE => Editor => Topic started by: Hoch on January 26, 2020, 12:54:52 pm

Title: I can't change the code editor font in Linux... Anyone?...
Post by: Hoch on January 26, 2020, 12:54:52 pm
Hi,

When I change the code editor font, the font picker displays the font correctly but Lazarus uses always the same one, no matter which font I choose. The only thing that changes is the size and spacing.

Check the appended screenshots. You can see that the font I choose is not displayed correctly in the preview of the prefs dialog and in the code editor.

And the font spacing is weird. It's very uncomfortable to work with this font spacing.

Things I've done:

. Tried all the monospace fonts
. Uninstalled Lazarus and installed again, renaming the /home/user_name/.lazarus folder to force a clean one.
. Downgraded linux kernel from 5.4 to 5.3
. Checked font permissions in /usr/share/fonts/
. Upgraded Lazarus 2.0.6 to the last one offered by pacman (25/12/2019)

Nothing works.

The font picker detects the fonts right. And other apps see and use the fonts correctly.

Clearly there is an issue with Lazarus.

System was Manjaro with 5.4 kernel, downgraded to 5.3.
Lazarus version is 2.0.6. (25/12/2019)

Any clues of where to look to fix this?...

Thank you in advance! :)
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: nomorelogic on April 09, 2021, 11:44:41 am
this topik is old but I've same problem

fonts are weird and there's no way to view a font like in other application
I'm on voidlinux, xfce4

any help is appreciated

thanks


Edit:
tried all monospaced fonts but none of them looks normal
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: nomorelogic on April 12, 2021, 08:54:14 am
just to show what "weird" means, I attach a screenshot

This malfunction appeared recently, not with a fresh Lazarus install.
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: Ñuño_Martínez on April 12, 2021, 11:48:23 am
Seems to be a problem with the font itself.  Maybe the font file isn't fully compatible or it is old or something.
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: nomorelogic on April 12, 2021, 12:02:54 pm
when installed Lazarus 1st time, display editor was really perfect
after some days, changing font in display option, this probelm appear

Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: nomorelogic on April 12, 2021, 12:52:31 pm
I tried removing Lazarus and reinstalling it: nothing changhes :(
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: lucamar on April 12, 2021, 04:45:09 pm
Does it happens only with this font or with any monospaced font you select?

I'd tend to agree with Ñuño that it looks like a problem with the font itself: either it's not correctly formed or it isn't marked as "monospace".

SynEdit wants a monospaced font and when you apply a non-monospaced one the result resembles your image: the space after the shorter characters (i, l, ...) is excesive while the wider ones (m, w, ...) might even be cut-out, all as your image seems to indicate.
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: Martin_fr on April 12, 2021, 05:16:48 pm
The "weird look" is a 2ndary issue.
Forget the spacing for a moment.

You say the font does not change, no matter what you select.
That means, if you change between fonts, that draw a line in the "0" (zero), or do just an oval (like the letter O) for a zero, you would always get the same "0".

Same you do a serif vs a none serif. The form, thickness, details of each char on it own do never change?

Now, if that is true, then there is an issue with font selection.

And apparently you end up with a none monospaced font. And that gets the spacing weirdness.



None monospaced fonts

The Editor displays all text according to mono spaced rules. That is like in a grid. An "i" and a "W" must have the same widths. If not the editor adjusts the widths, by padding or squeezing. => Weird look.
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: nomorelogic on April 12, 2021, 07:31:04 pm
just to be more precise I can attach 3 monospace fonts

I included a line of "O" letter and 0 (zero)

Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: winni on April 12, 2021, 08:16:38 pm
Hi!

Looking at the 3 Font examples:

* Theses Fonts are not monospaced fonts
* In all 3 screenshots it is always the same font


To check this confusion let's take first step:

look in your lazarus directory in the editoroptions.xml

In the 4th line there should be something  like

Code: Text  [Select][+][-]
  1. <Display DoNotWarnForFont="Liberation Mono" EditorFont="Liberation Mono" EditorFontSize="12" ExtraCharSpacing="1"/>

Do you find a correct fontname in this line?

Winni
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: Martin_fr on April 12, 2021, 08:47:11 pm
Just noted, the OP Hoch, has not posted/replied further to the topic. Maybe they solved it.
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: nomorelogic on April 13, 2021, 08:37:22 am
this is the 4th line of $HOME/.lazarus/editoroptions.xml

Code: Pascal  [Select][+][-]
  1. <Display DoNotWarnForFont="DejaVu Sans Mono"/>
  2.  


Using fpcupdeluxe I installed on the same system another lazarus (laz stable / fpc stable).
Using the new install, fonts are perfect (see attachment).
In this case the 4th line of .../lazstable/config_lazarus/editoroptions.xml is the same of previous "weird" installation:

Code: Pascal  [Select][+][-]
  1. <Display DoNotWarnForFont="DejaVu Sans Mono"/>
  2.  

Thus I have 2 lazarus (same version) on my system, so it's not a font issue.


Edit:
@winni
it seems that it doesn’t matter the font I select, at the end the editor is used almost always the same
in editoroptions.xml is reported the one I selected
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: C#R# on April 26, 2021, 05:12:51 pm
Hi,

I have the same problem, the characters overlaps the own space.
But, I have the problem only on qt5 interface
When the ide is compiled on gtk2, the problem disappear
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: Martin_fr on April 27, 2021, 02:51:51 pm
I have the same problem, the characters overlaps the own space.
But, I have the problem only on qt5 interface
When the ide is compiled on gtk2, the problem disappear

Same origin, but different effect.

If you look closely for the OT every char is squashed to the next.

In your image chars are cut off at certain intervals (whenever the highlight color changes).
If you select chars in a line, and extend the selection char by char, you will see the other chars moving.

The problem is still the font. It does not stick to the width it should. Though in your case SynEdit believes that it is monospaced.

Therefore SynEdit outputs the text without correcting the width. It prints the text in the current highlight. When the hl changes SynEdit calculates where the previous text should have ended, and continues there. But in your case the previous text did not end at the correct location.


I have no idea why the fort info on gtk/qt on your platforms goes wrong.

I suggest to report this as bug. (against the LCL widgetset for qt/gtk)



Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: winni on April 27, 2021, 04:41:37 pm
Hi!

AFAIK synedit only acceps monospaced fonts.

The bug is, that the IDE allows also proportional fonts.

Winni


PS.: Wikipedia has a (small) list of monospaced  fonts.
Liberation mono and many others missing

https://en.wikipedia.org/wiki/List_of_monospaced_typefaces (https://en.wikipedia.org/wiki/List_of_monospaced_typefaces)
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: Martin_fr on April 27, 2021, 05:28:13 pm
AFAIK synedit only acceps monospaced fonts.
Well yes... and a yet, not.

See the unit SynTextDrawer. And {$IFDEF SYNFONTDEBUG} sections.

SynEdit measures the font that it is given. It measure certain individual chars MWXi':m@ and some sequences.
If they do not return monospaced sizes (can also happen for sub-pixel sizes), the SynEdit will place each char into a forced pos. That is what happens to the OT.

So in that sense, SynEdit will "work" with none monospaced fonts, but the result is usually real bad.

-------
In the QT example, SynEdit got good measurements, but the real output is actually wider. No idea why.
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: winni on April 27, 2021, 06:26:44 pm


So in that sense, SynEdit will "work" with none monospaced fonts, but the result is usually real bad.

-------
In the QT example, SynEdit got good measurements, but the real output is actually wider. No idea why.


Hi!

Looking at proportional fonts with a monospaced distance is unreadable, makes headache and should be prohibited by the IDE

The wider output might come from the option "extra character spacing".

Winni
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: Martin_fr on April 27, 2021, 07:17:46 pm
Looking at proportional fonts with a monospaced distance is unreadable, makes headache and should be prohibited by the IDE

Quote
The bug is, that the IDE allows also proportional fonts.

Both valid points. Except the latter should be "A bug is".
It is not (or not necessarily) the bug causing the issues described here.

My understanding is that the original bug is, that the selected font is not used. And that includes, if the selected font is monospaced. So there is a bug that even affects monospaced fonts.

As for the 2nd issue, that may be caused by a none monospaced font.
But SynEdit should have measured it. So the measuring must be broken in QT.
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: C#R# on April 27, 2021, 09:34:59 pm
Hi Martin,

I think isn't a font problem, look this images, one is gtk2 and other is qt5(with fail).

Thanks !
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: Martin_fr on April 27, 2021, 10:45:20 pm
I think isn't a font problem, look this images, one is gtk2 and other is qt5(with fail).
Well, what I can see is that while you chosen the same font (font of the same name) under gtk2 and qt, the font that is used is different.
Look at line 16 of the preview, the lowercase "i" in "inc" is very different.

What I can also see is that on QT the "n" in the same "inc" is partly below the "X" in the line above. But that "X" should line up with the "i".
So it is not a monospaced font.

But SynEdit should have noted that using GetTextExtentPoint. And then using LCLIntf.ExtUTF8Out to specify the draw-width of each char.
So I can think of several scenarios.
Either GetTextExtentPoint or LCLIntf.ExtUTF8Out do not work.
Or the code gets a different font for measuring than it gets for actual drawing.


LCLIntf.ExtUTF8Out  can be tested by setting "Extra char spacing" to 1 (or any value other than 0)
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: Lutz Mändle on April 28, 2021, 01:57:38 am
This problem belongs to this bug https://bugs.freepascal.org/view.php?id=36483 (https://bugs.freepascal.org/view.php?id=36483).
In the bugreport a patch (https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/qt5/qtobjects.pas?root=lazarus&r1=62604&r2=62603&pathrev=62604 (https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/qt5/qtobjects.pas?root=lazarus&r1=62604&r2=62603&pathrev=62604)) is mentioned, which fixes the problem.

The problem can circumvented by unsetting the following environment variables:
KDE_FULL_SESSION
DESKTOP_SESSION
XDG_CURRENT_DESKTOP

My desktop link for starting Lazarus contains the following command line:
unset KDE_FULL_SESSION DESKTOP_SESSION XDG_CURRENT_DESKTOP;/usr/bin/startlazarus

This has the side effect, that theme settings for menu shortcuts, system dialogs, colours etc. are not applied.
Title: Re: I can't change the code editor font in Linux... Anyone?...
Post by: C#R# on September 21, 2021, 09:45:44 pm
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/d2aee554cb335ebabc21387bd6c1bb8bbe3004b0
TinyPortal © 2005-2018