diff options
author | 2016-03-31 16:42:01 +0100 | |
---|---|---|
committer | 2016-03-31 16:42:01 +0100 | |
commit | 27d55acdff0f6d0211b2d248092ae6a24c5cf059 (patch) | |
tree | 22410adfb5f3ff016b95f2d94b375ce61fea3dec /src | |
parent | ad04466a33984184f36deeac174d8d6cd3682420 (diff) |
borrow string processing code from ui.cpp so that £ works in layouts (using UTF-8 encoding at least) [David Haywood]
updated sc4fd7tha.lay with UTF8 encoding of £ sign [Krick]
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/rendlay.cpp | 55 | ||||
-rw-r--r-- | 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 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$1"> + <text string="£1"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -1001,7 +1001,7 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$1.60"> + <text string="£1.60"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -1027,7 +1027,7 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$2"> + <text string="£2"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -1053,7 +1053,7 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$2.40"> + <text string="£2.40"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -1079,7 +1079,7 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$3"> + <text string="£3"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -1105,7 +1105,7 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$4"> + <text string="£4"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -1131,7 +1131,7 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$5"> + <text string="£5"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -1157,7 +1157,7 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$6"> + <text string="£6"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -1183,7 +1183,7 @@ <color red="0.00" green="0.13" blue="0.00"> </color> </rect> - <text string="$8"> + <text string="£8"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -2923,7 +2923,7 @@ <bounds x="0.05" y="0.05" width="0.90" height="0.45"> </bounds> </text> - <text string="$4"> + <text string="£4"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.50" width="0.90" height="0.45"> @@ -2955,7 +2955,7 @@ <bounds x="0.05" y="0.05" width="0.90" height="0.45"> </bounds> </text> - <text string="$3"> + <text string="£3"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.50" width="0.90" height="0.45"> @@ -2987,7 +2987,7 @@ <bounds x="0.05" y="0.05" width="0.90" height="0.45"> </bounds> </text> - <text string="$2"> + <text string="£2"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.50" width="0.90" height="0.45"> @@ -3019,7 +3019,7 @@ <bounds x="0.05" y="0.05" width="0.90" height="0.45"> </bounds> </text> - <text string="$1"> + <text string="£1"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.50" width="0.90" height="0.45"> @@ -3051,7 +3051,7 @@ <bounds x="0.05" y="0.05" width="0.90" height="0.45"> </bounds> </text> - <text string="$8"> + <text string="£8"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.50" width="0.90" height="0.45"> @@ -3083,7 +3083,7 @@ <bounds x="0.05" y="0.05" width="0.90" height="0.45"> </bounds> </text> - <text string="$6"> + <text string="£6"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.50" width="0.90" height="0.45"> @@ -3953,7 +3953,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$1"> + <text string="£1"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -3979,7 +3979,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$1.20"> + <text string="£1.20"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4005,7 +4005,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$1.60"> + <text string="£1.60"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4031,7 +4031,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$2"> + <text string="£2"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4057,7 +4057,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$2.40"> + <text string="£2.40"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4083,7 +4083,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$3"> + <text string="£3"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4109,7 +4109,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$3.60"> + <text string="£3.60"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4135,7 +4135,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$4"> + <text string="£4"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4161,7 +4161,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$8"> + <text string="£8"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4187,7 +4187,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$7"> + <text string="£7"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4213,7 +4213,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$6"> + <text string="£6"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4239,7 +4239,7 @@ <color red="0.13" green="0.00" blue="0.06"> </color> </rect> - <text string="$5"> + <text string="£5"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> @@ -4529,7 +4529,7 @@ <color red="0.00" green="0.25" blue="0.00"> </color> </rect> - <text string="$1"> + <text string="£1"> <color red="0.0" green="0.0" blue="0.0"> </color> <bounds x="0.05" y="0.05" width="0.90" height="0.90"> |