G
Guest
Hi
If I make subsequent calls to MeasureCharacterRanges, specifying a rectangleF already determined by MeasureCharacterRanges, and the same Font and StringFormat, shouldn't it repeatedly determine the same bounds
Example
Dim f As New Font("Arial", 10
Dim sf As StringFormat = StringFormat.GenericDefaul
Dim s As String = "test string
Dim r As RectangleF =r.FromLTRB(100, 100, 200, 200
Dim g As Graphics = Me.CreateGraphic
Dim ranges As CharacterRange() = {New CharacterRange(0, s.Length)
Dim regions() As Regio
sf.SetMeasurableCharacterRanges(ranges
regions = g.MeasureCharacterRanges(s, f, r, sf
r = regions(0).GetBounds(g
Debug.WriteLine(r.ToString
regions = g.MeasureCharacterRanges(s, f, r, sf
r = regions(0).GetBounds(g
Debug.WriteLine(r.ToString
regions = g.MeasureCharacterRanges(s, f, r, sf
r = regions(0).GetBounds(g
Debug.WriteLine(r.ToString
This code outputs
{X=102,Y=101,Width=59,Height=15
{X=104,Y=102,Width=52,Height=14
{X=106,Y=103,Width=45,Height=13
My problem is this. If the first call to MeasureCharacterRanges returns proper bounds, then I should reasonably expect that subsequent calls would agree! My problem is that what I actually do in my project is call DrawString after a single call to MeasureCharacterRanges. Unfortunately, it too does not agree with the already determined bounds, and wraps my text unexpectedly
Does anyone have the answer to this
Thanks
Brett.
If I make subsequent calls to MeasureCharacterRanges, specifying a rectangleF already determined by MeasureCharacterRanges, and the same Font and StringFormat, shouldn't it repeatedly determine the same bounds
Example
Dim f As New Font("Arial", 10
Dim sf As StringFormat = StringFormat.GenericDefaul
Dim s As String = "test string
Dim r As RectangleF =r.FromLTRB(100, 100, 200, 200
Dim g As Graphics = Me.CreateGraphic
Dim ranges As CharacterRange() = {New CharacterRange(0, s.Length)
Dim regions() As Regio
sf.SetMeasurableCharacterRanges(ranges
regions = g.MeasureCharacterRanges(s, f, r, sf
r = regions(0).GetBounds(g
Debug.WriteLine(r.ToString
regions = g.MeasureCharacterRanges(s, f, r, sf
r = regions(0).GetBounds(g
Debug.WriteLine(r.ToString
regions = g.MeasureCharacterRanges(s, f, r, sf
r = regions(0).GetBounds(g
Debug.WriteLine(r.ToString
This code outputs
{X=102,Y=101,Width=59,Height=15
{X=104,Y=102,Width=52,Height=14
{X=106,Y=103,Width=45,Height=13
My problem is this. If the first call to MeasureCharacterRanges returns proper bounds, then I should reasonably expect that subsequent calls would agree! My problem is that what I actually do in my project is call DrawString after a single call to MeasureCharacterRanges. Unfortunately, it too does not agree with the already determined bounds, and wraps my text unexpectedly
Does anyone have the answer to this
Thanks
Brett.