From kde-core-devel Thu Aug 31 12:56:52 2006 From: Lubos Lunak Date: Thu, 31 Aug 2006 12:56:52 +0000 To: kde-core-devel Subject: Re: FEATURE: Forcing DPI setting for fonts Message-Id: <200608311456.52772.l.lunak () suse ! cz> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=115702905105497 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_Uyt9ExKkP9jltAG" --Boundary-00=_Uyt9ExKkP9jltAG Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Tuesday 29 August 2006 07:20, Germain Garand wrote: > Le Lundi 28 Ao=FBt 2006 13:47, Lubos Lunak a =E9crit : > > On Sunday 27 August 2006 11:31, Germain Garand wrote: > > > Le Samedi 26 Ao=FBt 2006 20:33, Lubos Lunak a =E9crit : > > > 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 misleadi= ng > (this is Microsoft vintage wording! it was already misleading 12 years ag= o, > 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=20 supposed to use it anyway :). And, given that, I think the what's this help should also make it clear th= at=20 it's just a "so you really want this, stupid?" option. Does something like= =20 this make sense? " This option forces a specific DPI value for fonts. It may be useful when th= e=20 real DPI of the hardware is not detected properly and it is also often=20 misused when poor quality fonts are used that do not look well with DPI=20 values other than 96 or 120 DPI. The use of this option is generally discouraged. For selecting proper DPI=20 value a better option is explicitly configuring it for the whole X server i= f=20 possible (e.g. DisplaySize in xorg.conf or adding "-dpi value" to=20 ServerLocalArgs=3D in $KDEDIR/share/config/kdm/kdmrc). When fonts do not re= nder=20 properly with real DPI value better fonts should be used or configuration o= f=20 font hinting should be checked. " Oh boy, people are weird ... =2D-=20 Lubos Lunak KDE developer =2D------------------------------------------------------------- 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 --Boundary-00=_Uyt9ExKkP9jltAG Content-Type: text/x-diff; charset="iso-8859-15"; name="fonts_dpi.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fonts_dpi.patch" --- 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 #include #include -#include +#include #include #include #include @@ -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 #include #include +#include #include #include #include @@ -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( - "

You have changed anti-aliasing related settings. This change will only affect newly started applications.

" - ), i18n("Anti-Aliasing Settings Changed"), "AAsettingsChanged", false); + "

Some changes such as anti-aliasing will only affect newly started applications.

" + ), 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 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 </env/*.sh and /env/*.sh # (where is $KDEHOME or ~/.kde, and is where KDE is installed) # --Boundary-00=_Uyt9ExKkP9jltAG--