I'm developing a game for Myanmar user, So I have to use zawgyi_one font for text related stuffs. The problem is when I use getWidth, the return value is wrong
here is my code:
local part = text:sub(last, index)
local lineTemp = TextField.new(self.font, part)
lineTemp:setLetterSpacing(self.letterSpacing)
if(lineTemp:getWidth()>self.width) then
-- every thing go wrongs from here
end |
For example, this text
ဧျပီ ၁ ရက္ေန႔တြင္ၾကားျဖတ္ ေရြးေကာက္ပြဲကိုက်င္းပခဲ့သည္။ |
return width = 380. This is wrong because this text go off screen(screen width is 720)
Comments
first case, while your screen might be 720px. You might have set different values in your Logical dimensions in project properties, and based on applied scaling mode the values are true.
Other thing might be some transformations applied to this element or parent elements.
And even if all above is correct and it really reports incorrect size, can you also check:
Likes: chipster123
text:getBounds works for me.