From 27d55acdff0f6d0211b2d248092ae6a24c5cf059 Mon Sep 17 00:00:00 2001 From: David Haywood Date: Thu, 31 Mar 2016 16:42:01 +0100 Subject: [PATCH] =?UTF-8?q?borrow=20string=20processing=20code=20from=20ui?= =?UTF-8?q?.cpp=20so=20that=20=C2=A3=20works=20in=20layouts=20(using=20UTF?= =?UTF-8?q?-8=20encoding=20at=20least)=20[David=20Haywood]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updated sc4fd7tha.lay with UTF8 encoding of £ sign [Krick] --- src/emu/rendlay.cpp | 55 +++++++++++++++++++++++++++------- src/mame/layout/sc4fd7tha.lay | 56 +++++++++++++++++------------------ 2 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp index bca0afc9b25..ab3e3d5b889 100644 --- a/src/emu/rendlay.cpp +++ b/src/emu/rendlay.cpp @@ -942,11 +942,22 @@ void layout_element::component::draw_text(running_machine &machine, bitmap_argb3 bitmap_argb32 tempbitmap(dest.width(), dest.height()); // loop over characters - for (const char *s = m_string.c_str(); *s != 0; s++) + const char *origs = m_string.c_str(); + const char *ends = origs + strlen(origs); + const char *s = origs; + unicode_char schar; + + // loop over characters + while (*s != 0) { + int scharcount = uchar_from_utf8(&schar, s, ends - s); + + if (scharcount == -1) + break; + // get the font bitmap rectangle chbounds; - font->get_scaled_bitmap_and_bounds(tempbitmap, bounds.height(), aspect, *s, chbounds); + font->get_scaled_bitmap_and_bounds(tempbitmap, bounds.height(), aspect, schar, chbounds); // copy the data into the target for (int y = 0; y < chbounds.height(); y++) @@ -977,7 +988,8 @@ void layout_element::component::draw_text(running_machine &machine, bitmap_argb3 } // advance in the X direction - curx += font->char_width(bounds.height(), aspect, *s); + curx += font->char_width(bounds.height(), aspect, schar); + s += scharcount; } // free the temporary bitmap and font @@ -1100,12 +1112,22 @@ void layout_element::component::draw_reel(running_machine &machine, bitmap_argb3 // 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; + unicode_char schar; + // loop over characters - for (const char *s = m_stopnames[fruit].c_str(); *s != 0; s++) + while (*s != 0) { + int scharcount = uchar_from_utf8(&schar, s, ends - s); + + if (scharcount == -1) + break; + // get the font bitmap rectangle chbounds; - font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, *s, chbounds); + font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, schar, chbounds); // copy the data into the target for (int y = 0; y < chbounds.height(); y++) @@ -1137,8 +1159,8 @@ void layout_element::component::draw_reel(running_machine &machine, bitmap_argb3 } // advance in the X direction - curx += font->char_width(ourheight/num_shown, aspect, *s); - + curx += font->char_width(ourheight/num_shown, aspect, schar); + s += scharcount; } } @@ -1250,12 +1272,23 @@ void layout_element::component::draw_beltreel(running_machine &machine, bitmap_a // 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; + unicode_char schar; + // loop over characters - for (const char *s = m_stopnames[fruit].c_str(); *s != 0; s++) + while (*s != 0) { + int scharcount = uchar_from_utf8(&schar, s, ends - s); + + if (scharcount == -1) + break; + // get the font bitmap rectangle chbounds; - font->get_scaled_bitmap_and_bounds(tempbitmap, dest.height(), aspect, *s, chbounds); + font->get_scaled_bitmap_and_bounds(tempbitmap, dest.height(), aspect, schar, chbounds); // copy the data into the target for (int y = 0; y < chbounds.height(); y++) @@ -1287,8 +1320,8 @@ void layout_element::component::draw_beltreel(running_machine &machine, bitmap_a } // advance in the X direction - curx += font->char_width(dest.height(), aspect, *s); - + curx += font->char_width(dest.height(), aspect, schar); + s += scharcount; } } diff --git a/src/mame/layout/sc4fd7tha.lay b/src/mame/layout/sc4fd7tha.lay index 5fdf86c0d3a..83e7f1d3c8e 100644 --- a/src/mame/layout/sc4fd7tha.lay +++ b/src/mame/layout/sc4fd7tha.lay @@ -975,7 +975,7 @@ - + @@ -1001,7 +1001,7 @@ - + @@ -1027,7 +1027,7 @@ - + @@ -1053,7 +1053,7 @@ - + @@ -1079,7 +1079,7 @@ - + @@ -1105,7 +1105,7 @@ - + @@ -1131,7 +1131,7 @@ - + @@ -1157,7 +1157,7 @@ - + @@ -1183,7 +1183,7 @@ - + @@ -2923,7 +2923,7 @@ - + @@ -2955,7 +2955,7 @@ - + @@ -2987,7 +2987,7 @@ - + @@ -3019,7 +3019,7 @@ - + @@ -3051,7 +3051,7 @@ - + @@ -3083,7 +3083,7 @@ - + @@ -3953,7 +3953,7 @@ - + @@ -3979,7 +3979,7 @@ - + @@ -4005,7 +4005,7 @@ - + @@ -4031,7 +4031,7 @@ - + @@ -4057,7 +4057,7 @@ - + @@ -4083,7 +4083,7 @@ - + @@ -4109,7 +4109,7 @@ - + @@ -4135,7 +4135,7 @@ - + @@ -4161,7 +4161,7 @@ - + @@ -4187,7 +4187,7 @@ - + @@ -4213,7 +4213,7 @@ - + @@ -4239,7 +4239,7 @@ - + @@ -4529,7 +4529,7 @@ - +