Difference between revisions of "CompositeFont"

From GiderosMobile
(Created page with "__NOTOC__ <languages /> <!-- GIDEROSOBJ:CompositeFont --> '''<translate>Supported platforms</translate>:''' File:Platform android.pngFile:Platform ios.pngFile:Platfo...")
 
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
 
 
<!-- GIDEROSOBJ:CompositeFont -->
 
<!-- GIDEROSOBJ:CompositeFont -->
'''<translate>Supported platforms</translate>:''' [[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/>
'''<translate>Available since</translate>:''' Gideros 2019.1<br/>
+
'''Available since:''' Gideros 2019.1<br/>
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/FontBase|FontBase]]<br/>
+
'''Inherits from:''' [[FontBase]]<br/>
=== <translate>Description</translate> ===
+
 
<translate><br />
+
=== Description ===
The [[Special:MyLanguage/CompositeFont|CompositeFont]] class is used to define fonts composed from other fonts. It allows to mix a regular font with
+
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.
an outlined font to create bordered font, and possibly more effects. <br />
+
 
<br /></translate>
+
=== Example ===
=== <translate>Examples</translate> ===
+
'''Drawing a black outline''':
'''Example'''<br/>
+
<syntaxhighlight lang="lua">
<source lang="lua">
+
local str = "My Composite Font text"
local cf= CompositeFont.new{
+
local nf = TTFont.new("fonts/Tahoma.ttf", 32, str) --Normal
{ font=outlinefont, color=0x000000 }, --Outlined font will be rendered in black
+
local of = TTFont.new("fonts/Tahoma.ttf", 32, str, false, 3) --Outlined
{ font=normalfont, x=1,y=2 }, --Normal font is drawn on top, with color coming from textfield and offseted by (1,2) logical coordinates
+
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
 
}
 
}
</source>
+
local tf = TextField.new(cf, str)
 +
tf:setTextColor(0xff0000)
 +
tf:setPosition(16, 64)
 +
stage:addChild(tf)
 +
</syntaxhighlight>
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
 
[[Special:MyLanguage/CompositeFont.new|CompositeFont.new]] ''<translate>creates a new CompositeFont object</translate>''<br/><!-- GIDEROSMTD:CompositeFont.new(definition) creates a new CompositeFont object -->
+
=== Methods ===
 +
[[CompositeFont.new]] ''creates a new CompositeFont object''<br/><!--GIDEROSMTD:CompositeFont.new(definition) creates a new CompositeFont object-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
=== Events ===
=== <translate>Constants</translate> ===
+
=== Constants ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 01:47, 29 November 2024

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
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)

Methods

CompositeFont.new creates a new CompositeFont object

Events

Constants