Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FontMgr
#1
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:

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:

[Image: Screenshot-2024-03-21-024631.png]

Update: Added functionality to read any string from the font name table like family name, style, full name, vendor, designer, copyright etc.


Attached Files
.zip   FontMgr.zip (Size: 7.88 KB / Downloads: 33)
Reply


Messages In This Thread
FontMgr - by a740g - 03-20-2024, 02:27 AM
RE: FontMgr - by SMcNeill - 03-20-2024, 03:01 AM
RE: FontMgr - by a740g - 03-20-2024, 08:24 AM
RE: FontMgr - by a740g - 03-20-2024, 09:31 PM
RE: FontMgr - by a740g - 03-21-2024, 04:57 PM
RE: FontMgr - by SpriggsySpriggs - 03-22-2024, 05:51 PM



Users browsing this thread: 5 Guest(s)