Example #1
0
File: util.c Project: aosm/X11
char *
faceEncoding(FT_Face face)
{
    BDF_PropertyRec p1, p2;
    int rc;

    rc = FT_Get_BDF_Property(face, "CHARSET_REGISTRY", &p1);
    if(rc != 0 || p1.type != BDF_PROPERTY_TYPE_ATOM)
        return NULL;
    rc = FT_Get_BDF_Property(face, "CHARSET_ENCODING", &p2);
    if(rc != 0 || p2.type != BDF_PROPERTY_TYPE_ATOM)
        return NULL;

    return sprintf_reliable("%s-%s", p1.u.atom, p2.u.atom);
}
Example #2
0
File: util.c Project: aosm/X11
int
faceWidth(FT_Face face)
{
    int rc;
    BDF_PropertyRec prop;
    rc = FT_Get_BDF_Property(face, "SETWIDTH_NAME", &prop);
    if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
        if(strcasecmp(prop.u.atom, "ultracondensed") == 0)
            return 1;
        else if(strcasecmp(prop.u.atom, "extracondensed") == 0)
            return 2;
        else if(strcasecmp(prop.u.atom, "condensed") == 0)
            return 3;
        else if(strcasecmp(prop.u.atom, "semicondensed") == 0)
            return 4;
        else if(strcasecmp(prop.u.atom, "normal") == 0)
            return 5;
        else if(strcasecmp(prop.u.atom, "semiexpanded") == 0)
            return 6;
        else if(strcasecmp(prop.u.atom, "expanded") == 0)
            return 7;
        else if(strcasecmp(prop.u.atom, "extraexpanded") == 0)
            return 8;
        else if(strcasecmp(prop.u.atom, "ultraexpanded") == 0)
            return 9;
        else
            return 5;
    } else
        return 5;               /* for now */
}
Example #3
0
File: util.c Project: aosm/X11
int
faceWeight(FT_Face face)
{
    int rc;
    BDF_PropertyRec prop;
    rc = FT_Get_BDF_Property(face, "WEIGHT_NAME", &prop);
    if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
        if(strcasecmp(prop.u.atom, "thin") == 0)
            return 100;
        else if(strcasecmp(prop.u.atom, "extralight") == 0)
            return 200;
        else if(strcasecmp(prop.u.atom, "light") == 0)
            return 300;
        else if(strcasecmp(prop.u.atom, "medium") == 0)
            return 500;
        else if(strcasecmp(prop.u.atom, "semibold") == 0)
            return 600;
        else if(strcasecmp(prop.u.atom, "bold") == 0)
            return 700;
        else if(strcasecmp(prop.u.atom, "extrabold") == 0)
            return 800;
        else if(strcasecmp(prop.u.atom, "black") == 0)
            return 900;
        else
            return 500;
    } else
        return 500;             /* for now */
}
Example #4
0
File: util.c Project: aosm/X11
int
faceItalicAngle(FT_Face face)
{
    int rc;
    BDF_PropertyRec prop;

    rc = FT_Get_BDF_Property(face, "ITALIC_ANGLE", &prop);
    if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER) {
        return (prop.u.integer - 64 * 90) * (TWO_SIXTEENTH / 64);
    }

    rc = FT_Get_BDF_Property(face, "SLANT", &prop);
    if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
        if(strcasecmp(prop.u.atom, "i") == 0 ||
           strcasecmp(prop.u.atom, "s") == 0)
            return -30 * TWO_SIXTEENTH;
        else
            return 0;
    } else
        return 0;               /* for now */
}
Example #5
0
File: util.c Project: aosm/X11
unsigned
faceFoundry(FT_Face face)
{
    int rc;
    BDF_PropertyRec prop;

    rc = FT_Get_BDF_Property(face, "FOUNDRY", &prop);
    if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
        if(strcasecmp(prop.u.atom, "adobe") == 0)
            return makeName("ADBE");
        else if(strcasecmp(prop.u.atom, "agfa") == 0)
            return makeName("AGFA");
        else if(strcasecmp(prop.u.atom, "altsys") == 0)
            return makeName("ALTS");
        else if(strcasecmp(prop.u.atom, "apple") == 0)
            return makeName("APPL");
        else if(strcasecmp(prop.u.atom, "arphic") == 0)
            return makeName("ARPH");
        else if(strcasecmp(prop.u.atom, "alltype") == 0)
            return makeName("ATEC");
        else if(strcasecmp(prop.u.atom, "b&h") == 0)
            return makeName("B&H ");
        else if(strcasecmp(prop.u.atom, "bitstream") == 0)
            return makeName("BITS");
        else if(strcasecmp(prop.u.atom, "dynalab") == 0)
            return makeName("DYNA");
        else if(strcasecmp(prop.u.atom, "ibm") == 0)
            return makeName("IBM ");
        else if(strcasecmp(prop.u.atom, "itc") == 0)
            return makeName("ITC ");
        else if(strcasecmp(prop.u.atom, "interleaf") == 0)
            return makeName("LEAF");
        else if(strcasecmp(prop.u.atom, "impress") == 0)
            return makeName("IMPR");
        else if(strcasecmp(prop.u.atom, "larabiefonts") == 0)
            return makeName("LARA");
        else if(strcasecmp(prop.u.atom, "linotype") == 0)
            return makeName("LINO");
        else if(strcasecmp(prop.u.atom, "monotype") == 0)
            return makeName("MT  ");
        else if(strcasecmp(prop.u.atom, "microsoft") == 0)
            return makeName("MS  ");
        else if(strcasecmp(prop.u.atom, "urw") == 0)
            return makeName("URW ");
        else if(strcasecmp(prop.u.atom, "y&y") == 0)
            return makeName("Y&Y ");
        else
            return makeName("UNKN");
    }
    /* For now */
    return makeName("UNKN");
}
Example #6
0
File: util.c Project: aosm/X11
int
faceFlags(FT_Face face)
{
    int flags = 0;
    BDF_PropertyRec prop;
    int rc;

    if(faceWeight(face) >= 650)
        flags |= FACE_BOLD;
    rc = FT_Get_BDF_Property(face, "SLANT", &prop);
    if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
        if(strcasecmp(prop.u.atom, "i") == 0 ||
           strcasecmp(prop.u.atom, "s") == 0)
            flags |= FACE_ITALIC;
    }
    return flags;
}
Example #7
0
FT_Error
get_file_info(FontManagerFontInfo *fileinfo, const gchar * filepath, gint index)
{
    FT_Face         face;
    FT_Library      library;
    FT_Error        error;
    PS_FontInfoRec  ps_info;
    BDF_PropertyRec prop;

    gsize   filesize = 0;
    gchar   * font = NULL;

    if (G_UNLIKELY(!g_file_get_contents(filepath, &font, &filesize, NULL))) {
        g_warning("Failed to load file : %s", filepath);
        return FT_Err_Cannot_Open_Resource;
    }

    error = FT_Init_FreeType(&library);
    if (G_UNLIKELY(error))
        return error;

    error = FT_New_Memory_Face(library, (const FT_Byte *) font, (FT_Long) filesize, index, &face);
    if (G_UNLIKELY(error)) {
        g_warning("Failed to create FT_Face for file : %s", filepath);
        return error;
    }

    font_manager_font_info_set_owner(fileinfo, get_file_owner(filepath));
    font_manager_font_info_set_filetype(fileinfo, FT_Get_X11_Font_Format(face));

    gchar * _size = g_format_size(filesize);
    font_manager_font_info_set_filesize(fileinfo, _size);
    g_free0(_size);

    gchar * _md5 = g_compute_checksum_for_data(G_CHECKSUM_MD5, (const guchar *) font, filesize);
    font_manager_font_info_set_checksum(fileinfo, _md5);
    g_free0(_md5);

    font_manager_font_info_set_psname(fileinfo, FT_Get_Postscript_Name(face));

    TT_OS2 * os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
    if (G_LIKELY(os2 && os2->version >= 0x0001 && os2->version != 0xffff)) {
        gchar * _vendor = get_vendor_from_vendor_id((gchar *) os2->achVendID);
        font_manager_font_info_set_vendor(fileinfo, _vendor);
        g_free0(_vendor);
        gchar * panose = g_strdup_printf("%i:%i:%i:%i:%i:%i:%i:%i:%i:%i", os2->panose[0],
                                          os2->panose[1], os2->panose[2], os2->panose[3],
                                          os2->panose[4], os2->panose[5], os2->panose[6],
                                          os2->panose[7], os2->panose[8], os2->panose[9]);
        font_manager_font_info_set_panose(fileinfo, panose);
        g_free0(panose);
    }

    if (G_LIKELY(FT_IS_SFNT(face)))
        get_sfnt_info(fileinfo, face);
    if (FT_Get_PS_Font_Info(face, &ps_info) == 0)
        get_ps_info(fileinfo, ps_info, face);

    gint lic_type = get_license_type(font_manager_font_info_get_license_data(fileinfo),
                                     font_manager_font_info_get_copyright(fileinfo),
                                     font_manager_font_info_get_license_url(fileinfo));
    gchar * _name = get_license_name(lic_type);
    font_manager_font_info_set_license_type(fileinfo, _name);
    g_free0(_name);

    if (!font_manager_font_info_get_license_url(fileinfo)) {
        gchar * _url = get_license_url(lic_type);
        if (_url)
            font_manager_font_info_set_license_url(fileinfo, _url);
        g_free0(_url);
    }

    if (!font_manager_font_info_get_version(fileinfo)) {
        TT_Header * head = (TT_Header *) FT_Get_Sfnt_Table (face, ft_sfnt_head);
        if (head)
            if (head->Font_Revision) {
                gchar * rev = g_strdup_printf("%f", (float) head->Font_Revision);
                font_manager_font_info_set_version(fileinfo, rev);
                g_free0(rev);
            }
    }

    if (!font_manager_font_info_get_vendor(fileinfo)) {
        int result = FT_Get_BDF_Property(face, "FOUNDRY", &prop);
        if(result == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM)
            font_manager_font_info_set_vendor(fileinfo, prop.u.atom);
        else
            font_manager_font_info_set_vendor(fileinfo, "Unknown Vendor");
    }

    FT_Done_Face(face);
    error = FT_Done_FreeType(library);
    g_free0(font);
    return error;
}
Example #8
0
static Lisp_Object
xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
{
  FcResult result;
  Display *display = FRAME_X_DISPLAY (f);
  Lisp_Object val, filename, idx, font_object;
  FcPattern *pat = NULL, *match;
  struct xftfont_info *xftfont_info = NULL;
  struct font *font;
  double size = 0;
  XftFont *xftfont = NULL;
  int spacing;
  char name[256];
  int len, i;
  XGlyphInfo extents;
  FT_Face ft_face;
  FcMatrix *matrix;

  val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX));
  if (! CONSP (val))
    return Qnil;
  val = XCDR (val);
  filename = XCAR (val);
  idx = XCDR (val);
  size = XINT (AREF (entity, FONT_SIZE_INDEX));
  if (size == 0)
    size = pixel_size;
  pat = FcPatternCreate ();
  FcPatternAddInteger (pat, FC_WEIGHT, FONT_WEIGHT_NUMERIC (entity));
  i = FONT_SLANT_NUMERIC (entity) - 100;
  if (i < 0) i = 0;
  FcPatternAddInteger (pat, FC_SLANT, i);
  FcPatternAddInteger (pat, FC_WIDTH, FONT_WIDTH_NUMERIC (entity));
  FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size);
  val = AREF (entity, FONT_FAMILY_INDEX);
  if (! NILP (val))
    FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val)));
  val = AREF (entity, FONT_FOUNDRY_INDEX);
  if (! NILP (val))
    FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) SDATA (SYMBOL_NAME (val)));
  val = AREF (entity, FONT_SPACING_INDEX);
  if (! NILP (val))
    FcPatternAddInteger (pat, FC_SPACING, XINT (val));
  val = AREF (entity, FONT_DPI_INDEX);
  if (! NILP (val))
    {
      double dbl = XINT (val);

      FcPatternAddDouble (pat, FC_DPI, dbl);
    }
  val = AREF (entity, FONT_AVGWIDTH_INDEX);
  if (INTEGERP (val) && XINT (val) == 0)
    FcPatternAddBool (pat, FC_SCALABLE, FcTrue);
  /* This is necessary to identify the exact font (e.g. 10x20.pcf.gz
     over 10x20-ISO8859-1.pcf.gz).  */
  FcPatternAddCharSet (pat, FC_CHARSET, ftfont_get_fc_charset (entity));

  xftfont_add_rendering_parameters (pat, entity);

  FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename));
  FcPatternAddInteger (pat, FC_INDEX, XINT (idx));


  block_input ();
  /* Make sure that the Xrender extension is added before the Xft one.
     Otherwise, the close-display hook set by Xft is called after the
     one for Xrender, and the former tries to re-add the latter.  This
     results in inconsistency of internal states and leads to X
     protocol error when one reconnects to the same X server.
     (Bug#1696)  */
  {
    int event_base, error_base;
    XRenderQueryExtension (display, &event_base, &error_base);
  }

  /* Substitute in values from X resources and XftDefaultSet.  */
  XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat);
  match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result);
  xftfont_fix_match (pat, match);

  FcPatternDestroy (pat);
  xftfont = XftFontOpenPattern (display, match);
  if (!xftfont)
    {
      unblock_input ();
      XftPatternDestroy (match);
      return Qnil;
    }
  ft_face = XftLockFace (xftfont);
  unblock_input ();

  /* We should not destroy PAT here because it is kept in XFTFONT and
     destroyed automatically when XFTFONT is closed.  */
  font_object = font_make_object (VECSIZE (struct xftfont_info), entity, size);
  ASET (font_object, FONT_TYPE_INDEX, Qxft);
  len = font_unparse_xlfd (entity, size, name, 256);
  if (len > 0)
    ASET (font_object, FONT_NAME_INDEX, make_string (name, len));
  len = font_unparse_fcname (entity, size, name, 256);
  if (len > 0)
    ASET (font_object, FONT_FULLNAME_INDEX, make_string (name, len));
  else
    ASET (font_object, FONT_FULLNAME_INDEX,
	  AREF (font_object, FONT_NAME_INDEX));
  ASET (font_object, FONT_FILE_INDEX, filename);
  ASET (font_object, FONT_FORMAT_INDEX,
	ftfont_font_format (xftfont->pattern, filename));
  font = XFONT_OBJECT (font_object);
  font->pixel_size = size;
  font->driver = &xftfont_driver;
  font->encoding_charset = font->repertory_charset = -1;

  xftfont_info = (struct xftfont_info *) font;
  xftfont_info->display = display;
  xftfont_info->xftfont = xftfont;
  /* This means that there's no need of transformation.  */
  xftfont_info->matrix.xx = 0;
  if (FcPatternGetMatrix (xftfont->pattern, FC_MATRIX, 0, &matrix)
      == FcResultMatch)
    {
      xftfont_info->matrix.xx = 0x10000L * matrix->xx;
      xftfont_info->matrix.yy = 0x10000L * matrix->yy;
      xftfont_info->matrix.xy = 0x10000L * matrix->xy;
      xftfont_info->matrix.yx = 0x10000L * matrix->yx;
    }
  if (INTEGERP (AREF (entity, FONT_SPACING_INDEX)))
    spacing = XINT (AREF (entity, FONT_SPACING_INDEX));
  else
    spacing = FC_PROPORTIONAL;
  if (! ascii_printable[0])
    {
      int ch;
      for (ch = 0; ch < 95; ch++)
	ascii_printable[ch] = ' ' + ch;
    }
  block_input ();

  /* Unfortunately Xft doesn't provide a way to get minimum char
     width.  So, we set min_width to space_width.  */

  if (spacing != FC_PROPORTIONAL
#ifdef FC_DUAL
      && spacing != FC_DUAL
#endif	/* FC_DUAL */
      )
    {
      font->min_width = font->max_width = font->average_width
	= font->space_width = xftfont->max_advance_width;
      XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents);
    }
  else
    {
      XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents);
      font->min_width = font->max_width = font->space_width
	= extents.xOff;
      if (font->space_width <= 0)
	/* dirty workaround */
	font->space_width = pixel_size;
      XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents);
      font->average_width = (font->space_width + extents.xOff) / 95;
    }
  unblock_input ();

  font->ascent = xftfont->ascent;
  font->descent = xftfont->descent;
  if (pixel_size >= 5)
    {
      /* The above condition is a dirty workaround because
	 XftTextExtents8 behaves strangely for some fonts
	 (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. */
      if (font->ascent < extents.y)
	font->ascent = extents.y;
      if (font->descent < extents.height - extents.y)
	font->descent = extents.height - extents.y;
    }
  font->height = font->ascent + font->descent;

  if (XINT (AREF (entity, FONT_SIZE_INDEX)) == 0)
    {
      int upEM = ft_face->units_per_EM;

      font->underline_position = -ft_face->underline_position * size / upEM;
      font->underline_thickness = ft_face->underline_thickness * size / upEM;
      if (font->underline_thickness > 2)
	font->underline_position -= font->underline_thickness / 2;
    }
  else
    {
      font->underline_position = -1;
      font->underline_thickness = 0;
    }
