Help with correcting font issue in Plasma/Qgis combination

,

I'm trying to troubleshoot an issue I've mentioned before and I'm stuck at a couple of places which I thought someone here might be able to help with.

First a brief recap of the problem - One of the applications in the Official Repository is a GIS application called QGIS. In it there's a few text editing widgets based on QScintilla. In these (ever since an update a few months ago), the location of the caret (the blinking cursor at the end of the edited text line) does not match the location of the last letter in the text string. More specifically, it is located exactly where the last letter would be if the string had no kerning (each letter took up the same space regardless of its shape).

Here it is with 'W's
image

and here with 'I's
image
In neither case has the caret been moved by the mouse or cursor keys, it's exactly where it ends up after typing the letters. Highlighting also selects letters as if there were no kerning and placing the caret manually (by mouse or arrow keys) also assumes no kerning - ie if I were to delete the letter immediately behind the caret, it would not delete the one which looks to be behind it, but one some way off.

As far as I can tell the issue only occurs on a Plasma/Manjaro combination. Plasma/Ubuntu has been tested and is fine, manjaro/XCFE has been tested and is fine. I've also tested QScintilla on it's own (by making a simple box in a python script) and that too is fine. I've reported the issue to the developers at Qgis, but since it is not replicable on any other set-up, no-one's moving on it. I've also reported it to KDE, but again, since it only happens on Qgis with Manjaro, no-one's dealing with it. Basically every organisation thinks it's the other's fault.

So I'm left trying to fix it myself and I need some help. I'm not experienced with programming, but I can learn if need be, I'm just looking to be pointed in the right direction.

According to the API documentation for QGIS, the text box which is malfunctioning is handled by QgisCodeEditor, the files for which are here and here. As you can see, they're not long and even with as little experience as I have, it's not hard to see what they do (mostly).

So the question (finally!) is - with such a limited amount of code to go on, it seems clear the problem is to do with Plasma presenting things like monospace font and Qfont styles (like QFont::TypeWriter). I thought these would be handled by Qt, but that would be the same on all systems, so where do I need to look within Plasma to see how it might handle these fonts and styles? I've tried playing around with fonts in the settings manager, but nothing makes any difference, so I think the font is set by Qt.

Hello,

I had a couple of minutes free, read some of your previous posts about QGIS and decided to do a test, but since i have no experience with the program, i went only empirical and changed the Style like this:

image

Fusion style somehow fails to follow the latest KDE Plasma ... but that is different than the issue you mentioned, and a cosmetic thing.
The files you provided as links

are for the 3.13 version of QGIS that is not yet even in Arch that still has the 3.12.1-1 build, so the 3.13 will be available later. It was flagged already as out of date
https://www.archlinux.org/packages/community/x86_64/qgis/

After looking around a bit on my end, i decided to change the Fonts to Droid Sans [MONO]

image

Restarted the QGIS and now when i edit a Field Calculator i no longer have the issue you presented regardless how long the text is.

image

Hope this helps! :slight_smile:

2 Likes

