From 32f926c360ffad8071cf3a7866907ec2a8153771 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 19 Feb 2021 15:03:21 +0100 Subject: Remove use of static global var gl_fontsize inside virtual member Fl_Gl_Window_Driver::alpha_mask_for_string() --- src/gl_draw.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/gl_draw.cxx') diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index 234edf275..043d1c1f3 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -412,7 +412,8 @@ int gl_texture_fifo::compute_texture(const char* str, int n) fifo[current].scale = Fl_Gl_Window_Driver::gl_scale; fifo[current].fdesc = gl_fontsize; - char *alpha_buf = Fl_Gl_Window_Driver::global()->alpha_mask_for_string(str, n, w, h); + Fl_Fontsize fs = Fl_Gl_Window_Driver::global()->effective_size(); + char *alpha_buf = Fl_Gl_Window_Driver::global()->alpha_mask_for_string(str, n, w, h, fs); // save GL parameters GL_UNPACK_ROW_LENGTH and GL_UNPACK_ALIGNMENT GLint row_length, alignment; @@ -496,8 +497,11 @@ void Fl_Gl_Window_Driver::draw_string_with_texture(const char* str, int n) gl_fifo->display_texture(index); } +Fl_Fontsize Fl_Gl_Window_Driver::effective_size() { + return fl_graphics_driver->font_descriptor()->size; +} -char *Fl_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, int h) +char *Fl_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs) { // write str to a bitmap that is just big enough // create an Fl_Image_Surface object @@ -511,7 +515,7 @@ char *Fl_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, // set up the text colour as white, which we will interpret as opaque fl_color(255,255,255); // Fix the font scaling - fl_font (fnt, gl_fontsize->size); // resize "fltk" font to current GL view scaling + fl_font (fnt, fs); // resize "fltk" font to current GL view scaling int desc = fl_descent(); // Render the text to the buffer fl_draw(str, n, 0, h - desc); -- cgit v1.2.3