@@ -489,11 +489,14 @@ static int ctr_font_get_message_width(void* data, const char* msg,
489489 int delta_x = 0 ;
490490 const struct font_glyph * glyph_q = NULL ;
491491 ctr_font_t * font = (ctr_font_t * )data ;
492+ const struct font_glyph * (* get_glyph )(void * , uint32_t )
493+ = font -> font_driver -> get_glyph ;
494+ void * font_data = font -> font_data ;
492495
493496 if (!font )
494497 return 0 ;
495498
496- glyph_q = font -> font_driver -> get_glyph (font -> font_data , '?' );
499+ glyph_q = get_glyph (font_data , '?' );
497500
498501 for (i = 0 ; i < msg_len ; i ++ )
499502 {
@@ -507,8 +510,7 @@ static int ctr_font_get_message_width(void* data, const char* msg,
507510
508511
509512 /* Do something smarter here ... */
510- if (!(glyph =
511- font -> font_driver -> get_glyph (font -> font_data , code )))
513+ if (!(glyph = get_glyph (font_data , code )))
512514 if (!(glyph = glyph_q ))
513515 continue ;
514516
@@ -539,6 +541,9 @@ static void ctr_font_render_line(
539541 int delta_y = 0 ;
540542 int x = roundf (pos_x * width );
541543 int y = roundf ((1.0f - pos_y ) * height );
544+ const struct font_glyph * (* get_glyph )(void * , uint32_t )
545+ = font -> font_driver -> get_glyph ;
546+ void * font_data = font -> font_data ;
542547
543548 /* For right/center alignment, compute width with a lightweight pass
544549 * that only accumulates advance_x — avoids the redundant glyph lookups
@@ -552,7 +557,7 @@ static void ctr_font_render_line(
552557 {
553558 const struct font_glyph * glyph ;
554559 uint32_t code = utf8_walk (& scan );
555- if (!(glyph = font -> font_driver -> get_glyph (font -> font_data , code )))
560+ if (!(glyph = get_glyph (font_data , code )))
556561 if (!(glyph = glyph_q ))
557562 continue ;
558563 width_accum += glyph -> advance_x ;
@@ -581,8 +586,7 @@ static void ctr_font_render_line(
581586 i += skip - 1 ;
582587
583588 /* Do something smarter here ... */
584- if (!(glyph =
585- font -> font_driver -> get_glyph (font -> font_data , code )))
589+ if (!(glyph = get_glyph (font_data , code )))
586590 if (!(glyph = glyph_q ))
587591 continue ;
588592
@@ -679,9 +683,12 @@ static void ctr_font_render_message(
679683{
680684 float line_height ;
681685 struct font_line_metrics * line_metrics = NULL ;
682- const struct font_glyph * glyph_q = font -> font_driver -> get_glyph (font -> font_data , '?' );
686+ const struct font_glyph * (* get_glyph )(void * , uint32_t )
687+ = font -> font_driver -> get_glyph ;
688+ void * font_data = font -> font_data ;
689+ const struct font_glyph * glyph_q = get_glyph (font_data , '?' );
683690 int lines = 0 ;
684- font -> font_driver -> get_line_metrics (font -> font_data , & line_metrics );
691+ font -> font_driver -> get_line_metrics (font_data , & line_metrics );
685692 line_height = (float )line_metrics -> height * scale / (float )height ;
686693 for (;;)
687694 {
0 commit comments