Skip to content

Commit

Permalink
Fix type cast from PangoFont to PangoFcFont
Browse files Browse the repository at this point in the history
The original code crashes in pango_fc_font_get_glyph on MacOS with M1.

Replacing the type cast with the macro made for that conversion
gives at least an error message before crashing:

    (process:12546): GLib-GObject-WARNING **: 08:38:02.472: invalid cast from 'PangoCairoCoreTextFont' to 'PangoFcFont'
    zsh: segmentation fault  ./pango_font_info_test

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Dec 22, 2020
1 parent e75b217 commit 8c859a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/training/pango_font_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ bool PangoFontInfo::GetSpacingProperties(const std::string& utf8_char,
utf8_char.length());
for (UNICHAR::const_iterator it = it_begin; it != it_end; ++it) {
PangoGlyph glyph_index = pango_fc_font_get_glyph(
reinterpret_cast<PangoFcFont*>(font), *it);
PANGO_FC_FONT(font), *it);
if (!glyph_index) {
// Glyph for given unicode character doesn't exist in font.
g_object_unref(font);
Expand Down Expand Up @@ -409,7 +409,7 @@ bool PangoFontInfo::CanRenderString(const char* utf8_word, int len,
dotted_circle_glyph = glyphs->glyphs[0].glyph;
#else // TODO: Do we need separate solution for non win build?
dotted_circle_glyph = pango_fc_font_get_glyph(
reinterpret_cast<PangoFcFont*>(font), kDottedCircleGlyph);
PANGO_FC_FONT(font), kDottedCircleGlyph);
#endif

if (TLOG_IS_ON(2)) {
Expand Down

0 comments on commit 8c859a7

Please sign in to comment.