local f = TTFont.new("simhei.ttf",40)
local str = "一二三四五"
local tf = TextField.new(f,str)
local a,b,c = tf:getTextPositionFromPoint(0,tf:getWidth())
-----------------------------------------------
how can i get chinese char position use variable a ?
-----------------------------------------------
my description is wrong, i need "rich text" or "text area" or "multiline text", emm... how to achieve it
Comments
my mistake...
i want get offset from mixed string.(like this "12取3a一sgواحدao上年")
and use "utf8.sub()" get char or substring.
like this
-------------------------
local f = TTFont.new("simhei.ttf",40)
local str_1 = "123456"
local tf = TextField.new(f,str)
tf:setPosition(100, 100)
stage:addChild(tf)
local offset_1 = tf:getTextPositionFromPoint(tf:getWidth(),0)
local char_1 = utf8.sub(str_1,offset_1,offset_1) -- but if "str_1" is mixed string, i cant get right offset.