]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcfreetype.c
Patrick Lam <plam@mit.edu>
[fontconfig.git] / src / fcfreetype.c
index 4ce9f961c6259684e3fb51e006e3048271fc1985..2689b9f2c63fb196c09db30dc2f2716951116738 100644 (file)
@@ -47,7 +47,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <libgen.h>
 #include "fcint.h"
 #include <ft2build.h>
 #include FT_FREETYPE_H
@@ -976,7 +975,6 @@ FcStringInPatternElement (FcPattern *pat, const char *elt, FcChar8 *string)
        if (!FcStrCmpIgnoreBlanksAndCase (old, string))
        {
            return FcTrue;
-           break;
        }
     return FcFalse;
 }
@@ -1222,7 +1220,7 @@ FcFreeTypeQuery (const FcChar8    *file,
      * or which are simply a FC_FAMILY and FC_STYLE glued together
      */
     {
-       int     fn, fa, st;
+       int     fn, fa;
        FcChar8 *full;
        FcChar8 *fam;
        FcChar8 *style;
@@ -1282,7 +1280,7 @@ FcFreeTypeQuery (const FcChar8    *file,
     }
 
     file2 = FcStrCopy (file);
-    if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)file2)))
+    if (!FcPatternAddString (pat, FC_FILE, FcStrBasename(file2)))
     {
        FcStrFree (file2);
        goto bail1;
@@ -1439,7 +1437,6 @@ FcFreeTypeQuery (const FcChar8    *file,
     if (!foundry)
     {
        int             rc;
-       BDF_PropertyRec prop;
        rc = FT_Get_BDF_Property(face, "FOUNDRY", &prop);
        if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM)
            foundry = (FcChar8 *) prop.u.atom;
@@ -1607,7 +1604,6 @@ FcFreeTypeQuery (const FcChar8    *file,
         if(face->num_fixed_sizes == 1) {
             int rc;
             int value;
-            BDF_PropertyRec prop;
 
            /* skip bitmap fonts which do not even have a family name */
            rc =  FT_Get_BDF_Property(face, "FAMILY_NAME", &prop);
@@ -2313,6 +2309,10 @@ FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
     int                    p;
 
     initial = 0;
+
+    if (!face)
+        return 0;
+
     /*
      * Find the current encoding
      */
@@ -2759,7 +2759,7 @@ GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *scri
     if ( ftglue_stream_seek ( stream, base_offset + 4L ) || ftglue_stream_frame_enter( stream, 2L ) )
        return error;
 
-    new_offset = ((FT_UShort)ftglue_stream_get_short ( stream )) + base_offset;
+    new_offset = GET_UShort() + base_offset;
 
     ftglue_stream_frame_exit( stream );
 
@@ -2773,7 +2773,7 @@ GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *scri
     if ( ftglue_stream_frame_enter( stream, 2L ) )
        return error;
 
-    *script_count = ((FT_UShort)ftglue_stream_get_short ( stream ));
+    *script_count = GET_UShort ();
 
     ftglue_stream_frame_exit( stream );
 
@@ -2788,8 +2788,8 @@ GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *scri
         if ( ftglue_stream_frame_enter( stream, 6L ) )
            goto Fail;
 
-       (*stags)[p] = ((FT_ULong)ftglue_stream_get_long ( stream ));
-       new_offset = ((FT_UShort)ftglue_stream_get_short ( stream )) + base_offset;
+       (*stags)[p] = GET_ULong ();
+       new_offset = GET_UShort () + base_offset;
 
         ftglue_stream_frame_exit( stream );
 
@@ -2812,7 +2812,7 @@ GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *scri
        goto Fail;
     }
 
-    // sort the tag list before returning it
+    /* sort the tag list before returning it */
     qsort(*stags, *script_count, sizeof(FT_ULong), compareulong);
 
     return TT_Err_Ok;
@@ -2820,6 +2820,7 @@ GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *scri
 Fail:
     *script_count = 0;
     ftglue_free( memory, *stags );
+    *stags = NULL;
     return error;
 }