Re: Webdings and other MS symbol fonts don't display

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

 



Revised patch attached, to declare zero language coverage for symbol fonts.

On 15-05-18 12:29 AM, Behdad Esfahbod wrote:
> Patch attached.  Needs documentation and comments, but otherwise looks about
> right to me.  Please review.
> 
> b
> 
> On 15-05-17 05:09 AM, Raimund Steger wrote:
>> On 05/14/15 21:38, Behdad Esfahbod wrote:
>>> On 15-05-14 03:32 AM, Raimund Steger wrote:
>>>> On 05/13/15 03:45, Behdad Esfahbod wrote:
>>>>> On 15-05-12 04:45 PM, Raimund Steger wrote:
>>>>>> [...]
>>>>
>>>> Anyway when I try rendering some text in WPF using WingDings I see that the
>>>> glyphs are accessible in two ways:
>>>>
>>>> * old 8-bit codepoints (0x20..0xff)
>>>> * PUA codepoints (0xf020..0xf0ff)
>>>
>>> What happens if you remove the macroman subtable?  Does it still do the 8-bit
>>> mapping?
>>
>> Yes, same behavior. (To avoid confusion with the stock Wingdings I renamed the
>> stripped font and used the WPF FontFamily constructor with a distinct
>> directory location, so I'm quite sure.)
>>
>>> [...]
>>>
>>> Ok, so detecting such symbol fonts and treating them specially is certainly
>>> possible.  We just need to figure out what special treatment is suitable.  I
>>> think I'm fine with adding your hack, but also marking the font with a special
>>> marker, such that only if a binding=strong family match happens the font is
>>> picked up and never as a fallback.  That should address all problems we know
>>> of, right? ;)
>>
>> I think the binding=strong check may not even be necessary. Since Wingdings
>> etc. aren't in any alias rules, the only way they would be chosen as fallback
>> (even in the presence of strong 'lang' elements) is if there was none other
>> available. And that's highly unlikely due to 49-sansserif.conf.
>>
>> After all, I don't recall any such bugreports for 2.8.0...
>>
>> Raimund
>>
>>

-- 
behdad
http://behdad.org/
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index 58b6b51..60496d9 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -96,6 +96,7 @@ typedef int		FcBool;
 #define FC_SCALABLE	    "scalable"		/* Bool */
 #define FC_COLOR	    "color"		/* Bool */
 #define FC_SCALE	    "scale"		/* double (deprecated) */
+#define FC_SYMBOL	    "symbol"		/* Bool */
 #define FC_DPI		    "dpi"		/* double */
 #define FC_RGBA		    "rgba"		/* Int */
 #define FC_MINSPACE	    "minspace"		/* Bool use minimum line spacing */
