Recent

Author Topic: High DPI on Linux  (Read 13188 times)

tk

  • Sr. Member
  • ****
  • Posts: 361
High DPI on Linux
« on: July 10, 2014, 05:02:14 pm »
Hi
do you know how to activate high DPI in Lazarus app on Linux?

http://wiki.lazarus.freepascal.org/High_DPI
This works on Windows but not on Linux.

Interesting is that the Lazarus program itself has bigger fonts on Linux when I change DPI in KDE.
But I cannot achieve this in my program.
The program I write now is very often used by older ppl where bigger fonts matter.
(true, those ppl use Windows in most cases)

I use Kubuntu v14.

Thanks

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: High DPI on Linux
« Reply #1 on: July 10, 2014, 05:31:55 pm »
Afaik that is for Windows only.

I don't know how deep such settings in KDE go, if its only for KDE using apps, or for all QT apps, or for all X apps.

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: High DPI on Linux
« Reply #2 on: July 10, 2014, 05:38:10 pm »
I think it is not finished in Lazarus yet.
When compiled under QT the app gets scaled but font size remains small.
In GTK2 the app is the same as with default DPI.

Never mind, will use always default DPI on Linux.

Rails

  • Guest
Re: High DPI on Linux
« Reply #3 on: July 10, 2014, 08:08:01 pm »
QT provides a tool called "QT Configuration" which can be used to set such things as fonts and widgetry for those desktop applications using QT. KDE has the equivalent built in AFAIK. For non QT desktops, the configurator can usually be found in the distro's repositories. In my experience, installing and using it can make a substantial impact on how a QT app appears on a non-QT desktop. The package name will vary between distros. For my Debian unstable system, it is currently named qt4-qtconfig.

Edit:

Laz's graphics unit has a record that provides the actual monitor DPI if it is reporting it via EDID and the OS is passing it on (not always a sure bet).

Code: [Select]
ScreenInfo.PixelsPerInchX
ScreenInfo.PixelsPerInchY 

If the monitor isn't reporting it or the OS is not passing it on, you will usually get 96 DPI. If the OS is not providing any DPI info at all, Lazarus will return a default of 72 DPI.

The screen on the laptop I am writing this on returns 118 DPI to my Laz application, which is accurate.

« Last Edit: July 10, 2014, 10:43:37 pm by Rails »

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: High DPI on Linux
« Reply #4 on: July 11, 2014, 01:20:01 am »
I think it is not finished in Lazarus yet.
When compiled under QT the app gets scaled but font size remains small.
In GTK2 the app is the same as with default DPI.

Never mind, will use always default DPI on Linux.

That is the best thing to do. For instance your KGrid demos use Tahoma fonts with size 8 & they look tiny in Linux (see screenshot GTK 2 Linux Cinnamon 17) but look OK in Windows. If you left it at default, it will be displayed with system font size.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: High DPI on Linux
« Reply #5 on: July 11, 2014, 10:51:28 am »
Thanks JD you are damn right!
The Tahoma font messed it up.
However, still I am not able to scale the form correctly in GTK2, in QT it now runs like a charm!

The Tahoma font is default font in Delphi AFAIK and stored in the forms. As you know I make the components cross IDE but it is true the lfm files should contain default font.

This app I am writing now has common DFM files both for Lazarus and Delphi (I need Delphi for Win because of missing alphacontrols in Lazarus).
Delphi stores default font name. Delphi messes this up.

However, isn't it a bug that Lazarus does not scale custom fonts under Linux?
Will probably deploy 2 binaries (QT and GTK2).

tk

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: High DPI on Linux
« Reply #6 on: July 11, 2014, 12:07:38 pm »

However, isn't it a bug that Lazarus does not scale custom fonts under Linux?
Will probably deploy 2 binaries (QT and GTK2).


