[Fontconfig] About FcFreeTypeQueryFace()

Nestal Wan me at nestal.net
Wed Jan 20 08:27:19 PST 2010


Hi,

I am new to FontConfig. I have a FT_Face and I want to get the
filename and font index from it. I found FcFreeTypeQueryFace() should
be useful. However, what should I put in the second and third
argument? I don't quite understand what is mean by "used solely as
data for pattern elements" as mentioned in the man page. I tried to
put NULL and zero but the call fails. If I put something non-zero, the
call success:

// something non-null
FcChar8 abc[1] ;

FcBlanks *b = FcBlanksCreate() ;
FcPattern *p = FcFreeTypeQueryFace( face, abc, 0, b ) ;
		
FcChar8 *filename2 ;
FcResult result ;
FcPattern *matched = FcFontMatch( 0, p, &result);

if (FcPatternGetString (matched, FC_FILE, 0, &filename2) != FcResultMatch)
	std::cout << "oops" << std::endl ;

int id ;
if (FcPatternGetInteger (matched, FC_INDEX, 0, &id) != FcResultMatch)
	std::cout << "oops2" << std::endl ;
		
std::cout << "file is " << filename2 << " " << id << std::endl ;

It actually works. I want to ask if it is OK to put some dummy
non-null pointer to the function?

Thanks in advance.

Nestal


More information about the Fontconfig mailing list