mirror of
https://github.com/holub/mame
synced 2025-07-03 17:08:39 +03:00
log some failures (nw)
This commit is contained in:
parent
658e5a1da2
commit
db69883e64
@ -122,39 +122,48 @@ 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
|
|
||||||
std::size_t const bitmap_width(std::max(std::ceil(bounds.size.width), CGFloat(1.0)));
|
|
||||||
std::size_t const bitmap_height(m_height);
|
|
||||||
width = std::ceil(advance.width);
|
|
||||||
xoffs = std::ceil(bounds.origin.x);
|
|
||||||
yoffs = 0;
|
|
||||||
bitmap.allocate(bitmap_width, bitmap_height);
|
|
||||||
|
|
||||||
// create graphics context
|
// turn everything into integers for MAME and allocate output bitmap
|
||||||
CGBitmapInfo const bitmap_info(kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
|
std::size_t const bitmap_width(std::max(std::ceil(bounds.size.width), CGFloat(1.0)));
|
||||||
CGColorSpaceRef const color_space(CGColorSpaceCreateDeviceRGB());
|
std::size_t const bitmap_height(m_height);
|
||||||
CGContextRef const context_ref(CGBitmapContextCreate(bitmap.raw_pixptr(0), bitmap_width, bitmap_height, 8, bitmap.rowpixels() * 4, color_space, bitmap_info));
|
width = std::ceil(advance.width);
|
||||||
if (context_ref)
|
xoffs = std::ceil(bounds.origin.x);
|
||||||
{
|
yoffs = 0;
|
||||||
CGFontRef const font_ref(CTFontCopyGraphicsFont(m_font, nullptr));
|
bitmap.allocate(bitmap_width, bitmap_height);
|
||||||
CGContextSetTextPosition(context_ref, -bounds.origin.x, m_baseline);
|
|
||||||
CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0);
|
// create graphics context and draw
|
||||||
CGContextSetFont(context_ref, font_ref);
|
CGBitmapInfo const bitmap_info(kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
|
||||||
CGContextSetFontSize(context_ref, POINT_SIZE);
|
CGColorSpaceRef const color_space(CGColorSpaceCreateDeviceRGB());
|
||||||
CGContextShowGlyphs(context_ref, &glyph, count);
|
CGContextRef const context_ref(CGBitmapContextCreate(bitmap.raw_pixptr(0), bitmap_width, bitmap_height, 8, bitmap.rowpixels() * 4, color_space, bitmap_info));
|
||||||
CGFontRelease(font_ref);
|
if (context_ref)
|
||||||
CGContextRelease(context_ref);
|
{
|
||||||
}
|
CGFontRef const font_ref(CTFontCopyGraphicsFont(m_font, nullptr));
|
||||||
CGColorSpaceRelease(color_space);
|
CGContextSetTextPosition(context_ref, -bounds.origin.x, m_baseline);
|
||||||
|
CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0);
|
||||||
|
CGContextSetFont(context_ref, font_ref);
|
||||||
|
CGContextSetFontSize(context_ref, POINT_SIZE);
|
||||||
|
CGContextShowGlyphs(context_ref, &glyph, count);
|
||||||
|
CGFontRelease(font_ref);
|
||||||
|
CGContextRelease(context_ref);
|
||||||
}
|
}
|
||||||
|
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