开发者

Modifying the kerning in System.Drawing.Graphics.DrawString()

I'm rendering text onto an image using the System.Drawing.Graphics class, and the DrawString() method.

I need to generate the text for this image in a very specific way so that it exactly - pixel for pixel - matches an existing image.

The problem is that the text generated by 开发者_Go百科DrawString() has a different kerning to the text in the existing image (my best guess is approximately 0.5 - 1 pixel per letter).

Can anyone tell me if it's possible to modify the kerning while using this namespace and method?

Also, it's a custom font that we're using and we had to convert this from open-type (which the source image used) to true-type. Might the kerning have been modified at this stage?


http://blog.stevex.net/rendering-text-using-the-net-framework/

The problem with these is that text kerning is measured differently – more accurately – but in a way that is often incompatible with the way app developers want to use these functions.

The solution:

ExtTextOut wasn’t smart enough to do this sort of kerning, so you don’t have this problem. Unfortunately the .NET framework doesn’t have any text drawing function that you can fall back on, so the only way to get the old behaviour is through P/Invoke to the ExtTextOut function in GDI.

The link has some example code.. hope that helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