Class TTFFont[in True Type]

Font representation of SDL TTF Class.

class TTFFont

more...

Summary

FontAscent()Get the maximum pixel ascent of all glyphs of the loaded font.
FontDescent()Get the maximum pixel descent of all glyphs of the loaded font.
FontFaceFamilyName()Determine the family name of this font.
FontFaceIsFixedWidth()Determines wether this font has fixed width or not.
FontFaceStyleName()Determine the face style name of this font.
FontFaces()Get the number of faces ("sub-fonts") available in the loaded font.
FontHeight()Get the maximum pixel height of all glyphs of the loaded font.
FontLineSkip()Get the recommended pixel height of a rendered line of text of the loaded font.
GetFontStyle()Get font render style
GlyphMetrics()Returns the metrics of a determined gliph in this font.
Render_Blended()Renders text on a final SDLSurface instance (medium).
Render_Shaded()Renders text on a final SDLSurface instance (medium).
Render_Solid()Renders text on a final SDLSurface instance (fast).
SetFontStyle()Set the rendering style of the loaded font.
SizeText()Determine rendering size of a text as it would be rendere on ttf.

Detailed description

Font representation of SDL TTF Class.

This class encapsulates all the font-specific methods and accessros that are provided by th SDL_ttf library.

Note: This class is private; it cannot be directly instantiated, it must be created through TTF.OpenFont

Methods

FontAscent()

Get the maximum pixel ascent of all glyphs of the loaded font.

TTFFont.FontAscent( )

Returns:Height of the ascent, in pixels.

FontDescent()

Get the maximum pixel descent of all glyphs of the loaded font.

TTFFont.FontDescent( )

Returns:Height of the descent, in pixels.

FontFaceFamilyName()

Determine the family name of this font.

TTFFont.FontFaceFamilyName( )

Returns:A string containing the family name of this font.

FontFaceIsFixedWidth()

Determines wether this font has fixed width or not.

TTFFont.FontFaceIsFixedWidth( )

Returns:True if the font is fixed width, false otherise.

FontFaceStyleName()

Determine the face style name of this font.

TTFFont.FontFaceStyleName( )

Returns: A string containing the style name, or nil if not available.

FontFaces()

Get the number of faces ("sub-fonts") available in the loaded font.

TTFFont.FontFaces( )

Returns:Number of faces stored in this font.

FontHeight()

Get the maximum pixel height of all glyphs of the loaded font.

TTFFont.FontHeight( )

Returns:Height of the font, in pixels.

You may use this height for rendering text as close together vertically as possible, though adding at least one pixel height to it will space it so they can't touch. Remember that SDL_ttf doesn't handle multiline printing, so you are responsible for line spacing, see the TTF_FontLineSkip as well.

FontLineSkip()

Get the recommended pixel height of a rendered line of text of the loaded font.

TTFFont.FontLineSkip( )

Returns:Recommended height, in pixels.

GetFontStyle()

Get font render style

TTFFont.GetFontStyle( )

Returns:Style currently active on this font.

Returned style can be TTF.STYLE_NORMAL or a bitfield or'd combination of the following:

GlyphMetrics()

Returns the metrics of a determined gliph in this font.

TTFFont.GlyphMetrics( charId, [metrics] )

charIdthe ID of the caracter of which the gliph are required.
metrics An instance of class TTFMetrics(or providing the same properties).
Returns: An instance of class TTFMetrics or nil.

This method stores the glyph metrics of character determined by the given charId into the minx, maxx, miny, maxy and advance properties of the object given as second parameter. If that object is not given, this method creates an instance of the TTFMetrics class and returns it. It is advisable to use repeatedly such instance to avoid useless garbage generation.

The function may fail if the charId is not found.

IF a fitting instace is provided as a parameter, then that value is returned. On failure, nil is returned.

Note: as object are always evaluated to true, the fact that this function returns an object can be used to determine if it was succesful or not.

Render_Blended()

Renders text on a final SDLSurface instance (medium).

TTFFont.Render_Blended( string, color )

stringA string or a character to be rendered.
color an SDLColor instance containing the color of the string.
Returns: an SDLSurface containing the rendered string.
Raises:
SDLErroron failure.

The first parameter may be a string or a numeric value, which will be interpreted as a single glyph to be rendered.

The color parameter may be any object providing r, g and b properties.

The function may fail if the some of the characters in the string cannot be represented with by this font.

Note: This function translates the input string in an UTF-8 string and then feeds it into TTF_RenderUTF_Solid as this is guaranteed to work with every character known by falcon and across any platform.

Render_Shaded()

Renders text on a final SDLSurface instance (medium).

TTFFont.Render_Shaded( string, color, bgcolor )

stringA string or a character to be rendered.
color an SDLColor instance containing the color of the string.
bgcolor an SDLColor instance containing the color of the background.
Returns: an SDLSurface containing the rendered string.
Raises:
SDLErroron failure.

The first parameter may be a string or a numeric value, which will be interpreted as a single glyph to be rendered.

The color parameter may be any object providing r, g and b properties.

The function may fail if the some of the characters in the string cannot be represented with by this font.

Note: This function translates the input string in an UTF-8 string and then feeds it into TTF_RenderUTF_Solid as this is guaranteed to work with every character known by falcon and across any platform.

Render_Solid()

Renders text on a final SDLSurface instance (fast).

TTFFont.Render_Solid( string, color )

stringA string or a character to be rendered.
color an SDLColor instance containing the color of the string.
Returns: an SDLSurface containing the rendered string.
Raises:
SDLErroron failure.

The first parameter may be a string or a numeric value, which will be interpreted as a single glyph to be rendered.

The color parameter may be any object providing r, g and b properties.

The function may fail if the some of the characters in the string cannot be represented with by this font.

Note: This function translates the input string in an UTF-8 string and then feeds it into TTF_RenderUTF_Solid as this is guaranteed to work with every character known by falcon and across any platform.

SetFontStyle()

Set the rendering style of the loaded font.

TTFFont.SetFontStyle( style )

styleRender style of this font.

The parameter can be TTF.STYLE_NORMAL or a bitfield or'd combination of the following:

SizeText()

Determine rendering size of a text as it would be rendere on ttf.

TTFFont.SizeText( string, [metrics] )

stringA string to be rendered.
metrics An instance of class TTFMetrics(or providing the same properties).
Returns: An instance of class TTFMetrics.

This method stores the width and height of the rendered string on the properties w and h of a given object.

The function may fail if the some of the characters in the string cannot be represented with by this font.

Note: This function translates the input string in an UTF-8 string and then feeds it into TTF_SizeUTF8 as this is guaranteed to work with every character known by falcon and across any platform.

IF a fitting instace is provided as a parameter, then that value is returned. On failure, nil is returned.

Note: as object are always evaluated to true, the fact that this function returns an object can be used to determine if it was succesful or not.


Made with faldoc 2.0.0