prefer to use FreeType for pango_cairo_font_map

This commit is contained in:
zdenop 2018-09-28 11:07:26 +02:00
parent 5fe1390748
commit 345e5ee1f3
2 changed files with 13 additions and 4 deletions

View File

@ -117,6 +117,14 @@ void PangoFontInfo::SoftInitFontConfig() {
} }
} }
PangoFontMap* PangoFontInfo::get_font_map() {
PangoFontMap* font_map =
pango_cairo_font_map_new_for_font_type(CAIRO_FONT_TYPE_FT);
if (!font_map) // cairo withtout support of Freetype?
font_map = pango_cairo_font_map_get_default();
return font_map;
}
// Re-initializes font config, whether or not already initialized. // Re-initializes font config, whether or not already initialized.
// If already initialized, any existing cache is deleted, just to be sure. // If already initialized, any existing cache is deleted, just to be sure.
/* static */ /* static */
@ -163,7 +171,7 @@ void PangoFontInfo::HardInitFontConfig(const std::string& fonts_dir,
static void ListFontFamilies(PangoFontFamily*** families, static void ListFontFamilies(PangoFontFamily*** families,
int* n_families) { int* n_families) {
PangoFontInfo::SoftInitFontConfig(); PangoFontInfo::SoftInitFontConfig();
PangoFontMap* font_map = pango_cairo_font_map_get_default(); PangoFontMap* font_map = PangoFontInfo::get_font_map();
DISABLE_HEAP_LEAK_CHECK; DISABLE_HEAP_LEAK_CHECK;
pango_font_map_list_families(font_map, families, n_families); pango_font_map_list_families(font_map, families, n_families);
} }
@ -202,7 +210,7 @@ bool PangoFontInfo::ParseFontDescriptionName(const std::string& name) {
// correspond to a completely different font family and face. // correspond to a completely different font family and face.
PangoFont* PangoFontInfo::ToPangoFont() const { PangoFont* PangoFontInfo::ToPangoFont() const {
SoftInitFontConfig(); SoftInitFontConfig();
PangoFontMap* font_map = pango_cairo_font_map_get_default(); PangoFontMap* font_map = PangoFontInfo::get_font_map();
PangoContext* context = pango_context_new(); PangoContext* context = pango_context_new();
pango_cairo_context_set_resolution(context, resolution_); pango_cairo_context_set_resolution(context, resolution_);
pango_context_set_font_map(context, font_map); pango_context_set_font_map(context, font_map);
@ -359,7 +367,7 @@ bool PangoFontInfo::CanRenderString(const char* utf8_word, int len,
// when there is an illegal grapheme sequence. // when there is an illegal grapheme sequence.
const char32 kDottedCircleGlyph = 9676; const char32 kDottedCircleGlyph = 9676;
bool bad_glyph = false; bool bad_glyph = false;
PangoFontMap* font_map = pango_cairo_font_map_get_default(); PangoFontMap* font_map = PangoFontInfo::get_font_map();
PangoContext* context = pango_context_new(); PangoContext* context = pango_context_new();
pango_context_set_font_map(context, font_map); pango_context_set_font_map(context, font_map);
PangoLayout* layout; PangoLayout* layout;
@ -483,7 +491,7 @@ bool FontUtils::IsAvailableFont(const char* input_query_desc,
PangoFont* selected_font = nullptr; PangoFont* selected_font = nullptr;
{ {
PangoFontInfo::SoftInitFontConfig(); PangoFontInfo::SoftInitFontConfig();
PangoFontMap* font_map = pango_cairo_font_map_get_default(); PangoFontMap* font_map = PangoFontInfo::get_font_map();
PangoContext* context = pango_context_new(); PangoContext* context = pango_context_new();
pango_context_set_font_map(context, font_map); pango_context_set_font_map(context, font_map);
{ {

View File

@ -94,6 +94,7 @@ class PangoFontInfo {
// environment variable and creating a fonts.conf file that points to the // environment variable and creating a fonts.conf file that points to the
// FLAGS_fonts_dir and the cache to FLAGS_fontconfig_tmpdir. // FLAGS_fonts_dir and the cache to FLAGS_fontconfig_tmpdir.
static void SoftInitFontConfig(); static void SoftInitFontConfig();
static PangoFontMap* get_font_map();
// Re-initializes font config, whether or not already initialized. // Re-initializes font config, whether or not already initialized.
// If already initialized, any existing cache is deleted, just to be sure. // If already initialized, any existing cache is deleted, just to be sure.
static void HardInitFontConfig(const std::string& fonts_dir, static void HardInitFontConfig(const std::string& fonts_dir,