我正在寻找一种方法来找到每个字母使用最少平均水平空间的字体,因为我的应用程序中有一些按钮需要在其中显示相当长的文本,目标是使按钮具有所需的最小宽度。
由于我已经知道要安装应用程序的环境,因此解决方案不一定是脚本或程序,对我来说在设计时拥有字体就足够了。
就其价值而言,它将是一个 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.
发布评论
评论(6)
我认为您并不真正想要绝对最窄的字体,因为这很可能是某种符号/实用字体,实际上可能不包含真实字符。当然,在我的系统上,“最窄”字体将是几乎不包含拉丁字符的字体,使得其中呈现的字符串的宽度几乎为零!
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.
尝试枚举所有字体,测量每种字体的“敏捷的棕色狐狸跳过了懒惰的狗”,然后选择占用空间最小的字体。
此链接解释了如何枚举字体
此链接解释了如何测量字符串
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
不敢相信这还没有被提及:只需减少按钮上的文本量!
如果您需要在按钮上放置一个句子,那么您就错了< /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.
如果是我,我会使用
Arial Narrow
If me, I will use
Arial Narrow
只需获取一些字体查看器应用程序,例如 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.
我只是回答这个问题,不评论这是否是一个好主意或是否是解决您问题的正确解决方案。
GetTextMetrics
。I'm just answering the question without any comment on whether it's a good idea or the right solution for your problem.
GetTextMetrics
.tmAveCharWidth
field of the metrics structure. If it's smaller than the smallest found so far, remember it and the font.