[GRASS-SVN] r67034 - grass/trunk/general/g.mkfontcap

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 7 06:47:27 PST 2015


Author: martinl
Date: 2015-12-07 06:47:27 -0800 (Mon, 07 Dec 2015)
New Revision: 67034

Modified:
   grass/trunk/general/g.mkfontcap/freetype_fonts.c
   grass/trunk/general/g.mkfontcap/main.c
Log:
g.mkfontscap: fix segfault on cygwin & Windows 7

Modified: grass/trunk/general/g.mkfontcap/freetype_fonts.c
===================================================================
--- grass/trunk/general/g.mkfontcap/freetype_fonts.c	2015-12-07 14:43:40 UTC (rev 67033)
+++ grass/trunk/general/g.mkfontcap/freetype_fonts.c	2015-12-07 14:47:27 UTC (rev 67034)
@@ -117,8 +117,11 @@
 				  maxfonts * sizeof(struct GFONT_CAP));
 		}
 
+		G_debug(3, "find_fonts(): file=%s",  filepath);
 		if (FT_New_Face(ftlibrary, filepath, index, &face) == 0) {
-		    facesinfile = face->num_faces;
+		    if (index == 0)
+			facesinfile = face->num_faces;
+
 		    /* Only use scalable fonts */
 		    if (face->face_flags & FT_FACE_FLAG_SCALABLE) {
 			char *buf_ptr;
@@ -139,14 +142,19 @@
 				       buf_ptr, (int)index);
 			else
 			    fontcap[totalfonts].name = G_store(buf_ptr);
-			/* There might not be a style name but there will always be a
-			 * family name. */
-			if (face->style_name == NULL)
-			    fontcap[totalfonts].longname =
-				G_store(face->family_name);
-			else
-			    G_asprintf(&fontcap[totalfonts].longname, "%s %s",
-				       face->family_name, face->style_name);
+			
+			if (face->family_name && face->family_name > (FT_String *) 31) { /* avoid segfault on cygwin */
+			    /* There might not be a style name but there will always be a
+			     * family name. */
+			    if (face->style_name == NULL)
+				fontcap[totalfonts].longname = G_store(face->family_name);
+			    else
+				G_asprintf(&fontcap[totalfonts].longname, "%s %s",
+					   face->family_name, face->style_name);
+			}
+			else {
+			    fontcap[totalfonts].longname = G_store("");
+			}
 			totalfonts++;
 		    }
 

Modified: grass/trunk/general/g.mkfontcap/main.c
===================================================================
--- grass/trunk/general/g.mkfontcap/main.c	2015-12-07 14:43:40 UTC (rev 67033)
+++ grass/trunk/general/g.mkfontcap/main.c	2015-12-07 14:47:27 UTC (rev 67034)
@@ -46,7 +46,7 @@
     "${HOME}/Library/Fonts",
     "/Library/Fonts",
     "/System/Library/Fonts",
-    "${WINDIR}/Fonts",
+    "${WINDIR}\\Fonts",
     NULL
 };
 



More information about the grass-commit mailing list