Tao.Sdl SDK Documentation

SdlTtf.TTF_OpenFontRW Method 

Open a font file suing RWOps 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_OpenFontRW( _
   ByVal src As IntPtr, _
   ByVal freesrc As Integer, _
   ByVal ptsize As Integer _
) As IntPtr
[C#]
public static IntPtr TTF_OpenFontRW(
   IntPtr src,
   int freesrc,
   int ptsize
);

Parameters

src
The font is loaded from this.
freesrc
A non-zero value mean is will automatically close/free the src for you.
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 src for use as a font, at ptsize size. This is actually TTF_OpenFontIndexRW(src, freesrc, ptsize, 0). This can load TTF and FON formats. Using SDL_RWops is not covered here, but they enable you to load from almost any source.

NOTE: src is not checked for NULL, so be careful.

Binds to C-function in SDL_ttf.h

            TTF_Font *TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize)
            

Example

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

See Also

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