forked from mia/Aegisub
Implemented font config file lister, except that it doesn't work.
Originally committed to SVN as r1453.
This commit is contained in:
parent
fec497a047
commit
d256a61703
3 changed files with 34 additions and 11 deletions
|
@ -43,8 +43,10 @@
|
||||||
#include "standard_paths.h"
|
#include "standard_paths.h"
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include "font_file_lister_freetype.h"
|
#include "font_file_lister_freetype.h"
|
||||||
|
#define FontListerClass FreetypeFontFileLister
|
||||||
#else
|
#else
|
||||||
#include "font_file_lister_fontconfig.h"
|
#include "font_file_lister_fontconfig.h"
|
||||||
|
#define FontListerClass FontConfigFontFileLister
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,13 +70,7 @@ FontFileLister::~FontFileLister() {
|
||||||
////////////////
|
////////////////
|
||||||
// Get instance
|
// Get instance
|
||||||
void FontFileLister::GetInstance() {
|
void FontFileLister::GetInstance() {
|
||||||
if (!instance) {
|
if (!instance) instance = new FontListerClass();
|
||||||
#ifdef WIN32
|
|
||||||
instance = new FreetypeFontFileLister();
|
|
||||||
#else
|
|
||||||
instance = new FontConfigFontFileLister();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2007, Rodrigo Braz Monteiro
|
// Copyright (c) 2007, David Lamparter, Rodrigo Braz Monteiro
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -46,7 +46,25 @@
|
||||||
wxArrayString FontConfigFontFileLister::DoGetFilesWithFace(wxString facename) {
|
wxArrayString FontConfigFontFileLister::DoGetFilesWithFace(wxString facename) {
|
||||||
wxArrayString results;
|
wxArrayString results;
|
||||||
|
|
||||||
// TODO: implement this
|
// Code stolen from asa
|
||||||
|
FcPattern *final, *tmp1, *tmp2;
|
||||||
|
FcResult res;
|
||||||
|
FcChar8 *filename;
|
||||||
|
char buffer[1024];
|
||||||
|
strcpy(buffer,facename.mb_str(wxConvUTF8));
|
||||||
|
|
||||||
|
// Get data from fconfig or something
|
||||||
|
tmp1 = FcPatternBuild(NULL,FC_FAMILY, FcTypeString,buffer,NULL);
|
||||||
|
if (!tmp1) return results;
|
||||||
|
tmp2 = FcFontRenderPrepare(fontconf, tmp1, aux);
|
||||||
|
FcPatternDestroy(tmp1);
|
||||||
|
final = FcFontMatch(fontconf, tmp2, &res);
|
||||||
|
FcPatternDestroy(tmp2);
|
||||||
|
if (!final) return results;
|
||||||
|
if (FcPatternGetString(final, FC_FILE, 0, &filename) == FcResultMatch) {
|
||||||
|
results.Add(wxString((char*) filename,wxConvLocal));
|
||||||
|
}
|
||||||
|
FcPatternDestroy(final);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@ -55,14 +73,18 @@ wxArrayString FontConfigFontFileLister::DoGetFilesWithFace(wxString facename) {
|
||||||
//////////////
|
//////////////
|
||||||
// Initialize
|
// Initialize
|
||||||
void FontConfigFontFileLister::DoInitialize() {
|
void FontConfigFontFileLister::DoInitialize() {
|
||||||
// TODO: implement this
|
fontconf = FcInitLoadConfigAndFonts();
|
||||||
|
aux = FcPatternCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
// Clean up
|
// Clean up
|
||||||
void FontConfigFontFileLister::DoClearData() {
|
void FontConfigFontFileLister::DoClearData() {
|
||||||
// TODO: implement this
|
if (aux) FcPatternDestroy(aux);
|
||||||
|
#ifdef HAVE_FCFINI
|
||||||
|
FcFini();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
// Includes
|
// Includes
|
||||||
|
#include <fontconfig/fontconfig.h>
|
||||||
|
#include <fontconfig/fcfreetype.h>
|
||||||
#include "font_file_lister.h"
|
#include "font_file_lister.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +49,9 @@
|
||||||
class FontConfigFontFileLister : public FontFileLister {
|
class FontConfigFontFileLister : public FontFileLister {
|
||||||
friend class FontFileLister;
|
friend class FontFileLister;
|
||||||
private:
|
private:
|
||||||
|
FcConfig *fontconf;
|
||||||
|
FcPattern *aux;
|
||||||
|
|
||||||
wxArrayString DoGetFilesWithFace(wxString facename);
|
wxArrayString DoGetFilesWithFace(wxString facename);
|
||||||
void DoInitialize();
|
void DoInitialize();
|
||||||
void DoClearData();
|
void DoClearData();
|
||||||
|
|
Loading…
Reference in a new issue