Dear David, dear Werner, dear all,

In the FreeType 2 module for XFree86 and in the mkfontscale utility, I
am using a number of internal interfaces.  I am attaching a proposed
interface for these, as well as the rather hackish implementation I'm
using right now.

Of course, I have no objection to you changing the interface
altogether, as long as you provide equivalent functionality in an
officially sanctioned (and stable) manner.  (Keith, do you have any
further requests?)

Thanks a lot,

                                        Juliusz

/* Returns true if the font prefers to be indexed by name.  Currently
   returns true for Type 1 fonts, which is suboptimal in the presence
   of OpenType/CFF fonts converted from Type 1.  But what else can be
   done? */

int FT_Face_Prefers_Names(FT_Face face);

/* Returns a human-readable name for the font technology used by the
   font.  The name should be suitable for use as an X11 FONT_TYPE
   property. */

char *FT_Face_Font_Type(FT_Face face);

typedef enum {
    ft_type1_info = 0,

    type1_max
} FT_Type1_Tag;

/* Returns a table from a Type 1 font, NULL otherwise. */

void *FT_Get_Type1_Table(FT_Face face, FT_Type1_Tag tag);

#include "freetype/freetype.h"
#include "freetype/internal/ftobjs.h"
#include "freetype/internal/t1types.h"
#include "freetype/ftmodule.h"
#include "fthack.h"

#define FACE_TYPE(face) ((face)->driver->clazz->root.module_name)

static int
mystrcmp(char *p, char *q)
{
    while(*p != '\0' || *q != '\0') {
        if(*p != *q)
            return 0;
        p++; q++;
    }
    return 1;
}

static int
isType1(FT_Face face)
{
    return mystrcmp(FACE_TYPE(face), "type1");
}

int
FT_Face_Prefers_Names(FT_Face face)
{
    return isType1(face);
}

char *
FT_Face_Font_Type(FT_Face face)
{
    /* The names "Type 1" and "TrueType" are sanctioned by XLFD, and
       should not be changed.  For other formats, anything goes. */

    if(mystrcmp(FACE_TYPE(face), "type1") == 0)
        return "Type 1";
    else if(mystrcmp(FACE_TYPE(face), "truetype") == 0)
        return "TrueType";
    else /* XXX */
        return FACE_TYPE(face);
}

void *
FT_Get_Type1_Table(FT_Face face, FT_Type1_Tag tag)
{
    if(!isType1(face))
        return NULL;

    switch(tag) {
    case ft_type1_info:
        return (void*)(&((T1_FaceRec*)face)->type1.font_info);
    default:
        return NULL;
    }
}

Reply via email to