summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/rendlay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/rendlay.cpp')
-rw-r--r--src/emu/rendlay.cpp49
1 files changed, 19 insertions, 30 deletions
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index 422b93e7268..50882d0d214 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -2295,7 +2295,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
auto font = machine.render().font_alloc("default");
- draw_text(*font, dest, bounds, m_string.c_str(), m_textalign, color(state));
+ draw_text(*font, dest, bounds, m_string, m_textalign, color(state));
}
private:
@@ -2985,7 +2985,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
auto font = machine.render().font_alloc("default");
- draw_text(*font, dest, bounds, string_format("%0*d", m_digits, state).c_str(), m_textalign, color(state));
+ draw_text(*font, dest, bounds, string_format("%0*d", m_digits, state), m_textalign, color(state));
}
private:
@@ -3137,18 +3137,13 @@ protected:
// allocate a temporary bitmap
bitmap_argb32 tempbitmap(dest.width(), dest.height());
- const char *origs = m_stopnames[fruit].c_str();
- const char *ends = origs + strlen(origs);
- const char *s = origs;
- char32_t schar;
-
// get the width of the string
float aspect = 1.0f;
s32 width;
while (1)
{
- width = font->string_width(ourheight / num_shown, aspect, m_stopnames[fruit].c_str());
+ width = font->string_width(ourheight / num_shown, aspect, m_stopnames[fruit]);
if (width < bounds.width())
break;
aspect *= 0.9f;
@@ -3157,9 +3152,11 @@ protected:
s32 curx = bounds.left() + (bounds.width() - width) / 2;
// loop over characters
- while (*s != 0)
+ std::string_view s = m_stopnames[fruit];
+ while (!s.empty())
{
- int scharcount = uchar_from_utf8(&schar, s, ends - s);
+ char32_t schar;
+ int scharcount = uchar_from_utf8(&schar, &s[0], s.length());
if (scharcount == -1)
break;
@@ -3199,7 +3196,7 @@ protected:
// advance in the X direction
curx += font->char_width(ourheight/num_shown, aspect, schar);
- s += scharcount;
+ s.remove_prefix(scharcount);
}
}
}
@@ -3294,7 +3291,7 @@ private:
s32 width;
while (1)
{
- width = font->string_width(dest.height(), aspect, m_stopnames[fruit].c_str());
+ width = font->string_width(dest.height(), aspect, m_stopnames[fruit]);
if (width < bounds.width())
break;
aspect *= 0.9f;
@@ -3305,15 +3302,12 @@ private:
// allocate a temporary bitmap
bitmap_argb32 tempbitmap(dest.width(), dest.height());
- const char *origs = m_stopnames[fruit].c_str();
- const char *ends = origs + strlen(origs);
- const char *s = origs;
- char32_t schar;
-
// loop over characters
- while (*s != 0)
+ std::string_view s = m_stopnames[fruit];
+ while (!s.empty())
{
- int scharcount = uchar_from_utf8(&schar, s, ends - s);
+ char32_t schar;
+ int scharcount = uchar_from_utf8(&schar, &s[0], s.length());
if (scharcount == -1)
break;
@@ -3353,7 +3347,7 @@ private:
// advance in the X direction
curx += font->char_width(dest.height(), aspect, schar);
- s += scharcount;
+ s.remove_prefix(scharcount);
}
}
}
@@ -3650,7 +3644,7 @@ void layout_element::component::draw_text(
render_font &font,
bitmap_argb32 &dest,
const rectangle &bounds,
- const char *str,
+ std::string_view str,
int align,
const render_color &color)
{
@@ -3696,15 +3690,10 @@ void layout_element::component::draw_text(
bitmap_argb32 tempbitmap(dest.width(), dest.height());
// loop over characters
- const char *origs = str;
- const char *ends = origs + strlen(origs);
- const char *s = origs;
- char32_t schar;
-
- // loop over characters
- while (*s != 0)
+ while (!str.empty())
{
- int scharcount = uchar_from_utf8(&schar, s, ends - s);
+ char32_t schar;
+ int scharcount = uchar_from_utf8(&schar, &str[0], str.length());
if (scharcount == -1)
break;
@@ -3743,7 +3732,7 @@ void layout_element::component::draw_text(
// advance in the X direction
curx += font.char_width(bounds.height(), aspect, schar);
- s += scharcount;
+ str.remove_prefix(scharcount);
}
}