Thanks so much for putting the time in. Your solution works only in part for me (but that's better than nothing, so very much appreciated).

I changed the font as you recommend and for the expression box it works perfectly. Unfortunately, there's a second part to this software to manage databases. It's here I do most of my work and this seems to be unaffected by the setting of fonts (which is why I hadn't noticed before that it worked in the main application).

If you ever have another few minutes spare, you can test this on your set up but it takes a bit more work. Add a geopackage layer (Layer>Create Layer>New Geopackage Layer), name it, add some random fields (just a test text field will do) and save it somehwere. Open the Database Manager (Database>DB Manager), add your geopackage layer if it's not already there (Right-Click on 'Geopackage'>New Connection...>load the geopackage you just saved). Open the Geopackage (click on the little arrow to the left of the name). Open an SQL window (Database>SQL Window - whilst still in the DB Manager). Try typing in there. It's still messed up on my system.
image.

Weird huh? I guess it's something to do with Qt defaults, it obviously only allows the user to use another font in some of it's windows but not others. So Plasma is not rendering certain Qt default fonts properly (but oonly certain fonts because all other QT applications seem to be fine). Not sure where to go next, I suppose either KDE or Qt, but in my recent experience they'll probably just blame each other and nothing will get done!

Still, thanks for finding the font trick, that certainly helps. I'm going to mention it to the developers, it might help them pinpoint the problem a bit better.

1 Like

Hey, yeah I managed to make some more time for this. Side note - fantastic software !

So, it seems the DB Manager is not using the fonts set by the QGIS, but is taking the default fonts directly form the KDE Plasma Fonts Settings, so this is making it a bit inconsistent, but, once you have a preferred MONOSPECE font, like Ubuntu Mono, Source Code Pro (medium), you can get a consistent font look and no more funkiness in DB Manager either.

image

In QGIS Settings i set the Layouts too to use the same font as in General and Plasma Settings.
Conclusion, the issue is due to the fonts family and a bit of inconsistency how each "module" window is reading the configuration. Hopefully this will make the job easier :slight_smile:

3 Likes

That's brilliant! You wouldn't believe the amount of time I've spent trying to find a workaround for this problem, thank you so much.

I did actually change the system fonts early on in my attempt at a solution, but it didn't seem to have an effect, it's weird that the Layout font has any impact because that's not even the right window - must be something screwed up in the software. I can't believe (given the amount of fiddling I did with settings and config files) that I didn't persist with font settings and went straight to source code issues. Sometimes the simple solution is staring you in the face whilst you're trying to change the entire application...!

Still, having to change my entire system to a monospace font just to get this to work is a bit of a pain, so I'll mention the success you've had to the QGIS developers and see if that helps them fix the problem. It would be nice if it could use kerned fonts as it should.

As a workaround it's worth it though, as you say QGIS really is a great piece of software. I work with SQL databases a lot and I use the Database manager within QGIS to manage then even if their content has nothing to do with GIS because it's just such a good database manager. You can actually load non-GIS databases into the main application and use the form editor to create data entry forms and then the layout editor to create reports all with more functionality than LibreBase or Beaver have. So pleased it's working again.

1 Like

Oh and @zeddock, I know you were looking for a solution to this problem too - see above.

1 Like

WONDERFUL!
@Isaacson @bogdancovaciu

Thank you all for sharing!!!

We can do this until resolved!

Hi @Isaacson,

Could you post here the link to the bug report you have submitted to the developers?
I'd like to have a look.
BTW, this also affects GNOME users. (Where is that *** Qt font setting?)

----EDIT----
Problem solved by re-installing qt5ct and changing the font there. Still it should be solved in QGIS for the whole application to use the same fonts...

Cheers,

Sure here It's incredibly rambling as it took a while to even get close to where the problem was.

If it affects Gnome users too, then it sounds like it's not even a KDE problem, but I'm sure I've heard that Xfce users didn't have it?

Do you mean the whole problem? Could you walk me through how you changed the font in qt5ct?

Also as a general aside to anyone following, @bogdancovaciu's solution only works for the DB Manager on my setup. The expression editor is unaffected by just changing the system font to a monospace one. I think that might be affected in a different way, possibly by the Qt font setting in Qgis, (the other half of his solution) rather than systemwide.

It's all starting to sound like some Qt fonts are just not being handled properly, but whether that's a fault of Qgis for using unsupported font types, or a fault of KDE/Gnome for not implementing them properly, I don't think is clear.

My understanding is that QGIS is not using consistently the font set up in its settings, and that sub-windows, such as the expression editor, use fonts from elsewhere, creating kerning/caret issues.

Indeed the font in the expression editor was changed, on my gnome, by changing the font in qt5ct to Noto sans (general) and Noto Mono (Fixed width). I do not remember which font was used before. It must be noted that this was not consistent with my overall settings in gnome, which already used the Noto fonts.
I had Qgis set to use Noto sans, but now it is set to QT default.

Neither qgis nor my gnome are supposed to use qt5ct. They were and are both set to kvantum.

That is part of the GTK+ Fonts settings that have no influence over Qt applications.

Kvantum does not deal with the Fonts for Qt applications, qt5ct does.
Gnome Style/Theme and Fonts are only influenced by Tweaks for all GTK+ applications, has no power over Qt. Qt Style and Fonts is set by qt5ct. If qt5ct is set to use GTK2 Style, it will use the theme set in Gnome Settings. If qt5ct is set to use Kvantum Style then the theme will be set by Kvantum Managet, but the fonts will still be set for it in qt5ct ... :slight_smile:

Good to know!
This bit previously let me believe that qt5ct was not needed/useful anymore:

"We have switched into qgnomeplatform instead qt5ct so now
-> qt5ct
-> qt5-styleplugins
are marked as orphans.

I think that is to default it to Kvantum Style, but then again, without qt5ct Fonts to Qt applications would have no available settings ... Probably the qgnomeplatform does that, but i didn't test it yet. My installs still have the qt5ct.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by