diff options
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/FontFactory.cpp | 32 | ||||
| -rw-r--r-- | src/libnrtype/FontFactory.h | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 95537734d..2b1087eec 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -949,6 +949,38 @@ void font_factory::AddFontsDir(char const *utf8dir) #endif } +void font_factory::AddFontFile(char const *utf8file) +{ +#ifdef USE_PANGO_WIN32 + g_info("Adding additional font only supported for fontconfig backend."); +#else + if (!Inkscape::IO::file_test(utf8file, G_FILE_TEST_IS_REGULAR)) { + g_warning("Font file '%s' does not exist and will be ignored.", utf8file); + return; + } + + gchar *file; +# ifdef WIN32 + file = g_win32_locale_filename_from_utf8(utf8file); +# else + file = g_filename_from_utf8(utf8file, -1, NULL, NULL, NULL); +# endif + + FcConfig *conf = NULL; +# if PANGO_VERSION_CHECK(1,38,0) + pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer)); +# endif + FcBool res = FcConfigAppFontAddFile(conf, (FcChar8 const *)file); + if (res = FcTrue) { + g_info("Font file '%s' added successfully.", utf8file); + } else { + g_warning("Could not add font file '%s'.", utf8file); + } + + g_free(file); +#endif +} + /* Local Variables: mode:c++ diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index c273be2f4..12260f99a 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -139,6 +139,9 @@ public: /// Add a directory from which to include additional fonts void AddFontsDir(char const *utf8dir); + /// Add a an additional font. + void AddFontFile(char const *utf8file); + private: void* loadedPtr; |
