mirror of
https://github.com/holub/mame
synced 2025-10-06 17:08:28 +03:00
attempt to fix hap issue (nw)
This commit is contained in:
parent
27d55acdff
commit
c53833d1e4
@ -416,8 +416,19 @@ float render_font::string_width(float height, float aspect, const char *string)
|
|||||||
{
|
{
|
||||||
// loop over the string and accumulate widths
|
// loop over the string and accumulate widths
|
||||||
int totwidth = 0;
|
int totwidth = 0;
|
||||||
for (const unsigned char *ptr = (const unsigned char *)string; *ptr != 0; ptr++)
|
|
||||||
totwidth += get_char(*ptr).width;
|
const char *ends = string + strlen(string);
|
||||||
|
const char *s = string;
|
||||||
|
unicode_char schar;
|
||||||
|
|
||||||
|
// loop over characters
|
||||||
|
while (*s != 0)
|
||||||
|
{
|
||||||
|
int scharcount = uchar_from_utf8(&schar, s, ends - s);
|
||||||
|
totwidth += get_char(schar).width;
|
||||||
|
s += scharcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// scale the final result based on height
|
// scale the final result based on height
|
||||||
return float(totwidth) * m_scale * height * aspect;
|
return float(totwidth) * m_scale * height * aspect;
|
||||||
|
Loading…
Reference in New Issue
Block a user