[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: FEATURE: Forcing DPI setting for fonts
From: Lubos Lunak <l.lunak () suse ! cz>
Date: 2006-08-25 14:47:00
Message-ID: 200608251647.00462.l.lunak () suse ! cz
[Download RAW message or body]
Hello,
this is basically http://bugs.kde.org/show_bug.cgi?id=111754 for the 3.5.x
branch. Or just google for things like 'kde gnome fonts dpi' to get more info
about the issue, like
http://process-of-elimination.net/wiki/Control_Font_DPI_in_X . In short, most
fonts are designed only for 96DPI and 120DPI and look horribly with other
DPIs. Since X by default computes real DPI and we just use it, while GNOME
forces it to 96DPI, we get a lot of "KDE has ugly fonts", despite us doing
things "properly". Go figure.
The patch adds a combobox allowing to force DPI this way, but it still
defaults to real DPI.
> The requirements for a new feature to get in KDE3.5.x are:
>
> - it needs to be already in trunk - we already have lot of code that went
> only into KDE3.5.x and not trunk, no need to make this even worse
check
> - it needs to be complete and ready - don't ask "I plan to develop this
> feature for 3.5.x, will it get in?"
check
> - it needs to be well-tested - create a branch or a patch and have it
> tested by other people, or even make independent public releases
> (kde-apps.org, in some distribution packages, whatever)
Well, this one is so simple that I don't think it really needs that much
testing. Still, I'm posting this mainly just in case somebody sees some
problem with messing with the DPI this way.
>
> - it needs to respect other freezes - if no new i18n messages are allowed,
> no feature changing those is allowed either
3 small i18n strings
> - it needs to be committed no later than a month before the next release is
> tagged (right now there's no date for 3.5.3, but presumably all releases
> will be announced at least a month in advance)
>
> - it must be mentioned in the changelog of the release (marked with "New:")
>
> - commit log must include "approved by ..." and don't forget the FEATURE:
> tag where applicable
>
> - last and the most important: It must be posted to the mailing list for
> the SVN module (kde-core-devel for those without) and must be approved by
> the module's maintainer (TWG for those without)
pending, pending, pending, pending
PS: There's also still pending my other patch with caching of wallpapers
(http://lists.kde.org/?l=kde-core-devel&m=114502950321763&w=2) that went
without any reaction at all. Should I take that as a permanent no? The latest
version of the patch is attached.
--
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)]
--- kdebase/kcontrol/krdb/krdb.cpp.sav 2006-05-16 16:52:21.000000000 +0200
+++ kdebase/kcontrol/krdb/krdb.cpp 2006-05-19 14:21:08.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,18 @@ 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';
+ else
+ {
+ KProcIO proc;
+ proc << "xrdb" << "-quiet" << "-remove" << "-nocpp";
+ proc.writeStdin( QCString( "Xft.dpi" ), true );
+ proc.closeWhenDone();
+ proc.start( KProcess::Block );
+ }
}
if (contents.length() > 0)
--- kdebase/kcontrol/fonts/fonts.cpp.sav 2006-05-19 11:27:11.000000000 +0200
+++ kdebase/kcontrol/fonts/fonts.cpp 2006-05-19 14:34:02.000000000 +0200
@@ -597,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());
+ 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);
@@ -632,6 +645,7 @@ void KFonts::defaults()
useAA = true;
cbAA->setChecked(useAA);
aaSettings->defaults();
+ cbDpi->setChecked(false);
emit changed(true);
}
@@ -644,6 +658,13 @@ void KFonts::load()
kdDebug(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);
}
@@ -652,9 +673,18 @@ 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( !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::homeDirPath() + "/.kderc" );
config->setGroup( "General" );
@@ -671,12 +701,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 or DPI settings will only affect \
newly started applications.</p>" + ), i18n("Font Settings Changed"), \
"FontSettingsChanged", false); useAA_original = useAA;
+ dpi_original = dpi;
}
runRdb(KRdbExportXftSettings);
--- kdebase/kcontrol/fonts/fonts.h.sav 2005-10-10 17:20:22.000000000 +0200
+++ kdebase/kcontrol/fonts/fonts.h 2006-05-19 14:29:14.000000000 +0200
@@ -108,7 +108,10 @@ protected slots:
private:
bool useAA, useAA_original;
+ int dpi_original;
QCheckBox *cbAA;
+ QCheckBox *cbDpi;
+ QComboBox* comboDpi;
QPtrList <FontUseItem> fontUseList;
FontAASettings *aaSettings;
};
--- kdebase/startkde.sav 2006-05-02 15:47:54.000000000 +0200
+++ kdebase/startkde 2006-05-19 14:21:32.000000000 +0200
@@ -68,6 +68,7 @@ kcmrandrrc [Screen0]
kcmrandrrc [Screen1]
kcmrandrrc [Screen2]
kcmrandrrc [Screen3]
+kcmfonts General fontDPI 0
EOF
kstartupconfig
if test $? -ne 0; then
@@ -132,6 +133,16 @@ if test "$kcmrandrrc_display_applyonstar
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) #
["09_cache_wallpapers.tar.gz" (application/x-tgz)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic