如何使用 Graphics.DrawString 绘制双倍高度文本?
我正在尝试使用 System.Drawing 模拟 POS 打印机,我需要的功能之一是以双倍高度绘制文本。 知道如何使用 .Net 的 Graphics 类来做到这一点吗?
我需要将文本绘制两倍大并压缩它还是绘制正常大小然后拉伸? 两者似乎都是混乱的选择,但还有其他选择吗?
I am trying to emulate a POS printer with System.Drawing and one of the functions I need is to draw text at double height. Any idea how I can do this using .Net's Graphics class?
Do I need to draw the text twice as large and condense it or draw normal size and then stretch? Both seem like messy options but is there an alternative?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 Graphics 对象上的变换矩阵 - 您可以独立控制水平和垂直缩放。
Look at the transformation matrix on the Graphics object - you can control horizontal and vertical scaling independently.
使用 ScaleTransform 并仅放大 y。
Use a ScaleTransform and only scale up the y.