Uli Gerhardt
Uli Gerhardt

Reputation: 14001

Find out if font has monospaced numbers

There are proportional fonts (i.e. not monospaced) that nevertheless provide monospaced numbers. E.g. see this Excel screenshot using Arial:

Excel screenshot

Note how the numbers are nicely aligned. How can I find out programmatically (probably WinAPI) if a font supports this feature?

Upvotes: 0

Views: 434

Answers (1)

Peter Constable
Peter Constable

Reputation: 3570

You won't find an API for that because there isn't any specific metadata value within the font file to indicate "the glyphs for digits in this font have fixed width". Some fonts may support both proportional and fixed-width ("lining") digits, in which case the font is likely to support the 'lnum' OpenType Layout feature. You should pick a font that supports this feature and then explicitly activate that feature when drawing the text.

Upvotes: 1

Related Questions