views:

441

answers:

6

Hello

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.

A: 

If me, I will use Arial Narrow

S.Mark
Ahh .. Damn! you beat me to it
Mahesh Velaga
I got the notification when I am about to click post answer :)
Mahesh Velaga
A: 

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

erikkallen
Yes, that is an obvious way to do it; less obvious to me is how exactly I'd go about a) enumerating all fonts and b) taking the one that occupies the least space.
René Nyffenegger
+1  A: 

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.

bobince
A: 

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.

PhiLho
A: 

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.

DisgruntledGoat
It has been mentioned, and I jave already commented on it.
René Nyffenegger
OK fine. I only read the first sentence of that comment and assumed it was another person posting an answer in a comment instead of as an answer...
DisgruntledGoat
A: 

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.
Adrian McCarthy