[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: FEATURE: Forcing DPI setting for fonts
From:       Lubos Lunak <l.lunak () suse ! cz>
Date:       2006-08-31 12:56:52
Message-ID: 200608311456.52772.l.lunak () suse ! cz
[Download RAW message or body]

On Tuesday 29 August 2006 07:20, Germain Garand wrote:
> Le Lundi 28 Août 2006 13:47, Lubos Lunak a écrit :
> > On Sunday 27 August 2006 11:31, Germain Garand wrote:
> > > Le Samedi 26 Août 2006 20:33, Lubos Lunak a écrit :
> > > right... now if a user with an already tweaked Xft.dpi simply modifies
> > > some other font options, isn't the patch going to remove that tweak by
> > > default? is this intended?
> >
> >  The removal is there in order to make turning that option off again
> > work.
> >
> > I can handle this by doing the removal only in kcmfonts (impossible to
> > get the original default at that time I'm afraid), so the setting
> > wouldn't be affected during KDE startup.
>
> ah good.

 Done.

> >  In layman's terms, please :). Do you have a serious reason against
> > inclusion of the patch or you just don't like it (which I don't either,
> > but oh well)?
>
> still one yes, "Normal Fonts/Huge Fonts" is completely wrong and misleading
> (this is Microsoft vintage wording! it was already misleading 12 years ago,
> so what now where 140dpi+ screens are common..). All it can do is nudge
> people that do not understand the setting to frivolously play with it.

 Let's call it just "96 DPI" and "120 DPI" then. People are not really 
supposed to use it anyway :).

 And, given that, I think the what's this help should also make it clear that 
it's just a "so you really want this, stupid?" option. Does something like 
this make sense?

"
This option forces a specific DPI value for fonts. It may be useful when the 
real DPI of the hardware is not detected properly and it is also often 
misused when poor quality fonts are used that do not look well with DPI 
values other than 96 or 120 DPI.

The use of this option is generally discouraged. For selecting proper DPI 
value a better option is explicitly configuring it for the whole X server if 
possible (e.g. DisplaySize in xorg.conf or adding "-dpi value" to 
ServerLocalArgs= in $KDEDIR/share/config/kdm/kdmrc). When fonts do not render 
properly with real DPI value better fonts should be used or configuration of 
font hinting should be checked.
"

 Oh boy, people are weird ...

-- 
Lubos Lunak
KDE developer
--------------------------------------------------------------
SUSE LINUX, s.r.o.   e-mail: l.lunak@suse.cz , l.lunak@kde.org
Lihovarska 1060/12   tel: +420 284 028 972
190 00 Prague 9      fax: +420 284 028 951
Czech Republic       http//www.suse.cz

["fonts_dpi.patch" (text/x-diff)]

--- kcontrol/krdb/krdb.cpp.sav	2006-08-31 13:24:04.000000000 +0200
+++ kcontrol/krdb/krdb.cpp	2006-08-31 13:32:52.000000000 +0200
@@ -34,7 +34,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>
@@ -533,6 +533,10 @@ void runRdb( uint flags )
     }
     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';
   }
 
   if (contents.length() > 0)
--- kcontrol/fonts/fonts.cpp.sav	2006-08-31 13:24:04.000000000 +0200
+++ kcontrol/fonts/fonts.cpp	2006-08-31 14:38:08.000000000 +0200
@@ -26,6 +26,7 @@
 #include <kipc.h>
 #include <kmessagebox.h>
 #include <knuminput.h>
+#include <kprocio.h>
 #include <ksimpleconfig.h>
 #include <kstandarddirs.h>
 #include <stdlib.h>
