Skip to content

Commit

Permalink
removed fontconfig dependency on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Aug 11, 2011
1 parent 585e467 commit 1ed9f12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Expand Up @@ -125,7 +125,7 @@ if env['PLATFORM'] == 'darwin': # Mac
LIBPATH=Split('/opt/local/lib .'),
CPPPATH='/opt/local/include/',
LINKFLAGS='-framework OpenAL -framework OpenGL')
env.ParseConfig('/opt/local/bin/pkg-config --cflags --libs freetype2 libpng fontconfig')
env.ParseConfig('/opt/local/bin/pkg-config --cflags --libs freetype2 libpng')
env.ParseConfig('/opt/local/bin/sdl-config --cflags --libs')
env.Library(target="jngl", source=source_files + Glob('sdl/*.cpp'))
testEnv = env.Clone()
Expand Down
30 changes: 4 additions & 26 deletions sdl/window.cpp
Expand Up @@ -20,7 +20,6 @@ along with JNGL. If not, see <http://www.gnu.org/licenses/>.
#include "../window.hpp"
#include "../debug.hpp"

#include <fontconfig/fontconfig.h>
#include <stdexcept>

namespace jngl
Expand Down Expand Up @@ -78,32 +77,11 @@ namespace jngl

std::string Window::GetFontFileByName(const std::string& fontname)
{
const double size = 12;
FcFontSet* fontSet = FcFontSetCreate();

FcPattern* pattern = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, fontname.c_str(), FC_SIZE, FcTypeDouble, size, NULL);
FcConfigSubstitute(NULL,pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);

FcResult result;
FcPattern* match = FcFontMatch(NULL, pattern, &result);
FcPatternDestroy(pattern);

if(!match)
{
FcFontSetDestroy(fontSet);
throw std::runtime_error(std::string("Couldn't load " + fontname));
std::string tmp = fontname;
if(fontname == "sans-serif") {
tmp = "Arial";
}
FcFontSetAdd(fontSet, match);

if(fontSet->nfont == 0)
{
throw std::runtime_error(std::string("Couldn't load " + fontname));
}

FcChar8* filename = NULL;
FcPatternGetString(fontSet->fonts[0], FC_FILE, 0, &filename);
return (const char*)filename;
return "/Library/Fonts/" + tmp + ".ttf";
}

Window::~Window()
Expand Down

0 comments on commit 1ed9f12

Please sign in to comment.