no linux does not scale any fonts custom or otherwise it just uses the default settings for the DM adn thats it it is a linux limitation not a lazarus one.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: High DPI on Linux
« Reply #7 on: July 11, 2014, 05:52:08 pm »
However, isn't it a bug that Lazarus does not scale custom fonts under Linux?
Will probably deploy 2 binaries (QT and GTK2).

tk

Fonts have always been my biggest issue with Linux. I'm never satisfied with the way the fonts are rendered. So I spend time tweaking configuration files anytime I change themes in Linux. I actually edit the GTK configuation files by hand.

See
GTK+
https://wiki.archlinux.org/index.php/GTK+
Uniform Look for Qt and GTK Applications
https://wiki.archlinux.org/index.php/Uniform_Look_for_Qt_and_GTK_Applications
GTK Fonts Are Too Big
http://superuser.com/questions/425018/gtk-fonts-are-too-big
How do I enlarge fonts for GTK applications?
http://superuser.com/questions/103022/how-do-i-enlarge-fonts-for-gtk-applications?rq=1

JD
« Last Edit: July 11, 2014, 05:58:48 pm by JD »
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: High DPI on Linux
« Reply #8 on: July 30, 2014, 10:18:43 pm »
Fonts have always been my biggest issue with Linux. I'm never satisfied with the way the fonts are rendered.
Strange, I have the opposite experience again. My fonts under Linux and FreeBSD look absolutely beautiful and sharp. Yet under Windows and OSX (except on my MacBook Pro Retina) it looks fuzzy, fat and generally crap.

I have a standard .fonts.conf file I use in my $HOME directory for many years. See text pasted below. For me the key ingredient was the hintstyle and lcdfilter setting.

Code: [Select]
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <dir>~/.fonts</dir>
  <match target="font">
    <edit mode="assign" name="rgba">
      <const>rgb</const>
    </edit>

    <edit mode="assign" name="hinting">
      <bool>true</bool>
    </edit>

    <edit mode="assign" name="hintstyle">
      <!-- hintnone, hintslight, hintmedium, hintfull -->
      <const>hintfull</const>
    </edit>

    <edit mode="assign" name="lcdfilter">
      <!-- lcdnone, lcddefault, lcdlight, lcdlegacy -->
      <const>lcddefault</const>
    </edit>
 </match>

 <!-- Here comes the font substitution -->
<!--
 <match target="pattern">
  <test name="family" qual="any"><string>Roboto</string></test>
  <edit name="family" mode="assign" binding="same"><string>Verdana</string></edit>
 </match>
-->
 <!-- Here comes the font substitution -->
 <match target="pattern">
  <test name="family" qual="any"><string>Helvetica</string></test>
  <edit name="family" mode="assign" binding="same"><string>Liberation Sans</string></edit>
 </match>
 <match target="pattern">
  <test name="family" qual="any"><string>Verdana Cursiva</string></test>
  <edit name="family" mode="assign" binding="same"><string>Liberation Sans</string></edit>
 </match>

</fontconfig>
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: High DPI on Linux
« Reply #9 on: July 30, 2014, 11:04:59 pm »
no linux does not scale any fonts custom or otherwise it just uses the default settings for the DM and thats it it is a linux limitation not a lazarus one.
I'm sorry, but that is total rubbish. GTK2 and QT4 can scale widgets and fonts perfectly for lower or higher DPI settings. So too can the fpGUI Toolkit (see a quick test I put together - original form was designed at 96 dpi).

The bug is with LCL, not Linux, FreeBSD or any other X11 based system.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: High DPI on Linux
« Reply #10 on: July 30, 2014, 11:28:00 pm »
Thanks for sharing. How do I use this? Do I just put your .fonts.conf file in my $HOME directory OR is there anything else I need to do?

BTW Even if I'm not totally satisfied with Linux fonts, it doesn't stop me from using it extensively. My major work is done in Linux nowadays using cross-platform software (Win/Linux) so that I can switch easily if the need arises.

JD

Fonts have always been my biggest issue with Linux. I'm never satisfied with the way the fonts are rendered.
Strange, I have the opposite experience again. My fonts under Linux and FreeBSD look absolutely beautiful and sharp. Yet under Windows and OSX (except on my MacBook Pro Retina) it looks fuzzy, fat and generally crap.

