Difference between revisions of "CompositeFont"

From GiderosMobile
m (made it more clear to use curly braces)
m
Line 15: Line 15:
 
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=0x000000 }, --Draw outline in black
+
{ font=of, color=0x0 }, --Draw outline in black
 
{ font=nf, x=1, y=2 }, --Draw normal text with an offset
 
{ font=nf, x=1, y=2 }, --Draw normal text with an offset
 
}
 
}

Revision as of 02:48, 15 December 2021

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 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{ -- *** 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)

Methods

CompositeFont.new creates a new CompositeFont object

Events

Constants