Am 26.04.2012 14:47, schrieb Brian Potkin:
It's at times like this I begin to wonder what I have failed to do
correctly. :)

Furthermore, could you please install the libfontconfig1-dev package and compile the attached source with "gcc fc-test.c -o fc-test -lfontconfig".

It's the relevant part from texttopdf.c copied into a dedicated executable. Now please try "./fc-test FreeMono" and tell me the results. As this is more or less a re-implementation of "fc-match -s", the results should be identical up to the point where a monospaced truetype font is found. Can you confirm?

 - Fabian
#include <stdio.h>
#include <fontconfig/fontconfig.h>

int main (int argc, char *argv[])
{
char *font = argv[1];
FcPattern *pattern;
FcFontSet *candidates;
FcChar8   *fontname = NULL;
int i;

if (!font)
        return 1;

FcInit ();
pattern = FcNameParse ((const FcChar8 *)font);
FcPatternAddInteger (pattern, FC_SPACING, FC_MONO);
FcConfigSubstitute (0, pattern, FcMatchPattern);
FcDefaultSubstitute (pattern);

candidates = FcFontSort (0, pattern, FcTrue, 0, 0);
FcPatternDestroy (pattern);

for (i = 0; i < candidates->nfont; i++) {
        FcChar8 *fontformat=NULL;
        int spacing=0;
        FcPatternGetString  (candidates->fonts[i], FC_FONTFORMAT, 0, 
&fontformat);
        FcPatternGetInteger (candidates->fonts[i], FC_SPACING,    0, &spacing);

        printf ("C: %s\n", FcPatternFormat (candidates->fonts[i], (const 
FcChar8 *)"%{file|cescape}"));

        if ( (fontformat)&&(spacing == FC_MONO) ) {
                if (strcmp((const char *)fontformat, "TrueType") == 0) {
                  fontname = FcPatternFormat (candidates->fonts[i], (const 
FcChar8 *)"%{file|cescape}/%{index}");
                  break;
                } else if (strcmp((const char *)fontformat, "CFF") == 0) {
                  fontname = FcPatternFormat (candidates->fonts[i], (const 
FcChar8 *)"%{file|cescape}");
                  break;
                }
        }
}
FcFontSetDestroy (candidates);

if (fontname)
        printf("S: %s\n", fontname);

return 0;
}

Reply via email to