@@ -596,12 +597,25 @@ KFonts::KFonts(QWidget *parent, const ch
    cbAA = new QCheckBox( i18n( "Use a&nti-aliasing for fonts" ), this);
    QWhatsThis::add(cbAA, 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());
+   cbForceDpi = new QCheckBox( i18n( "Force fonts DPI" ), this );
+   lay->addWidget( cbForceDpi );
+   comboForceDpi = new QComboBox( this );
+   comboForceDpi->insertItem( i18n( "96 DPI" ));
+   comboForceDpi->insertItem( i18n( "120 DPI" ));
+   comboForceDpi->setDisabled( true );
+   connect( cbForceDpi, SIGNAL( toggled( bool )), comboForceDpi, SLOT( setEnabled( \
bool ))); +   connect( cbForceDpi, SIGNAL( toggled( bool )), SLOT( changed()));
+   connect( comboForceDpi, SIGNAL( activated( int )), SLOT( changed()));
+   lay->addWidget( comboForceDpi );
+   lay->addStretch();
 
    layout->addStretch(1);
 
@@ -643,6 +657,13 @@ void KFonts::load( bool useDefaults )
   useAA_original = useAA = aaSettings->load( useDefaults );
   cbAA->setChecked(useAA);
 
+  KConfig cfgfonts("kcmfonts", true);
+  cfgfonts.setGroup("General");
+  int dpi = cfgfonts.readNumEntry( "forceFontDPI", 0 );
+  cbForceDpi->setChecked( dpi == 96 || dpi == 120 );
+  comboForceDpi->setCurrentItem( dpi == 120 ? 1 : 0 );
+  dpi_original = dpi;
+
   emit changed( useDefaults );
 }
 
@@ -651,9 +672,27 @@ void KFonts::save()
 
   for ( FontUseItem* i = fontUseList.first(); i; i = fontUseList.next() )
       i->writeFont();
-
   KGlobal::config()->sync();
 
+  KConfig cfgfonts("kcmfonts");
+  cfgfonts.setGroup("General");
+  int dpi;
+  if( !cbForceDpi->isChecked())
+      dpi = 0;
+  else
+      dpi = comboForceDpi->currentItem() == 0 ? 96 : 120;
+  cfgfonts.writeEntry( "forceFontDPI", dpi );
+  cfgfonts.sync();
+  // if the setting is reset in the module, remove the dpi value,
+  // otherwise don't explicitly remove it and leave any possible system-wide value
+  if( dpi == 0 && dpi_original != 0 ) {
+      KProcIO proc;
+      proc << "xrdb" << "-quiet" << "-remove" << "-nocpp";
+      proc.writeStdin( QCString( "Xft.dpi" ), true );
+      proc.closeWhenDone();
+      proc.start( KProcess::Block );
+  }
+
   // KDE-1.x support
   KSimpleConfig* config = new KSimpleConfig( QDir::homeDirPath() + "/.kderc" );
   config->setGroup( "General" );
@@ -670,12 +709,13 @@ void KFonts::save()
 
   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 will only affect newly started \
applications.</p>" +      ), i18n("Font Settings Changed"), "FontSettingsChanged", \
false);  useAA_original = useAA;
+    dpi_original = dpi;
   }
 
   runRdb(KRdbExportXftSettings);
--- kcontrol/fonts/fonts.h.sav	2006-08-31 13:24:04.000000000 +0200
+++ kcontrol/fonts/fonts.h	2006-08-31 13:24:42.000000000 +0200
@@ -110,7 +110,10 @@ protected slots:
 
 private:
     bool useAA, useAA_original;
+    int dpi_original;
     QCheckBox *cbAA;
+    QCheckBox *cbDpi;
+    QComboBox* comboDpi;
     QPtrList <FontUseItem> fontUseList;
     FontAASettings *aaSettings;
 };
--- startkde.sav	2006-05-02 15:47:54.000000000 +0200
+++ startkde	2006-05-19 14:21:32.000000000 +0200
@@ -68,6 +68,7 @@ kcmrandrrc [Screen0]
 kcmrandrrc [Screen1]
 kcmrandrrc [Screen2]
 kcmrandrrc [Screen3]
+kcmfonts General forceFontDPI 0
 EOF
 kstartupconfig
 if test $? -ne 0; then
@@ -132,6 +133,16 @@ if test "$kcmrandrrc_display_applyonstar
     done
 fi
 
+if test "$kcmfonts_general_forcefontdpi" -eq 120; then
+    xrdb -quiet -merge -nocpp <<EOF
+Xft.dpi: 120
+EOF
+elif test "$kcmfonts_general_forcefontdpi" -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)  #



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic