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

List:       kde-core-devel
Subject:    Fwd: Re: So we really want *pixel* size
From:       Lars Knoll <lars () trolltech ! com>
Date:       2001-01-30 9:58:43
[Download RAW message or body]

FYI,

Lars

----------  Forwarded Message  ----------
Subject: Re: So we really want *pixel* size
Date: Tue, 30 Jan 2001 09:33:41 +0000
From: Magnus Kessler <Magnus.Kessler@gmx.net>
To: lars@trolltech.com


Dear Lars,

I just want to give my thoughts for the discussion on kde-core-devel. Excuse
me for sending this directly to you -- I'm currently not subscribed to the
list.

I am currently using KDE on a system with a (real) screen resolution of
133dpi. This high resolution allows me easily to use a default font size of
9pt (> 16px @ 133dpi) and I can read fonts down to about 4pt (> 7 px @
133dpi). For me (working on a Laptop) the "smallest" setting in khtml is just
about right, but I would still prefer to be able to set the fontsize (in
POINTS) per value.

In a previous job I worked in an environment where my homedirectory was
accessible from different computers each of which had a different screen
resolution (out of my control, since the XServer could not be persuaded to
change its dpi settings (SGI)). Using points even in this environment it was
possible to get a relatively consistent look across the different machines,
whereas fonts looked hugely different in size when specified as pixels.

I have been using the following patch on khtml_settings.cc for a couple of
weeks now without any problems (both on KDE_2_0_1BRANCH and CVS HEAD). I have
attempted to create a minimum impact (for normal users) patch while allowing
users to set point values in the konquerorrc file (set FontSize to an
(positive) integer other than -2, -1, 0, 1, 2).

Please review the attached patch and tell me what you think. BTW this patch
has been inspired by an article by Todd Fahrner on
http://style.metrius.com/font_size_intervals/altintervals.html. The formula
used in this patch is analogous to similar formulae used to create well
tempered intervals in music, as hinted in Todd's article. Somewhere on Todd's
site I also found his proposal for a UI, which I attach as well.

I would be very glad if my patch (or something similar) would make it into
the 2.1 release.

Best wishes,

Magnus Kessler

-------------------------------------------------------

["khtml_settings.patch" (text/x-c++)]

retrieving revision 1.39
diff -u -3 -p -r1.39 khtml_settings.cc
--- khtml_settings.cc   2000/11/12 14:40:46     1.39
+++ khtml_settings.cc   2000/11/27 21:59:49
@@ -25,6 +25,7 @@
 #include <kglobal.h>
 #include <klocale.h>
 #include <kcharsets.h>
+#include <math.h>

 #define MAXFONTSIZES 15
 // xx-small, x-small, small, medium, large, x-large, xx-large, ...
@@ -127,8 +128,6 @@ void KHTMLSettings::init( KConfig * conf
   if ( reset || config->hasKey( "MinimumFontSize" ) )
   {
     m_minFontSize = config->readNumEntry( "MinimumFontSize", \
                HTML_DEFAULT_MIN_FONT_SIZE );
-    if(m_minFontSize < 6)
-        m_minFontSize = 6;
   }

     if( reset ) {
@@ -306,12 +305,34 @@ void KHTMLSettings::resetFontSizes()
 {
     m_fontSizes.clear();
     for ( int i = 0; i < MAXFONTSIZES; i++ )
-        if( m_fontSize == 0 ) // small
+    {
+        if( m_fontSize == 0 )
+        {
+            // small predefined
             m_fontSizes << defaultSmallFontSizes[ i ];
-        else if( m_fontSize == 2 ) // large
+        }
+        else if( m_fontSize == 1 )
+        {
+            // medium predefined
+            m_fontSizes << defaultMediumFontSizes[ i ];
+        }
+        else if( m_fontSize == 2 )
+        {
+            // large predefined
             m_fontSizes << defaultLargeFontSizes[ i ];
+        }
         else
-            m_fontSizes << defaultMediumFontSizes[ i ];
+        {
+            /*
+                the formula used here satisfies the condition, that
+                after 4 steps the size has exactly doubled and that
+                there is a constant ratio beween subsequent steps (before round+     \
(pow(2, 0.25) == 1.189207115; close to CSS recommendation of 1.+            */ +      \
double tone = i - 3; // this is because i==3 is the medium sized en+            \
m_fontSizes << rint(m_fontSize * pow(pow(2, 1.0/4.0), tone)); +        }
+  }
 }
 
 void KHTMLSettings::setFontSizes(const QValueList<int> &_newFontSizes )
Index: khtml_settings.cc
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_settings.cc,v
retrieving revision 1.52
diff -u -3 -p -r1.52 khtml_settings.cc
--- khtml_settings.cc	2001/01/15 21:31:27	1.52
+++ khtml_settings.cc	2001/01/30 09:15:36
@@ -27,6 +27,8 @@
 #include <kcharsets.h>
 #include <kdebug.h>
 
+#include <math.h>
+
 #define MAXFONTSIZES 15
 // xx-small, x-small, small, medium, large, x-large, xx-large, ...
 const int defaultXSmallFontSizes[MAXFONTSIZES] =
@@ -134,8 +136,6 @@ void KHTMLSettings::init( KConfig * conf
   if ( reset || config->hasKey( "MinimumFontSize" ) )
   {
     m_minFontSize = config->readNumEntry( "MinimumFontSize", \
                HTML_DEFAULT_MIN_FONT_SIZE );
-    if(m_minFontSize < 6)
-        m_minFontSize = 6;
   }
 
     if( reset ) {
@@ -385,6 +385,7 @@ void KHTMLSettings::resetFontSizes()
 {
     m_fontSizes.clear();
     for ( int i = 0; i < MAXFONTSIZES; i++ )
+    {
 	switch( m_fontSize ) {
 	    case -1:
 		m_fontSizes << defaultXSmallFontSizes[ i ];
@@ -399,10 +400,21 @@ void KHTMLSettings::resetFontSizes()
 		m_fontSizes << defaultXLargeFontSizes[ i ];
 		break;
 	    case 1:
-	    default:
 		m_fontSizes << defaultMediumFontSizes[ i ];
 		break;
+	    default:
+            /*
+                the formula used here satisfies the condition, that
+                after 4 steps the size has exactly doubled and that
+                there is a constant ratio beween subsequent steps (before rounding).
+                (pow(2, 0.25) == 1.189207115; close to CSS recommendation of 1.2
+                i == 3 is the medium sized entry
+            */
+		m_fontSizes << rint(m_fontSize * pow(pow(2, 1.0/4.0), i-3));
+		break;
+            
 	}
+    }
 }
 
 void KHTMLSettings::setFontSizes(const QValueList<int> &_newFontSizes )


["cssuiprefs.GIF" (image/gif)]

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

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