I have a standard .fonts.conf file I use in my $HOME directory for many years. See text pasted below. For me the key ingredient was the hintstyle and lcdfilter setting.

Code: [Select]
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <dir>~/.fonts</dir>
  <match target="font">
    <edit mode="assign" name="rgba">
      <const>rgb</const>
    </edit>

    <edit mode="assign" name="hinting">
      <bool>true</bool>
    </edit>

    <edit mode="assign" name="hintstyle">
      <!-- hintnone, hintslight, hintmedium, hintfull -->
      <const>hintfull</const>
    </edit>

    <edit mode="assign" name="lcdfilter">
      <!-- lcdnone, lcddefault, lcdlight, lcdlegacy -->
      <const>lcddefault</const>
    </edit>
 </match>

 <!-- Here comes the font substitution -->
<!--
 <match target="pattern">
  <test name="family" qual="any"><string>Roboto</string></test>
  <edit name="family" mode="assign" binding="same"><string>Verdana</string></edit>
 </match>
-->
 <!-- Here comes the font substitution -->
 <match target="pattern">
  <test name="family" qual="any"><string>Helvetica</string></test>
  <edit name="family" mode="assign" binding="same"><string>Liberation Sans</string></edit>
 </match>
 <match target="pattern">
  <test name="family" qual="any"><string>Verdana Cursiva</string></test>
  <edit name="family" mode="assign" binding="same"><string>Liberation Sans</string></edit>
 </match>

</fontconfig>
« Last Edit: July 30, 2014, 11:34:58 pm by JD »
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: High DPI on Linux
« Reply #11 on: July 30, 2014, 11:52:01 pm »
Thanks for sharing. How do I use this? Do I just put your .fonts.conf file in my $HOME directory OR is there anything else I need to do?

That's all there is to it! :) I can't remember if the effect is immediate, or if you need to restart your apps, or the whole desktop environment. I think it was immediate.

Optional:
You can then copy any extra fonts you want into the $HOME/.fonts/ directory, and your X11 will immediately see them. For example, I have the MS Web Fonts copied in there, plus a few others I use. Liberation Sans is also a very nice font - a good free Helvetica or Arial replacement. I don't know if it already comes standard with Linux distros or not - if not, it is in the package repositories and easy to install.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: High DPI on Linux
« Reply #12 on: July 31, 2014, 12:07:41 pm »
The Liberation fonts are standard on most distros nowadays. LibreOffice uses them as its default fonts even on Windows!  :D

There is an even more comprehensive enhancement to the fonts.conf file at
http://www.binarytides.com/gorgeous-looking-fonts-ubuntu-linux/ & https://gist.github.com/silv3rm00n/5599072.

Alternatively, instead of saving the file as fonts.conf in the $HOME directory one can save the file as ~/.config/.fontconfig/conf.d

JD
« Last Edit: July 31, 2014, 12:44:16 pm by JD »
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: High DPI on Linux
« Reply #13 on: July 31, 2014, 02:47:55 pm »
On my system (FreeBSD 10) the actual path is $HOME/.config/fontconfig/fonts.conf but the $HOME/.fonts.conf still works too. In fact, I made the $HOME/.fonts.conf a symbolic link to the one in .config/ directory.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: High DPI on Linux
« Reply #14 on: July 31, 2014, 04:41:16 pm »
On my system (FreeBSD 10) the actual path is $HOME/.config/fontconfig/fonts.conf but the $HOME/.fonts.conf still works too. In fact, I made the $HOME/.fonts.conf a symbolic link to the one in .config/ directory.

After doing all this (with a few hits & misses provoking reinstalling my Linux system), I'm quite pleased with the results. It looks very good now. Maybe not as good as on a Mac (the ultimate - in my opinion) but for something free is more than worth it.  :D
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

 

TinyPortal © 2005-2018