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

List:       konq-e
Subject:    [warwick@trolltech.com: Font bug.]
From:       Simon Hausmann <hausmann () kde ! org>
Date:       2001-03-12 13:33:53
[Download RAW message or body]

For those not subscribed to embedded-interest :)

Bye,
 Simon

----- Forwarded message from Warwick Allison <warwick@trolltech.com> -----

From: Warwick Allison <warwick@trolltech.com>
To: "Qt/Embedded interest list" <qt-embedded-interest@trolltech.com>
Subject: Font bug.
Date: Mon, 12 Mar 2001 16:23:45 +1000
Message-Id: <0103121623450K.01187@bippy>

There was a font bug in 2.2.4 that somehow missed detection. If you get 
wrong-sized characters when using multiple sizes of the same font with 
truetype fonts, then you will want to apply the attached patch.

Thanks to Ian Collinson for detecting this bug!

--
Warwick


----- End forwarded message -----

["fixscaledfont.patch" (application/x-patch)]

--- src/kernel/qfontfactoryttf_qws.cpp	Mon Mar 12 16:18:42 EST 2001
+++ qt/2.3/src/kernel/qfontfactoryttf_qws.cpp	Mon Mar 12 16:18:42 EST 2001
@@ -62,37 +62,7 @@
     {
 	QDiskFontFT *df = (QDiskFontFT*)(f->p);
 	myface=df->face;
-
-	int psize=(ptsize<<6)/10;
-
-	// Assume 72 dpi for now
-	const int dpi=72;
-	FT_Error err;
-	err=FT_Set_Char_Size(myface, psize,psize,dpi,dpi);
-	if (err) {
-	    if (FT_IS_SCALABLE(myface) ) {
-		qWarning("Set char size error %x for size %d",err,ptsize);
-	    } else {
-		int best=-1;
-		int bdh=99;
-		for (int i=0; i<myface->num_fixed_sizes; i++) {
-		    FT_Bitmap_Size& sz=myface->available_sizes[i];
-		    int dh = sz.height - ptsize*dpi/72/10;
-		    dh = QABS(dh);
-		    if ( dh < bdh ) {
-			bdh=dh;
-			best=i;
-		    }
-		}
-		if ( best >= 0 )
-		    err=FT_Set_Pixel_Sizes(myface,
-			myface->available_sizes[best].width,
-			myface->available_sizes[best].height);
-		if ( err )
-		    qWarning("Set char size error %x for size %d",err,ptsize);
-	    }
-	}
-
+	selectThisSize();
 	// A 1-pixel baseline is excluded in Qt/Windows/X11 fontmetrics
 	// (see QFontMetrics::height())
 	//
@@ -135,6 +105,8 @@
 
     QGlyph render(QChar ch)
     {
+	selectThisSize();
+
 	int index = ch.unicode();
 	if ( !unicode(index) )
 	    index = 0;
@@ -195,6 +167,40 @@
     }
 
     FT_Face myface;
+
+private:
+    void selectThisSize()
+    {
+	int psize=(ptsize<<6)/10;
+
+	// Assume 72 dpi for now
+	const int dpi=72;
+	FT_Error err;
+	err=FT_Set_Char_Size(myface, psize,psize,dpi,dpi);
+	if (err) {
+	    if (FT_IS_SCALABLE(myface) ) {
+		qWarning("Set char size error %x for size %d",err,ptsize);
+	    } else {
+		int best=-1;
+		int bdh=99;
+		for (int i=0; i<myface->num_fixed_sizes; i++) {
+		    FT_Bitmap_Size& sz=myface->available_sizes[i];
+		    int dh = sz.height - ptsize*dpi/72/10;
+		    dh = QABS(dh);
+		    if ( dh < bdh ) {
+			bdh=dh;
+			best=i;
+		    }
+		}
+		if ( best >= 0 )
+		    err=FT_Set_Pixel_Sizes(myface,
+			myface->available_sizes[best].width,
+			myface->available_sizes[best].height);
+		if ( err )
+		    qWarning("Set char size error %x for size %d",err,ptsize);
+	    }
+	}
+    }
 };
 
 QFontFactoryFT::QFontFactoryFT()


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

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