]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcfreetype.c
Bug 75: dont build docs unless docbook is available. Dont install docs
[fontconfig.git] / src / fcfreetype.c
index 95be9cce712c654f9f4e1f57b04285d6d4b5f702..df13ad369932f89f87582cda548a8dce1419819a 100644 (file)
@@ -358,6 +358,9 @@ FcFreeTypeQuery (const FcChar8      *file,
     int                    spacing;
     TT_OS2         *os2;
     PS_FontInfoRec  psfontinfo;
+#ifdef USE_FTBDF
+    BDF_PropertyRec prop;
+#endif
     TT_Header      *head;
     const FcChar8   *exclusiveLang = 0;
     FT_SfntName            sname;
@@ -792,7 +795,6 @@ FcFreeTypeQuery (const FcChar8      *file,
     
     if (FT_Get_PS_Font_Info(face, &psfontinfo) == 0)
     {
-#if 0
        if (weight == -1 && psfontinfo.weight)
        {
            weight = FcIsWeight (psfontinfo.weight);
@@ -800,7 +802,6 @@ FcFreeTypeQuery (const FcChar8      *file,
                printf ("\tType1 weight %s maps to %d\n",
                        psfontinfo.weight, weight);
        }
-#endif
      
 #if 0
        /* 
@@ -834,7 +835,6 @@ FcFreeTypeQuery (const FcChar8      *file,
 
     if (width == -1)
     {
-       BDF_PropertyRec prop;
        if (MY_Get_BDF_Property(face, "RELATIVE_SETWIDTH", &prop) == 0 &&
            (prop.type == BDF_PROPERTY_TYPE_INTEGER ||
             prop.type == BDF_PROPERTY_TYPE_CARDINAL))
@@ -857,25 +857,13 @@ FcFreeTypeQuery (const FcChar8    *file,
            case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
            }
        }
-       else if (MY_Get_BDF_Property (face, "SETWIDTH_NAME", &prop) == 0 &&
-                prop.type == BDF_PROPERTY_TYPE_ATOM)
+       if (width == -1 &&
+           MY_Get_BDF_Property (face, "SETWIDTH_NAME", &prop) == 0 &&
+           prop.type == BDF_PROPERTY_TYPE_ATOM)
        {
-           static struct {
-               FcChar8     *width_name;
-               int         width;
-           } FcSetWidths[] = {
-           };
-           int i;
-
+           width = FcIsWidth (prop.u.atom);
            if (FcDebug () & FC_DBG_SCANV)
-               printf ("\tsetwidth: %s\n", prop.u.atom);
-           for (i = 0; i < sizeof (FcSetWidths) / sizeof (FcSetWidths[0]); i++)
-               if (!FcStrCmpIgnoreBlanksAndCase ((FcChar8 *) prop.u.atom,
-                                        FcSetWidths[i].width_name))
-               {
-                   width = FcSetWidths[i].width;
-                   break;
-               }
+               printf ("\tsetwidth %s maps to %d\n", prop.u.atom, width);
        }
     }
 
@@ -946,6 +934,20 @@ FcFreeTypeQuery (const FcChar8     *file,
     if (!cs)
        goto bail1;
 
+#ifdef USE_FTBDF
+    /* For PCF fonts, override the computed spacing with the one from
+       the property */
+    if(MY_Get_BDF_Property(face, "SPACING", &prop) == 0 &&
+       prop.type == BDF_PROPERTY_TYPE_ATOM) {
+        if(strcmp(prop.u.atom, "c") || strcmp(prop.u.atom, "C"))
+            spacing = FC_CHARCELL;
+        else if(strcmp(prop.u.atom, "m") || strcmp(prop.u.atom, "M"))
+            spacing = FC_MONO;
+        else if(strcmp(prop.u.atom, "p") || strcmp(prop.u.atom, "P"))
+            spacing = FC_PROPORTIONAL;
+    }
+#endif
+
     /*
      * Skip over PCF fonts that have no encoded characters; they're
      * usually just Unicode fonts transcoded to some legacy encoding
@@ -964,7 +966,12 @@ FcFreeTypeQuery (const FcChar8     *file,
        goto bail2;
 
     if (!FcPatternAddLangSet (pat, FC_LANG, ls))
+    {
+       FcLangSetDestroy (ls);
        goto bail2;
+    }
+
+    FcLangSetDestroy (ls);
 
     if (spacing != FC_PROPORTIONAL)
        if (!FcPatternAddInteger (pat, FC_SPACING, spacing))
@@ -978,6 +985,47 @@ FcFreeTypeQuery (const FcChar8     *file,
                goto bail1;
        if (!FcPatternAddBool (pat, FC_ANTIALIAS, FcFalse))
            goto bail1;
+#ifdef USE_FTBDF
+        if(face->num_fixed_sizes == 1) {
+            int rc;
+            int value;
+            BDF_PropertyRec prop;
+
+            rc = MY_Get_BDF_Property(face, "PIXEL_SIZE", &prop);
+            if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
+                value = prop.u.integer;
+            else if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_CARDINAL)
+                value = prop.u.cardinal;
+            else
+                goto nevermind;
+            if(value != face->available_sizes[0].height)
+                /* ``impossible'' */
+                goto nevermind;
+
+            rc = MY_Get_BDF_Property(face, "POINT_SIZE", &prop);
+            if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
+                value = prop.u.integer;
+            else if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_CARDINAL)
+                value = prop.u.cardinal;
+            else
+                goto nevermind;
+            if(!FcPatternAddDouble(pat, FC_SIZE, value / 10.0))
+                goto nevermind;
+
+            rc = MY_Get_BDF_Property(face, "RESOLUTION_Y", &prop);
+            if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
+                value = prop.u.integer;
+            else if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_CARDINAL)
+                value = prop.u.cardinal;
+            else
+                goto nevermind;
+            if(!FcPatternAddDouble(pat, FC_DPI, (double)value))
+                goto nevermind;
+
+        }
+    nevermind:
+        ;
+#endif
     }
 
     /*
@@ -1575,7 +1623,7 @@ FcFreeTypeUseNames (FT_Face face)
     if (!FT_Has_PS_Glyph_Names (face))
        return FcFalse;
     for (map = 0; map < face->num_charmaps; map++)
-       if (face->charmaps[map]->encoding == FT_ENCODING_ADOBE_CUSTOM)
+       if (face->charmaps[map]->encoding == ft_encoding_adobe_custom)
            return FcTrue;
     return FcFalse;
 }
@@ -1716,7 +1764,7 @@ FcFreeTypeCheckGlyph (FT_Face face, FcChar32 ucs4,
                      FT_UInt glyph, FcBlanks *blanks,
                      FT_Pos *advance)
 {
-    FT_Int         load_flags = FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
+    FT_Int         load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
     FT_GlyphSlot    slot;
     
     /*