freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Freetype] FreeType feature request: export font properties


From: Juliusz Chroboczek
Subject: [Freetype] FreeType feature request: export font properties
Date: 11 Jan 2003 21:42:56 +0100

Dear all,

Please accept my best wishes for the new year.

Both the BDF and PCF backends parse font properties (font-level
metrics) but don't export them to the client.  I would like to request
a supported interface to get at these data.  I'm attaching the
somewhat hackish code that I'm currently using.

Additionally, an interface to enumerate all properties in a font might
turn out to be useful in the future (but I don't need it right now).

Thanks a lot,

                                        Juliusz

#define PROP_ATOM 1
#define PROP_INTEGER 2
#define PROP_CARDINAL 3

typedef union _FontProperty {
    char *atom;
    long int32;
    unsigned long card32;
} FontProperty;

static int
fontType(FT_Face face, char *name)
{
    if(face && face->driver) {
        FT_Module driver = (FT_Module)face->driver;
        if(driver->clazz && driver->clazz->module_name) {
            if(strcmp(driver->clazz->module_name, name) == 0)
                return 1;
        }
    }
    return 0;
}

int
faceProperty(FT_Face face, char *name,
             int *type_return, FontProperty *prop_return)
{
    int i;
    if(fontType(face, "pcf")) {
        PCF_Face pf = (PCF_Face)face;
        for(i = 0; i < pf->nprops; i++) {
            if(strcmp(pf->properties[i].name, name) == 0) {
                if(type_return)
                    *type_return = 
                        pf->properties[i].isString ? PROP_ATOM : PROP_INTEGER;
                *prop_return = *(FontProperty*)&pf->properties[i].value;
                return 1;
            }
        }
        return 0;
    } else if(fontType(face, "bdf")) {
        BDF_Face bf = (BDF_Face)face;
        for(i = 0; i < bf->bdffont->props_used; i++) {
            if(strcmp(bf->bdffont->props[i].name, name) == 0) {
                if(type_return)
                    *type_return = bf->bdffont->props[i].format;
                *prop_return = *(FontProperty*)&bf->bdffont->props[i].value;
                return 1;
            }
        }
        return 0;
    }
    return -1;
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]