Improve text extent rounding in wxGCDCImpl::DoGetTextExtent()
Change wxGCDCImpl::DoGetTextExtent() from rounding to the nearest
integer to rounding up: if e.g. height is 15.3 then 16 pixels should be
used for height, and not 15. Rounding was previously improved from
casting (which appears to be the initial code) in 0417955ddb
(adding
correct filling area to arc, correct rounding and clipping, 2007-10-21).
Issues with nearest rounding became more visible after off-by-one fixes
for wxDC::DrawLabel() with wxALIGN_RIGHT and wxALIGN_BOTTOM positioning.
When using e.g. wxALIGN_RIGHT with a width of 72.4 the text could now be
drawn beyond the extent on the right because the text is not offset by
one to the left any longer.
This commit is contained in:
@@ -1279,13 +1279,13 @@ void wxGCDCImpl::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *
|
||||
);
|
||||
|
||||
if ( height )
|
||||
*height = (wxCoord)wxRound(h);
|
||||
*height = (wxCoord)ceil(h);
|
||||
if ( descent )
|
||||
*descent = (wxCoord)wxRound(d);
|
||||
*descent = (wxCoord)ceil(d);
|
||||
if ( externalLeading )
|
||||
*externalLeading = (wxCoord)wxRound(e);
|
||||
*externalLeading = (wxCoord)ceil(e);
|
||||
if ( width )
|
||||
*width = (wxCoord)wxRound(w);
|
||||
*width = (wxCoord)ceil(w);
|
||||
|
||||
if ( theFont )
|
||||
{
|
||||
|
Reference in New Issue
Block a user