This function is used to enable various effects on an SDF font. The font must have been enabled to use SDF in The Font Editor or at runtime using font_enable_sdf.
These effects will appear when you use your font at runtime with draw_set_font, or use it in a text track in a Sequence.
The enable argument takes true/false for enabling/disabling effects. The actual properties for your effects are supplied in the optional params struct.
This function supports the following effects:
Each effect has its own set of properties, described below. These properties are supplied in a struct.
A single font can have any of these effects applied to it at the same time.
IMPORTANT The SDF spread value limits how far an effect can spread from a glyph's edge.
There are a few "general" properties:
The following properties are provided for Outline:
The following properties are provided for Glow:
The following properties are provided for Drop Shadow:
The offset of the drop shadow is affected by the scale at which the text is drawn, so a 10px offset will become 100px when drawn with a scale of 10.
The colour of an effect will be multiplied with whatever blend colour is set when the text is drawn.
font_enable_effects(ind, enable, [params]);
Argument | Type | Description |
---|---|---|
ind | Font Asset | The index of the font (must be SDF-enabled) |
enable | Boolean | Enable (true) or disable (false) effects |
params | Struct | OPTIONAL A struct containing effect properties |
N/A
Create Event
font_enable_effects(fnt_outline, true, {
outlineEnable: true,
outlineDistance: 2,
outlineColour: c_black
});
font_enable_effects(fnt_glow, true, {
glowEnable: true,
glowEnd: 16,
glowColour: c_red
});
This modifies two font assets that presumably have SDF enabled.
The first font fnt_outline gets outline enabled with some properties set, and the second font fnt_glow gets some glow properties.
You would draw text with these fonts by doing this in a Draw event:
Draw Event
draw_set_font(fnt_outline);
draw_text(x, y, "This font has an outline.");
draw_set_font(fnt_glow);
draw_text(x, y + 60, "This font has a glow.");
This switches to the outline font to draw text with an outline, and then switches to the glow font to draw glowing text.
The result of this font can be seen in Fig. 1 at the top of this page.
font_enable_effects(fnt_heading, true, {
dropShadowEnable: true,
dropShadowSoftness: 20,
dropShadowOffsetX: 4,
dropShadowOffsetY: 4,
dropShadowAlpha: 1,
outlineEnable: true,
outlineDistance: 2,
outlineColour: c_black,
glowEnable: true,
glowEnd: 6,
glowColour: c_red,
glowAlpha: 4
});
This example demonstrates that you can apply multiple effects to the same font at once: