Index: khtml_part.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
retrieving revision 1.530.2.16
diff -u -p -b -r1.530.2.16 khtml_part.cpp
--- khtml_part.cpp	2001/11/09 02:50:23	1.530.2.16
+++ khtml_part.cpp	2002/03/11 11:30:59
@@ -467,6 +467,8 @@ void KHTMLPart::init( KHTMLView *view, G
   d = new KHTMLPartPrivate(parent());
   kdDebug(6050) << "KHTMLPart::init this=" << this << " d=" << d << endl;
 
+  m_scalingFactor = 100;
+
   d->m_view = view;
   setWidget( d->m_view );
 
@@ -4360,6 +4362,13 @@ void KHTMLPart::slotActiveFrameChanged( 
 
     // (note: childObject returns 0 if the argument is 0)
     d->m_extension->setExtensionProxy( KParts::BrowserExtension::childObject( d->m_activeFrame ) );
+}
+
+void KHTMLPart::setScalingFactor( ushort factor )
+{
+    m_scalingFactor = factor;
+    if ( d->m_doc )
+	d->m_doc->applyChanges();
 }
 
 void KHTMLPart::setActiveNode(const DOM::Node &node)
Index: khtml_part.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.h,v
retrieving revision 1.146.2.1
diff -u -p -b -r1.146.2.1 khtml_part.h
--- khtml_part.h	2001/10/30 00:22:51	1.146.2.1
+++ khtml_part.h	2002/03/11 11:30:59
@@ -722,6 +722,9 @@ public:
    */
   QString jsDefaultStatusBarText() const;
 
+  void setScalingFactor( ushort factor );
+  ushort scalingFactor() const { return m_scalingFactor; }
+
 signals:
   /**
    * Emitted if the cursor is moved over an URL.
@@ -1046,6 +1049,8 @@ private:
   void checkEmitLoadEvent();
   void emitLoadEvent();
   void emitUnloadEvent();
+
+  ushort m_scalingFactor;
 
   KHTMLPartPrivate *d;
   friend class KHTMLPartPrivate;
Index: khtml_settings.cc
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_settings.cc,v
retrieving revision 1.65.2.1
diff -u -p -b -r1.65.2.1 khtml_settings.cc
--- khtml_settings.cc	2001/09/07 15:05:44	1.65.2.1
+++ khtml_settings.cc	2002/03/11 11:31:00
@@ -126,6 +126,9 @@ void KHTMLSettings::init( KConfig * conf
     if ( reset || config->hasKey( "MinimumFontSize" ) )
         m_minFontSize = config->readNumEntry( "MinimumFontSize", HTML_DEFAULT_MIN_FONT_SIZE );
 
+    if ( reset || config->hasKey( "FixedFontSize" ) )
+        m_fixedFontSize = config->readNumEntry( "FixedFontSize", 0 );
+
     if ( reset || config->hasKey( "MediumFontSize" ) ) {
         m_fontSize = config->readNumEntry( "MediumFontSize", 10 );
         resetFontSizes();
Index: khtml_settings.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_settings.h,v
retrieving revision 1.23
diff -u -p -b -r1.23 khtml_settings.h
--- khtml_settings.h	2001/03/10 21:21:12	1.23
+++ khtml_settings.h	2002/03/11 11:31:00
@@ -82,6 +82,7 @@ public:
     void resetFontSizes();
 
     int minFontSize() const { return m_minFontSize; }
+    uint fixedFontSize() const { return m_fixedFontSize; }
 
     // the charset used to display the current document.
     QFont::CharSet charset() const { return m_charset; }
@@ -137,6 +138,7 @@ private:
     int m_fontSize;
     QValueList<int>     m_fontSizes;
     int m_minFontSize;
+    uint m_fixedFontSize;
 
     QFont::CharSet m_charset;
     QFont::CharSet m_script;
Index: css/css_valueimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/css_valueimpl.cpp,v
retrieving revision 1.49
diff -u -p -b -r1.49 css_valueimpl.cpp
--- css/css_valueimpl.cpp	2001/07/29 16:12:45	1.49
+++ css/css_valueimpl.cpp	2002/03/11 11:31:00
@@ -29,9 +29,17 @@
 #include "dom_string.h"
 #include "dom_stringimpl.h"
 #include "dom_nodeimpl.h"
+#include "xml/dom_docimpl.h"
+#include "rendering/render_style.h"
 
 #include "misc/loader.h"
+#include "misc/helper.h"
 
+#include "khtmlview.h"
+#include "khtml_part.h"
+#include "khtml_settings.h"
+
+#include <qpaintdevicemetrics.h>
 #include <kdebug.h>
 
 #include "cssvalues.h"
@@ -657,6 +665,61 @@ DOM::DOMString CSSPrimitiveValueImpl::cs
 	    break;
     }
     return text;
+}
+
+int CSSPrimitiveValueImpl::computeLength(khtml::RenderStyle *style, DOM::DocumentImpl *doc )
+{
+    return ( int ) computeLengthFloat( style, doc );
+}
+
+float CSSPrimitiveValueImpl::computeLengthFloat(khtml::RenderStyle *style, DOM::DocumentImpl *doc )
+{
+    float dpiY = 72.; // fallback
+    QPaintDeviceMetrics *devMetrics = doc->paintDeviceMetrics();
+    if ( devMetrics )
+        dpiY = devMetrics->logicalDpiY();
+    if ( !khtml::printpainter && dpiY < 96 )
+        dpiY = 96.;
+
+    float factor = 1.;
+    float documentScalingFactor = (float)doc->view()->part()->scalingFactor() / 100.;
+    switch(m_type)
+    {
+    case CSSPrimitiveValue::CSS_EMS:
+       	factor = style->font().pixelSize();
+	documentScalingFactor = 1.;
+	break;
+    case CSSPrimitiveValue::CSS_EXS:
+	{
+        QFontMetrics fm = khtml::fontMetrics(style->font());
+        QRect b = fm.boundingRect('x');
+        factor = b.height();
+	documentScalingFactor = 1.;
+        break;
+	}
+    case CSSPrimitiveValue::CSS_PX:
+        break;
+    case CSSPrimitiveValue::CSS_CM:
+	factor = dpiY/2.54; //72dpi/(2.54 cm/in)
+        break;
+    case CSSPrimitiveValue::CSS_MM:
+	factor = dpiY/25.4;
+        break;
+    case CSSPrimitiveValue::CSS_IN:
+            factor = dpiY;
+        break;
+    case CSSPrimitiveValue::CSS_PT:
+            factor = dpiY/72.;
+        break;
+    case CSSPrimitiveValue::CSS_PC:
+        // 1 pc == 12 pt
+            factor = dpiY*12./72.;
+        break;
+    default:
+        return -1;
+    }
+    return m_value.num*factor*documentScalingFactor;
+
 }
 
 // -----------------------------------------------------------------
Index: css/css_valueimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/css_valueimpl.h,v
retrieving revision 1.24
diff -u -p -b -r1.24 css_valueimpl.h
--- css/css_valueimpl.h	2001/07/29 16:12:45	1.24
+++ css/css_valueimpl.h	2002/03/11 11:31:00
@@ -32,6 +32,7 @@
 
 namespace khtml {
     class CachedImage;
+    class RenderStyle;
 };
 
 namespace DOM {
@@ -177,6 +178,20 @@ public:
 
     virtual bool parseString( const DOMString &string, bool = false);
     virtual DOM::DOMString cssText() const;
+
+    /*
+     * computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
+     * the fontinfo in case val is defined in em or ex.
+     *
+     * The metrics have to be a bit different for screen and printer output.
+     * For screen output we assume 1 inch == 72 px, for printer we assume 300 dpi
+     *
+     * this is screen/printer dependent, so we probably need a config option for this,
+     * and some tool to calibrate.
+     */
+    int computeLength(khtml::RenderStyle *style, DOM::DocumentImpl *doc );
+
+    float computeLengthFloat(khtml::RenderStyle *style, DOM::DocumentImpl *doc );
 
 protected:
     int m_type;
Index: css/csshelper.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/csshelper.cpp,v
retrieving revision 1.28.2.1
diff -u -p -b -r1.28.2.1 csshelper.cpp
--- css/csshelper.cpp	2001/08/10 20:46:39	1.28.2.1
+++ css/csshelper.cpp	2002/03/11 11:31:00
@@ -22,78 +22,11 @@
  */
 #include "csshelper.h"
 
-#include <qfontmetrics.h>
-#include <qfontinfo.h>
-#include <qpaintdevice.h>
-#include <qpaintdevicemetrics.h>
-#include <qfontdatabase.h>
-
-#include <kcharsets.h>
-#include <kglobal.h>
-#include <kdebug.h>
-
-#include "rendering/render_style.h"
-#include "css_valueimpl.h"
-#include "dom/css_value.h"
-#include "misc/helper.h"
 #include "xml/dom_stringimpl.h"
-#include "khtml_settings.h"
 
 using namespace DOM;
 using namespace khtml;
 
-int khtml::computeLength(DOM::CSSPrimitiveValueImpl *val, RenderStyle *style, QPaintDeviceMetrics *devMetrics )
-{
-    return ( int ) computeLengthFloat( val, style, devMetrics );
-}
-
-float khtml::computeLengthFloat(DOM::CSSPrimitiveValueImpl *val, RenderStyle *style, QPaintDeviceMetrics *devMetrics )
-{
-    unsigned short type = val->primitiveType();
-
-    float dpiY = 72.; // fallback
-    if ( devMetrics )
-        dpiY = devMetrics->logicalDpiY();
-    if ( !khtml::printpainter && dpiY < 96 )
-        dpiY = 96.;
-
-    float factor = 1.;
-    switch(type)
-    {
-    case CSSPrimitiveValue::CSS_EMS:
-       	factor = style->font().pixelSize();
-		break;
-    case CSSPrimitiveValue::CSS_EXS:
-	{
-        QFontMetrics fm = khtml::fontMetrics(style->font());
-        QRect b = fm.boundingRect('x');
-        factor = b.height();
-        break;
-	}
-    case CSSPrimitiveValue::CSS_PX:
-        break;
-    case CSSPrimitiveValue::CSS_CM:
-	factor = dpiY/2.54; //72dpi/(2.54 cm/in)
-        break;
-    case CSSPrimitiveValue::CSS_MM:
-	factor = dpiY/25.4;
-        break;
-    case CSSPrimitiveValue::CSS_IN:
-            factor = dpiY;
-        break;
-    case CSSPrimitiveValue::CSS_PT:
-            factor = dpiY/72.;
-        break;
-    case CSSPrimitiveValue::CSS_PC:
-        // 1 pc == 12 pt
-            factor = dpiY*12./72.;
-        break;
-    default:
-        return -1;
-    }
-    return val->getFloatValue(type)*factor;
-}
-
 DOMString khtml::parseURL(const DOMString &url)
 {
     DOMStringImpl* i = url.implementation();
@@ -138,52 +71,3 @@ DOMString khtml::parseURL(const DOMStrin
     return j;
 }
 
-
-void khtml::setFontSize( QFont &f,  int  pixelsize, const KHTMLSettings *s, QPaintDeviceMetrics *devMetrics )
-{
-    QFontDatabase db;
-
-    float size = pixelsize;
-
-    float toPix = 1.;
-    if ( !khtml::printpainter )
-        toPix = devMetrics->logicalDpiY()/72.;
-
-    // ok, now some magic to get a nice unscaled font
-    // ### all other font properties should be set before this one!!!!
-    // ####### make it use the charset needed!!!!
-    QFont::CharSet cs = s->charset();
-    QString charset = KGlobal::charsets()->xCharsetName( cs );
-
-    if( !db.isSmoothlyScalable(f.family(), db.styleString(f), charset) )
-    {
-        QValueList<int> pointSizes = db.smoothSizes(f.family(), db.styleString(f), charset);
-        // lets see if we find a nice looking font, which is not too far away
-        // from the requested one.
-        //kdDebug() << "khtml::setFontSize family = " << f.family() << " size requested=" << size << endl;
-
-        QValueList<int>::Iterator it;
-        float diff = 1; // ### 100% deviation
-        float bestSize = 0;
-        for( it = pointSizes.begin(); it != pointSizes.end(); ++it )
-        {
-            float newDiff = ((*it)*toPix - size)/size;
-            //kdDebug( 6080 ) << "smooth font size: " << *it << " diff=" << newDiff << endl;
-            if(newDiff < 0) newDiff = -newDiff;
-            if(newDiff < diff)
-            {
-                diff = newDiff;
-                bestSize = *it;
-            }
-        }
-        //kdDebug( 6080 ) << "best smooth font size: " << bestSize << " diff=" << diff << endl;
-        if ( bestSize != 0 && diff < 0.2 ) // 20% deviation, otherwise we use a scaled font...
-            size = bestSize*toPix;
-//         else if ( size > 4 && size < 16 )
-//             size = float( int( ( size + 1 ) / 2 )*2 );
-    }
-
-    //qDebug(" -->>> using %f pixel font", size);
-
-    f.setPixelSizeFloat( size );
-}
Index: css/csshelper.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/csshelper.h,v
retrieving revision 1.8
diff -u -p -b -r1.8 csshelper.h
--- css/csshelper.h	2001/06/02 23:37:07	1.8
+++ css/csshelper.h	2002/03/11 11:31:00
@@ -41,29 +41,9 @@ namespace khtml
     class RenderStyle;
 
     /*
-     * computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
-     * the fontinfo in case val is defined in em or ex.
-     *
-     * The metrics have to be a bit different for screen and printer output.
-     * For screen output we assume 1 inch == 72 px, for printer we assume 300 dpi
-     *
-     * this is screen/printer dependent, so we probably need a config option for this,
-     * and some tool to calibrate.
-     */
-    int computeLength(DOM::CSSPrimitiveValueImpl *val, RenderStyle *style, QPaintDeviceMetrics *devMetrics );
-
-    float computeLengthFloat(DOM::CSSPrimitiveValueImpl *val, RenderStyle *style, QPaintDeviceMetrics *devMetrics );
-
-    /*
      * mostly just removes the url("...") brace
      */
     DOM::DOMString parseURL(const DOM::DOMString &url);
-
-    /*
-      Sets the font to the size closest to the requested one while trying not to use a scaled bitmap font
-    */
-    void setFontSize(  QFont &f,  int pixelSize, const KHTMLSettings *s, QPaintDeviceMetrics *devMetrics );
-
 };
 
 
Index: css/cssstyleselector.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.169.2.4
diff -u -p -b -r1.169.2.4 cssstyleselector.cpp
--- css/cssstyleselector.cpp	2001/11/01 18:56:45	1.169.2.4
+++ css/cssstyleselector.cpp	2002/03/11 11:31:02
@@ -828,7 +828,7 @@ void CSSOrderedPropertyList::append(DOM:
 // -------------------------------------------------------------------------------------
 // this is mostly boring stuff on how to apply a certain rule to the renderstyle...
 
-static Length convertToLength( CSSPrimitiveValueImpl *primitiveValue, RenderStyle *style, QPaintDeviceMetrics *paintDeviceMetrics, bool *ok = 0 )
+static Length convertToLength( CSSPrimitiveValueImpl *primitiveValue, RenderStyle *style, DOM::DocumentImpl *doc, bool *ok = 0 )
 {
     Length l;
     if ( !primitiveValue ) {
@@ -837,7 +837,7 @@ static Length convertToLength( CSSPrimit
     } else {
 	int type = primitiveValue->primitiveType();
 	if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-	    l = Length(computeLength(primitiveValue, style, paintDeviceMetrics), Fixed);
+	    l = Length(primitiveValue->computeLength(style, doc), Fixed);
 	else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
 	    l = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)), Percent);
 	else if(type == CSSPrimitiveValue::CSS_NUMBER)
@@ -852,7 +852,8 @@ void khtml::applyRule(khtml::RenderStyle
 {
     CSSValueImpl *value = prop->value();
 
-    QPaintDeviceMetrics *paintDeviceMetrics = e->ownerDocument()->paintDeviceMetrics();
+    DOM::DocumentImpl *doc = e->ownerDocument();
+    QPaintDeviceMetrics *paintDeviceMetrics = doc->paintDeviceMetrics();
 
     //kdDebug( 6080 ) << "applying property " << prop->m_id << endl;
 
@@ -880,7 +881,6 @@ void khtml::applyRule(khtml::RenderStyle
         case CSS_VAL_FIXED:
             {
                 style->setBackgroundAttachment(false);
-                DocumentImpl *doc = e->ownerDocument();
 		// only use slow repaints if we actually have a background pixmap
                 if( style->backgroundImage() )
                     doc->view()->useSlowRepaints();
@@ -1291,7 +1291,6 @@ void khtml::applyRule(khtml::RenderStyle
             p = ABSOLUTE; break;
         case CSS_VAL_FIXED:
             {
-                DocumentImpl *doc = e->ownerDocument();
                 doc->view()->useSlowRepaints();
                 p = FIXED;
                 break;
@@ -1392,7 +1391,7 @@ void khtml::applyRule(khtml::RenderStyle
       Length l;
       int type = primitiveValue->primitiveType();
       if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-	l = Length(computeLength(primitiveValue, style, paintDeviceMetrics), Fixed);
+	l = Length(primitiveValue->computeLength(style, doc), Fixed);
       else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
 	l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
       else
@@ -1406,7 +1405,7 @@ void khtml::applyRule(khtml::RenderStyle
       Length l;
       int type = primitiveValue->primitiveType();
       if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-	l = Length(computeLength(primitiveValue, style, paintDeviceMetrics), Fixed);
+	l = Length(primitiveValue->computeLength(style, doc), Fixed);
       else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
 	l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
       else
@@ -1418,7 +1417,7 @@ void khtml::applyRule(khtml::RenderStyle
         {
         if(!primitiveValue) break;
         short spacing = 0;
-        spacing = computeLength(primitiveValue, style, paintDeviceMetrics);
+        spacing = primitiveValue->computeLength(style, doc);
         style->setBorderSpacing(spacing);
         break;
         }
@@ -1624,7 +1623,7 @@ void khtml::applyRule(khtml::RenderStyle
             width = 5;
             break;
         case CSS_VAL_INVALID:
-            width = computeLength(primitiveValue, style, paintDeviceMetrics);
+            width = primitiveValue->computeLength(style, doc);
             break;
         default:
             return;
@@ -1676,7 +1675,7 @@ void khtml::applyRule(khtml::RenderStyle
             return;
         }
         if(!primitiveValue) return;
-        int width = computeLength(primitiveValue, style, paintDeviceMetrics);
+        int width = primitiveValue->computeLength(style, doc);
 // reason : letter or word spacing may be negative.
 //      if( width < 0 ) return;
         switch(prop->m_id)
@@ -1774,7 +1773,7 @@ void khtml::applyRule(khtml::RenderStyle
         } else if(primitiveValue && !apply) {
             int type = primitiveValue->primitiveType();
             if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-                l = Length(computeLength(primitiveValue, style, paintDeviceMetrics), Fixed);
+                l = Length(primitiveValue->computeLength(style, doc), Fixed);
             else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
                 l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
             else
@@ -1851,7 +1850,7 @@ void khtml::applyRule(khtml::RenderStyle
         {
             int type = primitiveValue->primitiveType();
             if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-                l = Length(computeLength(primitiveValue, style, paintDeviceMetrics), Fixed);
+                l = Length(primitiveValue->computeLength(style, doc), Fixed);
             else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
             {
                 // ### compute from parents height!!!
@@ -1918,7 +1917,7 @@ void khtml::applyRule(khtml::RenderStyle
 	  int type = primitiveValue->primitiveType();
 	  Length l;
 	  if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-	    l = Length( computeLength(primitiveValue, style, paintDeviceMetrics), Fixed );
+	    l = Length( primitiveValue->computeLength(style, doc), Fixed );
 	  else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
 	    l = Length( int( primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) ), Percent );
 
@@ -1932,7 +1931,7 @@ void khtml::applyRule(khtml::RenderStyle
         QFont f = style->font();
         int oldSize;
         float size = 0;
-        int minFontSize = e->ownerDocument()->view()->part()->settings()->minFontSize();
+        int minFontSize = doc->view()->part()->settings()->minFontSize();
 
         float toPix = 1.; // fallback
         if ( !khtml::printpainter )
@@ -1940,7 +1939,7 @@ void khtml::applyRule(khtml::RenderStyle
         if ( !khtml::printpainter && toPix < 96./72. )
             toPix = 96./72.;
 
-        QValueList<int> standardSizes = e->ownerDocument()->view()->part()->fontSizes();
+        QValueList<int> standardSizes = doc->view()->part()->fontSizes();
         if(e->parentNode()) {
             oldSize = e->parentNode()->style()->font().pixelSize();
         } else {
@@ -1990,7 +1989,7 @@ void khtml::applyRule(khtml::RenderStyle
             if(e->parentNode())
                 parentStyle = e->parentNode()->style();
             if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-                size = computeLengthFloat(primitiveValue, parentStyle, paintDeviceMetrics);
+                size = primitiveValue->computeLengthFloat(parentStyle, doc);
             else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
                 size = (primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)
                                   * parentStyle->font().pixelSize()) / 100;
@@ -2005,10 +2004,8 @@ void khtml::applyRule(khtml::RenderStyle
 
         //kdDebug( 6080 ) << "computed raw font size: " << size << endl;
 
-        const KHTMLSettings *s = e->ownerDocument()->view()->part()->settings();
+        doc->setFontSize( f, (int)size );
 
-        setFontSize( f, (int)size, s, paintDeviceMetrics );
-
         //KGlobal::charsets()->setQFont(f, e->ownerDocument()->view()->part()->settings()->charset);
         style->setFont(f);
         return;
@@ -2056,7 +2053,7 @@ void khtml::applyRule(khtml::RenderStyle
         if(primitiveValue->getIdent() == CSS_VAL_NORMAL)
             lineHeight = Length(-100, Percent);
         else if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-            lineHeight = Length(computeLength(primitiveValue, style, paintDeviceMetrics), Fixed);
+            lineHeight = Length(primitiveValue->computeLength(style, doc), Fixed);
         else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
             lineHeight = Length(int( style->font().pixelSize() * int( primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed);
         else if(type == CSSPrimitiveValue::CSS_NUMBER)
@@ -2109,10 +2106,10 @@ void khtml::applyRule(khtml::RenderStyle
 	    RectImpl *rect = primitiveValue->getRectValue();
 	    if ( !rect )
 		break;
-	    top = convertToLength( rect->top(), style, paintDeviceMetrics );
-	    right = convertToLength( rect->right(), style, paintDeviceMetrics );
-	    bottom = convertToLength( rect->bottom(), style, paintDeviceMetrics );
-	    left = convertToLength( rect->left(), style, paintDeviceMetrics );
+	    top = convertToLength( rect->top(), style, doc );
+	    right = convertToLength( rect->right(), style, doc );
+	    bottom = convertToLength( rect->bottom(), style, doc );
+	    left = convertToLength( rect->left(), style, doc );
 
 	} else if ( primitiveValue->getIdent() != CSS_VAL_AUTO ) {
 	    break;
@@ -2146,7 +2143,7 @@ void khtml::applyRule(khtml::RenderStyle
         if(!value->isValueList()) return;
         CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
         int len = list->length();
-	const KHTMLSettings *s = e->ownerDocument()->view()->part()->settings();
+	const KHTMLSettings *s = doc->view()->part()->settings();
 	QString available = s->availableFamilies();
 	QFont f = style->font();
 	QString family;
Index: rendering/render_replaced.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_replaced.cpp,v
retrieving revision 1.53
diff -u -p -b -r1.53 render_replaced.cpp
--- rendering/render_replaced.cpp	2001/07/29 19:48:46	1.53
+++ rendering/render_replaced.cpp	2002/03/11 11:31:02
@@ -29,6 +29,8 @@
 
 #include "misc/helper.h"
 #include "khtmlview.h"
+#include "khtml_part.h"
+#include "khtml_settings.h"
 
 using namespace khtml;
 
@@ -94,7 +96,8 @@ short RenderReplaced::calcReplacedWidth(
         if ( ih > 0 && ( h.isPercent() || h.isFixed() ) )
             width = ( ( h.isPercent() ? calcReplacedHeight() : h.value )*intrinsicWidth() ) / ih;
         else
-            width = intrinsicWidth();
+        //    width = intrinsicWidth();
+            width = ( intrinsicWidth() * root()->view()->part()->scalingFactor() ) / 100;
         break;
     }
     case Percent:
@@ -113,7 +116,8 @@ short RenderReplaced::calcReplacedWidth(
         width = w.value;
         break;
     default:
-        width = intrinsicWidth();
+        width = ( intrinsicWidth() * root()->view()->part()->scalingFactor() ) / 100;
+        //width = intrinsicWidth();
         break;
     };
 
@@ -132,7 +136,8 @@ int RenderReplaced::calcReplacedHeight()
         if( iw > 0 && ( w.isFixed() || w.isPercent() ))
             height = (( w.isPercent() ? calcReplacedWidth() : w.value ) * intrinsicHeight()) / iw;
         else
-            height = intrinsicHeight();
+        //    height = intrinsicHeight();
+            height = ( intrinsicHeight() * root()->view()->part()->scalingFactor() ) / 100;
     }
     break;
     case Percent:
@@ -155,7 +160,8 @@ int RenderReplaced::calcReplacedHeight()
         height = h.value;
         break;
     default:
-        height = intrinsicHeight();
+        height = ( intrinsicHeight() * root()->view()->part()->scalingFactor() ) / 100;
+        //height = intrinsicHeight();
     };
 
     return height;
Index: xml/dom_docimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.102.2.3
diff -u -p -b -r1.102.2.3 dom_docimpl.cpp
--- xml/dom_docimpl.cpp	2001/11/01 18:36:11	1.102.2.3
+++ xml/dom_docimpl.cpp	2002/03/11 11:31:03
@@ -43,6 +43,7 @@
 #include <qstack.h>
 #include <qlist.h>
 #include <qpaintdevicemetrics.h>
+#include <qfontdatabase.h>
 #include "misc/htmlhashes.h"
 #include "misc/loader.h"
 #include <kdebug.h>
@@ -591,7 +592,7 @@ void DocumentImpl::recalcStyle()
         if(size < settings->minFontSize())
             size = settings->minFontSize();
 
-        khtml::setFontSize( f, int(size),  settings, paintDeviceMetrics() );
+        setFontSize( f, int(size) );
         KGlobal::charsets()->setQFont(f, settings->charset());
     }
 
@@ -1450,6 +1451,63 @@ void DocumentImpl::removeWindowEventList
 EventListener *DocumentImpl::createHTMLEventListener(QString code)
 {
     return view()->part()->createHTMLEventListener(code);
+}
+
+void DocumentImpl::setFontSize( QFont &f, int pixelSize )
+{
+    QFontDatabase db;
+    const KHTMLSettings *settings = m_view->part()->settings();
+
+    uint fixedFontSize = settings->fixedFontSize();
+    if ( fixedFontSize != 0 )
+    {
+	f.setPixelSize( fixedFontSize );
+	return;
+    }
+
+    float size = ( pixelSize * m_view->part()->scalingFactor() ) / 100;
+
+    float toPix = 1.;
+    if ( !khtml::printpainter && m_paintDeviceMetrics )
+        toPix = m_paintDeviceMetrics->logicalDpiY()/72.;
+
+    // ok, now some magic to get a nice unscaled font
+    // ### all other font properties should be set before this one!!!!
+    // ####### make it use the charset needed!!!!
+    QFont::CharSet cs = settings->charset();
+    QString charset = KGlobal::charsets()->xCharsetName( cs );
+
+    if( !db.isSmoothlyScalable(f.family(), db.styleString(f), charset) )
+    {
+        QValueList<int> pointSizes = db.smoothSizes(f.family(), db.styleString(f), charset);
+        // lets see if we find a nice looking font, which is not too far away
+        // from the requested one.
+        //kdDebug() << "khtml::setFontSize family = " << f.family() << " size requested=" << size << endl;
+
+        QValueList<int>::Iterator it;
+        float diff = 1; // ### 100% deviation
+        float bestSize = 0;
+        for( it = pointSizes.begin(); it != pointSizes.end(); ++it )
+        {
+            float newDiff = ((*it)*toPix - size)/size;
+            //kdDebug( 6080 ) << "smooth font size: " << *it << " diff=" << newDiff << endl;
+            if(newDiff < 0) newDiff = -newDiff;
+            if(newDiff < diff)
+            {
+                diff = newDiff;
+                bestSize = *it;
+            }
+        }
+        //kdDebug( 6080 ) << "best smooth font size: " << bestSize << " diff=" << diff << endl;
+        if ( bestSize != 0 && diff < 0.2 ) // 20% deviation, otherwise we use a scaled font...
+            size = bestSize*toPix;
+//         else if ( size > 4 && size < 16 )
+//             size = float( int( ( size + 1 ) / 2 )*2 );
+    }
+
+    //qDebug(" -->>> using %f pixel font", size);
+
+    f.setPixelSizeFloat( size );
 }
 
 // ----------------------------------------------------------------------------
Index: xml/dom_docimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_docimpl.h,v
retrieving revision 1.57.2.1
diff -u -p -b -r1.57.2.1 dom_docimpl.h
--- xml/dom_docimpl.h	2001/08/27 12:50:17	1.57.2.1
+++ xml/dom_docimpl.h	2002/03/11 11:31:03
@@ -264,6 +264,10 @@ public:
     virtual void removeWindowEventListener(int id);
     EventListener *createHTMLEventListener(QString code);
 
+    /*
+      Sets the font to the size closest to the requested one while trying not to use a scaled bitmap font
+    */
+    void setFontSize( QFont &f, int pixelSize );
 signals:
     void finishedParsing();
 
