diff -Naur orig/build/te4core.lua new/build/te4core.lua --- orig/build/te4core.lua 2014-12-28 02:25:57.000000000 +0100 +++ new/build/te4core.lua 2015-02-04 22:53:57.783178696 +0100 @@ -119,7 +119,7 @@ configuration "linux" libdirs {"/opt/SDL-2.0/lib/"} - links { "dl", "SDL2", "SDL2_ttf", "SDL2_image", "png", "openal", "vorbisfile", "GL", "GLU", "m", "pthread" } + links { "dl", "SDL2", "SDL2_ttf", "SDL2_image", "png", "openal", "vorbisfile", "GL", "GLU", "m", "pthread", "fontconfig" } linkoptions { "-Wl,-E" } defines { [[TENGINE_HOME_PATH='".t-engine"']], 'SELFEXE_LINUX' } if steamlin64 then steamlin64() end diff -Naur orig/premake4.lua new/premake4.lua --- orig/premake4.lua 2014-05-19 10:42:14.000000000 +0200 +++ new/premake4.lua 2015-02-04 22:52:19.993180301 +0100 @@ -30,7 +30,8 @@ } else includedirs { - "/opt/SDL-2.0/include/SDL2", + "/usr/include/SDL2", + "/usr/include/fontconfig", "/usr/include/GL", } end diff -Naur orig/src/core_lua.c new/src/core_lua.c --- orig/src/core_lua.c 2015-02-03 17:51:52.000000000 +0100 +++ new/src/core_lua.c 2015-02-04 22:51:29.329847799 +0100 @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef __APPLE__ #include @@ -643,12 +644,69 @@ auxiliar_setclass(L, "sdl{font}", -1); SDL_RWops *src = PHYSFSRWOPS_openRead(name); - if (!src) - { - return luaL_error(L, "could not load font: %s (%d)", name, size); + if (!src) { + // FontConfig + FcInit(); // Not very efficient, possibly not thread safe. + FcChar8 *filename, *family = NULL, *style = NULL; + FcPattern *pattern, *match; + FcResult result; + + // Mapping of family and style. + static struct { + const char* fontname; + const char* fontfamily; + const char* fontstyle; + } mapping[] = { + {"Vera.ttf", "vera", "regular"}, + {"VeraBd.ttf", "vera", "bold"}, + {"VeraIt.ttf", "vera", "italic"}, + {"VeraMono.ttf", "monospace", "regular"}, + {"VeraMoBd.ttf", "monospace", "bold"}, + {"DroidSans.ttf", "droidsans", "regular"}, + {"DroidSansMono.ttf", "droidsansmono", "regular"}, + {"DroidSans-Bold.ttf", "droidsans", "bold"}, + {"DroidSerif.ttf", "droidserif", "regular"}, + {"DroidSerif-Bold.ttf", "droidserif", "bold"}, + {"DroidSerif-Italic.ttf", "droidserif", "italic"}, + {"DroidSerif-BoldItalic.ttf", "droidserif", "bold italic"} + }; + const int n_mappings = 12; + int i = 0; + for (i=0; i