TexturePackFont.new: Difference between revisions

From GiderosMobile
No edit summary
m Text replacement - "<source" to "<syntaxhighlight"
Line 4: Line 4:
=== Description ===
=== Description ===
Creates a new '''TexturePackFont''' object.
Creates a new '''TexturePackFont''' object.
<source lang="lua">
<syntaxhighlight lang="lua">
TexturePackFont.new(texturePack,mappings,scale,anchor)
TexturePackFont.new(texturePack,mappings,scale,anchor)
</source>
</source>
Line 16: Line 16:
=== Example ===
=== Example ===
'''Try to simulate arabic letters'''
'''Try to simulate arabic letters'''
<source lang="lua">
<syntaxhighlight lang="lua">
local tp = TexturePack.new({"fonts/ar_ba.png", "fonts/ar_ta.png", "fonts/ar_tha.png"}) -- path to png images
local tp = TexturePack.new({"fonts/ar_ba.png", "fonts/ar_ta.png", "fonts/ar_tha.png"}) -- path to png images
local font = TexturePackFont.new(tp, {ba="fonts/ar_ba.png", ta="fonts/ar_ta.png", sa="fonts/ar_tha.png"}, 3, 0) -- tp, mappings, scale, anchory
local font = TexturePackFont.new(tp, {ba="fonts/ar_ba.png", ta="fonts/ar_ta.png", sa="fonts/ar_tha.png"}, 3, 0) -- tp, mappings, scale, anchory

Revision as of 13:31, 13 July 2023

Available since: Gideros 2021.9
Class: TexturePackFont

Description

Creates a new TexturePackFont object. <syntaxhighlight lang="lua"> TexturePackFont.new(texturePack,mappings,scale,anchor) </source>

Parameters

texturePack: (TexturePack) the TexturePack object that will be wrapped in this font
mappings: (table) a character to filename map to associate characters with TexturePack images
scale: (double) a scale factor to apply to the texture pack images (default = 1)
anchor: (double) where the images should be laid relative to the text baseline (default = 1)

Example

Try to simulate arabic letters <syntaxhighlight lang="lua"> local tp = TexturePack.new({"fonts/ar_ba.png", "fonts/ar_ta.png", "fonts/ar_tha.png"}) -- path to png images local font = TexturePackFont.new(tp, {ba="fonts/ar_ba.png", ta="fonts/ar_ta.png", sa="fonts/ar_tha.png"}, 3, 0) -- tp, mappings, scale, anchory local tf = TextField.new(font, "bata") local tf2 = TextField.new(font, "taba sa") local tf3 = TextField.new(font, "sa") tf:setPosition(64*6, 64*1) tf2:setPosition(64*6, 64*2) tf3:setPosition(64*6, 64*3) stage:addChild(tf) stage:addChild(tf2) stage:addChild(tf3) </source>