File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1356,6 +1356,8 @@ Displays text on the HUD.
1356
1356
text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
1357
1357
* `alignment`: The alignment of the text.
1358
1358
* `offset`: offset in pixels from position.
1359
+ * `size`: size of the text.
1360
+ The player-set font size is multiplied by size.x (y value isn't used).
1359
1361
1360
1362
### `statbar`
1361
1363
Original file line number Diff line number Diff line change @@ -319,16 +319,21 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
319
319
floor (e->pos .Y * (float ) m_screensize.Y + 0.5 ));
320
320
switch (e->type ) {
321
321
case HUD_ELEM_TEXT: {
322
+ irr::gui::IGUIFont *textfont = font;
323
+ if (e->size .X > 0 )
324
+ textfont = g_fontengine->getFont (
325
+ e->size .X * g_fontengine->getDefaultFontSize ());
326
+
322
327
video::SColor color (255 , (e->number >> 16 ) & 0xFF ,
323
328
(e->number >> 8 ) & 0xFF ,
324
329
(e->number >> 0 ) & 0xFF );
325
330
core::rect<s32> size (0 , 0 , e->scale .X , text_height * e->scale .Y );
326
331
std::wstring text = unescape_translate (utf8_to_wide (e->text ));
327
- core::dimension2d<u32> textsize = font ->getDimension (text.c_str ());
332
+ core::dimension2d<u32> textsize = textfont ->getDimension (text.c_str ());
328
333
v2s32 offset ((e->align .X - 1.0 ) * (textsize.Width / 2 ),
329
334
(e->align .Y - 1.0 ) * (textsize.Height / 2 ));
330
335
v2s32 offs (e->offset .X , e->offset .Y );
331
- font ->draw (text.c_str (), size + pos + offset + offs, color);
336
+ textfont ->draw (text.c_str (), size + pos + offset + offs, color);
332
337
break ; }
333
338
case HUD_ELEM_STATBAR: {
334
339
v2s32 offs (e->offset .X , e->offset .Y );
You can’t perform that action at this time.
0 commit comments