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

[XaraXtreme-dev] Fix for bug 1058



Find attached below a fix for non-language symbol fonts, e.g., 
Dingbats. With this fix I can finally see the Dingbats characters in 
the fonts.xar test file created using Xtreme.

The bug report did not say which other fonts were affected, just "many 
fonts, e.g., Dingbats", so, Alex, can you have a look whether it has 
fixed the other problems, too?

Martin
Index: wxOil/ftfonts.cpp
===================================================================
--- wxOil/ftfonts.cpp	(Revision 1093)
+++ wxOil/ftfonts.cpp	(Arbeitskopie)
@@ -709,14 +709,26 @@
 	// We must unlock this before returning!
 	FT_Face pFreeTypeFace = pango_fc_font_lock_face(pFcFont);
 
-	if (!pFreeTypeFace->charmap ||
-		pFreeTypeFace->charmap->encoding != ( ( (FT_UInt32)('u') << 24 )
-											| ( (FT_UInt32)('n') << 16 )
-											| ( (FT_UInt32)('i') <<  8 )
-											|   (FT_UInt32)('c')       ) )
+	// The default charmap is always unicode if present, but we may
+	// have a symbol font which we may want to drive in symbol mode.
+	// Check whether there is just an Adobe custom encoding in addition
+	// to the synthesized unicode charmap and if so, use that instead.
+	FT_CharMap pCustomCharmap = NULL;
+	for (int mapnum = 0; mapnum < pFreeTypeFace->num_charmaps; mapnum++)
 	{
-		ERROR2(FALSE, "FTFontMan - no Unicode encoding present");
+		FT_CharMap pThisMap = pFreeTypeFace->charmaps[mapnum];
+		if (pThisMap->encoding == FT_ENCODING_ADOBE_CUSTOM) {
+			pCustomCharmap = pThisMap;
+			// we go on checking the other encodings
+		}
+		else if (pThisMap->encoding != FT_ENCODING_UNICODE) {
+			// there is an encoding that is neither a custom one
+			// nor a Unicode encoding, so this is a language font
+			pCustomCharmap = NULL;
+			break;
+		}
 	}
+	if (pCustomCharmap) FT_Set_Charmap(pFreeTypeFace, pCustomCharmap);
 	
 	// We should not have seen non-scalable fonts anyway, but just in case...
 	if (!FT_IS_SCALABLE(pFreeTypeFace))