Fix Bug 285162: adjust documentation view font settings by values taken from system settings (DE)
ClosedPublic

Authored by antonanikin on Oct 1 2016, 5:12 AM.

Details

Summary

The patch sets Sans Serif font as default for documentation view.
Font settings are adjusted to system setting (DE):

  • Sans Serif font (we assume that is the default system font).
  • Monospace font.
  • Sizes for all fonts.

Only Serif font family setting is taken from fontconfig (system settings for such font is missing).

BUG: 285162

Test Plan

Tested with master branch.

Diff Detail

Repository
R33 KDevPlatform
Lint
Lint Skipped
Unit
Unit Tests Skipped
antonanikin updated this revision to Diff 7018.Oct 1 2016, 5:12 AM
antonanikin retitled this revision from to [kdevplatform] font settings fro documentation view.
antonanikin updated this object.
antonanikin edited the test plan for this revision. (Show Details)
antonanikin added a reviewer: KDevelop.
antonanikin set the repository for this revision to R33 KDevPlatform.
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptOct 1 2016, 5:12 AM
antonanikin retitled this revision from [kdevplatform] font settings fro documentation view to [kdevplatform] font settings for the documentation view.Oct 1 2016, 2:30 PM
apol added a subscriber: apol.Oct 2 2016, 5:49 PM

Why do we need special settings for the documentation?
Shouldn't the system fonts be enough?

antonanikin added a comment.EditedOct 3 2016, 12:46 AM

System font settings applied only for UI elements, not for QWebView therefore any web browser has own font settings dialog. The system font is usually a Sans Serif font, but HTML engines also requires Serif font settings for "normal quality" rendering. And last - same font size setting (12 e.g.) for UI and Web-content produces fonts which are not equals (Web font is smaller).

The simplest way to "fix" documentation fonts - only increase it's size to "normal" values (according with current system font size). But then we have the problem - default font families for Sans, Serif Serif and Monospace fonts. My test shows that QWebView gets font families from fontconfig (e.g. fc-match monospace) and ignores KDE's System Settings. But most of users don't change fontconfig settings and as a result we have:

  • some default Sans Serif font from fontconfig which is used by QWebView,
  • selected by user Sans Serif system font for UI
  • different font sizes for UI and HTML-content.

I see your point that there is a problem with not the correct fonts to be used in the Webview. But is another font config dialog really required to solve it? E.g. the user already selected (or KTextEditor did it by default) fonts for the editor panes; same for sans serif fonts selected for the UI. Can't such fonts be silently applied to the Webview?

I see your point that there is a problem with not the correct fonts to be used in the Webview. But is another font config dialog really required to solve it? E.g. the user already selected (or KTextEditor did it by default) fonts for the editor panes; same for sans serif fonts selected for the UI. Can't such fonts be silently applied to the Webview?

