Difference between revisions of "TexturePackFont.new"
From GiderosMobile
Line 13: | Line 13: | ||
'''scale''': (double) a scale factor to apply to the texture pack images (default = 1)<br/> | '''scale''': (double) a scale factor to apply to the texture pack images (default = 1)<br/> | ||
'''anchor''': (double) where the images should be laid relative to the text baseline (default = 1)<br/> | '''anchor''': (double) where the images should be laid relative to the text baseline (default = 1)<br/> | ||
+ | |||
+ | === Example === | ||
+ | '''Try to simulate arabic letters''' | ||
+ | <source 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> | ||
{{TexturePackFont}} | {{TexturePackFont}} |
Revision as of 14:45, 8 June 2023
Available since: Gideros 2021.9
Class: TexturePackFont
Description
Creates a new TexturePackFont object.
TexturePackFont.new(texturePack,mappings,scale,anchor)
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
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)