Visual Studio 2017
wxWidgets-3.1.3
I want to draw text that fills a rectangle also centred. The font size
should be selected based on the text size ( single or mulitple lines )
relative to the size of the rectangle.
Code: Select all
std::wstring text = L"Hello, world!";
wxRect screen(0,0,1440,900);
wxFontInfo fi;
fi.Family(wxFONTFAMILY_ROMAN).Style(wxFONTSTYLE_NORMAL).Weight(wxFONTWEIGHT_NORMAL);
wxFont font(fi);
wxClientDC dc(this);
font.Scale(50); // Would want to determine the scale factor based in the size of text relative to wxRect
dc.SetFont(font);
wxRect text_rect(screen.x, screen.y, screen.width, screen.height * 0.45f);
dc.DrawLabel(text, text_rect, wxALIGN_CENTRE);