freetype
[Top][All Lists]
Advanced

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

Re: [Freetype] FreeType feature request: export font properties


From: David Turner
Subject: Re: [Freetype] FreeType feature request: export font properties
Date: Thu, 16 Jan 2003 13:07:24 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2a) Gecko/20020910

Hi Juliusz,

Juliusz Chroboczek wrote:
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).

I've started working on this on my machine, but I doubt it will make
it for 2.1.4 which should appear this week-end. Probably for next week
though...

the new API will be added to FT_BDH_H, since properties are BDF concepts
(and PCF are compressed BDF files), this to prevent yet another public
source :-)

Cheers,

- David Turner
- The FreeType Project  (www.freetype.org)

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;
}

_______________________________________________
Freetype mailing list
address@hidden
http://www.freetype.org/mailman/listinfo/freetype






reply via email to

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