CompositeFont: Difference between revisions
From GiderosMobile
No edit summary |
changed example |
||
| Line 10: | Line 10: | ||
=== <translate>Example</translate> === | === <translate>Example</translate> === | ||
'''Drawing black outline''':<br/> | |||
<source lang="lua"> | <source lang="lua"> | ||
local str = "My Composited Font text" | |||
local nf = TTFont.new("fonts/Tahoma.ttf", 32, str, true) --Normal | |||
local of = TTFont.new("fonts/Tahoma.ttf", 32, str, true, 3) --Outlined | |||
local cf= CompositeFont.new{ | local cf= CompositeFont.new{ | ||
{ font= | { font=of, color=0x000000 }, --Draw outline in black | ||
{ font= | { 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) | |||
</source> | </source> | ||
Revision as of 04:39, 10 January 2020
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 black outline:
local str = "My Composited Font text"
local nf = TTFont.new("fonts/Tahoma.ttf", 32, str, true) --Normal
local of = TTFont.new("fonts/Tahoma.ttf", 32, str, true, 3) --Outlined
local cf= CompositeFont.new{
{ font=of, color=0x000000 }, --Draw outline in black
{ 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 |