Re: Caching Postscript names

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

 



On Wednesday 04 June 2008 15:05:55 Isaiah Beerbower wrote:
> On 6/3/08, Isaiah Beerbower <public@xxxxxxxxxx> wrote:
> > On Tue, Jun 3, 2008 at 3:28 PM, Keith Packard <keithp@xxxxxxxxxx> wrote:
> >> On Tue, 2008-06-03 at 12:18 -0400, Isaiah Beerbower wrote:
> >>> I am working on GNUstep's (http://www.gnustep.org/) font support. One
> >>> of GNUstep's goals is to implement the OpenStep specification
> >>> (http://www.gnustep.org/resources/OpenStepSpec.pdf.gz). Fontconfig is
> >>> already being used by GNUstep, however, in order to properly implement
> >>> the OpenStep standard  the Postscript name should be used to uniquely
> >>> reference a font. Right now GNUstep is using the full font name,
> >>> however, it would be better if the Postscript name was cached so that
> >>> it could be used instead. So my final question is: what are the pros
> >>> and cons to adding the Postscript name to the properties which
> >>> Fontconfig caches?
> >>>
> >>> I've included a patch (below) which adds the functionality.
> >>
> >> That seems fine, however note that this won't let you search for fonts
> >> by postscript name. If you want to do that, you can modify the font
> >> matching code to look for postscript names in the pattern.
> >
> > Yes, I would want it to be searchable. I'll send a new patch as soon
> > as I have it ready.
>
> And here it is (attached).

It does not work for me unless FC_POSTSCRIPT_NAME_OBJECT is added to the end 
of the list. Not sure why, fc-match prints nothing and FC_DEBUG=2 shows a 
garbled font pattern. Maybe some other list has to be updated as well? 
Anyway, the attached patch seems to work fine.
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index cd650a1..831b53e 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -81,6 +81,7 @@ typedef int		FcBool;
 #define FC_PIXEL_SIZE	    "pixelsize"		/* Double */
 #define FC_SPACING	    "spacing"		/* Int */
 #define FC_FOUNDRY	    "foundry"		/* String */
+#define FC_POSTSCRIPT_NAME	    "postscriptname"		/* String */
 #define FC_ANTIALIAS	    "antialias"		/* Bool (depends) */
 #define FC_HINTING	    "hinting"		/* Bool (true) */
 #define FC_HINT_STYLE	    "hintstyle"		/* Int */
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index a79308c..c041249 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1121,6 +1121,7 @@ FcFreeTypeQueryFace (const FT_Face  face,
 #endif
     FcChar8	    *complex;
     const FcChar8   *foundry = 0;
+    const FcChar8   *psname = 0;
     int		    spacing;
     TT_OS2	    *os2;
 #if HAVE_FT_GET_PS_FONT_INFO
@@ -1370,6 +1371,13 @@ FcFreeTypeQueryFace (const FT_Face  face,
 	++nfamily;
     }
 
+	psname = (const FcChar8 *) FT_Get_Postscript_Name(face);
+	if (psname)
+	{
+    if (!FcPatternAddString (pat, FC_POSTSCRIPT_NAME, psname))
+	goto bail1;
+	}
+
     if (!FcPatternAddString (pat, FC_FILE, file))
 	goto bail1;
 
diff --git a/src/fcint.h b/src/fcint.h
index 8912d16..7e1fc3f 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -849,7 +849,8 @@ FcListPatternMatchAny (const FcPattern *p,
 #define FC_EMBEDDED_BITMAP_OBJECT	39
 #define FC_DECORATIVE_OBJECT	40
 #define FC_LCD_FILTER_OBJECT	41
-#define FC_MAX_BASE_OBJECT	FC_LCD_FILTER_OBJECT
+#define FC_POSTSCRIPT_NAME_OBJECT	42
+#define FC_MAX_BASE_OBJECT	FC_POSTSCRIPT_NAME_OBJECT
 
 FcPrivate FcBool
 FcNameBool (const FcChar8 *v, FcBool *result);
diff --git a/src/fcmatch.c b/src/fcmatch.c
index f104e05..a7c2878 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -187,66 +187,70 @@ static FcMatcher _FcMatchers [] = {
     { FC_FOUNDRY_OBJECT,	FcCompareString,	0, 0 },
 #define MATCH_FOUNDRY	    0
 #define MATCH_FOUNDRY_INDEX 0
+
+    { FC_POSTSCRIPT_NAME_OBJECT,	FcCompareString,	1, 1 },
+#define MATCH_POSTSCRIPT_NAME	    1
+#define MATCH_POSTSCRIPT_NAME_INDEX 1
     
-    { FC_CHARSET_OBJECT,	FcCompareCharSet,	1, 1 },
-#define MATCH_CHARSET	    1
-#define MATCH_CHARSET_INDEX 1
+    { FC_CHARSET_OBJECT,	FcCompareCharSet,	2, 2 },
+#define MATCH_CHARSET	    2
+#define MATCH_CHARSET_INDEX 2
     
-    { FC_FAMILY_OBJECT,    	FcCompareFamily,	2, 4 },
-#define MATCH_FAMILY	    2
-#define MATCH_FAMILY_STRONG_INDEX   2
-#define MATCH_FAMILY_WEAK_INDEX	    4
+    { FC_FAMILY_OBJECT,    	FcCompareFamily,	3, 5 },
+#define MATCH_FAMILY	    3
+#define MATCH_FAMILY_STRONG_INDEX   3
+#define MATCH_FAMILY_WEAK_INDEX	    5
     
-    { FC_LANG_OBJECT,		FcCompareLang,	3, 3 },
-#define MATCH_LANG	    3
-#define MATCH_LANG_INDEX    3
+    { FC_LANG_OBJECT,		FcCompareLang,	4, 4 },
+#define MATCH_LANG	    4
+#define MATCH_LANG_INDEX    4
     
-    { FC_SPACING_OBJECT,	FcCompareNumber,	5, 5 },
-#define MATCH_SPACING	    4
-#define MATCH_SPACING_INDEX 5
+    { FC_SPACING_OBJECT,	FcCompareNumber,	6, 6 },
+#define MATCH_SPACING	    5
+#define MATCH_SPACING_INDEX 6
     
-    { FC_PIXEL_SIZE_OBJECT,	FcCompareSize,	6, 6 },
-#define MATCH_PIXEL_SIZE    5
-#define MATCH_PIXEL_SIZE_INDEX	6
+    { FC_PIXEL_SIZE_OBJECT,	FcCompareSize,	7, 7 },
+#define MATCH_PIXEL_SIZE    6
+#define MATCH_PIXEL_SIZE_INDEX	7
     
-    { FC_STYLE_OBJECT,		FcCompareString,	7, 7 },
-#define MATCH_STYLE	    6
-#define MATCH_STYLE_INDEX   7
+    { FC_STYLE_OBJECT,		FcCompareString,	8, 8 },
+#define MATCH_STYLE	    7
+#define MATCH_STYLE_INDEX   8
     
-    { FC_SLANT_OBJECT,		FcCompareNumber,	8, 8 },
-#define MATCH_SLANT	    7
-#define MATCH_SLANT_INDEX   8
+    { FC_SLANT_OBJECT,		FcCompareNumber,	9, 9 },
+#define MATCH_SLANT	    8
+#define MATCH_SLANT_INDEX   9
     
-    { FC_WEIGHT_OBJECT,		FcCompareNumber,	9, 9 },
-#define MATCH_WEIGHT	    8
-#define MATCH_WEIGHT_INDEX  9
+    { FC_WEIGHT_OBJECT,		FcCompareNumber,	10, 10 },
+#define MATCH_WEIGHT	    9
+#define MATCH_WEIGHT_INDEX  10
     
-    { FC_WIDTH_OBJECT,		FcCompareNumber,	10, 10 },
-#define MATCH_WIDTH	    9
-#define MATCH_WIDTH_INDEX   10
+    { FC_WIDTH_OBJECT,		FcCompareNumber,	11, 11 },
+#define MATCH_WIDTH	    10
+#define MATCH_WIDTH_INDEX   11
     
-    { FC_DECORATIVE_OBJECT,	FcCompareBool,		11, 11 },
-#define MATCH_DECORATIVE	10
-#define MATCH_DECORATIVE_INDEX	11
+    { FC_DECORATIVE_OBJECT,	FcCompareBool,		12, 12 },
+#define MATCH_DECORATIVE	11
+#define MATCH_DECORATIVE_INDEX	12
 
-    { FC_ANTIALIAS_OBJECT,	FcCompareBool,		12, 12 },
-#define MATCH_ANTIALIAS		    11
-#define MATCH_ANTIALIAS_INDEX	    12
+    { FC_ANTIALIAS_OBJECT,	FcCompareBool,		13, 13 },
+#define MATCH_ANTIALIAS		    12
+#define MATCH_ANTIALIAS_INDEX	    13
     
-    { FC_RASTERIZER_OBJECT,	FcCompareString,	13, 13 },
-#define MATCH_RASTERIZER	    12
-#define MATCH_RASTERIZER_INDEX	    13
+    { FC_RASTERIZER_OBJECT,	FcCompareString,	14, 14 },
+#define MATCH_RASTERIZER	    13
+#define MATCH_RASTERIZER_INDEX	    14
 
-    { FC_OUTLINE_OBJECT,	FcCompareBool,		14, 14 },
-#define MATCH_OUTLINE		    13
-#define MATCH_OUTLINE_INDEX	    14
+    { FC_OUTLINE_OBJECT,	FcCompareBool,		15, 15 },
+#define MATCH_OUTLINE		    14
+#define MATCH_OUTLINE_INDEX	    15
 
-    { FC_FONTVERSION_OBJECT,	FcCompareNumber,	15, 15 },
-#define MATCH_FONTVERSION	    14
-#define MATCH_FONTVERSION_INDEX	    15
+    { FC_FONTVERSION_OBJECT,	FcCompareNumber,	16, 16 },
+#define MATCH_FONTVERSION	    15
+#define MATCH_FONTVERSION_INDEX	    16
 };
 
-#define NUM_MATCH_VALUES    16
+#define NUM_MATCH_VALUES    17
 
 static FcMatcher*
 FcObjectToMatcher (FcObject object)
@@ -257,6 +261,8 @@ FcObjectToMatcher (FcObject object)
     switch (object) {
     case FC_FOUNDRY_OBJECT:
 	i = MATCH_FOUNDRY; break;
+    case FC_POSTSCRIPT_NAME_OBJECT:
+	i = MATCH_POSTSCRIPT_NAME; break;
     case FC_FONTVERSION_OBJECT:
 	i = MATCH_FONTVERSION; break;
     case FC_FAMILY_OBJECT:
diff --git a/src/fcname.c b/src/fcname.c
index 7a5371b..fd32e41 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -75,7 +75,8 @@ static const FcObjectType _FcBaseObjectTypes[] = {
     { FC_EMBOLDEN,	FcTypeBool },
     { FC_EMBEDDED_BITMAP,   FcTypeBool },
     { FC_DECORATIVE,	FcTypeBool },
-    { FC_LCD_FILTER,	FcTypeInteger }, /* 41 */
+    { FC_LCD_FILTER,	FcTypeInteger },
+    { FC_POSTSCRIPT_NAME,	FcTypeString, }, /* 42 */
 };
 
 #define NUM_OBJECT_TYPES    (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0])
_______________________________________________
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