Hi,

I noticed a little problem with the Graphics.MeasureString-Function:
I have a Textline, which contains Tabs. I use a StringFormat-Object, which
represents the TabStops. The DrawString-Method calculates the Tabs in the
text correctly. But MeasureString ignores them. I'm using the function as
following:

Dim w As Single = g.MeasureString(MyText, Me.Font, New PointF(x, y),
MyStringFormat).Width

x,y contains exactly the Drawing-Position of MyText (otherwise I would see
this in DrawString). And MyStringFormat stands for an GenericTypographic
-Object, which I'm using in the whole project for all Drawing-Operations.
It's extended with the Tabstopps.

Any suggestions?

Peter

RE: Bug in MeasureString ? by Peter

Peter
Sun May 22 15:01:02 CDT 2005

I have to revise: The DrawString() Methode doesn't measure the Tabs correct,
too.
Or is it my mistake? The Documentation says, that it's possible to define
Tabstops in the StringFormat. But that is only working, if you begin from
character 0 at the line.
Assumed a Tab-Width with 4 characters, see the following text: "A\tB". If
you call MeasureString or DrawString with the whole text, the result is OK.
But what's going on, if you call the function for the Substring "\tB" (with
specifying the correct Position - of course). They doesn't result in an
expected way).

But if this isn't intended so by Microsoft, what should be the
origin-Argument in MeasureString for?