ecere/gfx/fontManagement: Fixed non-fixed pitch listing
authorJerome St-Louis <jerome@ecere.com>
Thu, 4 Aug 2016 13:53:26 +0000 (09:53 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 4 Aug 2016 13:53:26 +0000 (09:53 -0400)
ecere/src/gfx/fontManagement.ec

index d811a60..2b3f714 100644 (file)
@@ -458,24 +458,23 @@ public Map<String, FontInfo> ListAvailableFonts()
       for(i = 0; i < fontSet->nfont; i++)
       {
          FcPattern * font = fontSet->fonts[i];
-         String family;
-         int spacing;
-         FcCharSet * charSet;
+         String family = null;
+         int spacing = 0;
+         FcCharSet * charSet = null;
+
+         FcPatternGetString(font, FC_FAMILY, 0, (byte **)&family);
+         FcPatternGetInteger(font, FC_SPACING, 0, &spacing);
+         FcPatternGetCharSet(font, FC_CHARSET, 0, &charSet);
 
-         if(FcPatternGetString(font, FC_FAMILY, 0, (byte **)&family) == FcResultMatch &&
-            FcPatternGetInteger(font, FC_SPACING, 0, &spacing) == FcResultMatch &&
-            FcPatternGetCharSet(font, FC_CHARSET, 0, &charSet) == FcResultMatch)
+         if(family && !it.Index(family, true))
          {
-            if(!it.Index(family, true))
+            it.data =
             {
-               it.data =
-               {
-                  fixedPitch = spacing == FC_MONO,
-                  defaultOrAnsiCharSet =
-                     FcCharSetHasChar(charSet, '[') && FcCharSetHasChar(charSet, '{') &&
-                     FcCharSetHasChar(charSet, 'a') && FcCharSetHasChar(charSet, 'Z');
-               };
-            }
+               fixedPitch = spacing == FC_MONO,
+               defaultOrAnsiCharSet =
+                  FcCharSetHasChar(charSet, '[') && FcCharSetHasChar(charSet, '{') &&
+                  FcCharSetHasChar(charSet, 'a') && FcCharSetHasChar(charSet, 'Z');
+            };
          }
       }
    }