From 613cf37150bd6d18c5026e19014faceed5b155c9 Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 5 Jun 2020 21:02:09 +0300 Subject: [PATCH] ensure, that opengl font glyph height >= width to prevent overruns --- libs/gtkutil/glfont.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/gtkutil/glfont.cpp b/libs/gtkutil/glfont.cpp index 85f54017..c2787f29 100644 --- a/libs/gtkutil/glfont.cpp +++ b/libs/gtkutil/glfont.cpp @@ -809,7 +809,8 @@ GLFont *glfont_create( const char* font_string ){ pango_layout_set_text( layout, reinterpret_cast( &c ), 1 ); pango_layout_get_extents( layout, NULL, &log_rect ); - if ( log_rect.width > 0 && log_rect.height > 0 ) { + if ( log_rect.width > 0 && log_rect.height > 0 + && PANGO_PIXELS_CEIL( log_rect.width ) <= font_height ) { // ensure, that height >= width bitmap.rows = PANGO_PIXELS_CEIL( log_rect.height ); bitmap.width = PANGO_PIXELS_CEIL( log_rect.width ); bitmap.pitch = bitmap.width; @@ -865,6 +866,8 @@ GLFont *glfont_create( const char* font_string ){ glPixelStorei( GL_UNPACK_ALIGNMENT, alignment ); + GlobalOpenGL_debugAssertNoErrors(); + g_object_unref( G_OBJECT( layout ) ); }