diff --git a/src/fcdefault.c b/src/fcdefault.c
index 7c16f48..4643e46 100644
--- a/src/fcdefault.c
+++ b/src/fcdefault.c
@@ -38,6 +38,7 @@ static const struct {
     { FC_GLOBAL_ADVANCE_OBJECT,    FcTrue	},  /* !FC_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
     { FC_EMBEDDED_BITMAP_OBJECT,   FcTrue 	},  /* !FC_LOAD_NO_BITMAP */
     { FC_DECORATIVE_OBJECT,	   FcFalse	},
+    { FC_SYMBOL_OBJECT,		   FcFalse	},
 };
 
 #define NUM_FC_BOOL_DEFAULTS	(int) (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0])
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index afbd9ac..8d4cd1b 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1201,6 +1201,8 @@ FcFreeTypeQueryFace (const FT_Face  face,
     FcRange	    *r = NULL;
     double	    lower_size = 0.0L, upper_size = DBL_MAX;
 
+    FcBool	    symbol = FcFalse;
+
     FcInitDebug (); /* We might be called with no initizalization whatsoever. */
 
     pat = FcPatternCreate ();
@@ -1803,6 +1805,11 @@ FcFreeTypeQueryFace (const FT_Face  face,
     if (!cs)
 	goto bail1;
 
+    /* The FcFreeTypeCharSetAndSpacing() chose the encoding; test it for symbol. */
+    symbol = face->charmap && face->charmap->encoding == FT_ENCODING_MS_SYMBOL;
+    if (!FcPatternAddBool (pat, FC_SYMBOL, symbol))
+	goto bail1;
+
 #if HAVE_FT_GET_BDF_PROPERTY
     /* For PCF fonts, override the computed spacing with the one from
        the property */
@@ -1835,9 +1842,16 @@ FcFreeTypeQueryFace (const FT_Face  face,
     if (!FcPatternAddCharSet (pat, FC_CHARSET, cs))
 	goto bail2;
 
-    ls = FcFreeTypeLangSet (cs, exclusiveLang);
-    if (!ls)
-	goto bail2;
+    if (!symbol)
+    {
+	ls = FcFreeTypeLangSet (cs, exclusiveLang);
+	if (!ls)
+	    goto bail2;
+    }
+    else
+    {
+	ls = FcLangSetCreate ();
+    }
 
     if (!FcPatternAddLangSet (pat, FC_LANG, ls))
     {
@@ -2093,6 +2107,12 @@ FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
 	glyphindex = FT_Get_Char_Index (face, (FT_ULong) ucs4);
 	if (glyphindex)
 	    return glyphindex;
+	if (ucs4 < 0x100 && face->charmap && face->charmap->encoding == FT_ENCODING_MS_SYMBOL)
+	{
+	    glyphindex = FT_Get_Char_Index (face, (FT_ULong) ucs4 + 0xF000);
+	    if (glyphindex)
+		return glyphindex;
+	}
     }
 #if HAVE_FT_HAS_PS_GLYPH_NAMES
     /*
@@ -2253,6 +2273,14 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing
 		}
 		ucs4 = FT_Get_Next_Char (face, ucs4, &glyph);
 	    }
+	    if (fcFontEncodings[o] == FT_ENCODING_MS_SYMBOL)
+	    {
+		for (ucs4 = 0xF000; ucs4 < 0xF100; ucs4++)
+		{
+		    if (FcCharSetHasChar (fcs, ucs4))
+			FcCharSetAddChar (fcs, ucs4 - 0xF000);
+		}
+	    }
 #ifdef CHECK
 	    for (ucs4 = 0; ucs4 < 0x10000; ucs4++)
 	    {
@@ -2267,6 +2295,8 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing
 	    }
 #endif
 	}
+
+       break;
     }
 #if HAVE_FT_HAS_PS_GLYPH_NAMES
     /*
diff --git a/src/fcmatch.c b/src/fcmatch.c
index 46d08bc..623d4aa 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -292,6 +292,7 @@ typedef enum _FcMatcherPriority {
     PRI1(LANG),
     PRI_FAMILY_WEAK,
     PRI_POSTSCRIPT_NAME_WEAK,
+    PRI1(SYMBOL),
     PRI1(SPACING),
     PRI1(SIZE),
     PRI1(PIXEL_SIZE),
diff --git a/src/fcobjs.h b/src/fcobjs.h
index 573fa61..1fc4f65 100644
--- a/src/fcobjs.h
+++ b/src/fcobjs.h
@@ -69,4 +69,5 @@ FC_OBJECT (PRGNAME,		FcTypeString,	NULL)
 FC_OBJECT (HASH,		FcTypeString,	NULL)	/* deprecated */
 FC_OBJECT (POSTSCRIPT_NAME,	FcTypeString,	FcComparePostScript)
 FC_OBJECT (COLOR,		FcTypeBool,	FcCompareBool)
+FC_OBJECT (SYMBOL,		FcTypeBool,	FcCompareBool)
 /* ^-------------- Add new objects here. */
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux