2012-11-27 2 views
4

내 C++ 프로그램이 설치된 Win32 컴퓨터에 설치된 글꼴을 감지하려고합니다. 나는 GTK + 번들에서 라이브러리를 가져 와서 fontconfig를 시도했다.fontconfig는 글꼴을 찾지 않습니다.

#include<fontconfig.h> 

FcBool success = FcInit(); 
if (!success) { 
    return false; 
} 

FcConfig *config = FcInitLoadConfigAndFonts(); 
if(!config) { 
    return false; 
} 

FcChar8 *s, *file; 

FcPattern *p = FcPatternCreate(); 
FcObjectSet *os = FcObjectSetBuild (FC_FAMILY,NULL); 
FcFontSet *fs = FcFontList(config, p, os); 

LOG("Total fonts: %d\n", fs->nfont); 
for (int i=0; fs && i < fs->nfont; i++) { 
    FcPattern *font = fs->fonts[i]; 

    s = FcNameUnparse(font); 
    LOG("Font: %s\n", s); 
    free(s); 

    if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) { 
     LOG("Filename: %s\n", file); 
    } 
} 

// destroy objects here ... 

불행하게도이 테스트 응용 프로그램에서만 인쇄 :

총 글꼴 : 나는에 설치된 글꼴이 알고 0

나는 다음과 같은 테스트 코드를 사용 내 컴퓨터와 나는 Gimp2.0이 그것들을 감지 했으므로 나의 테스트 코드에 뭔가 잘못 됐음을 알아야한다. 누구 아이디어가 있습니까?

fontconfig-1.dll을 연결하는 것 이외에는 아무 것도하지 않았습니다. 어떤 설정 파일이나 아무것도 만들지 않았습니다. 왜냐하면 어디서나 읽을 수 없기 때문입니다.

의견을 보내 주셔서 감사합니다.

답변

1

대신 :

FcConfig *config = FcInitLoadConfigAndFonts(); 

시도 :

FcConfig *config = FcConfigCreate(); 
FcConfigAppFontAddDir(config, (const FcChar8 *)"C:\\Windows\\Fonts"); 

(이 게으른 버전입니다, 당신은 ... GetWindowsDirectory을 이동에 적응해야한다)

관련 문제