Bug 111754 - Font Manager Needs the Ability to Control Font DPI
Summary: Font Manager Needs the Ability to Control Font DPI
Status: RESOLVED FIXED
Alias: None
Product: kcontrol
Classification: Miscellaneous
Component: general (show other bugs)
Version: 3.4.1
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: Daniel Molkentin
URL:
Keywords:
: 124637 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-08-30 10:30 UTC by Matt T. Proud
Modified: 2006-11-11 08:23 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt T. Proud 2005-08-30 10:30:50 UTC
Version:           3.4.1 (using KDE KDE 3.4.1)
Installed from:    Gentoo Packages
OS:                Linux

On numerous machines running KDE on differing Linux distributions, I have noticed the fonts that KDE has chosen to use are often displayed in a non-optimal DPI, often resulting in their being rendered too large to be acceptable. With this in mind, even though one can set such things from the command line, it is imperative that KControl integrates some sort of a font DPI control mechanism.

I wish that I could give a screenshot for how poorly 100+ dpi rendered fonts look in a place where 96 dpi should be used.
Comment 1 Pau Tallada Crespí 2005-09-01 15:02:04 UTC
*** This bug has been confirmed by popular vote. ***
Comment 2 Lubos Lunak 2006-05-19 14:53:35 UTC
*** Bug 124637 has been marked as a duplicate of this bug. ***
Comment 3 Lubos Lunak 2006-05-19 15:25:02 UTC
SVN commit 542498 by lunakl:

Make it possible to explicitly force 96DPI or 120DPI.
Apparently there are enough people who for some strange
reason think that using the real DPI is a bug.
FEATURE: 111754



 M  +36 -5     kcontrol/fonts/fonts.cpp  
 M  +3 -0      kcontrol/fonts/fonts.h  
 M  +13 -1     kcontrol/krdb/krdb.cpp  
 M  +11 -0     startkde  


--- trunk/KDE/kdebase/workspace/kcontrol/fonts/fonts.cpp #542497:542498
@@ -618,13 +618,26 @@
    cbAA = new QCheckBox( i18n( "Use a&nti-aliasing for fonts" ), this);
    cbAA->setWhatsThis( i18n("If this option is selected, KDE will smooth the edges of curves in "
                               "fonts."));
-   lay->addStretch();
    QPushButton *aaSettingsButton = new QPushButton( i18n( "Configure..." ), this);
    connect(aaSettingsButton, SIGNAL(clicked()), SLOT(slotCfgAa()));
    connect(cbAA, SIGNAL(toggled(bool)), aaSettingsButton, SLOT(setEnabled(bool)));
    lay->addWidget( cbAA );
    lay->addWidget( aaSettingsButton );
+   lay->addStretch();
 
+   lay = new QHBoxLayout( layout, KDialog::spacingHint());
+   cbDpi = new QCheckBox( i18n( "Force DPI" ), this );
+   lay->addWidget( cbDpi );
+   comboDpi = new QComboBox( this );
+   comboDpi->insertItem( i18n( "Normal fonts (96 DPI)" ));
+   comboDpi->insertItem( i18n( "Huge fonts (120 DPI)" ));
+   comboDpi->setDisabled( true );
+   connect( cbDpi, SIGNAL( toggled( bool )), comboDpi, SLOT( setEnabled( bool )));
+   connect( cbDpi, SIGNAL( toggled( bool )), SLOT( changed()));
+   connect( comboDpi, SIGNAL( activated( int )), SLOT( changed()));
+   lay->addWidget( comboDpi );
+   lay->addStretch();
+
    layout->addStretch(1);
 
    aaSettings=new FontAASettings(this);
@@ -653,6 +666,7 @@
   useAA = true;
   cbAA->setChecked(useAA);
   aaSettings->defaults();
+  cbDpi->setChecked(false);
   emit changed(true);
 }
 
@@ -665,6 +679,13 @@
   kDebug(1208) << "AA:" << useAA << endl;
   cbAA->setChecked(useAA);
 
+  KConfig cfgfonts("kcmfonts", true);
+  cfgfonts.setGroup("General");
+  int dpi = cfgfonts.readNumEntry( "fontDPI", 0 );
+  cbDpi->setChecked( dpi == 96 || dpi == 120 );
+  comboDpi->setCurrentItem( dpi == 120 ? 1 : 0 );
+  dpi_original = dpi;
+
   emit changed(false);
 }
 
@@ -673,9 +694,18 @@
 
   for ( FontUseItem* i = fontUseList.first(); i; i = fontUseList.next() )
       i->writeFont();
-
   KGlobal::config()->sync();
 