Ok, we can get monospace font setting from KTextEditor, you are right. But serif font setting will be get from fontconfig. By default, this (unconfigurable) serif font is used for displaying documentation text (tested with man pages, Qt and CMake). Personally, I prefer sans serif for "main text" but current version of documentation plugin don't allow to do it. It will be best variant to have global "HTML fonts" system settings, but now it's impossible :(.

apol added a comment.Oct 3 2016, 10:48 AM

I would really prefer to be able to go without any KCM.

Can you look into testing if it works by using the general font for those that don't have a clear mapping to QFontDatabase::systemFont? Maybe enforce a font family in these?

Can you look into testing if it works by using the general font for those that don't have a clear mapping to QFontDatabase::systemFont? Maybe enforce a font family in these?

Ok, I comment results later.

I would really prefer to be able to go without any KCM.

But what's wrong with the additional settings? I agree that it is not necessary to overload the interface, but too simplify it, too bad - we may get a situation like in Gnome DE (many settings are removed because they "confuse and scare users").

brauch added a subscriber: brauch.Oct 3 2016, 3:36 PM

I agree, we should just use the system-wide GUI font here. Settings are good if they solve problems or differentiate use cases; this IMO doesn't, it just fixes a bug, which is that the web view uses a different font than the rest of the application.

Ok. Then say your suggests about last problem - Serif font. It's setting available only from fontconfig, which often is "not-synchronized" with DE settings. We can solve it with:

  1. Get value from fontconfig "as is" and hope for a "not too bad "result :)
  1. Replace Serif font with system font, which is Sans Serif for most users (I don't know anyone who uses Serif for UI).

As for me, I would prefer 2nd variant.

apol added a comment.Oct 3 2016, 11:10 PM
  1. Replace Serif font with system font, which is Sans Serif for most users (I don't know anyone who uses Serif for UI).

We can have an intermediate. Enforce the font family onto the system's font. Something like:

QFont f = qGuiApp->font();
f.setFamily("Serif");
return f;

This way we'd maintain size and other settings the user might have set.

antonanikin updated this revision to Diff 7079.Oct 4 2016, 10:44 AM
antonanikin updated this object.
antonanikin edited the test plan for this revision. (Show Details)

New (simplified) version. Default font is set to Sans Serif.

Form system setting (DE) we are get following settings:

  • Sans Serif font (we assume that is the default system font).
  • Monospace font.
  • Sizes for all fonts.

From fontconfig we are get only Serif font family.

apol added inline comments.Oct 4 2016, 11:11 AM
documentation/standarddocumentationview.cpp
46

why + 4?
Also just now I realize that they don't use QFont there...

antonanikin added inline comments.Oct 4 2016, 11:23 AM
documentation/standarddocumentationview.cpp
46

+4 is "heuristic" value, ensure that the HTML-font size be close to system font size. If we pass original size to QWebView the resulting font size will be too small.

antonanikin retitled this revision from [kdevplatform] font settings for the documentation view to Fix Bug 285162: adjust documentation view font settings by values taken from system settings (DE).Oct 7 2016, 4:20 AM
antonanikin updated this object.

I didn't so exactly follow this, but I'm confused why the "+4" is necessary. This sounds like something which would break on other systems. Don't we get the correct font size from e.g. the KDE default font?

antonanikin updated this revision to Diff 7287.Oct 11 2016, 2:17 AM

I didn't so exactly follow this, but I'm confused why the "+4" is necessary. This sounds like something which would break on other systems. Don't we get the correct font size from e.g. the KDE default font?

"Magic constant" is removed. Now we use pixelSize of system fonts. It works good on my system (linux) but resulting font size is slightly bigger than system font. It can be "fixed" with pixelSize() - 1, but I think it not necessary (and this again adds "magic constatnt"), slightly bigger new documentation fonts are better then current too small sizes.

apol added a comment.Oct 11 2016, 12:33 PM

Have you tried using the pointSize instead?

antonanikin updated this revision to Diff 7304.Oct 11 2016, 1:57 PM

Have you tried using the pointSize instead?

@apol, yes - it provides too small fonts.

Example for following system fonts:

  • QFontDatabase::GeneralFont (Sans Serif) - Ubuntu 14
  • QFontDatabase::FixedFont - Ubuntu Mono 16
  • QFontDatabase::SmallestReadableFont - Ubuntu 13

Result with using pixelSize():

Result with using pointSize():

apol accepted this revision.Oct 11 2016, 2:25 PM
apol added a reviewer: apol.
This revision is now accepted and ready to land.Oct 11 2016, 2:25 PM
brauch accepted this revision.Oct 11 2016, 2:31 PM
brauch added a reviewer: brauch.

I'm still confused why this doesn't give the same font, but ok, if it works go for it ;)

I'm still confused why this doesn't give the same font, but ok, if it works go for it ;)

@brauch, it seems that HTML engines uses pixel-size for fonts. I check my Firefox settings again and found font sizes also differ from UI system settings.

This revision was automatically updated to reflect the committed changes.