[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : phil
Repository : xara
Revision   : 762
Date       : Mon Apr  3 16:49:57 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/fontbase.cpp
   M /Trunk/XaraLX/wxOil/ftfonts.cpp

Martin W.'s Patch14


Diff:
Index: Trunk/XaraLX/wxOil/ftfonts.cpp
===================================================================
--- Trunk/XaraLX/wxOil/ftfonts.cpp	(revision 761)
+++ Trunk/XaraLX/wxOil/ftfonts.cpp	(revision 762)
@@ -844,7 +844,7 @@
 							   UINT32* pNumCoords,
 							   wxDC* pDC)
 {
-	TRACEUSER("wuerthne", _T("FTFontMan::GetCharOutline"));
+	TRACEUSER("wuerthne", _T("FTFontMan::GetCharOutline %04x"), ChDesc.GetCharCode());
 	// Check some input parameters
 	ERROR2IF(ppCoords==NULL,FALSE,"FTFontMan::GetCharOutline ppCoords==NULL");
 	ERROR2IF(ppVerbs==NULL,FALSE,"FTFontMan::GetCharOutline ppVerbs==NULL");
@@ -942,7 +942,8 @@
 	Outputs:	character widths into pCharWidthsBuf
 	Returns:	TRUE if the widths could be retrieved
 				FALSE if not.
-	Purpose:	This function returns the raw widths of a range of characters
+	Purpose:	This function returns the widths of a range of characters scaled
+				to DefaultHeight
 
 ********************************************************************************************/
 
@@ -956,8 +957,8 @@
 	if (!GetPangoFcFontAndFreeTypeFaceForCharDesc(ChDesc, &pPangoFcFont, &pFreeTypeFace)) return FALSE;
 
 	// get the design size
-	// INT32 DesignSize = pFreeTypeFace->units_per_EM;
-	// TRACEUSER("wuerthne", _T("DesignSize = %d"), DesignSize);
+	INT32 DesignSize = pFreeTypeFace->units_per_EM;
+	TRACEUSER("wuerthne", _T("GetCharWidth, DesignSize = %d"), DesignSize);
 
 	for (UINT32 i = 0; i < NumChars; i++) {
 		// load the glyph data for our character into the font's glyph slot
@@ -967,7 +968,7 @@
 			ERROR2(FALSE, "FTFontMan::GetCharWidth - could not load glyph");
 		}
 		FT_GlyphSlotRec *pGlyph = pFreeTypeFace->glyph;
-		pCharWidthsBuf[i] = pGlyph->linearHoriAdvance;
+		pCharWidthsBuf[i] = ScaleToDefaultHeight(pGlyph->linearHoriAdvance, DesignSize);
 	}
 	pango_fc_font_unlock_face(pPangoFcFont);
 	return TRUE;
Index: Trunk/XaraLX/wxOil/fontbase.cpp
===================================================================
--- Trunk/XaraLX/wxOil/fontbase.cpp	(revision 761)
+++ Trunk/XaraLX/wxOil/fontbase.cpp	(revision 762)
@@ -883,11 +883,16 @@
 BOOL FontMetricsCacheEntry::CacheFontMetrics( wxDC* pDC, CharDescription FontDesc,
 												MILLIPOINT DefaultHeight, INT32 DesignSize )
 {
-	// get font metrics and convert from design size in pixels to default height in millipoints
 	INT32 Ascent;
 	INT32 Descent;
 
+	// these values are ignored - the DesignSize needs to be read from the font, so the
+	// scaling needs to be done by FTFontMan itself
+	IGNORE(DefaultHeight);
+	IGNORE(DesignSize);
+
 #ifdef __WXGTK__
+	// TRACEUSER("wuerthne", _T("CacheFontMetrics DesignSize = %d"), DesignSize);
 	if (FTFontMan::GetAscentDescent(FontDesc, &Ascent, &Descent) == FALSE) return FALSE;
 	// scaling to DefaultHeight was done in GetAscentDescent already
 	SetFontAscent( Ascent );
@@ -897,8 +902,9 @@
 	static INT32 pTempCharWidthBuf[NUMCHARS];
 	if (FTFontMan::GetCharWidth(FontDesc, FIRSTCHAR, LASTCHAR, pTempCharWidthBuf)==FALSE)
 		return FALSE;
+	// scaling to DefaultHeight was done in GetCharWidth already
 	for (INT32 i=0; i<NUMCHARS; i++)
-		pCharWidths[i] = MulDiv(pTempCharWidthBuf[i], DefaultHeight, DesignSize);
+		pCharWidths[i] = pTempCharWidthBuf[i];
 
 	// if 'em' char in cache, get it from the cache else calculate its width separately
 	if (CharInCacheRange(FONTEMCHAR))
@@ -909,7 +915,8 @@
 		INT32 TempCharWidth = 0;
 		if (FTFontMan::GetCharWidth(FontDesc, FONTEMCHAR, FONTEMCHAR, &TempCharWidth)==FALSE)
 			return FALSE;
-		SetFontEmWidth( MulDiv(TempCharWidth, DefaultHeight, DesignSize) );
+		// scaling to DefaultHeight was done in GetCharWidth already
+		SetFontEmWidth( TempCharWidth );
 	}
 
 	// update cache tag


Xara