Tao.Sdl SDK Documentation

SdlTtf.TTF_OpenFont Method 

Open a font file and create a font of the specified point size. Some .fon fonts will have several sizes embedded in the file, so the point size becomes the index of choosing which size. If the value is too high, the last indexed size will be the default.

[Visual Basic]
Public Shared Function TTF_OpenFont( _
   ByVal file As String, _
   ByVal ptsize As Integer _
) As IntPtr
[C#]
public static IntPtr TTF_OpenFont(
   string file,
   int ptsize
);

Parameters

file
File name to load font from.
ptsize
Point size (based on 72DPI) to load font as. This basically translates to pixel height.

Return Value

a pointer to the font as a TTF_Font. NULL is returned on errors.

Remarks

Load file for use as a font, at ptsize size. This is actually TTF_OpenFontIndex(file, ptsize, 0). This can load TTF and FON files.

Binds to C-function in SDL_ttf.h

            TTF_Font *TTF_OpenFont(const char *file, int ptsize)
            

Example

            // load font.ttf at size 16 into font
                    TTF_Font *font;
                    font=TTF_OpenFont("font.ttf", 16);
                    if(!font)
                {
                    printf("TTF_OpenFont: %s\n", TTF_GetError());
                    // handle error
                }
            

See Also

SdlTtf Class | Tao.Sdl Namespace | TTF_OpenFontIndex | TTF_OpenFontRW | TTF_CloseFont