Use AddFontResource Win32api call on windows to load fonts...

...from fonts/ dir since fontconfig doesn't affect cairo's win32 font
backend.
This commit is contained in:
Sergey Popov 2008-11-17 11:39:33 +00:00
parent 04c473bd5f
commit ebd51fe737
2 changed files with 29 additions and 0 deletions

View file

@ -25,12 +25,18 @@
#include "serialization/parser.hpp"
#include "serialization/preprocessor.hpp"
#include "marked-up_text.hpp"
#include "foreach.hpp"
#include <list>
#include <set>
#include <stack>
#include <fontconfig/fontconfig.h>
#include <cairo-features.h>
#ifdef CAIRO_HAS_WIN32_FONT
#include <windows.h>
#endif
#define DBG_FT LOG_STREAM(debug, display)
#define LOG_FT LOG_STREAM(info, display)
@ -288,6 +294,17 @@ manager::manager()
ERR_FT << "Could not load the true type fonts\n";
throw error();
}
#if CAIRO_HAS_WIN32_FONT
foreach(const std::string& path, get_binary_paths("fonts")) {
std::vector<std::string> files;
get_files_in_dir(path, &files, NULL, ENTIRE_FILE_PATH);
foreach(const std::string& file, files)
if(file.substr(file.length() - 4) == ".ttf")
AddFontResource(file.c_str());
}
#endif
}
manager::~manager()
@ -296,6 +313,16 @@ manager::~manager()
clear_fonts();
TTF_Quit();
#if CAIRO_HAS_WIN32_FONT
foreach(const std::string& path, get_binary_paths("fonts")) {
std::vector<std::string> files;
get_files_in_dir(path, &files, NULL, ENTIRE_FILE_PATH);
foreach(const std::string& file, files)
if(file.substr(file.length() - 4) == ".ttf")
RemoveFontResource(file.c_str());
}
#endif
}
//structure used to describe a font, and the subset of the Unicode character

View file

@ -469,6 +469,8 @@ void ttext::rerender(const bool force) const
// Draw twice otherwise we have some problems due to transparency
// we overcome the problem with drawing twice which is a kind of hack.
pango_cairo_show_layout(cr, layout_);
// On Windows drawing twice is not enough.
pango_cairo_show_layout(cr, layout_);
surface_.assign(SDL_CreateRGBSurfaceFrom(
surface_buffer_, width, height, 32, stride,