mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
quick fixes to some more stuff that isn't supplementary plane clean
This commit is contained in:
parent
938371b64f
commit
ae0e3fbf57
@ -18,6 +18,10 @@
|
||||
|
||||
#include "ui/cmdrender.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
const UINT64 render_font::CACHED_BDF_HASH_SIZE;
|
||||
|
||||
//**************************************************************************
|
||||
@ -55,6 +59,8 @@ inline render_font::glyph &render_font::get_char(unicode_char chnum)
|
||||
static glyph dummy_glyph;
|
||||
|
||||
// grab the table; if none, return the dummy character
|
||||
if ((chnum / 256) >= ARRAY_LENGTH(m_glyphs))
|
||||
return dummy_glyph;
|
||||
if (!m_glyphs[chnum / 256] && m_format == FF_OSD)
|
||||
m_glyphs[chnum / 256] = new glyph[256];
|
||||
if (!m_glyphs[chnum / 256])
|
||||
@ -444,18 +450,18 @@ float render_font::string_width(float height, float aspect, const char *string)
|
||||
|
||||
float render_font::utf8string_width(float height, float aspect, const char *utf8string)
|
||||
{
|
||||
int length = strlen(utf8string);
|
||||
std::size_t const length = std::strlen(utf8string);
|
||||
|
||||
// loop over the string and accumulate widths
|
||||
int count;
|
||||
int totwidth = 0;
|
||||
for (int offset = 0; offset < length; offset += count)
|
||||
INT32 totwidth = 0;
|
||||
for (std::size_t offset = 0U; offset < length; offset += unsigned(count))
|
||||
{
|
||||
unicode_char uchar;
|
||||
count = uchar_from_utf8(&uchar, utf8string + offset, length - offset);
|
||||
if (count == -1)
|
||||
if (count < 0)
|
||||
break;
|
||||
if (uchar < 0x10000)
|
||||
|
||||
totwidth += get_char(uchar).width;
|
||||
}
|
||||
|
||||
@ -617,7 +623,7 @@ bool render_font::load_bdf()
|
||||
}
|
||||
|
||||
// if we have everything, allocate a new character
|
||||
if (charnum >= 0 && charnum < 65536 && rawdata != nullptr && bmwidth >= 0 && bmheight >= 0)
|
||||
if (charnum >= 0 && charnum < (256 * ARRAY_LENGTH(m_glyphs)) && rawdata != nullptr && bmwidth >= 0 && bmheight >= 0)
|
||||
{
|
||||
// if we don't have a subtable yet, make one
|
||||
if (!m_glyphs[charnum / 256])
|
||||
@ -741,7 +747,7 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
|
||||
|
||||
// determine the number of characters
|
||||
int numchars = 0;
|
||||
for (int chnum = 0; chnum < 65536; chnum++)
|
||||
for (int chnum = 0; chnum < (256 * ARRAY_LENGTH(m_glyphs)); chnum++)
|
||||
{
|
||||
if (m_glyphs[chnum / 256])
|
||||
{
|
||||
@ -789,7 +795,7 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
|
||||
|
||||
// loop over all characters
|
||||
int tableindex = 0;
|
||||
for (int chnum = 0; chnum < 65536; chnum++)
|
||||
for (int chnum = 0; chnum < (256 * ARRAY_LENGTH(m_glyphs)); chnum++)
|
||||
{
|
||||
glyph &gl = get_char(chnum);
|
||||
if (gl.width > 0)
|
||||
|
@ -96,14 +96,14 @@ private:
|
||||
int m_height; // height of the font, from ascent to descent
|
||||
int m_yoffs; // y offset from baseline to descent
|
||||
float m_scale; // 1 / height precomputed
|
||||
glyph *m_glyphs[256]; // array of glyph subtables
|
||||
glyph *m_glyphs[17*256]; // array of glyph subtables
|
||||
std::vector<char> m_rawdata; // pointer to the raw data for the font
|
||||
UINT64 m_rawsize; // size of the raw font data
|
||||
std::unique_ptr<osd_font> m_osdfont; // handle to the OSD font
|
||||
|
||||
int m_height_cmd; // height of the font, from ascent to descent
|
||||
int m_yoffs_cmd; // y offset from baseline to descent
|
||||
glyph *m_glyphs_cmd[256]; // array of glyph subtables
|
||||
EQUIVALENT_ARRAY(m_glyphs, glyph *) m_glyphs_cmd; // array of glyph subtables
|
||||
std::vector<char> m_rawdata_cmd; // pointer to the raw data for the font
|
||||
|
||||
// constants
|
||||
|
@ -53,7 +53,6 @@ menu::global_state_ptr menu::get_global_state(running_machine &machine)
|
||||
std::lock_guard<std::mutex> guard(s_global_state_guard);
|
||||
auto const it(s_global_states.find(&machine));
|
||||
return (it != s_global_states.end()) ? it->second : global_state_ptr();
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
@ -12,6 +12,10 @@
|
||||
#include "rendfont.h"
|
||||
#include "render.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
namespace ui {
|
||||
/***************************************************************************
|
||||
INLINE FUNCTIONS
|
||||
@ -111,8 +115,8 @@ text_layout::~text_layout()
|
||||
|
||||
void text_layout::add_text(const char *text, const char_style &style)
|
||||
{
|
||||
int position = 0;
|
||||
int text_length = strlen(text);
|
||||
std::size_t position = 0;
|
||||
std::size_t const text_length = std::strlen(text);
|
||||
|
||||
while (position < text_length)
|
||||
{
|
||||
@ -124,16 +128,15 @@ void text_layout::add_text(const char *text, const char_style &style)
|
||||
{
|
||||
// get the current character
|
||||
unicode_char schar;
|
||||
int scharcount;
|
||||
scharcount = uchar_from_utf8(&schar, &text[position], text_length - position);
|
||||
if (scharcount == -1)
|
||||
int const scharcount = uchar_from_utf8(&schar, &text[position], text_length - position);
|
||||
if (scharcount < 0)
|
||||
break;
|
||||
|
||||
// if the line starts with a tab character, center it regardless
|
||||
text_justify line_justify = justify();
|
||||
if (schar == '\t')
|
||||
{
|
||||
position += scharcount;
|
||||
position += unsigned(scharcount);
|
||||
line_justify = text_layout::CENTER;
|
||||
}
|
||||
|
||||
@ -142,12 +145,11 @@ void text_layout::add_text(const char *text, const char_style &style)
|
||||
}
|
||||
|
||||
// get the current character
|
||||
int scharcount;
|
||||
unicode_char ch;
|
||||
scharcount = uchar_from_utf8(&ch, &text[position], text_length - position);
|
||||
int const scharcount = uchar_from_utf8(&ch, &text[position], text_length - position);
|
||||
if (scharcount < 0)
|
||||
break;
|
||||
position += scharcount;
|
||||
position += unsigned(scharcount);
|
||||
|
||||
// set up source information
|
||||
source_info source = { 0, };
|
||||
|
Loading…
Reference in New Issue
Block a user