@@ -905,6 +905,8 @@ static void *gl2_raster_font_init(void *data,
905905static int gl2_raster_font_get_message_width (void * data , const char * msg ,
906906 size_t msg_len , float scale )
907907{
908+ void * font_data ;
909+ const struct font_glyph * (* get_glyph )(void * , uint32_t );
908910 const struct font_glyph * glyph_q = NULL ;
909911 gl2_raster_t * font = (gl2_raster_t * )data ;
910912 const char * msg_end = msg + msg_len ;
@@ -915,16 +917,17 @@ static int gl2_raster_font_get_message_width(void *data, const char *msg,
915917 || !font -> font_data )
916918 return 0 ;
917919
918- glyph_q = font -> font_driver -> get_glyph (font -> font_data , '?' );
920+ get_glyph = font -> font_driver -> get_glyph ;
921+ font_data = font -> font_data ;
922+ glyph_q = get_glyph (font_data , '?' );
919923
920924 while (msg < msg_end )
921925 {
922926 const struct font_glyph * glyph ;
923927 unsigned code = utf8_walk (& msg );
924928
925929 /* Do something smarter here ... */
926- if (!(glyph = font -> font_driver -> get_glyph (
927- font -> font_data , code )))
930+ if (!(glyph = get_glyph (font_data , code )))
928931 if (!(glyph = glyph_q ))
929932 continue ;
930933
@@ -975,6 +978,8 @@ static void gl2_raster_font_render_line(gl2_t *gl,
975978 float inv_tex_size_y = 1.0f / font -> tex_height ;
976979 float inv_win_width = 1.0f / gl -> vp .width ;
977980 float inv_win_height = 1.0f / gl -> vp .height ;
981+ const struct font_glyph * (* get_glyph )(void * , uint32_t ) = font -> font_driver -> get_glyph ;
982+ void * font_data = font -> font_data ;
978983
979984 /* For right/center alignment, compute width with a lightweight pass
980985 * that only accumulates advance_x — avoids the redundant glyph lookups
@@ -989,7 +994,7 @@ static void gl2_raster_font_render_line(gl2_t *gl,
989994 {
990995 const struct font_glyph * glyph ;
991996 uint32_t code = utf8_walk (& scan );
992- if (!(glyph = font -> font_driver -> get_glyph (font -> font_data , code )))
997+ if (!(glyph = get_glyph (font_data , code )))
993998 if (!(glyph = glyph_q ))
994999 continue ;
9951000 width_accum += glyph -> advance_x ;
@@ -1001,7 +1006,7 @@ static void gl2_raster_font_render_line(gl2_t *gl,
10011006 x -= (int )(width_accum * scale ) / 2 ;
10021007 }
10031008
1004- glyph_q = font -> font_driver -> get_glyph (font -> font_data , '?' );
1009+ glyph_q = get_glyph (font_data , '?' );
10051010
10061011 while (msg < msg_end )
10071012 {
@@ -1013,8 +1018,7 @@ static void gl2_raster_font_render_line(gl2_t *gl,
10131018 unsigned code = utf8_walk (& msg );
10141019
10151020 /* Do something smarter here ... */
1016- if (!(glyph = font -> font_driver -> get_glyph (
1017- font -> font_data , code )))
1021+ if (!(glyph = get_glyph (font_data , code )))
10181022 if (!(glyph = glyph_q ))
10191023 continue ;
10201024
0 commit comments