如何确定“最窄”范围? Windows 上的字体?

发布于 2024-08-12 13:33:42 字数 178 浏览 7 评论 0 原文

我正在寻找一种方法来找到每个字母使用最少平均水平空间的字体,因为我的应用程序中有一些按钮需要在其中显示相当长的文本,目标是使按钮具有所需的最小宽度。

由于我已经知道要安装应用程序的环境,因此解决方案不一定是脚本或程序,对我来说在设计时拥有字体就足够了。

就其价值而言,它将是一个 ms-Access 应用程序。

I am looking for a way to find the font that uses the least average horizontal space per letter, since I have a few buttons in my application that need to show a rather long text in it, and the goal is to make the buttons with the minimal width necessary.

Since I already know the environment where the application is going to be installed, the solution needs not necessarily be a script or program, it is sufficient for me to have the font at design time.

For what it is worth, it is going to be an ms-Access application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

冷清清 2024-08-19 13:33:42

我认为您并不真正想要绝对最窄的字体,因为这很可能是某种符号/实用字体,实际上可能不包含真实字符。当然,在我的系统上,“最窄”字体将是几乎不包含拉丁字符的字体,使得其中呈现的字符串的宽度几乎为零!

Arial Narrow 由 Office 安装,因此对于 Access 应用程序来说这似乎是一个合理的选择。如果您想要比这更窄的字体,我认为您必须捆绑自己的特定字体。

I don't think you really want the absolute narrowest font, as that may well be some kind of symbol/utility font which may not actually contain real characters. Certainly on my system here the ‘narrowest’ font would be one that contains almost no Latin characters, making the width of the string rendered in it almost zero!

Arial Narrow is installed by Office, so that would seem a reasonable choice for an Access application. If you want narrower than that I think you'd have to bundle a particular font of your own.

杀お生予夺 2024-08-19 13:33:42

尝试枚举所有字体,测量每种字体的“敏捷的棕色狐狸跳过了懒惰的狗”,然后选择占用空间最小的字体。

此链接解释了如何枚举字体

此链接解释了如何测量字符串

Try to enumerate all fonts, measuring "The quick brown fox jumped over the lazy dog" with each one and then take the one that occupies the least space.

This link explains how to enumerate fonts

This link explains how to measure strings

负佳期 2024-08-19 13:33:42

不敢相信这还没有被提及:只需减少按钮上的文本量!

如果您需要在按钮上放置一个句子,那么您就错了< /em>.您应该有一两个单词,最好是用户将执行的操作(而不是确定/取消)。如有必要,您可以使用该对话框来更具体地描述每个操作的含义。

更不用说较窄的字体会使文本更难以阅读,无论文本内容有多少。

Can't believe this hasn't been mentioned yet: just reduce the amount of text on the buttons!

If you need to put a sentence on a button then You're Doing It Wrong. You should have one or two words, preferably with the action the user will do (as opposed to OK/Cancel). You can use the dialog for a more specific description of what each action entails, if necessary.

Not to mention a narrower font makes the text harder to read anyway, however much there is.

童话 2024-08-19 13:33:42

如果是我,我会使用 Arial Narrow

If me, I will use Arial Narrow

美羊羊 2024-08-19 13:33:42

只需获取一些字体查看器应用程序,例如 AMP Font Viewer。他们通常提供一个选项来列出所有已安装的字体,并以任意字符串和字体本身显示。

在我的系统上,我看到很多字体(非标准)比 Arial Narrow 窄。比如众所周知的 Haettenschweiler,或者一些“压缩”字体。

Just get some font viewer application like AMP Font Viewer. They often offer an option to list all installed fonts displayed with an arbitrary string with the font itself.

On my system, I see lot of fonts (non standard) narrower than Arial Narrow. Like the well known Haettenschweiler, or a number of "condensed" fonts.

若水般的淡然安静女子 2024-08-19 13:33:42

我只是回答这个问题,不评论这是否是一个好主意或是否是解决您问题的正确解决方案。

  1. 枚举字体。
  2. 对于每种字体,实例化它,将其选择到 DC 中,然后使用 call GetTextMetrics
  3. 检查指标结构的 tmAveCharWidth 字段。如果它比迄今为止找到的最小的小,请记住它和字体。
  4. 从 DC 中选择字体并销毁它。
  5. 重新创建平均字符宽度最小的字体并使用它。

I'm just answering the question without any comment on whether it's a good idea or the right solution for your problem.

  1. Enumerate the fonts.
  2. For each font, instantiate it, select it into the DC, and use call GetTextMetrics.
  3. Check the tmAveCharWidth field of the metrics structure. If it's smaller than the smallest found so far, remember it and the font.
  4. Select the font out of the DC and destroy it.
  5. Recreate the font with the smallest average character width and use it.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文