[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).
This commit is contained in:
Bill Currie 2022-12-08 16:57:45 +09:00
parent 95f55dfc34
commit 5fd510ade4
4 changed files with 6 additions and 1 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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;
}

View File

@ -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;