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
This commit is contained in:
Vadim Zeitlin
2018-05-01 15:10:55 +02:00
parent 83af2a428e
commit 9b554c0974

View File

@@ -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);