+  KConfig cfgfonts("kcmfonts");
+  cfgfonts.setGroup("General");
+  int dpi;
+  if( !cbDpi->isChecked())
+      dpi = 0;
+  else
+      dpi = comboDpi->currentItem() == 0 ? 96 : 120;
+  cfgfonts.writeEntry( "fontDPI", dpi );
+  cfgfonts.sync();
+
   // KDE-1.x support
   KSimpleConfig* config = new KSimpleConfig( QDir::homePath() + "/.kderc" );
   config->setGroup( "General" );
@@ -692,12 +722,13 @@
 
   kapp->processEvents(); // Process font change ourselves
 
-  if(aaSettings->save( useAA ) || (useAA != useAA_original) ) {
+  if(aaSettings->save( useAA ) || (useAA != useAA_original) || dpi != dpi_original) {
     KMessageBox::information(this,
       i18n(
-        "<p>You have changed anti-aliasing related settings. This change will only affect newly started applications.</p>"
-      ), i18n("Anti-Aliasing Settings Changed"), "AAsettingsChanged", false);
+        "<p>Some changes such as anti-aliasing or DPI settings will only affect newly started applications.</p>"
+      ), i18n("Font Settings Changed"), "FontSettingsChanged", false);
     useAA_original = useAA;
+    dpi_original = dpi;
   }
 
   runRdb(KRdbExportXftSettings);
--- trunk/KDE/kdebase/workspace/kcontrol/fonts/fonts.h #542497:542498
@@ -111,7 +111,10 @@
 
 private:
     bool useAA, useAA_original;
+    int dpi_original;
     QCheckBox *cbAA;
+    QCheckBox *cbDpi;
+    QComboBox* comboDpi;
     Q3PtrList <FontUseItem> fontUseList;
     FontAASettings *aaSettings;
 };
--- trunk/KDE/kdebase/workspace/kcontrol/krdb/krdb.cpp #542497:542498
@@ -38,7 +38,7 @@
 #include <kdebug.h>
 #include <kglobalsettings.h>
 #include <kstandarddirs.h>
-#include <kprocess.h>
+#include <kprocio.h>
 #include <ksavefile.h>
 #include <ktempfile.h>
 #include <klocale.h>
@@ -543,6 +543,18 @@
     }
     if(!subPixel.isEmpty())
       contents += "Xft.rgba: " + subPixel + '\n';
+    KConfig cfgfonts("kcmfonts", true);
+    cfgfonts.setGroup("General");
+    if( cfgfonts.readNumEntry( "fontDPI", 0 ) != 0 )
+      contents += "Xft.dpi: " + cfgfonts.readEntry( "fontDPI" ) + '\n';
+    else
+    {
+      KProcIO proc;
+      proc << "xrdb" << "-quiet" << "-remove" << "-nocpp";
+      proc.writeStdin( QByteArray( "Xft.dpi" ), true );
+      proc.closeWhenDone();
+      proc.start( KProcess::Block );
+    }
   }
 
   if (contents.length() > 0)
--- trunk/KDE/kdebase/workspace/startkde #542497:542498
@@ -72,6 +72,7 @@
 kcmrandrrc [Screen1]
 kcmrandrrc [Screen2]
 kcmrandrrc [Screen3]
+kcmfonts General fontDPI 0
 EOF
 kstartupconfig
 if test $? -ne 0; then
@@ -136,6 +137,16 @@
     done
 fi
 
+if test "$kcmfonts_general_fontdpi" -eq 120; then
+    xrdb -quiet -merge -nocpp <<EOF
+Xft.dpi: 120
+EOF
+elif test "$kcmfonts_general_fontdpi" -eq 96; then
+    xrdb -quiet -merge -nocpp <<EOF
+Xft.dpi: 96
+EOF
+fi
+
 # Source scripts found in <localprefix>/env/*.sh and <prefixes>/env/*.sh
 # (where <localprefix> is $KDEHOME or ~/.kde, and <prefixes> is where KDE is installed)
 #
Comment 4 Daniel Hahler 2006-09-17 04:23:27 UTC
IMHO this is not really "RESOLVED": you can now only change between 96, 120 or "NULL".

It would be far better to (additionally?) allow a custom value/number.
Comment 5 Viking do Cerrado 2006-10-07 17:33:54 UTC
IMHO dAniel hAhler is right.

And maybe having a box for setting it inside
KDE Control Center\Appearance & Themes\Fonts
Comment 6 Jon Ringle 2006-11-11 08:23:33 UTC
When using KDE inside of a VMware virtual machine with the vmware-tools installed, and you resize the VMWare application then something recalculates the DPI with the assumption that the "physical" monitor dimensions is static. In a virtual machine, this does not hold true, since there is a virtual monitor that changes size in proportion to a change in resolution and the DPI in this case should remain constant. It would be nice if KDE would offer a means of forcing a DPI no matter what resolution is currently being used.