mirror of
https://github.com/holub/mame
synced 2025-07-03 00:56:03 +03:00
log some failures (nw)
This commit is contained in:
parent
658e5a1da2
commit
db69883e64
@ -122,14 +122,24 @@ bool osd_font_osx::get_bitmap(char32_t chnum, bitmap_argb32 &bitmap, std::int32_
|
|||||||
UniChar const uni_char(chnum);
|
UniChar const uni_char(chnum);
|
||||||
CFIndex const count(1);
|
CFIndex const count(1);
|
||||||
CGGlyph glyph;
|
CGGlyph glyph;
|
||||||
CTFontGetGlyphsForCharacters(m_font, &uni_char, &glyph, count);
|
if (!CTFontGetGlyphsForCharacters(m_font, &uni_char, &glyph, count))
|
||||||
|
{
|
||||||
|
osd_printf_verbose("osd_font_osd::get_bitmap: failed to get glyph for U+%04X\n", unsigned(chnum));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to get glyph bounds
|
||||||
|
CGRect bounds;
|
||||||
|
if (CGRectEqualToRect(CTFontGetBoundingRectsForGlyphs(m_font, kCTFontHorizontalOrientation, &glyph, &bounds, count), CGRectNull))
|
||||||
|
{
|
||||||
|
osd_printf_verbose("osd_font_osd::get_bitmap: failed to get glyph bounds for U+%04X\n", unsigned(chnum));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// try to get metrics
|
// try to get metrics
|
||||||
CGRect const bounds(CTFontGetBoundingRectsForGlyphs(m_font, kCTFontDefaultOrientation, &glyph, nullptr, count));
|
|
||||||
CGSize advance;
|
CGSize advance;
|
||||||
CTFontGetAdvancesForGlyphs(m_font, kCTFontDefaultOrientation, &glyph, &advance, count);
|
CTFontGetAdvancesForGlyphs(m_font, kCTFontHorizontalOrientation, &glyph, &advance, count);
|
||||||
if (!CGRectEqualToRect(bounds, CGRectNull))
|
|
||||||
{
|
|
||||||
// turn everything into integers for MAME and allocate output bitmap
|
// turn everything into integers for MAME and allocate output bitmap
|
||||||
std::size_t const bitmap_width(std::max(std::ceil(bounds.size.width), CGFloat(1.0)));
|
std::size_t const bitmap_width(std::max(std::ceil(bounds.size.width), CGFloat(1.0)));
|
||||||
std::size_t const bitmap_height(m_height);
|
std::size_t const bitmap_height(m_height);
|
||||||
@ -138,7 +148,7 @@ bool osd_font_osx::get_bitmap(char32_t chnum, bitmap_argb32 &bitmap, std::int32_
|
|||||||
yoffs = 0;
|
yoffs = 0;
|
||||||
bitmap.allocate(bitmap_width, bitmap_height);
|
bitmap.allocate(bitmap_width, bitmap_height);
|
||||||
|
|
||||||
// create graphics context
|
// create graphics context and draw
|
||||||
CGBitmapInfo const bitmap_info(kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
|
CGBitmapInfo const bitmap_info(kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
|
||||||
CGColorSpaceRef const color_space(CGColorSpaceCreateDeviceRGB());
|
CGColorSpaceRef const color_space(CGColorSpaceCreateDeviceRGB());
|
||||||
CGContextRef const context_ref(CGBitmapContextCreate(bitmap.raw_pixptr(0), bitmap_width, bitmap_height, 8, bitmap.rowpixels() * 4, color_space, bitmap_info));
|
CGContextRef const context_ref(CGBitmapContextCreate(bitmap.raw_pixptr(0), bitmap_width, bitmap_height, 8, bitmap.rowpixels() * 4, color_space, bitmap_info));
|
||||||
@ -154,7 +164,6 @@ bool osd_font_osx::get_bitmap(char32_t chnum, bitmap_argb32 &bitmap, std::int32_
|
|||||||
CGContextRelease(context_ref);
|
CGContextRelease(context_ref);
|
||||||
}
|
}
|
||||||
CGColorSpaceRelease(color_space);
|
CGColorSpaceRelease(color_space);
|
||||||
}
|
|
||||||
|
|
||||||
// bitmap will be valid if we drew to it
|
// bitmap will be valid if we drew to it
|
||||||
return bitmap.valid();
|
return bitmap.valid();
|
||||||
|
Loading…
Reference in New Issue
Block a user