03-20-2024, 02:27 AM
(This post was last modified: 03-21-2024, 04:55 PM by a740g.
Edit Reason: Update library
)
This is basically a continuation of some code I posted here.
I originally planned this for an upcoming update to InForm-PE's UiEditor. However, while experimenting with this, it turned out to be nice little 4-function cross-platform library. I am sharing it here hoping it might be useful.
The library has 4 functions:
Demo output:
Update: Added functionality to read any string from the font name table like family name, style, full name, vendor, designer, copyright etc.
I originally planned this for an upcoming update to InForm-PE's UiEditor. However, while experimenting with this, it turned out to be nice little 4-function cross-platform library. I am sharing it here hoping it might be useful.
The library has 4 functions:
Code: (Select All)
''' @brief Builds an array of fonts from that are available in the host OS (user installed + system installed).
''' @param fontList This a dynamic string array. The function will redimension fontList starting from 1.
''' @return The count of fonts found.
FUNCTION FontMgr_BuildList~& (fontList() AS STRING)
''' @brief Returns the font name by directly probing a font file.
''' @param filePath This the font file path name.
''' @param fontIndex This is the font index inside a TTC and it is always zero based. Must be 0 for TTF & OTF.
''' @param nameId The component needed from the font's name table
''' @return The name of the font. Invalid filePath or fontIndex will return an empty string.
FUNCTION FontMgr_GetName$ (filePath AS STRING, fontIndex AS _UNSIGNED LONG, nameId AS _UNSIGNED _BYTE)
''' @brief Returns the number of fonts in a collection (TTC).
''' @param filePath This the font file path name.
''' @return 1 or more for valid font files. 0 for invalid font files.
FUNCTION FontMgr_GetCount~& (filePath AS STRING)
''' @brief Probes and returns the supported font size range (useful for bitmap fonts).
''' @param filePath This the font file path name.
''' @param fontIndex This is the font index inside a TTC and it is always zero based. Must be 0 for TTF & OTF.
''' @param outMinSize [OUT] The minimum size supported by the font
''' @param outMaxSize [OUT] The maximum size supported by the font
''' @return True if a valid size range was probed
FUNCTION FontMgr_GetSizeRange%% (filePath AS STRING, fontIndex AS _UNSIGNED LONG, outMinSize AS _UNSIGNED _BYTE, outMaxSize AS _UNSIGNED _BYTE)
Demo output:
Update: Added functionality to read any string from the font name table like family name, style, full name, vendor, designer, copyright etc.