diff --git a/common/font/outline_font.cpp b/common/font/outline_font.cpp index 3ec4dcf877..638baab88a 100644 --- a/common/font/outline_font.cpp +++ b/common/font/outline_font.cpp @@ -335,6 +335,8 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphs( BOX2I* aBBox, std::vector guard( m_freeTypeMutex ); FT_Face face = m_face; double scaler = faceSize(); @@ -562,6 +564,9 @@ void OUTLINE_FONT::RenderToOpenGLCanvas( KIGFX::OPENGL_GAL& aGal, const wxString unsigned int glyphCount; hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( buf, &glyphCount ); hb_glyph_position_t* glyphPos = hb_buffer_get_glyph_positions( buf, &glyphCount ); + + std::lock_guard guard( m_freeTypeMutex ); + hb_font_t* referencedFont = hb_ft_font_create_referenced( m_face ); hb_ft_font_set_funcs( referencedFont ); diff --git a/include/font/outline_font.h b/include/font/outline_font.h index 82af25ec34..0ccf703920 100644 --- a/include/font/outline_font.h +++ b/include/font/outline_font.h @@ -137,9 +137,14 @@ protected: private: // FreeType variables + + /** + * Mutex for freetype access, FT_Library and FT_Face are not thread safe + */ static std::mutex m_freeTypeMutex; static FT_Library m_freeType; FT_Face m_face; + const int m_faceSize; bool m_fakeBold; bool m_fakeItal;