Difference between revisions of "CompositeFont"
From GiderosMobile
Line 12: | Line 12: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local str = "My Composite Font text" | local str = "My Composite Font text" | ||
− | local nf = TTFont.new("fonts/Tahoma.ttf", 32, str | + | local nf = TTFont.new("fonts/Tahoma.ttf", 32, str) --Normal |
− | local of = TTFont.new("fonts/Tahoma.ttf", 32, str, | + | local of = TTFont.new("fonts/Tahoma.ttf", 32, str, false, 3) --Outlined |
local cf= CompositeFont.new{ -- *** PLEASE NOTICE THE CURLY BRACES { } INSTEAD OF ( ) *** | local cf= CompositeFont.new{ -- *** PLEASE NOTICE THE CURLY BRACES { } INSTEAD OF ( ) *** | ||
{ font=of, color=0x0, alpha=1 }, -- draw outline in black (if you pass a color you MUST pass its alpha) | { font=of, color=0x0, alpha=1 }, -- draw outline in black (if you pass a color you MUST pass its alpha) |
Latest revision as of 01:47, 29 November 2024
Supported platforms:
Available since: Gideros 2019.1
Inherits from: FontBase
Description
The CompositeFont class is used to define fonts composed from other fonts. It allows to mix a regular font with an outlined font to create bordered font, and possibly more effects.
Example
Drawing a black outline:
local str = "My Composite Font text"
local nf = TTFont.new("fonts/Tahoma.ttf", 32, str) --Normal
local of = TTFont.new("fonts/Tahoma.ttf", 32, str, false, 3) --Outlined
local cf= CompositeFont.new{ -- *** PLEASE NOTICE THE CURLY BRACES { } INSTEAD OF ( ) ***
{ font=of, color=0x0, alpha=1 }, -- draw outline in black (if you pass a color you MUST pass its alpha)
{ font=nf, x=1, y=2 }, -- draw normal text with an offset
}
local tf = TextField.new(cf, str)
tf:setTextColor(0xff0000)
tf:setPosition(16, 64)
stage:addChild(tf)
MethodsCompositeFont.new creates a new CompositeFont object |
EventsConstants |