[Fontconfig] font matching doesn't work for me

Tomasz Grobelny grotk at poczta.onet.pl
Wed Jul 16 15:51:44 PDT 2003


I was writing such a code but it doesn't work as expected:

//construct a pattern
pat=FcPatternCreate();
FcValue value;

value.type=FcTypeString;
value.u.s=_family.ascii();
FcPatternAdd(pat, FC_FAMILY, value, true);

value.type=FcTypeInteger;
value.u.i=_weight;
FcPatternAdd(pat, FC_WEIGHT, value, true);

value.type=FcTypeInteger;
value.u.i=_slant;
FcPatternAdd(pat, FC_SLANT, value, true);

value.type=FcTypeDouble;
value.u.d=_size;
FcPatternAdd(pat, FC_SIZE, value, true);

value.type=FcTypeDouble;
value.u.d=_size;
FcPatternAdd(pat, FC_PIXEL_SIZE, value, true);

//check if constructed - ok
FcValue* v;
FcPatternGet(pat, FC_FAMILY, 0, v);
cout<<"get family: "<<v->u.s<<endl;
// (...)
FcConfig* config=FcInitLoadConfig();
FcDefaultSubstitute(pat);
FcConfigSubstitute(config, pat, FcMatchPattern);
FcResult* result=new FcResult;
font=FcFontMatch(config, pat, result);
// and now result contains FcResultNoMatch - why?

I tried to get Helvetica, Times, or Times New Roman - none of these worked. 
What's wrong with this code?

Tomek



More information about the Fontconfig mailing list