don't add 0.5 to GetTextExtent() results and do take trailing spaces into account, as wxDC does (patch 1814620)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49671 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
0a5b15da92
commit
595fda6f9c
@ -1123,11 +1123,11 @@ void wxGDIPlusContext::GetTextExtent( const wxString &str, wxDouble *width, wxDo
|
|||||||
f->GetSize() / ffamily.GetEmHeight(FontStyleRegular);
|
f->GetSize() / ffamily.GetEmHeight(FontStyleRegular);
|
||||||
|
|
||||||
if ( height )
|
if ( height )
|
||||||
*height = rHeight * factorY + 0.5 ;
|
*height = rHeight * factorY;
|
||||||
if ( descent )
|
if ( descent )
|
||||||
*descent = rDescent * factorY + 0.5 ;
|
*descent = rDescent * factorY;
|
||||||
if ( externalLeading )
|
if ( externalLeading )
|
||||||
*externalLeading = (rHeight - rAscent - rDescent) * factorY + 0.5 ;
|
*externalLeading = (rHeight - rAscent - rDescent) * factorY;
|
||||||
// measuring empty strings is not guaranteed, so do it by hand
|
// measuring empty strings is not guaranteed, so do it by hand
|
||||||
if ( str.IsEmpty())
|
if ( str.IsEmpty())
|
||||||
{
|
{
|
||||||
@ -1142,12 +1142,14 @@ void wxGDIPlusContext::GetTextExtent( const wxString &str, wxDouble *width, wxDo
|
|||||||
StringFormat strFormat;
|
StringFormat strFormat;
|
||||||
CharacterRange strRange(0,wcslen(s));
|
CharacterRange strRange(0,wcslen(s));
|
||||||
strFormat.SetMeasurableCharacterRanges(1,&strRange);
|
strFormat.SetMeasurableCharacterRanges(1,&strRange);
|
||||||
|
strFormat.SetFormatFlags(StringFormatFlagsMeasureTrailingSpaces);
|
||||||
|
|
||||||
Region region ;
|
Region region ;
|
||||||
m_context->MeasureCharacterRanges(s, -1 , f,layoutRect, &strFormat,1,®ion) ;
|
m_context->MeasureCharacterRanges(s, -1 , f,layoutRect, &strFormat,1,®ion) ;
|
||||||
RectF bbox ;
|
RectF bbox ;
|
||||||
region.GetBounds(&bbox,m_context);
|
region.GetBounds(&bbox,m_context);
|
||||||
if ( width )
|
if ( width )
|
||||||
*width = bbox.GetRight()-bbox.GetLeft()+0.5;
|
*width = bbox.GetRight()-bbox.GetLeft();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1176,6 +1178,7 @@ void wxGDIPlusContext::GetPartialTextExtents(const wxString& text, wxArrayDouble
|
|||||||
ranges[i].Length = 1 ;
|
ranges[i].Length = 1 ;
|
||||||
}
|
}
|
||||||
strFormat.SetMeasurableCharacterRanges(len,ranges);
|
strFormat.SetMeasurableCharacterRanges(len,ranges);
|
||||||
|
strFormat.SetFormatFlags(StringFormatFlagsMeasureTrailingSpaces);
|
||||||
m_context->MeasureCharacterRanges(ws, -1 , f,layoutRect, &strFormat,1,regions) ;
|
m_context->MeasureCharacterRanges(ws, -1 , f,layoutRect, &strFormat,1,regions) ;
|
||||||
|
|
||||||
RectF bbox ;
|
RectF bbox ;
|
||||||
|
Loading…
Reference in New Issue
Block a user