From 9b554c0974f6d625d5c88009a223e0df366d132b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 1 May 2018 15:10:55 +0200 Subject: [PATCH] Avoid narrowing conversion in wxMac struct initialization Multiplying 2 float values is promoted to double, which is then narrowed to float when initializing CGPoint with it, resulting in errors in C++11 build. Fix this by initializing the CGFloat variable, which doesn't uniform initialization, to the correct value instead, as this also seems more clear ("height" is the height at which the strike is drawn). Closes https://github.com/wxWidgets/wxWidgets/pull/793 --- src/osx/carbon/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index e77c6172cf..699e483512 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -2245,8 +2245,8 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo if ( fref->GetStrikethrough() ) { CGFloat width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); - CGFloat height = CTFontGetXHeight( font ); - CGPoint points[] = { {0.0, height * 0.6f}, {width, height * 0.6f} }; + CGFloat height = CTFontGetXHeight( font ) * 0.6; + CGPoint points[] = { {0.0, height}, {width, height} }; CGContextSetStrokeColorWithColor(m_cgContext, col); CGContextSetShouldAntialias(m_cgContext, false); CGContextSetLineWidth(m_cgContext, 1.0);