ensure, that opengl font glyph height >= width to prevent overruns

This commit is contained in:
Garux 2020-06-05 21:02:09 +03:00
parent e357564ff8
commit 613cf37150

View File

@ -809,7 +809,8 @@ GLFont *glfont_create( const char* font_string ){
pango_layout_set_text( layout, reinterpret_cast<const char*>( &c ), 1 ); pango_layout_set_text( layout, reinterpret_cast<const char*>( &c ), 1 );
pango_layout_get_extents( layout, NULL, &log_rect ); 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.rows = PANGO_PIXELS_CEIL( log_rect.height );
bitmap.width = PANGO_PIXELS_CEIL( log_rect.width ); bitmap.width = PANGO_PIXELS_CEIL( log_rect.width );
bitmap.pitch = bitmap.width; bitmap.pitch = bitmap.width;
@ -865,6 +866,8 @@ GLFont *glfont_create( const char* font_string ){
glPixelStorei( GL_UNPACK_ALIGNMENT, alignment ); glPixelStorei( GL_UNPACK_ALIGNMENT, alignment );
GlobalOpenGL_debugAssertNoErrors();
g_object_unref( G_OBJECT( layout ) ); g_object_unref( G_OBJECT( layout ) );
} }