--- src/fbi-2.07/fb-gui.c 2006-08-14 20:38:05.000000000 +0100
+++ fbi-2.07/fb-gui.c 2012-01-15 19:56:23.000000000 +0000
@@ -627,10 +627,11 @@
FcResult result = 0;
FT_Face face = NULL;
FcPattern *pattern,*match;
- char *fontname,*h;
+ char *fontname = NULL, *h = NULL;
FcChar8 *filename;
double pixelsize;
int rc;
+ int ok = 0;
/* parse + match font name */
pattern = FcNameParse(fcname);
@@ -638,8 +639,10 @@
FcDefaultSubstitute(pattern);
match = FcFontMatch (0, pattern, &result);
FcPatternDestroy(pattern);
- if (FcResultMatch != result)
- return NULL;
+ if (FcResultMatch != result) {
+ ok = 0;
+ goto out;
+ }
fontname = FcNameUnparse(match);
h = strchr(fontname, ':');
if (h)
@@ -649,22 +652,37 @@
result = FcPatternGetFTFace(match, FC_FT_FACE, 0, &face);
if (FcResultMatch == result) {
fprintf(stderr,"using \"%s\", face=%p\n",fontname,face);
- return face;
+ ok = 1;
+ goto out;
}
/* failing that use the filename */
result = FcPatternGetString (match, FC_FILE, 0, &filename);
if (FcResultMatch == result) {
- result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixelsize);
+ result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixelsize);
+
if (FcResultMatch != result)
pixelsize = 16;
- fprintf(stderr,"using \"%s\", pixelsize=%.2lf file=%s\n",
- fontname,pixelsize,filename);
+
+ fprintf(stderr,"using \"%s\", pixelsize=%.2lf
file=%s\n",fontname,pixelsize,filename);
+ ok = 1;
rc = FT_New_Face (freetype, filename, 0, &face);
- if (rc)
- return NULL;
+
+ if (rc) {
+ ok = 0;
+ goto out;
+ }
+
FT_Set_Pixel_Sizes(face, 0, (int)pixelsize);
- return face;
+ }
+
+out:
+ free(fontname);
+ FcPatternDestroy(match);
+
+ if (ok) {
+ /* we good */
+ return face;
}
/* oops, didn't work */
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]