- This wiki is out of date, use the continuation of this wiki instead
Load ttf
From FenixWiki
Revision as of 12:29, 29 February 2008 (edit) Sandman (Talk | contribs) (New page: Category:functions Category:networkdll Category:dll '''Up to Network.DLL Functions''' ---- ==Definition== '''INT''' load_ttf ( <'''STRING''' ...) ← Previous diff |
Current revision (00:54, 1 March 2008) (edit) (undo) Sandman (Talk | contribs) m |
||
(2 intermediate revisions not shown.) | |||
Line 1: | Line 1: | ||
[[Category:functions]] | [[Category:functions]] | ||
- | [[Category: | + | [[Category:ttfdll]] |
[[Category:dll]] | [[Category:dll]] | ||
- | [[Functioncategory: | + | [[Functioncategory:Ttfdll|'''Up to TTF.DLL Functions''']] |
---- | ---- | ||
Line 10: | Line 10: | ||
'''INT''' load_ttf ( <'''STRING''' filename> , <'''INT''' height> ) | '''INT''' load_ttf ( <'''STRING''' filename> , <'''INT''' height> ) | ||
- | Loads a [[TTF]] file into memory. | + | Loads a [[TTF]] file as a [[font]] into memory. |
+ | |||
+ | Also called '''TTF_Load'''() (if TTF.fh is included). | ||
== Parameters == | == Parameters == | ||
Line 16: | Line 18: | ||
| '''STRING''' filename || - The filename of the [[TTF]] file that you wish to load (including extension and possible path). | | '''STRING''' filename || - The filename of the [[TTF]] file that you wish to load (including extension and possible path). | ||
|- | |- | ||
- | | '''INT''' height || - The height of the font | + | | '''INT''' height || - The height in pixels of the to be created font, a size indication. |
|} | |} | ||
Line 23: | Line 25: | ||
{| | {| | ||
| -1 || - Error: file does not exist; insufficient memory; failed to init freetype.dll; error while loading file; error creating new font. | | -1 || - Error: file does not exist; insufficient memory; failed to init freetype.dll; error while loading file; error creating new font. | ||
+ | |- | ||
+ | | 0 || - Invalid filename. | ||
|- | |- | ||
| >0 || - The FontID. | | >0 || - The FontID. | ||
Line 55: | Line 59: | ||
Begin | Begin | ||
+ | set_text_color(rgb(255,0,255)); | ||
fontID = load_ttf("myttf.ttf",20); | fontID = load_ttf("myttf.ttf",20); | ||
Line 67: | Line 72: | ||
End | End | ||
</pre> | </pre> | ||
- | Used in example: [[write]](), [[key]](), [[unload_fnt]]() | + | Used in example: [[set_text_color]](), [[rgb]](), [[load_ttf]](), [[write]](), [[key]](), [[unload_fnt]]() |
{{Ttffuncbox}} | {{Ttffuncbox}} |
Current revision
Contents |
[edit] Definition
INT load_ttf ( <STRING filename> , <INT height> )
Loads a TTF file as a font into memory.
Also called TTF_Load() (if TTF.fh is included).
[edit] Parameters
STRING filename | - The filename of the TTF file that you wish to load (including extension and possible path). |
INT height | - The height in pixels of the to be created font, a size indication. |
[edit] Returns
INT : FontID
-1 | - Error: file does not exist; insufficient memory; failed to init freetype.dll; error while loading file; error creating new font. |
0 | - Invalid filename. |
>0 | - The FontID. |
[edit] Errors
Insufficient memory | - There is insufficient memory available. This error doesn't occur often. |
Failed to init freetype.dll | - There was an error initializing freetype.dll |
Error loading file | - There occurred an error while trying to load the file. |
Error creating new font | - There occurred an error while trying to create a new font. |
[edit] Notes
This function gets a TrueType font and creates a new font with generated glyphs based on the recovered font in the standard characters set (ISO-8859-1). These glyphs are generated with two colours, being colour 0 (transparent) and the color last set by set_text_color(). The first one is the background colour and the last one is the colour of the characters self.
It's possible to save the loaded font as FNT with save_fnt(). This way the font can be reused on platforms not supporting TTF.DLL. Note that a FNT file only has information about the font for one size, while a TTF file has information for any size.
The specified size is only an indication; some characters may be a little higher in fact.
[edit] Example
include "TTF.fh"; Process Main() Private int fontID; Begin set_text_color(rgb(255,0,255)); fontID = load_ttf("myttf.ttf",20); write(fontID,160,100,4,"Look at my TTF font!"); Repeat frame; Until(key(_ESC)) unload_fnt(fontID); End
Used in example: set_text_color(), rgb(), load_ttf(), write(), key(), unload_fnt()
TTF.DLL Functions | |
• Load_ttf() • Load_ttfaa() • |
Categories: Functions | Ttfdll | Dll