| Header file: | font.h |
| Object name: | fFONTNAMER |
| Object index: | 2 of 3 Objects (Others: fFONT and fFONTCHOOSER) |
The fFONTNAMER is a class designed to gather the names of all the installed fonts on the system. You can then use these names to set fonts with the fFONT object or do whatever else you want with them.
Important note: this object does not work. Windows thought it was a very nice big joke to make getting the names of the fonts a callback function, and thus we've all paid the price in that the list is very hard to get. My attempts failed for a reason I have not been able to track down. If you're good with the API, please have a look at it, and see if you can fix it. This would be a valuable component to have, if it worked.
If you do not wish to include this class with the font.h stuff, then please define F_FONT_H_NO_FONT_NAMER before you include the font.h file.
| Prototype | Description |
| int FindNames(int MaxNumber, char* Search); | This function goes away and does the search with the funny callback thingos and then returns the number of files that it found. MaxNumber is the maximum number of fonts to return. Search is the first few letters of the font to look for. You can use some of the functions further down this table to retrieve the fonts. |
| int FindNames(HDC HDCDevice, int MaxNumber, char* Search); | This function is like the above function except that it takes one more parameter. It takes a HDC as a parameter. This HDC means that the object will find fonts relevant to the device that the HDC belongs to. You can call this function with the HDC to a printer to get the fonts that can be printed on that printer. |
| int GetNumberFonts(void); | After you have searched for the fonts, this function will return the number of fonts that it found. |
| char* GetFontName(int Index); | This function reutrns the name of the font specified by Index. Index is zero based. |
| bool IsFontTrueType(int Index); | This function returns TRUE if the font specified by Index is a true type font. Index is zero based. |
| void IsFontDeviceFont(int Index); | This function returns TRUE if the font specified by Index is a device font. By a device font, I think it means that it is built into the device and the device does not need to have that font uploaded to it. The relevance of this to you is very little - except maybe if you try to manipulate the physical font file, because it most likely won't exist. Index is zero based. The information about this function needs to be taken with a grain of salt, its just what I think it does... |
| void IsFontRasterFont(int Index); | This function returns TRUE if the font specified by Index is a raster font. A raster font is built by having a grid of dots (not unlike a bitmap), and each dot has on/off information. When scaling a raster font, it may become pixelised easily and look shoddy. A true type font is different. It is a vector style - it has instructions like, "Line from 0,0 to 10,10", which can easily be scaled and look really good. Does that help? Index is zero based. |
| void CleanUp(void); | This function wipes all the memory that was used to store the names of the fonts due to the way Windows handles getting the fonts. Use this when you are finished with the fonts. If you don't use this, the memory will be cleared when the object is destroyed. Until then, there may be quite a large amount of memory tied up in this - at minimum 8 times the maximum number of fonts, but most likely 20-30 times this amount. So, for example, if we say to look for 300 fonts, then the minimum memory usage is 8x300, or 2,400 bytes. The average usage might well be 25x300, or 7,500 bytes. Well, it is a large block when you think that an int number takes up 4 bytes... |
The following snippet gives a basic idea of how to use this component.
//Create one...
fFONTNAMER FontNames;
//Search for...
FontNames.FindNames(300, "");
//Get them all...
for (int X = 0; X < FontNames.GetNumberFonts(); X++)
{
... = FontNames.GetFontName(X);
if (FontNames.IsFontTrueType(X))
{
//Font is true type (for what difference that makes)
}
}
//And when you are done...
FontNames.CleanUp();
| Back to index | The FreeFoote Foundation Classes Documentation |