在System.Drawing.Graphics.DrawString()中修改字距调整 [英] Modifying the kerning in System.Drawing.Graphics.DrawString()

查看:195
本文介绍了在System.Drawing.Graphics.DrawString()中修改字距调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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.

问题在于DrawString()生成的文本与现有图像中的文本具有不同的字距调整(我的最佳猜测是每个字母大约0.5-1像素).

The problem is that the text generated by 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?

此外,这是我们使用的自定义字体,我们必须将其从open-type(源图像使用的字体)转换为true-type.字距调整是否可以在此阶段进行修改?

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/

这些问题是,对字距调整的衡量方式有所不同-更准确-但其方式通常与应用程序开发人员希望使用这些功能的方式不兼容.

解决方案:

ExtTextOut不够聪明,无法进行此类字距调整,因此您不会遇到此问题.不幸的是,.NET框架没有任何可以依靠的文本绘制功能,因此,获得旧行为的唯一方法是通过P/Invoke调用GDI中的ExtTextOut函数.

该链接包含一些示例代码.希望对您有所帮助!

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

这篇关于在System.Drawing.Graphics.DrawString()中修改字距调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