Drawstring problem

S

Saeid

Hi All,


I'm trying tp print to texts in the same position with
different font sizes on a graphics object (say a printer
or a picturebox) and I'm using the format string object
to remove spaces around a character but it doesn't work.

Private Sub PictureBox1_Paint(ByVal sender As
Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Handles PictureBox1.Paint
'
Dim format As New StringFormat(CType
(StringFormat.GenericTypographic.Clone, StringFormat))

With e.Graphics
.PageUnit =
GraphicsUnit.Millimeter
.TextRenderingHint =
TextRenderingHint.AntiAlias
.DrawLine(New Pen(Color.Blue),
10, 0, 10, 200)
.DrawString("P", New Font
("Arial", 10, GraphicsUnit.Millimeter), Brushes.Green,
New RectangleF(10, 10, 100, 100), format)
.DrawString("P", New Font
("Arial", 48, GraphicsUnit.Millimeter), Brushes.Green,
New RectangleF(10, 10, 150, 165), format)
End With
'
End Sub


Does anyone have any idea how to work out this problem.
Any help appreciated.


Regards,
Saeid
 
A

Armin Zingler

Saeid said:
I'm trying tp print to texts in the same position with
different font sizes on a graphics object (say a printer
or a picturebox) and I'm using the format string object
to remove spaces around a character but it doesn't work.

Private Sub PictureBox1_Paint(ByVal sender As
Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Handles PictureBox1.Paint
'
Dim format As New StringFormat(CType
(StringFormat.GenericTypographic.Clone, StringFormat))

With e.Graphics
.PageUnit =
GraphicsUnit.Millimeter
.TextRenderingHint =
TextRenderingHint.AntiAlias
.DrawLine(New Pen(Color.Blue),
10, 0, 10, 200)
.DrawString("P", New Font
("Arial", 10, GraphicsUnit.Millimeter), Brushes.Green,
New RectangleF(10, 10, 100, 100), format)
.DrawString("P", New Font
("Arial", 48, GraphicsUnit.Millimeter), Brushes.Green,
New RectangleF(10, 10, 150, 165), format)
End With
'
End Sub


Does anyone have any idea how to work out this problem.
Any help appreciated.

I tried your code. Where do you expect the space to be removed? Do you mean
the space between the left side of the "P" and the vertical bar?
 
A

Armin Zingler

Yes Exactly, They should be all in the same Y position
but they're not. Thanks


I think the letters start at the same Y position. At the bigger char, also
the space between the (green) letter itself and the top of the char is
bigger.

As this is not a VB.NET specific question, please turn to
microsoft.public.dotnet.framework.drawing, or, probably better,
microsoft.public.win32.programmer.gdi
 
G

Guest

Thanks Armin, I'll do that.


Regards,
Saeid
-----Original Message-----



I think the letters start at the same Y position. At the bigger char, also
the space between the (green) letter itself and the top of the char is
bigger.

As this is not a VB.NET specific question, please turn to
microsoft.public.dotnet.framework.drawing, or, probably better,
microsoft.public.win32.programmer.gdi


--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top