summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/rendfont.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/rendfont.cpp')
-rw-r--r--src/emu/rendfont.cpp50
1 files changed, 21 insertions, 29 deletions
diff --git a/src/emu/rendfont.cpp b/src/emu/rendfont.cpp
index 89c174c31bf..9a05e5514c5 100644
--- a/src/emu/rendfont.cpp
+++ b/src/emu/rendfont.cpp
@@ -123,7 +123,7 @@ render_font::render_font(render_manager &manager, const char *filename)
m_yoffs(0),
m_scale(1.0f),
m_rawsize(0),
- m_osdfont(nullptr),
+ m_osdfont(),
m_height_cmd(0),
m_yoffs_cmd(0)
{
@@ -132,21 +132,20 @@ render_font::render_font(render_manager &manager, const char *filename)
// if this is an OSD font, we're done
if (filename != nullptr)
- {
+ {
m_osdfont = manager.machine().osd().font_alloc();
- if (m_osdfont != nullptr)
+ if (m_osdfont)
{
if (m_osdfont->open(manager.machine().options().font_path(), filename, m_height))
{
- m_scale = 1.0f / (float)m_height;
- m_format = FF_OSD;
+ m_scale = 1.0f / (float)m_height;
+ m_format = FF_OSD;
- //mamep: allocate command glyph font
- render_font_command_glyph();
- return;
- }
- global_free(m_osdfont);
- m_osdfont = nullptr;
+ //mamep: allocate command glyph font
+ render_font_command_glyph();
+ return;
+ }
+ m_osdfont.reset();
}
}
@@ -157,15 +156,15 @@ render_font::render_font(render_manager &manager, const char *filename)
// attempt to load the cached version of the font first
if (filename != nullptr && load_cached_bdf(filename))
{
- //mamep: allocate command glyph font
- render_font_command_glyph();
- return;
+ //mamep: allocate command glyph font
+ render_font_command_glyph();
+ return;
}
// load the raw data instead
emu_file ramfile(OPEN_FLAG_READ);
- file_error filerr = ramfile.open_ram(font_uismall, sizeof(font_uismall));
- if (filerr == FILERR_NONE)
+ osd_file::error filerr = ramfile.open_ram(font_uismall, sizeof(font_uismall));
+ if (filerr == osd_file::error::NONE)
load_cached(ramfile, 0);
render_font_command_glyph();
}
@@ -199,13 +198,6 @@ render_font::~render_font()
}
delete[] elem;
}
-
- // release the OSD font
- if (m_osdfont != nullptr)
- {
- m_osdfont->close();
- global_free(m_osdfont);
- }
}
@@ -470,8 +462,8 @@ bool render_font::load_cached_bdf(const char *filename)
{
// first try to open the BDF itself
emu_file file(manager().machine().options().font_path(), OPEN_FLAG_READ);
- file_error filerr = file.open(filename);
- if (filerr != FILERR_NONE)
+ osd_file::error filerr = file.open(filename);
+ if (filerr != osd_file::error::NONE)
return false;
// determine the file size and allocate memory
@@ -494,7 +486,7 @@ bool render_font::load_cached_bdf(const char *filename)
{
emu_file cachefile(manager().machine().options().font_path(), OPEN_FLAG_READ);
filerr = cachefile.open(cachedname.c_str());
- if (filerr == FILERR_NONE)
+ if (filerr == osd_file::error::NONE)
{
// if we have a cached version, load it
bool result = load_cached(cachefile, hash);
@@ -667,7 +659,7 @@ bool render_font::load_cached(emu_file &file, UINT32 hash)
// validate the header
if (header[0] != 'f' || header[1] != 'o' || header[2] != 'n' || header[3] != 't')
return false;
- if (header[4] != (UINT8)(hash >> 24) || header[5] != (UINT8)(hash >> 16) || header[6] != (UINT8)(hash >> 8) || header[7] != (UINT8)hash)
+ if (hash && (header[4] != (UINT8)(hash >> 24) || header[5] != (UINT8)(hash >> 16) || header[6] != (UINT8)(hash >> 8) || header[7] != (UINT8)hash))
return false;
m_height = (header[8] << 8) | header[9];
m_scale = 1.0f / (float)m_height;
@@ -730,8 +722,8 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
// attempt to open the file
emu_file file(manager().machine().options().font_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
- file_error filerr = file.open(filename);
- if (filerr != FILERR_NONE)
+ osd_file::error filerr = file.open(filename);
+ if (filerr != osd_file::error::NONE)
return false;
// determine the number of characters