summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/rendfont.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/rendfont.c')
-rw-r--r--src/emu/rendfont.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/src/emu/rendfont.c b/src/emu/rendfont.c
index b4070dc45ec..62a0581f9ab 100644
--- a/src/emu/rendfont.c
+++ b/src/emu/rendfont.c
@@ -53,9 +53,9 @@ 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 (m_glyphs[chnum / 256].count() == 0 && m_format == FF_OSD)
- m_glyphs[chnum / 256].resize(256);
- if (m_glyphs[chnum / 256].count() == 0)
+ if (!m_glyphs[chnum / 256] && m_format == FF_OSD)
+ m_glyphs[chnum / 256] = new glyph[256];
+ if (!m_glyphs[chnum / 256])
return dummy_glyph;
// if the character isn't generated yet, do it now
@@ -86,6 +86,8 @@ render_font::render_font(render_manager &manager, const char *filename)
m_rawsize(0),
m_osdfont(NULL)
{
+ memset(m_glyphs, 0, sizeof(m_glyphs));
+
// if this is an OSD font, we're done
if (filename != NULL)
{
@@ -127,10 +129,14 @@ render_font::~render_font()
{
// free all the subtables
for (int tablenum = 0; tablenum < 256; tablenum++)
- for (int charnum = 0; charnum < m_glyphs[tablenum].count(); charnum++)
+ if (m_glyphs[tablenum])
{
- glyph &gl = m_glyphs[tablenum][charnum];
- m_manager.texture_free(gl.texture);
+ for (unsigned int charnum = 0; charnum < 256; charnum++)
+ {
+ glyph &gl = m_glyphs[tablenum][charnum];
+ m_manager.texture_free(gl.texture);
+ }
+ delete[] m_glyphs[tablenum];
}
// release the OSD font
@@ -378,7 +384,7 @@ bool render_font::load_cached_bdf(const char *filename)
m_rawdata.resize(m_rawsize + 1);
// read the first chunk
- UINT32 bytes = file.read(m_rawdata, MIN(CACHED_BDF_HASH_SIZE, m_rawsize));
+ UINT32 bytes = file.read(&m_rawdata[0], MIN(CACHED_BDF_HASH_SIZE, m_rawsize));
if (bytes != MIN(CACHED_BDF_HASH_SIZE, m_rawsize))
return false;
@@ -411,10 +417,10 @@ bool render_font::load_cached_bdf(const char *filename)
// read in the rest of the font
if (bytes < m_rawsize)
{
- UINT32 read = file.read(m_rawdata + bytes, m_rawsize - bytes);
+ UINT32 read = file.read(&m_rawdata[bytes], m_rawsize - bytes);
if (read != m_rawsize - bytes)
{
- m_rawdata.reset();
+ m_rawdata.clear();
return false;
}
}
@@ -445,7 +451,7 @@ bool render_font::load_bdf()
// first find the FONTBOUNDINGBOX tag
const char *ptr;
- for (ptr = m_rawdata; ptr != NULL; ptr = next_line(ptr))
+ for (ptr = &m_rawdata[0]; ptr != NULL; ptr = next_line(ptr))
{
// we only care about a tiny few fields
if (strncmp(ptr, "FONTBOUNDINGBOX ", 16) == 0)
@@ -514,8 +520,8 @@ bool render_font::load_bdf()
if (charnum >= 0 && charnum < 65536 && rawdata != NULL && bmwidth >= 0 && bmheight >= 0)
{
// if we don't have a subtable yet, make one
- if (m_glyphs[charnum / 256].count() == 0)
- m_glyphs[charnum / 256].resize(256);
+ if (!m_glyphs[charnum / 256])
+ m_glyphs[charnum / 256] = new glyph[256];
// fill in the entry
glyph &gl = m_glyphs[charnum / 256][charnum % 256];
@@ -534,7 +540,7 @@ bool render_font::load_bdf()
}
// make sure all the numbers are the same width
- if (m_glyphs[0].count() > '9')
+ if (m_glyphs[0])
{
int maxwidth = 0;
for (int ch = '0'; ch <= '9'; ch++)
@@ -577,10 +583,10 @@ bool render_font::load_cached(emu_file &file, UINT32 hash)
// now read the rest of the data
m_rawdata.resize(filesize - CACHED_HEADER_SIZE);
- bytes_read = file.read(m_rawdata, filesize - CACHED_HEADER_SIZE);
+ bytes_read = file.read(&m_rawdata[0], filesize - CACHED_HEADER_SIZE);
if (bytes_read != filesize - CACHED_HEADER_SIZE)
{
- m_rawdata.reset();
+ m_rawdata.clear();
return false;
}
@@ -592,8 +598,8 @@ bool render_font::load_cached(emu_file &file, UINT32 hash)
int chnum = (info[0] << 8) | info[1];
// if we don't have a subtable yet, make one
- if (m_glyphs[chnum / 256].count() == 0)
- m_glyphs[chnum / 256].resize(256);
+ if (!m_glyphs[chnum / 256])
+ m_glyphs[chnum / 256] = new glyph[256];
// fill in the entry
glyph &gl = m_glyphs[chnum / 256][chnum % 256];
@@ -602,13 +608,13 @@ bool render_font::load_cached(emu_file &file, UINT32 hash)
gl.yoffs = (INT16)((info[6] << 8) | info[7]);
gl.bmwidth = (info[8] << 8) | info[9];
gl.bmheight = (info[10] << 8) | info[11];
- gl.rawdata = (char *)m_rawdata + offset;
+ gl.rawdata = &m_rawdata[offset];
// advance the offset past the character
offset += (gl.bmwidth * gl.bmheight + 7) / 8;
if (offset > filesize - CACHED_HEADER_SIZE)
{
- m_rawdata.reset();
+ m_rawdata.clear();
return false;
}
}
@@ -637,7 +643,7 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
int numchars = 0;
for (int chnum = 0; chnum < 65536; chnum++)
{
- if (m_glyphs[chnum / 256].count() > 0)
+ if (m_glyphs[chnum / 256])
{
glyph &gl = m_glyphs[chnum / 256][chnum % 256];
if (gl.width > 0)
@@ -654,7 +660,7 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
dynamic_buffer tempbuffer(65536);
// write the header
- UINT8 *dest = tempbuffer;
+ UINT8 *dest = &tempbuffer[0];
*dest++ = 'f';
*dest++ = 'o';
*dest++ = 'n';
@@ -671,13 +677,13 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
*dest++ = numchars >> 16;
*dest++ = numchars >> 8;
*dest++ = numchars & 0xff;
- assert(dest - tempbuffer == CACHED_HEADER_SIZE);
- UINT32 bytes_written = file.write(tempbuffer, dest - tempbuffer);
- if (bytes_written != dest - tempbuffer)
+ assert(dest == &tempbuffer[CACHED_HEADER_SIZE]);
+ UINT32 bytes_written = file.write(&tempbuffer[0], CACHED_HEADER_SIZE);
+ if (bytes_written != dest - &tempbuffer[0])
throw emu_fatalerror("Error writing cached file");
// write the empty table to the beginning of the file
- bytes_written = file.write(chartable, numchars * CACHED_CHAR_SIZE);
+ bytes_written = file.write(&chartable[0], numchars * CACHED_CHAR_SIZE);
if (bytes_written != numchars * CACHED_CHAR_SIZE)
throw emu_fatalerror("Error writing cached file");
@@ -692,7 +698,7 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
if (gl.bitmap.valid())
{
// write the data to the tempbuffer
- dest = tempbuffer;
+ dest = &tempbuffer[0];
UINT8 accum = 0;
UINT8 accbit = 7;
@@ -719,8 +725,8 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
*dest++ = accum;
// write the data
- bytes_written = file.write(tempbuffer, dest - tempbuffer);
- if (bytes_written != dest - tempbuffer)
+ bytes_written = file.write(&tempbuffer[0], dest - &tempbuffer[0]);
+ if (bytes_written != dest - &tempbuffer[0])
throw emu_fatalerror("Error writing cached file");
// free the bitmap and texture
@@ -748,7 +754,7 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
// seek back to the beginning and rewrite the table
file.seek(CACHED_HEADER_SIZE, SEEK_SET);
- bytes_written = file.write(chartable, numchars * CACHED_CHAR_SIZE);
+ bytes_written = file.write(&chartable[0], numchars * CACHED_CHAR_SIZE);
if (bytes_written != numchars * CACHED_CHAR_SIZE)
throw emu_fatalerror("Error writing cached file");
return true;