Difference between revisions of "CompositeFont"
From GiderosMobile
m |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | ||
'''Available since:''' Gideros 2019.1<br/> | '''Available since:''' Gideros 2019.1<br/> | ||
− | '''Inherits from:''' [[ | + | '''Inherits from:''' [[FontBase]]<br/> |
=== Description === | === 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. | + | 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 === | === Example === | ||
− | '''Drawing black outline''': | + | '''Drawing a black outline''': |
− | < | + | <syntaxhighlight lang="lua"> |
− | local str = "My | + | local str = "My Composite Font text" |
local nf = TTFont.new("fonts/Tahoma.ttf", 32, str, true) --Normal | local nf = TTFont.new("fonts/Tahoma.ttf", 32, str, true) --Normal | ||
local of = TTFont.new("fonts/Tahoma.ttf", 32, str, true, 3) --Outlined | local of = TTFont.new("fonts/Tahoma.ttf", 32, str, true, 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 }, -- | + | { font=of, color=0x0 }, -- draw outline in black |
− | { font=nf, x=1, y=2 }, -- | + | { font=nf, x=1, y=2 }, -- draw normal text with an offset |
} | } | ||
local tf = TextField.new(cf, str) | local tf = TextField.new(cf, str) | ||
Line 22: | Line 22: | ||
tf:setPosition(16, 64) | tf:setPosition(16, 64) | ||
stage:addChild(tf) | stage:addChild(tf) | ||
− | </ | + | </syntaxhighlight> |
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== Methods === | === Methods === | ||
− | [[ | + | [[CompositeFont.new]] ''creates a new CompositeFont object''<br/><!--GIDEROSMTD:CompositeFont.new(definition) creates a new CompositeFont object--> |
− | <!-- GIDEROSMTD:CompositeFont.new(definition) creates a new CompositeFont object --> | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| |
Latest revision as of 14:27, 13 July 2023
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, true) --Normal
local of = TTFont.new("fonts/Tahoma.ttf", 32, str, true, 3) --Outlined
local cf= CompositeFont.new{ -- *** PLEASE NOTICE THE CURLY BRACES { } INSTEAD OF ( ) ***
{ font=of, color=0x0 }, -- 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 |