|
@@ -117,8 +117,11 @@ static void find_fonts(const char *dirpath)
|
|
|
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 @@ static void find_fonts(const char *dirpath)
|
|
|
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++;
|
|
|
}
|
|
|
|