From 5fd510ade496b8ff2bb8c62090d961de63d831b0 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 8 Dec 2022 16:57:45 +0900 Subject: [PATCH] [ui] Add font to renderer when loading This causes some problems with linking if libQFgui is linked with libQFrenderer (which is necessary in the long run), but it seems everything gets away with it for now (which, tbh, I don't like). --- include/QF/ui/font.h | 1 + libs/ruamoko/rua_gui.c | 2 +- libs/ui/font.c | 3 +++ libs/ui/text.c | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/QF/ui/font.h b/include/QF/ui/font.h index ab526a8ab..6ea183d6d 100644 --- a/include/QF/ui/font.h +++ b/include/QF/ui/font.h @@ -51,6 +51,7 @@ typedef struct font_s { FT_Long num_glyphs; vrect_t *glyph_rects; vec2i_t *glyph_bearings; + uint32_t fontid; } font_t; void Font_Init (void); diff --git a/libs/ruamoko/rua_gui.c b/libs/ruamoko/rua_gui.c index b9ef12e2f..95a25be51 100644 --- a/libs/ruamoko/rua_gui.c +++ b/libs/ruamoko/rua_gui.c @@ -60,7 +60,7 @@ bi (Font_Load) QFile *font_file = QFS_FOpenFile (font_path); font_t *font = Font_Load (font_file, font_size); - R_INT (pr) = r_funcs->Draw_AddFont (font); + R_INT (pr) = font->fontid; } bi (Font_String) diff --git a/libs/ui/font.c b/libs/ui/font.c index 29e6704f0..afb293670 100644 --- a/libs/ui/font.c +++ b/libs/ui/font.c @@ -36,6 +36,8 @@ #include "QF/sys.h" #include "QF/math/bitop.h" +#include "QF/plugin/vid_render.h" + #include "QF/ui/font.h" #include "compat.h" @@ -131,6 +133,7 @@ Font_Load (QFile *font_file, int size) copy_glyph (rect, slot, font); } + font->fontid = r_funcs->Draw_AddFont (font); return font; } diff --git a/libs/ui/text.c b/libs/ui/text.c index 5b65a64ea..0177f38d4 100644 --- a/libs/ui/text.c +++ b/libs/ui/text.c @@ -165,6 +165,7 @@ Text_View (font_t *font, passage_t *passage) .glyphid = glyphid, .x = xp + bearing[0], .y = yp - bearing[1], + .fontid = font->fontid, }; x += xa; y += ya;