C# windows 窗体 - 是否可以通过公制系统以编程方式确定文本大小?如果是这样,如何? [英] C# windows form - Is it possible to programmatically determine text size through the metric system? If so, how?

查看:51
本文介绍了C# windows 窗体 - 是否可以通过公制系统以编程方式确定文本大小?如果是这样,如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道将文档格式化为小卡片的尺寸是多么尴尬吗?我正在尝试为自己编写一个程序,以便我可以做到这一点,部分原因是我的笔迹不好,我需要写一些物理感谢"卡片,部分原因只是为了体验.

You know how it's kinda awkward to format a document into the dimensions of a small card? I'm trying to write myself a program so that I can do that, partially because my handwriting is bad and I need to write some physical "thank you" cards, and partially just for the experience.

我计划这样做的方法是制作一个 C# windows 窗体并根据卡片的尺寸调整富文本框的大小.然后我会将它转换成一个 rtf 文件,这样我就可以在一台有打印机的电脑上打印出来.事情是,据我所知,您只能使用像素作为指标来调整大小.像素并不是衡量您将要打印在纸上的东西的非常一致的方式,因为它们完全取决于您的屏幕分辨率.

The way I was planning on doing this was by making a C# windows form and resizing a rich text box based on the measurements of the card. I would then convert it into an rtf file, so I can print it out on a computer that actually has a printer. The thing is, as far as I know, you can only resize using pixels as a metric. And pixels aren't a very consistent way to measure something that you're going to print on paper, as they're completely dependant on the resolution of your screen.

如何使用有形的测量值(例如厘米)来调整某些内容的大小?

How could I resize something using a tangible measurement, like centimeters?

推荐答案

位图测量指标是像素.Bitmat 格式有一个元数据,它是 DPI(每英寸点数),用于通过简单的公式将像素大小转换为厘米大小:

Bitmaps measuring metric is pixels. Bitmat formats have a piece of metadata it is DPI (dots per inch) that is used to translate a size in pixels to a size in centimeters via the simple formula:

厘米 = 像素/dpi * 2.54在构建 Image 类时,必须使用 SetPropertyItem 方法设置元数据:

centimeters = pixels / dpi * 2.54 when you are building your Image class you must set metadata using the SetPropertyItem Method:

PropertyTagResolutionUnit - 将厘米设置为3"PropertyTagXResolution - 本质上是 X DPI,只要 PropertyTagResolutionUnit 以厘米为单位PropertyTagYResolution - 只要 PropertyTagResolutionUnit 以厘米为单位的 Y DPI

PropertyTagResolutionUnit - set this to "3" for centimeter PropertyTagXResolution - Essentially the X DPI as long as PropertyTagResolutionUnit is in centimeters PropertyTagYResolution - The Y DPI as long as PropertyTagResolutionUnit is in centimeters

点击此链接了解有关 PropertyTag 值的更多信息:https://msdn.microsoft.com/en-us/library/ee491082.aspx

follow this link for more information about PropertyTag Values: https://msdn.microsoft.com/en-us/library/ee491082.aspx

http://zigmaweb.com

这篇关于C# windows 窗体 - 是否可以通过公制系统以编程方式确定文本大小?如果是这样,如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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