Name
hw_FindTTFFont -- find a TrueType font file (V5.0)
Synopsis
STRPTR file = hw_FindTTFFont(STRPTR name, int weight, int slant, int
                  fileonly, int *offset, int *len, int *tmp);
Function
This function can be used to find a matching TrueType font file for the specified font attributes. You have to pass a font family name in parameter 1. Additionally, you have to pass one of the following font weight constants in parameter 2:

 
#define HWFONTWEIGHT_THIN       0
#define HWFONTWEIGHT_EXTRALIGHT 40
#define HWFONTWEIGHT_ULTRALIGHT 40
#define HWFONTWEIGHT_LIGHT      50
#define HWFONTWEIGHT_BOOK       75
#define HWFONTWEIGHT_NORMAL     80
#define HWFONTWEIGHT_REGULAR    80
#define HWFONTWEIGHT_MEDIUM     100
#define HWFONTWEIGHT_SEMIBOLD   180
#define HWFONTWEIGHT_DEMIBOLD   180
#define HWFONTWEIGHT_BOLD       200
#define HWFONTWEIGHT_EXTRABOLD  205
#define HWFONTWEIGHT_ULTRABOLD  205
#define HWFONTWEIGHT_HEAVY      210
#define HWFONTWEIGHT_BLACK      210
#define HWFONTWEIGHT_EXTRABLACK 215
#define HWFONTWEIGHT_ULTRABLACK 215

If you pass -1 in the weight argument, hw_FindTTFFont() will ignore both the weight and the slant parameters. The slant parameter may be set to one of the following special constants:

 
#define HWFONTSLANT_ROMAN       0
#define HWFONTSLANT_ITALIC      100
#define HWFONTSLANT_OBLIQUE     110

If the fileonly parameter is set to True, hw_FindTTFFont() will only return stand-alone TrueType font files. If fileonly is set to False, hw_FindTTFFont() might also return TrueType fonts that have been linked into other files. In that case, hw_FindTTFFont() will write the TrueType font's location and its size inside the container file to the offset and len integer pointers that you have to pass as parameters 5 and 6.

Finally, if fileonly is False, hw_FindTTFFont() might also extract a TrueType font from a TTC file, write it to a temporary file and return this temporary file to you. If that is the case, hw_FindTTFFont() will write True to the tmp integer pointer that is the last parameter of this function. So if you find out that hw_FindTTFFont() has written True to the integer pointer you've passed as the last parameter, you will have to delete the temporary file when you're done with it.

Inputs
name
family name of the font file to find
weight
desired font weight or -1 (see above)
slant
desired font slant (see above)
fileonly
set this to True if you only want to have stand-alone files and no files-within-files or temporary TrueType fonts extracted by Hollywood (see above)
offset
must be set to an integer pointer that receives the offset of linked fonts in bytes
len
must be set to an integer pointer that receives the length of linked fonts in bytes
tmp
must be set to an integer pointer that is set to True or False depending on whether this function has created a temporary file
Designer compatibility
Supported since Designer 4.0

Results
file
fully-qualified path to a TrueType font file that matches your request or NULL if no font could be found

Show TOC