Re: GDI+ renders some phrases without spaces

From: Bob Powell [MVP] (bob_at__spamkiller_bobpowell.net)
Date: 02/08/05


Date: Tue, 8 Feb 2005 16:36:35 +0100

Working with small fonts is particularly hard. This article might help you.

http://windowsforms.net/articles/gdiptext.aspx

You should really be setting the TextRenderingHint property before you draw.
If you don't like the effect of the AntialiasGridFit try ClearTypeGridFit.

-- 
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Robert Bouillon" <djwhizzard@hotmail.com> wrote in message 
news:uHOhDkMDFHA.3924@TK2MSFTNGP15.phx.gbl...
> Sure. Less the try catch and some non-relevant code...
>
> PrivateFontCollection fonts = new PrivateFontCollection();
> fonts.AddFontFile(ctx.Server.MapPath("/Fonts/KR-08-53.TTF"));
> Kroeger0853 = new
> Font(fonts.Families[0],6,FontStyle.Bold,GraphicsUnit.Point);
>
> SizeF size = Ruler.MeasureString(text,Kroeger0853,400);
> b = new Bitmap((int)size.Width,10);
> g = Graphics.FromImage(b);
> g.Clear(BackColor);
> g.DrawString(text,Kroeger0853,new SolidBrush(ForeColor),0,0);
> transb = SetTwoColorTransparancy(b,ForeColor,BackColor);
> b.Dispose();
> ctx.Response.ContentType="image/gif";
> transb.Save(ctx.Response.OutputStream, ImageFormat.Gif);
>
> Only thing I could think of is the fact that a 6-point font is 
> non-standard,
> but again, it renders fine in IE and in Photoshop. The font comes out
> perfect using GDI+; it's just the character spacing that's off.
>
> Thanks.
>
> --ROBERT
>
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:%23YNEoyCDFHA.1040@TK2MSFTNGP09.phx.gbl...
>> Any chance of some code that demonstrates the problem?
>>
>> -- 
>> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>> http://www.bobpowell.net/tipstricks.htm
>>
>> Answer those GDI+ questions with the GDI+ FAQ
>> http://www.bobpowell.net/faqmain.htm
>>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>>
>>
>>
>> "Robert Bouillon" <djwhizzard@hotmail.com> wrote in message
>> news:eQ$hYu9CFHA.3976@tk2msftngp13.phx.gbl...
>> >I seem to have a kerning problem I can't resolve.
>> >
>> > I'm using a non-standard font for a website, so I created dynamic image
>> > generation to render the font. In photoshop and in Internet explorer,
> with
>> > the font specified explicitly in css, rendering is perfect. However 
>> > when
> I
>> > generate the string in .NET, the string is often "crumpled" in places
> with
>> > no spaces between characters.
>> >
>> > I would assume IE uses the same GDI calls to render the font, so I'm 
>> > not
>> > sure what I'm missing.
>> >
>> > I can post GIF's if anyone needs further clarification.
>> >
>> > Thanks.
>> >
>> > --ROBERT
>> >
>> >
>>
>>
>
> 


Relevant Pages

  • Re: Font size based on the client rectangle of the control.
    ... The only way to change the font width independently of the height is to draw ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: GDI+ renders some phrases without spaces
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... > generation to render the font. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: DrawString - few font styls in the same row
    ... If you're using GDI or GDI+ to render text then there is no simple way, ... position of each contiguous block of formatted text and render it, ... both accept Font parameters. ... Is it possible to draw string with few font styls, like in WORD (i.e. Bold ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: DrawString unicode
    ... GDI+ doesn't use the uniscribe to render the unicode string. ... > Are you certain that the font you are using is a font that supports the ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Forms font not propogated to user-control
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Somewhere along the way I explicitly set the Font ... When I drop this control on a Form and then change the Font on the ...
    (microsoft.public.dotnet.framework.windowsforms)