[GRASS-SVN] r67074 - grass/branches/releasebranch_7_0/general/g.mkfontcap

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Dec 12 04:42:12 PST 2015


Author: martinl
Date: 2015-12-12 04:42:12 -0800 (Sat, 12 Dec 2015)
New Revision: 67074

Modified:
   grass/branches/releasebranch_7_0/general/g.mkfontcap/freetype_fonts.c
   grass/branches/releasebranch_7_0/general/g.mkfontcap/main.c
Log:
g.mkfontscap: fix segfault on cygwin & Windows 7
              (merge r67034 from trunk)


Modified: grass/branches/releasebranch_7_0/general/g.mkfontcap/freetype_fonts.c
===================================================================
--- grass/branches/releasebranch_7_0/general/g.mkfontcap/freetype_fonts.c	2015-12-12 12:39:11 UTC (rev 67073)
+++ grass/branches/releasebranch_7_0/general/g.mkfontcap/freetype_fonts.c	2015-12-12 12:42:12 UTC (rev 67074)
@@ -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/branches/releasebranch_7_0/general/g.mkfontcap/main.c
===================================================================
--- grass/branches/releasebranch_7_0/general/g.mkfontcap/main.c	2015-12-12 12:39:11 UTC (rev 67073)
+++ grass/branches/releasebranch_7_0/general/g.mkfontcap/main.c	2015-12-12 12:42:12 UTC (rev 67074)
@@ -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