Tao.Sdl SDK Documentation

SdlTtf.TTF_OpenFontIndex 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_OpenFontIndex( _
   ByVal file As String, _
   ByVal ptsize As Integer, _
   ByVal index As Long _
) As IntPtr
[C#]
public static IntPtr TTF_OpenFontIndex(
   string file,
   int ptsize,
   long index
);

Parameters

file
File name to load font from.
ptsize
Point size (based on 72DPI) to load font as. This basically translates to pixel height.
index
choose a font face from a multiple font face containing file. The first face is always index 0.

Return Value

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

Remarks

Load file, face index, for use as a font, at ptsize size. This is actually TTF_OpenFontIndexRW(SDL_RWFromFile(file), ptsize, index), but checks that the RWops it creates is not NULL. This can load TTF and FON files.

Binds to C-function in SDL_ttf.h

            TTF_Font *TTF_OpenFontIndex(const char *file, int ptsize, long index)
            

Example

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

See Also

SdlTtf Class | Tao.Sdl Namespace | TTF_OpenFontIndexRW | TTF_OpenFont | TTF_CloseFont