diff options
Diffstat (limited to 'src/osd/modules/font/font_windows.cpp')
-rw-r--r-- | src/osd/modules/font/font_windows.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/osd/modules/font/font_windows.cpp b/src/osd/modules/font/font_windows.cpp index 95f10c0a051..0ec65b67aea 100644 --- a/src/osd/modules/font/font_windows.cpp +++ b/src/osd/modules/font/font_windows.cpp @@ -1,22 +1,19 @@ // license:BSD-3-Clause // copyright-holders:Aaron Giles /* - * font_windows.c + * font_windows.cpp * */ #include "font_module.h" -#include "modules/osdmodule.h" #if defined(OSD_WINDOWS) || defined(SDLMAME_WIN32) -#include "font_module.h" -#include "modules/osdmodule.h" - #include "strconv.h" +#include "unicode.h" #include "corestr.h" -#include "corealloc.h" +#include "osdcore.h" #include <cstring> @@ -27,7 +24,10 @@ #include <io.h> +namespace osd { + namespace { + class osd_font_windows : public osd_font { public: @@ -84,8 +84,8 @@ bool osd_font_windows::open(std::string const &font_path, std::string const &_na logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; // copy in the face name - osd::text::tstring face = osd::text::to_tstring(name); - _tcsncpy(logfont.lfFaceName, face.c_str(), ARRAY_LENGTH(logfont.lfFaceName)); + text::tstring face = text::to_tstring(name); + _tcsncpy(logfont.lfFaceName, face.c_str(), std::size(logfont.lfFaceName)); logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0; // create the font @@ -109,8 +109,8 @@ bool osd_font_windows::open(std::string const &font_path, std::string const &_na } // if it doesn't match our request, fail - std::string utf = osd::text::from_tstring(&realname[0]); - int result = core_stricmp(utf.c_str(), name.c_str()); + std::string utf = text::from_tstring(&realname[0]); + int result = core_stricmp(utf, name); // if we didn't match, nuke our font and fall back if (result != 0) @@ -200,7 +200,7 @@ bool osd_font_windows::get_bitmap(char32_t chnum, bitmap_argb32 &bitmap, int32_t // now draw the character char16_t tempchar[UTF16_CHAR_MAX]; - UINT const count = INT(utf16_from_uchar(tempchar, ARRAY_LENGTH(tempchar), chnum)); + UINT const count = INT(utf16_from_uchar(tempchar, std::size(tempchar), chnum)); SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff)); SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00)); ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, nullptr, reinterpret_cast<LPCWSTR>(tempchar), count, nullptr); @@ -260,7 +260,7 @@ bool osd_font_windows::get_bitmap(char32_t chnum, bitmap_argb32 &bitmap, int32_t // copy the bits into it for (int y = 0; y < bitmap.height(); y++) { - uint32_t *dstrow = &bitmap.pix32(y); + uint32_t *dstrow = &bitmap.pix(y); uint8_t *srcrow = &bits[(y + actbounds.min_y) * rowbytes]; for (int x = 0; x < bitmap.width(); x++) { @@ -289,7 +289,7 @@ class font_win : public osd_module, public font_module public: font_win() : osd_module(OSD_FONT_PROVIDER, "win"), font_module() { } - virtual int init(const osd_options &options) override { return 0; } + virtual int init(osd_interface &osd, const osd_options &options) override { return 0; } virtual osd_font::ptr font_alloc() override { return std::make_unique<osd_font_windows>(); } @@ -299,7 +299,7 @@ private: static int CALLBACK font_family_callback(LOGFONT const *lpelfe, TEXTMETRIC const *lpntme, DWORD FontType, LPARAM lParam) { auto &result = *reinterpret_cast<std::vector<std::pair<std::string, std::string> > *>(lParam); - std::string face = osd::text::from_tstring(lpelfe->lfFaceName); + std::string face = text::from_tstring(lpelfe->lfFaceName); if ((face[0] != '@') && (result.empty() || (result.back().first != face))) result.emplace_back(face, face); return TRUE; } @@ -327,10 +327,12 @@ bool font_win::get_font_families(std::string const &font_path, std::vector<std:: } // anonymous namespace +} // namespace osd + #else // defined(OSD_WINDOWS) || defined(SDLMAME_WIN32) -MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win") +namespace osd { namespace { MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win") } } #endif // defined(OSD_WINDOWS) || defined(SDLMAME_WIN32) -MODULE_DEFINITION(FONT_WINDOWS, font_win) +MODULE_DEFINITION(FONT_WINDOWS, osd::font_win) |