game: text can now be bold

This commit is contained in:
Crypto City 2023-05-03 21:11:57 +00:00
parent 72a0e5f44c
commit 11f2809ae5
2 changed files with 5 additions and 3 deletions

2
external/tb vendored

@ -1 +1 @@
Subproject commit 9b526a3a926c97c7e7e76a4f3938bd6daceb62b7
Subproject commit 0cfb7ade5a7546c4f8fbd471b5bb471847bb7b61

View File

@ -160,6 +160,7 @@ struct font_t
{
TBFontDescription fd;
TBFontFace *font;
bool bold;
bool italic;
};
@ -170,6 +171,7 @@ uint_ptr tb_document_container::create_font(const tchar_t* faceName, int size, i
font->fd = fd;
font->fd.SetSize(size);
font->font = g_font_manager->CreateFontFace(font->fd);
font->bold = weight >= 700;
font->italic = italic == fontStyleItalic;
if (fm)
{
@ -190,14 +192,14 @@ void tb_document_container::delete_font(uint_ptr hFont)
int tb_document_container::text_width(const tchar_t* text, uint_ptr hFont)
{
font_t *font = (font_t*)hFont;
return font->font->GetStringWidth(text, TB_ALL_TO_TERMINATION, font->italic);
return font->font->GetStringWidth(text, TB_ALL_TO_TERMINATION, font->bold, font->italic);
}
void tb_document_container::draw_text(uint_ptr hdc, const tchar_t* text, uint_ptr hFont, web_color color, const position& pos)
{
font_t *font = (font_t*)hFont;
const uint32_t c = *(const uint32_t*)&color;
font->font->DrawString(pos.x, pos.y, c, c, font->italic, text);
font->font->DrawString(pos.x, pos.y, c, c, font->bold, font->italic, text);
}
int tb_document_container::pt_to_px(int pt) const