Visual Basic for Applications/Font Utilities

Summary

 * This page lists VBA procedures that are mainly to do with fonts.  That is to say, how VBA handles fonts.
 * The function GetTextPoints finds the width of text in points. A label on a userform extends when loaded with the string.  The width is then read from the control.   The userform and its contents are loaded but never shown.    Despite its seeming lack of elegance, this method is perhaps the simplest way of getting the fitting width for text, correct for any variation in the font.   The function is useful in the precise sizing of controls for complex layouts, such as tables within text boxes.
 * The procedure ListAllExcelFonts lists Excel's fonts on a worksheet.  It makes use of GetTextPoints.  While listing whether or not the font is monospaced, it also makes a sample of test text in each font.   It also lists the width in points for the sample text in each font.   Normalizing these width figures might be more useful but it is unclear as to which font is best to represent the standard.   As ever, informed comments would be useful.
 * The procedure FontExists tests whether or not a font exists.  It returns true in the function name if the parameter font name exists, otherwise it returns false.   Run testit to try the function.

Font Tests
The function GetTextPoints can be used to determine whether or not a font is monospaced. Although at first sight it would appear suitable for determining the presence of kerning, the userform control used to measure the width of text does not kern the text applied to it in any case. As such, kerning will always be found to be absent. The tests, whether used visually or in an automated mode, compare the lengths of selected strings. If the strings of the first pair below are the same length, then the font is monospaced. Elsewhere, if kerning had been applied, then the strings of the second pair would be different in length. Monospace test strings: IIIIIIIIII HHHHHHHHHH

Kerning test strings: for completeness only. AAAAATTTTT ATATATATAT