TSdlTtfFont
A TTF Font.
Definition
Unit: Neslib.Sdl3.Ttf
Properties
Name | Description |
---|---|
Ascent | The offset from the baseline to the top of a font. |
Descent | The offset from the baseline to the bottom of a font. |
Direction | The direction to be used for text shaping by the font. |
FamilyName | The font's family name. |
Generation | The font generation. |
Height | The total height of a font. |
Hinting | The font's current hinter setting. |
IsFixedWidth | Whether the font is fixed-width. |
IsKerningEnabled | Whether kerning is enabled for the font. |
IsScalable | Query whether a font is scalable or not. |
IsSdfEnabled | Whether Signed Distance Field rendering for the font is enabled. |
Language | The language to be used for text shaping by the font, as a BCP47 language code. Set to an empty string to reset the value. |
LineSkip | The spacing between lines of text for a font. |
NumFaces | The number of faces of the font. |
Outline | The font's current outline. |
Properties | The properties associated with the font. |
Script | The script to be used for text shaping by the font. This is an ISO 15924 code. |
Size | The font's size in points. |
Style | The font's current style. |
StyleName | The font's style name. |
WrapAlignment | The font's current wrap alignment option. |
Constructors
Name | Description |
---|---|
Create(TSdlProperties) | Create a font with the specified properties. |
Create(TSdlIOStream, Boolean, Single) | Create a font from a TSdlIOStream, using a specified point size. |
Create(String, Single) | Create a font from a file, using a specified point size. |
Operators
Name | Description |
---|---|
Equal(TSdlTtfFont, TSdlTtfFont) | Used to compare against another TSdlTtfFont. |
Equal(TSdlTtfFont, Pointer) | Used to compare against nil . |
Implicit | Used to set the value to nil . |
NotEqual(TSdlTtfFont, TSdlTtfFont) | Used to compare against another TSdlTtfFont. |
NotEqual(TSdlTtfFont, Pointer) | Used to compare against nil . |
Methods
Name | Description |
---|---|
AddFallback | Add a fallback font. |
ClearFallbacks | Remove all fallback fonts. |
Clone | Create a copy of this font. |
Free | Disposes of the font. |
GetDpi | Get font target resolutions, in dots per inch. |
GetGlyphImage(UCS4Char, TSdlTtfImageType) | Get the pixel image for a Unicode codepoint. |
GetGlyphImage(UCS4Char) | Get the pixel image for a Unicode codepoint. |
GetGlyphImageForIndex(Integer, TSdlTtfImageType) | Get the pixel image for a character index. |
GetGlyphImageForIndex(Integer) | Get the pixel image for a character index. |
GetGlyphKerning | Query the kerning size between the glyphs of two Unicode codepoints. |
GetGlyphMetrics | Query the metrics (dimensions) of a font's glyph for a Unicode codepoint. |
GetTextSize(String, Integer) | Calculate the dimensions of a rendered string of Unicode text. |
GetTextSize(String) | Calculate the dimensions of a rendered string of Unicode text. |
HasGlyph | Check whether a glyph is provided by the font for a Unicode codepoint. |
MeasureText(String, Integer, Integer) | Calculate how much of a Unicode string will fit in a given width. |
MeasureText(String, Integer) | Calculate how much of a Unicode string will fit in a given width. |
RemoveFallback | Remove a fallback font. |
RenderGlyph(UCS4Char, TSdlTtfRenderMode, TSdlColor, TSdlColor) | |
RenderGlyph(UCS4Char, TSdlTtfRenderMode, TSdlColor) | Render a single 32-bit codepoint a new surface. |
RenderText(String, TSdlTtfRenderMode, TSdlColor, TSdlColor, Integer) | |
RenderText(String, TSdlTtfRenderMode, TSdlColor, Integer) | Render Unicode text to a new surface, optionally wrapping the text. |
SetSizeDpi | Set font size dynamically with target resolutions, in dots per inch. |
Property Descriptions
Ascent
The offset from the baseline to the top of a font.
This is a positive value, relative to the baseline.
property Ascent: Integer read GetAscent
Type: Integer
Remarks
It is safe to use this property from any thread.
Descent
The offset from the baseline to the bottom of a font.
This is a negative value, relative to the baseline.
property Descent: Integer read GetDescent
Type: Integer
Remarks
It is safe to use this property from any thread.
Direction
The direction to be used for text shaping by the font.
This function only supports left-to-right text shaping if SDL_ttf was not built with HarfBuzz support.
This updates any TSdlTtfText objects using this font.
Returns TSdlTtfDirection.Invalid if it hasn't been set.
property Direction: TSdlTtfDirection read GetDirection write SetDirection
Type: TSdlTtfDirection
Exceptions
ESdlError
: Raised on failure.
Remarks
This property should be used on the thread that created the font.
FamilyName
The font's family name.
This string is dictated by the contents of the font file.
property FamilyName: String read GetFamilyName
Type: String
Remarks
It is safe to use this property from any thread.
Generation
The font generation.
The generation is incremented each time font properties change that require rebuilding glyphs, such as style, size, etc.
property Generation: Cardinal read GetGeneration
Type: Cardinal
Exceptions
ESdlError
: Raised on failure.
Remarks
This property should be used on the thread that created the font.
Height
The total height of a font.
This is usually equal to point size.
property Height: Integer read GetHeight
Type: Integer
Remarks
It is safe to use this property from any thread.
Hinting
The font's current hinter setting.
This updates any TSdlTtfText objects using this font, and clears already-generated glyphs, if any, from the cache.
property Hinting: TSdlTtfHinting read GetHinting write SetHinting
Type: TSdlTtfHinting
Remarks
This property should be used on the thread that created the font.
IsFixedWidth
Whether the font is fixed-width.
A "fixed-width" font means all glyphs are the same width across; a lowercase 'i' will be the same size across as a capital 'W', for example. This is common for terminals and text editors, and other apps that treat text as a grid. Most other things (WYSIWYG word processors, web pages, etc) are more likely to not be fixed-width in most cases.
property IsFixedWidth: Boolean read GetIsFixedWidth
Type: Boolean
Remarks
It is safe to use this property from any thread.
IsKerningEnabled
Whether kerning is enabled for the font.
Newly-opened fonts default to allowing kerning. This is generally a good policy unless you have a strong reason to disable it, as it tends to produce better rendering (with kerning disabled, some fonts might render the word kerning
as something that looks like keming
for example).
This updates any TSdlTtfText objects using this font.
property IsKerningEnabled: Boolean read GetIsKerningEnabled write SetIsKerningEnabled
Type: Boolean
Remarks
This property should be used on the thread that created the font.
IsScalable
Query whether a font is scalable or not.
Scalability lets us distinguish between outline and bitmap fonts.
property IsScalable: Boolean read GetIsScalable
Type: Boolean
See Also
Remarks
It is safe to use this property from any thread.
IsSdfEnabled
Whether Signed Distance Field rendering for the font is enabled.
SDF is a technique that helps fonts look sharp even when scaling and rotating, and requires special shader support for display.
This works with Blended APIs, and generates the raw signed distance values in the alpha channel of the resulting texture.
This updates any TSdlTtfText objects using this font, and clears already-generated glyphs, if any, from the cache.
property IsSdfEnabled: Boolean read GetIsSdfEnabled write SetIsSdfEnabled
Type: Boolean
Exceptions
ESdlError
: Raised on failure.
Remarks
This property should be used on the thread that created the font.
Language
The language to be used for text shaping by the font, as a BCP47 language code. Set to an empty string to reset the value.
This method fails if SDL_ttf isn't built with HarfBuzz support.
This updates any TTF_Text objects using this font.
property Language: String write SetLanguage
Type: String
Exceptions
ESdlError
: Raised on failure.
Remarks
This property should be used on the thread that created the font.
LineSkip
The spacing between lines of text for a font.
This updates any TSdlTtfText objects using this font.
property LineSkip: Integer read GetLineSkip write SetLineSkip
Type: Integer
Remarks
This property should be used on the thread that created the font.
NumFaces
The number of faces of the font.
property NumFaces: Integer read GetNumFaces
Type: Integer
Remarks
It is safe to use this property from any thread.
Outline
The font's current outline.
This uses the font properties TSdlTtfProperty.FontOutlineLineCap
, TSdlTtfProperty.FontOutlineLineJoin
, and TSdlTtfProperty.FontOutlineMiterLimit
when setting the font outline.
This updates any TSdlTtfText objects using this font, and clears already-generated glyphs, if any, from the cache.
Set to 0 to use the default value.
property Outline: Integer read GetOutline write SetOutline
Type: Integer
Exceptions
ESdlError
: Raised on failure.
Remarks
This property should be used on the thread that created the font.
Properties
The properties associated with the font.
The following read-write properties are provided by SDL:
TSdlTtfProperty.FontOutlineLineCap
: The TSdlTtfLineCap value used when setting the font outline, defaults toTSdlTtfLineCap.Round
.TSdlTtfProperty.FontOutlineLineJoin
: The TSdlTtfLineJoin value used when setting the font outline, defaults toTSdlTtfLineJoin.Round
.TSdlTtfProperty.FontMiterLimit
: The miter limit used when setting the font outline, defaults to 0. This is a 16.16 integer fixed point value, meaning should should divide by 65,536 to get the floating- point equivalent.
property Properties: TSdlProperties read GetProperties
Type: TSdlProperties
Exceptions
ESdlError
: Raised on failure.
Remarks
It is safe to use this property from any thread.
Script
The script to be used for text shaping by the font. This is an ISO 15924 code.
This method fails if SDL_ttf isn't built with HarfBuzz support. Returns 0 if a script hasn't been set.
This updates any TSdlTtfText objects using this font.
property Script: Cardinal read GetScript write SetScript
Type: Cardinal
Exceptions
ESdlError
: Raised on failure.
See Also
Remarks
This property should be used on the thread that created the font.
Size
The font's size in points.
Changing this updates any TSdlTtfText objects using this font, and clears already-generated glyphs, if any, from the cache.
property Size: Single read GetSize write SetSize
Type: Single
Exceptions
ESdlError
: Raised on failure.
See Also
Remarks
This property should be used on the thread that created the font.
Style
The font's current style.
Setting this updates any TSdlTtfText objects using this font, and clears already-generated glyphs, if any, from the cache.
property Style: TSdlTtfFontStyles read GetStyle write SetStyle
Type: TSdlTtfFontStyles
Remarks
This property should be used on the thread that created the font.
StyleName
The font's style name.
This string is dictated by the contents of the font file.
property StyleName: String read GetStyleName
Type: String
Remarks
It is safe to use this property from any thread.
WrapAlignment
The font's current wrap alignment option.
This updates any TSdlTtfText objects using this font.
property WrapAlignment: TSdlTtfHorizontalAlignment read GetWrapAlignment write SetWrapAlignment
Type: TSdlTtfHorizontalAlignment
Remarks
This property should be used on the thread that created the font.
Constructor Descriptions
Create
Create a font with the specified properties.
These are the supported properties:
TSdlTtfProperty.FontCreateFilename
: the font file to open, if a TSdlIOStream isn't being used. This is required ifTSdlTtfProperty.FontCreateIOStream
andTSdlTtfProperty.FontCreateExistingFont
aren't set.TSdlTtfProperty.FontCreateIOStream
: a TSdlIOStream containing the font to be opened. This should not be closed until the font is closed. This is required ifTSdlTtfProperty.FontCreateFilename
andTSdlTtfProperty.FontCreateExistingFont
aren't set.TSdlTtfProperty.FontCreateIOStreamOffset
: the offset in the iostream for the beginning of the font, defaults to 0.TSdlTtfProperty.FontCreateIOStreamAutoClose
: True if closing the font should also close the associated TSdlIOStream.TSdlTtfProperty.FontCreateSize
: the point size of the font. 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.TSdlTtfProperty.FontCreateFace
: the face index of the font, if the font contains multiple font faces.TSdlTtfProperty.FontCreateHorizontalDpi
: the horizontal DPI to use for font rendering, defaults toTSdlTtfProperty.FontCreateVerticalDpi
if set, or 72 otherwise.TSdlTtfProperty.FontCreateVerticalDpi
: the vertical DPI to use for font rendering, defaults toTSdlTtfProperty.FontCreateHorizontalDpi
if set, or 72 otherwise.TSdlTtfProperty.FontCreateExistingFont
: an optional TSdlTtfFont that, if set, will be used as the font data source and the initial size and style of the new font.
constructor Create(const AProps: TSdlProperties); overload
Parameters
AProps
: TSdlProperties
: The properties to use.
Exceptions
ESdlError
: Raised on failure.
See Also
Remarks
It is safe to call this constructor from any thread.
Create
Create a font from a TSdlIOStream, using a 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.
If ACloseIO
is True, ASrc
will be automatically closed once the font is freed. Otherwise you should close ASrc
yourself after freeing the font. The stream must stay alive while the font is in use.
When done with the font, use Free to dispose of it.
constructor Create(const ASrc: TSdlIOStream; const ACloseIO: Boolean; const APtSize: Single); overload
Parameters
ASrc
: TSdlIOStream
: A TSdlIOStream to provide a font file's data.
ACloseIO
: Boolean
: True to close ASrc
when the font is freed, False to leave it open.
APtSize
: Single
: Point size to use for the newly-opened font.
Exceptions
ESdlError
: Raised on failure.
See Also
Remarks
It is safe to call this constructor from any thread.
Create
Create a font from a file, using a 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.
When done with the font, use Free to dispose of it.
constructor Create(const AFile: String; const APtSize: Single); overload
Parameters
AFile
: String
: Path to font file.
APtSize
: Single
: Point size to use for the newly-opened font.
Exceptions
ESdlError
: Raised on failure.
See Also
Remarks
It is safe to call this constructor from any thread.
Operator Descriptions
Equal(TSdlTtfFont, TSdlTtfFont)
Used to compare against another TSdlTtfFont.
class operator Equal(const ALeft, ARight: TSdlTtfFont): Boolean; inline; static
Parameters
ALeft
: TSdlTtfFont
ARight
: TSdlTtfFont
Returns
Boolean
Equal(TSdlTtfFont, Pointer)
Used to compare against nil
.
class operator Equal(const ALeft: TSdlTtfFont; const ARight: Pointer): Boolean; inline; static
Parameters
ALeft
: TSdlTtfFont
ARight
: Pointer
Returns
Boolean
Implicit(Pointer)
Used to set the value to nil
.
class operator Implicit(const AValue: Pointer): TSdlTtfFont; inline; static
Parameters
AValue
: Pointer
Returns
NotEqual(TSdlTtfFont, TSdlTtfFont)
Used to compare against another TSdlTtfFont.
class operator NotEqual(const ALeft, ARight: TSdlTtfFont): Boolean; inline; static
Parameters
ALeft
: TSdlTtfFont
ARight
: TSdlTtfFont
Returns
Boolean
NotEqual(TSdlTtfFont, Pointer)
Used to compare against nil
.
class operator NotEqual(const ALeft: TSdlTtfFont; const ARight: Pointer): Boolean; inline; static
Parameters
ALeft
: TSdlTtfFont
ARight
: Pointer
Returns
Boolean
Method Descriptions
AddFallback(TSdlTtfFont)
Add a fallback font.
Add a font that will be used for glyphs that are not in this font. The fallback font should have the same size and style as this font.
If there are multiple fallback fonts, they are used in the order added.
This updates any TSdlTtfText objects using this font.
procedure AddFallback(const AFallback: TSdlTtfFont); inline
Exceptions
ESdlError
: Raised on failure.
Parameters
AFallback
: TSdlTtfFont
: The font to add as a fallback.
See Also
Remarks
This method should be called on the thread that created both fonts.
ClearFallbacks
Remove all fallback fonts.
This updates any TSdlTtfText objects using this font.
procedure ClearFallbacks
See Also
Remarks
This method should be called on the thread that created the font.
Clone
Create a copy of this font.
The copy will be distinct from the original, but will share the font file and have the same size and style as the original.
When done with the returned font, use Free to dispose of it.
function Clone: TSdlTtfFont; inline
Exceptions
ESdlError
: Raised on failure.
Returns
See Also
Remarks
This method should be called on the thread that created the original font.
Free
Disposes of the font.
Call this when done with a font. This method will free any resources associated with it. It is safe to call this function on nil.
The font is not valid after being passed to this method.
procedure Free; inline
Remarks
This method should not be called while any other thread is using the font.
GetDpi(Integer, Integer)
Get font target resolutions, in dots per inch.
procedure GetDpi(out AHDpi, AVDpi: Integer); inline
Exceptions
ESdlError
: Raised on failure.
Parameters
AHDpi
: Integer
: Set to the target horizontal DPI.
AVDpi
: Integer
: Set to the target vertical DPI.
See Also
GetGlyphImage(UCS4Char, TSdlTtfImageType)
Get the pixel image for a Unicode codepoint.
function GetGlyphImage(const ACodepoint: UCS4Char; out AImageType: TSdlTtfImageType): TSdlSurface; overload; inline
Exceptions
ESdlError
: Raised on failure.
Parameters
ACodepoint
: UCS4Char
: The codepoint to check.
AImageType
: TSdlTtfImageType
: Is set to the glyph image type.
Returns
TSdlSurface
: A TSdlSurface containing the glyph.
Remarks
This method should be called on the thread that created the font.
GetGlyphImage(UCS4Char)
Get the pixel image for a Unicode codepoint.
function GetGlyphImage(const ACodepoint: UCS4Char): TSdlSurface; overload; inline
Exceptions
ESdlError
: Raised on failure.
Parameters
ACodepoint
: UCS4Char
: The codepoint to check.
Returns
TSdlSurface
: A TSdlSurface containing the glyph.
Remarks
This method should be called on the thread that created the font.
GetGlyphImageForIndex(Integer, TSdlTtfImageType)
Get the pixel image for a character index.
This is useful for text engine implementations, which can call this with the GlyphIndex
in a TSdlTtfCopyOperation.
function GetGlyphImageForIndex(const AGlyphIndex: Integer; out AImageType: TSdlTtfImageType): TSdlSurface; overload; inline
Exceptions
ESdlError
: Raised on failure.
Parameters
AGlyphIndex
: Integer
: The index of the glyph to return.
AImageType
: TSdlTtfImageType
: Is set to the glyph image type.
Returns
TSdlSurface
: A TSdlSurface containing the glyph.
Remarks
This method should be called on the thread that created the font.
GetGlyphImageForIndex(Integer)
Get the pixel image for a character index.
This is useful for text engine implementations, which can call this with the GlyphIndex
in a TSdlTtfCopyOperation.
function GetGlyphImageForIndex(const AGlyphIndex: Integer): TSdlSurface; overload; inline
Exceptions
ESdlError
: Raised on failure.
Parameters
AGlyphIndex
: Integer
: The index of the glyph to return.
Returns
TSdlSurface
: A TSdlSurface containing the glyph.
Remarks
This method should be called on the thread that created the font.
GetGlyphKerning(UCS4Char, UCS4Char)
Query the kerning size between the glyphs of two Unicode codepoints.
function GetGlyphKerning(const APrevious, ACurrent: UCS4Char): Integer; inline
Exceptions
ESdlError
: Raised on failure.
Parameters
APrevious
: UCS4Char
: The previous codepoint.
ACurrent
: UCS4Char
: The current codepoint.
Returns
Integer
: The kerning size between the two glyphs, in pixels.
Remarks
This method should be called on the thread that created the font.
GetGlyphMetrics(UCS4Char, Integer, Integer, Integer, Integer, Integer)
Query the metrics (dimensions) of a font's glyph for a Unicode codepoint.
To understand what these metrics mean, here is a useful link:
https://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
procedure GetGlyphMetrics(const ACodepoint: UCS4Char; out AMinX, AMaxX, AMinY, AMaxY, AAdvance: Integer); inline
Parameters
ACodepoint
: UCS4Char
: The codepoint to check.
AMinX
: Integer
: Is set to the minimum x coordinate of the glyph from the left edge of its bounding box. This value may be negative.
AMaxX
: Integer
: Is set to the maximum x coordinate of the glyph from the left edge of its bounding box.
AMinY
: Integer
: Is set to the minimum y coordinate of the glyph from Is set to the maximum y coordinate of the glyph from the bottom edge of its bounding box.Is set to the distance to the next glyph from the left edge of this glyph's bounding box.
AMaxY
: Integer
AAdvance
: Integer
GetTextSize(String, Integer)
Calculate the dimensions of a rendered string of Unicode text.
This will report the width and height, in pixels, of the space that the specified string will take to fully render.
Text is wrapped to multiple lines on line endings and on word boundaries if it extends beyond AWrapWidth
in pixels.
If AWrapWidth is 0, this function will only wrap on newline characters.
function GetTextSize(const AText: String; const AWrapWidth: Integer): TSdlSize; overload; inline
Exceptions
ESdlError
: Raised on failure.
Parameters
AText
: String
: Text to calculate.
AWrapWidth
: Integer
: The maximum width or 0 to wrap on newline characters.
Returns
TSdlSize
: The size in pixels.
Remarks
This method should be called on the thread that created the font.
GetTextSize(String)
Calculate the dimensions of a rendered string of Unicode text.
This will report the width and height, in pixels, of the space that the specified string will take to fully render.
function GetTextSize(const AText: String): TSdlSize; overload; inline
Exceptions
ESdlError
: Raised on failure.
Parameters
AText
: String
: Text to calculate
Returns
TSdlSize
: The size in pixels.
Remarks
This method should be called on the thread that created the font.
HasGlyph(UCS4Char)
Check whether a glyph is provided by the font for a Unicode codepoint.
function HasGlyph(const ACodepoint: UCS4Char): Boolean; inline
Parameters
ACodepoint
: UCS4Char
: The codepoint to check.
Returns
Boolean
: True if the font provides a glyph for this character, False if not.
Remarks
This method should be called on the thread that created the font.
MeasureText(String, Integer, Integer)
Calculate how much of a Unicode string will fit in a given width.
This reports the number of characters that can be rendered before reaching AMaxWidth
.
This does not need to render the string to do this calculation.
function MeasureText(const AText: String; const AMaxWidth: Integer; out AMeasuredWidth: Integer): Integer; overload
Exceptions
ESdlError
: Raised on failure.
Parameters
AText
: String
: Text to calculate.
AMaxWidth
: Integer
: Maximum width, in pixels, available for the string, or 0 for unbounded width.
AMeasuredWidth
: Integer
: Is set to the width, in pixels, of the string that will fit.
Returns
Integer
: The length of the string that will fit.
Remarks
This method should be called on the thread that created the font.
MeasureText(String, Integer)
Calculate how much of a Unicode string will fit in a given width.
This reports the number of characters that can be rendered before reaching AMaxWidth
.
This does not need to render the string to do this calculation.
function MeasureText(const AText: String; const AMaxWidth: Integer = 0): Integer; overload
Exceptions
ESdlError
: Raised on failure.
Parameters
AText
: String
: Text to calculate.
AMaxWidth
: Integer = 0
: (Optional) maximum width, in pixels, available for the string, or 0 (default) for unbounded width.
Returns
Integer
: The length of the string that will fit.
Remarks
This method should be called on the thread that created the font.
RemoveFallback(TSdlTtfFont)
Remove a fallback font.
This updates any TSdlTtfText objects using this font.
procedure RemoveFallback(const AFallback: TSdlTtfFont); inline
Parameters
AFallback
: TSdlTtfFont
: The font to remove as a fallback.
See Also
Remarks
This method should be called on the thread that created both fonts.
RenderGlyph(UCS4Char, TSdlTtfRenderMode, TSdlColor, TSdlColor)
function RenderGlyph(const ACodepoint: UCS4Char; const AMode: TSdlTtfRenderMode; const AForegroundColor, ABackgroundColor: TSdlColor): TSdlSurface; overload
Parameters
ACodepoint
: UCS4Char
AMode
: TSdlTtfRenderMode
AForegroundColor
: TSdlColor
ABackgroundColor
: TSdlColor
Returns
RenderGlyph(UCS4Char, TSdlTtfRenderMode, TSdlColor)
Render a single 32-bit codepoint a new surface.
This method will allocate a new 8-bit or 32-bit surface, depending on AMode:
- TSdlTtfRenderMode.Fast: creates an 8-bit palettized surface where palette index 0 is transparent, and palette index 1 is set to the given AForegroundColor. ABackgroundColor is not used. * TSdlTtfRenderMode.AntiAliasedPalette: creates an 8-bit palettized surface where palette index 0 is set to the given ABackgroundColor and the remainder of the palette contains a color gradient/ramp that goes from ABackgroundColor to AForegroundColor. * TSdlTtfRenderMode.AntiAliasedAlpha: creates a 32-bit ARGB surface where the Alpha values are used for anti-aliasing. ABackgroundColor is not used. * TSdlTtfRenderMode.Subpixel: creates a 32-bit ARGB surface that used both alpha-blending and subpixel blending with ABackgroundColor to create sharp looking text for LCD displays.
The glyph is rendered without any padding or centering in the X direction, and aligned normally in the Y direction.
function RenderGlyph(const ACodepoint: UCS4Char; const AMode: TSdlTtfRenderMode; const AForegroundColor: TSdlColor): TSdlSurface; overload; inline
Exceptions
ESdlError
: Raised on failure.
Parameters
ACodepoint
: UCS4Char
: The Unicode codepoint of the character to render.
AMode
: TSdlTtfRenderMode
: The render mode.
AForegroundColor
: TSdlColor
: The foreground color for the text.
Returns
TSdlSurface
: A new surface.
Remarks
This method should be called on the thread that created the font.
RenderText(String, TSdlTtfRenderMode, TSdlColor, TSdlColor, Integer)
function RenderText(const AText: String; const AMode: TSdlTtfRenderMode; const AForegroundColor, ABackgroundColor: TSdlColor; const AWrapLength: Integer = -1): TSdlSurface; overload
Parameters
AText
: String
AMode
: TSdlTtfRenderMode
AForegroundColor
: TSdlColor
ABackgroundColor
: TSdlColor
AWrapLength
: Integer = -1
Returns
RenderText(String, TSdlTtfRenderMode, TSdlColor, Integer)
Render Unicode text to a new surface, optionally wrapping the text.
This method will allocate a new 8-bit or 32-bit surface, depending on AMode:
- TSdlTtfRenderMode.Fast: creates an 8-bit palettized surface where palette index 0 is transparent, and palette index 1 is set to the given AForegroundColor. ABackgroundColor is not used. * TSdlTtfRenderMode.AntiAliasedPalette: creates an 8-bit palettized surface where palette index 0 is set to the given ABackgroundColor and the remainder of the palette contains a color gradient/ramp that goes from ABackgroundColor to AForegroundColor. * TSdlTtfRenderMode.AntiAliasedAlpha: creates a 32-bit ARGB surface where the Alpha values are used for anti-aliasing. ABackgroundColor is not used. * TSdlTtfRenderMode.Subpixel: creates a 32-bit ARGB surface that used both alpha-blending and subpixel blending with ABackgroundColor to create sharp looking text for LCD displays.
You can optionally wrap the text based on the AWrapLength
parameter:
- If
AWrapLength
<render unicode text to a new surface, optionally wrapping the text.
this method will allocate a new 8-bit or 32-bit surface, depending on amode:
- tsdlttfrendermode.fast: creates an 8-bit palettized surface where palette index 0 is transparent, and palette index 1 is set to the given aforegroundcolor. abackgroundcolor is not used. * tsdlttfrendermode.antialiasedpalette: creates an 8-bit palettized surface where palette index 0 is set to the given abackgroundcolor and the remainder of the palette contains a color gradient/ramp that goes from abackgroundcolor to aforegroundcolor. * tsdlttfrendermode.antialiasedalpha: creates a 32-bit argb surface where the alpha values are used for anti-aliasing. abackgroundcolor is not used. * tsdlttfrendermode.subpixel: creates a 32-bit argb surface that used both alpha-blending and subpixel blending with abackgroundcolor to create sharp looking text for lcd displays.
you can optionally wrap the text based on the awraplength
parameter:
- if
awraplength
>(default), then text will not be wrapped (not even on newline characters). You'll get a surface with a single line of text, as long as the string requires. * IfAWrapLength
= 0, then text will only be wrapped on newline characters. * IfAWrapLength
> 0, then text will be wrapped on newline characters and on word boundaries if it extends beyondAWrapLength
in pixels. </render unicode text to a new surface, optionally wrapping the text.
this method will allocate a new 8-bit or 32-bit surface, depending on amode:
- tsdlttfrendermode.fast: creates an 8-bit palettized surface where palette index 0 is transparent, and palette index 1 is set to the given aforegroundcolor. abackgroundcolor is not used. * tsdlttfrendermode.antialiasedpalette: creates an 8-bit palettized surface where palette index 0 is set to the given abackgroundcolor and the remainder of the palette contains a color gradient/ramp that goes from abackgroundcolor to aforegroundcolor. * tsdlttfrendermode.antialiasedalpha: creates a 32-bit argb surface where the alpha values are used for anti-aliasing. abackgroundcolor is not used. * tsdlttfrendermode.subpixel: creates a 32-bit argb surface that used both alpha-blending and subpixel blending with abackgroundcolor to create sharp looking text for lcd displays.
you can optionally wrap the text based on the awraplength
parameter:
- if
awraplength
>Text to render.The render mode.The foreground color for the text.(Optional) background color for the text. Is only used (and must be specified) for TSdlTtfRenderMode.AntiAliasedPalette and TSdlTtfRenderMode.Subpixel.(Optional) maximum width of the text surface.A new surface. Raised on failure. This method should be called on the thread that created the font.
function RenderText(const AText: String; const AMode: TSdlTtfRenderMode; const AForegroundColor: TSdlColor; const AWrapLength: Integer = -1): TSdlSurface; overload; inline
Parameters
AText
: String
AMode
: TSdlTtfRenderMode
AForegroundColor
: TSdlColor
AWrapLength
: Integer = -1
Returns
SetSizeDpi(Single, Integer, Integer)
Set font size dynamically with target resolutions, in dots per inch.
This updates any TSdlTtdText objects using this font, and clears already-generated glyphs, if any, from the cache.
procedure SetSizeDpi(const APtSize: Single; const AHDpi, AVDpi: Integer); inline
Exceptions
ESdlError
: Raised on failure.
Parameters
APtSize
: Single
: the new point size.
AHDpi
: Integer
: The target horizontal DPI.
AVDpi
: Integer
: The target vertical DPI.
See Also
Remarks
This method should be called on the thread that created the font.