#ifdef HAVE_LIBOTF
  xftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
  xftfont_info->otf = NULL;
#endif	/* HAVE_LIBOTF */
  xftfont_info->ft_size = ft_face->size;

  font->baseline_offset = 0;
  font->relative_compose = 0;
  font->default_ascent = 0;
  font->vertical_centering = 0;
#ifdef FT_BDF_H
  if (! (ft_face->face_flags & FT_FACE_FLAG_SFNT))
    {
      BDF_PropertyRec rec;

      if (FT_Get_BDF_Property (ft_face, "_MULE_BASELINE_OFFSET", &rec) == 0
	  && rec.type == BDF_PROPERTY_TYPE_INTEGER)
	font->baseline_offset = rec.u.integer;
      if (FT_Get_BDF_Property (ft_face, "_MULE_RELATIVE_COMPOSE", &rec) == 0
	  && rec.type == BDF_PROPERTY_TYPE_INTEGER)
	font->relative_compose = rec.u.integer;
      if (FT_Get_BDF_Property (ft_face, "_MULE_DEFAULT_ASCENT", &rec) == 0
	  && rec.type == BDF_PROPERTY_TYPE_INTEGER)
	font->default_ascent = rec.u.integer;
    }
#endif

  return font_object;
}
static int
doDirectory(const char *dirname_given, int numEncodings, ListPtr encodingsToDo)
{
    char *dirname, *fontscale_name, *filename, *encdir;
    FILE *fontscale, *encfile;
    DIR *dirp;
    struct dirent *entry;
    FT_Error ftrc;
    FT_Face face;
    ListPtr encoding, xlfd, lp;
    HashTablePtr entries;
    HashBucketPtr *array;
    int i, n, found, rc;
    int isBitmap=0,xl=0;

    if (exclusionSuffix)
        xl = strlen (exclusionSuffix);

    i = strlen(dirname_given);
    if(i == 0)
        dirname = dsprintf("./");
    else if(dirname_given[i - 1] != '/')
        dirname = dsprintf("%s/", dirname_given);
    else
        dirname = dsprintf("%s", dirname_given);

    if(dirname == NULL) {
        perror("dirname");
        exit(1);
    }

    if (onlyEncodings)
	goto encodings;

    entries = makeHashTable();
    if(doBitmaps && !doScalable) {
        readFontScale(entries, dirname);
    }

    if(strcmp(outfilename, "-") == 0)
        fontscale_name = NULL;
    else {
        if(outfilename[0] == '/')
            fontscale_name = dsprintf("%s", outfilename);
        else
            fontscale_name = dsprintf("%s%s", dirname, outfilename);
        if(fontscale_name == NULL) {
            perror("fontscale_name");
            exit(1);
        }
    }

    dirp = opendir(dirname);
    if(dirp == NULL) {
        fprintf(stderr, "%s: ", dirname);
        perror("opendir");
        return 0;
    }

    if(fontscale_name == NULL)
        fontscale = stdout;
    else
        fontscale = fopen(fontscale_name, "wb");

    if(fontscale == NULL) {
        fprintf(stderr, "%s: ", fontscale_name);
        perror("fopen(w)");
        return 0;
    }

    while((entry = readdir(dirp)) != NULL) {
        int have_face = 0;
        char *xlfd_name = NULL;
	struct stat f_stat;
	int tprio = 1;

        xlfd = NULL;

	if (xl) {
	    int dl = strlen (entry->d_name);
	    if (strcmp (entry->d_name + dl - xl, exclusionSuffix) == 0)
		continue;
	}

        filename = dsprintf("%s%s", dirname, entry->d_name);

#define PRIO(x) ((x << 1) + tprio)
#ifdef DT_LNK
	if (entry->d_type != DT_UNKNOWN) {
	    if (entry->d_type == DT_LNK)
		tprio = 0;
	} else
#endif
#ifdef S_ISLNK
	{
#ifndef WIN32
	    if (lstat(filename, &f_stat))
		goto done;
	    if (S_ISLNK(f_stat.st_mode))
		tprio = 0;
#endif
	}
#else
	;
#endif
        if(doBitmaps)
            rc = bitmapIdentify(filename, &xlfd_name);
        else
            rc = 0;

        if(rc < 0)
            goto done;

        if(rc == 0) {
            ftrc = FT_New_Face(ft_library, filename, 0, &face);
            if(ftrc)
                goto done;
            have_face = 1;

            isBitmap = ((face->face_flags & FT_FACE_FLAG_SCALABLE) == 0);

            if(!isBitmap) {
                /* Workaround for bitmap-only SFNT fonts */
                if(FT_IS_SFNT(face) && face->num_fixed_sizes > 0 &&
                   strcmp(FT_Get_X11_Font_Format(face), "TrueType") == 0) {
                    TT_MaxProfile *maxp;
                    maxp = FT_Get_Sfnt_Table(face, ft_sfnt_maxp);
                    if(maxp != NULL && maxp->maxContours == 0)
                        isBitmap = 1;
                }
            }

            if(isBitmap) {
                if(!doBitmaps)
                    goto done;
            } else {
                if(!doScalable)
                    goto done;
            }

            if(isBitmap) {
                BDF_PropertyRec prop;
                rc = FT_Get_BDF_Property(face, "FONT", &prop);
                if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
                    xlfd_name = strdup(prop.u.atom);
                    if(xlfd_name == NULL)
                        goto done;
                }
            }
        }

        if(xlfd_name) {
            /* We know it's a bitmap font, and we know its XLFD */
            int n = strlen(xlfd_name);
            if(reencodeLegacy &&
               n >= 12 && strcasecmp(xlfd_name + n - 11, "-iso10646-1") == 0) {
                char *s;

                s = malloc(n - 10);
                memcpy(s, xlfd_name, n - 11);
                s[n - 11] = '\0';
                xlfd = listCons(s, xlfd);
            } else {
                /* Not a reencodable font -- skip all the rest of the loop body */
                putHash(entries, xlfd_name, entry->d_name, PRIO(filePrio(entry->d_name)));
                goto done;
            }
        }

        if(!have_face) {
            ftrc = FT_New_Face(ft_library, filename, 0, &face);
            if(ftrc)
                goto done;
            have_face = 1;
            isBitmap = ((face->face_flags & FT_FACE_FLAG_SCALABLE) == 0);

            if(!isBitmap) {
                if(face->num_fixed_sizes > 0) {
                    TT_MaxProfile *maxp;
                    maxp = FT_Get_Sfnt_Table(face, ft_sfnt_maxp);
                    if(maxp != NULL && maxp->maxContours == 0)
                        isBitmap = 1;
                }
            }
        }

        if(xlfd == NULL)
            xlfd = makeXLFD(entry->d_name, face, isBitmap);

        found = 0;

        for(lp = xlfd; lp; lp = lp->next) {
            char buf[MAXFONTNAMELEN];
            for(encoding = encodings; encoding; encoding = encoding->next) {
                if(checkEncoding(face, encoding->value)) {
                    found = 1;
                    snprintf(buf, MAXFONTNAMELEN, "%s-%s",
                            lp->value, encoding->value);
                    putHash(entries, buf, entry->d_name, PRIO(filePrio(entry->d_name)));
                }
            }
            for(encoding = extra_encodings; encoding;
                encoding = encoding->next) {
                if(checkExtraEncoding(face, encoding->value, found)) {
                    /* Do not set found! */
                    snprintf(buf, MAXFONTNAMELEN, "%s-%s",
                            lp->value, encoding->value);
                    putHash(entries, buf, entry->d_name, PRIO(filePrio(entry->d_name)));
                }
            }
        }
    done:
        if(have_face)
            FT_Done_Face(face);
        deepDestroyList(xlfd);
        xlfd = NULL;
        free(filename);
#undef PRIO
    }

    closedir(dirp);
    n = hashElements(entries);
    fprintf(fontscale, "%d\n", n);
    array = hashArray(entries, 1);
    for(i = 0; i < n; i++)
        fprintf(fontscale, "%s %s\n", array[i]->value, array[i]->key);
    destroyHashArray(array);
    entries = NULL;
    if(fontscale_name) {
        fclose(fontscale);
        free(fontscale_name);
    }

 encodings:
    encdir = dsprintf("%s%s", dirname, "encodings.dir");

    if(encdir == NULL) {
	perror("encodings");
	exit(1);
    }
    unlink(encdir);

    if (numEncodings) {
	encfile = fopen(encdir, "w");
	if(encfile == NULL) {
	    perror("open(encodings.dir)");
	    exit(1);
	}
        fprintf(encfile, "%d\n", numEncodings);
        encodingsToDo = sortList(encodingsToDo);
        for(lp = encodingsToDo; lp; lp = lp->next) {
            fprintf(encfile, "%s\n", lp->value);
        }
	fclose (encfile);
    }

    free(dirname);
    return 1;
}