From 5cbc697f234011070bcba2b199348686fd21ed16 Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Fri, 14 Aug 2026 10:48:07 -0700 Subject: [PATCH] parts: use bold width for text layout Fixes the remaining issues with item descriptions in Rance 9. --- src/hll/StoatSpriteEngine.c | 2 +- src/parts/text.c | 3 ++- src/text.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hll/StoatSpriteEngine.c b/src/hll/StoatSpriteEngine.c index 11e92e6..5380861 100644 --- a/src/hll/StoatSpriteEngine.c +++ b/src/hll/StoatSpriteEngine.c @@ -146,7 +146,7 @@ void StoatSpriteEngine_SP_SetTextSpriteColor(int r, int g, int b) void StoatSpriteEngine_SP_SetTextSpriteBoldWeight(float weight) { - //NOTICE("StoatSpriteEngine.SP_SetTextSpriteBoldWeight(%f)", weight); + text_sprite_ts.bold_width = weight; } void StoatSpriteEngine_SP_SetTextSpriteEdgeWeight(float weight) diff --git a/src/parts/text.c b/src/parts/text.c index 4325cd6..57bff27 100644 --- a/src/parts/text.c +++ b/src/parts/text.c @@ -90,7 +90,7 @@ static const char *parts_text_append_char(struct parts_text *t, const char *str) ch->advance = gfx_render_textf(&ch->t, 0, 0, ch->ch, &t->ts, false); line->width += ch->advance; - line->height = max(line->height, height); + line->height = max(line->height, height + ceilf(t->ts.bold_width)*2); return str + len; } @@ -205,6 +205,7 @@ bool PE_SetFont(int parts_no, int type, int size, int r, int g, int b, float bol text->ts.weight = bold_weight * 1000; text->ts.edge_color = (SDL_Color) { edge_r, edge_g, edge_b, 255 }; text_style_set_edge_width(&text->ts, edge_weight); + text->ts.bold_width = bold_weight; parts_text_rerender(parts, text); return true; } diff --git a/src/text.c b/src/text.c index 61ba99a..6ea9141 100644 --- a/src/text.c +++ b/src/text.c @@ -174,7 +174,7 @@ float gfx_size_text(struct text_style *ts, const char *text) { struct font_size *size = text_style_font_size(ts); float edge_advance = gfx_text_advance_edges - ? ts->edge_left + ts->edge_right + ceilf(ts->bold_width) + ? ts->edge_left + ts->edge_right + ceilf(ts->bold_width)*2 : 0.0f; float x = 0.0f; while (*text) {