DrawString error?

K

kynos

I would like to paint a box using DrawString, standard Unicode
characters (box drawings characters) and monospaced font.

Unfortunately for some fonts painted lines contain a break.

Example code, in whom one can see the error:

private void Form1_Paint (object sender, PaintEventArgs e)
(
Font font = new Font ( "Courier New", 9);
e.Graphics.DrawString (new String ( '\u2500', 200),
font,
new SolidBrush (Color.Red), new PointF (0, 0),
StringFormat.GenericTypographic);
)

I must use DrawString, not the DrawLine etc. fuctions.
Does anybody knows how paint lines via the DrawString, so that did not
have the breaks?
 
T

TAB

Hi

If I understand you right, you mean a line break or word wrap, if so you
could use
StringFormat strFormat = StringFormat.GenericTypographic;
strFormat.FormatFlags |= StringFormatFlags.NoWrap;
 
K

kynos

Hi,

Thanks for your reply, but I do not mean word wrap or a line break.
If you choose Courier New, _eight_ pts font, and DrawString using
string containts some graphical unicode character ('horizontal line')
you have straight line without gaps on it.

But if you choose _nine_ pts (and several another sizes) font there
are gaps on the line.

Please, try the code I posted before - it looks really strange.
 
T

TAB

Using your example, I get a straight red line across the form, no gaps.
Something wrong with your font file?
 
K

kynos

I have got gaps on XP Pro SP3 and Vista Ultimate SP1.
The example was run on MSV C# Express Edition 2008.

Have you tried my code with 8 pts and 9 pts font size?
And there is no difference betwen them?
On my systems, with the 9 pts font, the gaps size is about 1 pixel,
and take place every few (5) character.
 
T

TAB

I have so far tried 7, 7.5, 8, 8.5 9, 10, 11 and they all show nothing like
you describe, so I am still aiming at a font problem or maybe a graphics
driver problem?
 
T

TAB

Yes, exact copy of your example. Only changed font size. By the way, I'm
running Vista SP1, .NET 3.5 VS 2008 C# Express.
 

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