java - LibGDX autoscale text in Label -
in libgdx project have label displays number wich bigger. when number gets big, bigger label. how can size of text gets smaller when text bigger label, isn't big more?
i never tried it, if label documentation, there setfontscale method.
did try ?
the width of label given yourlabel.getprefwidth()
, width of text inside label given yourlabel.getglyphlayout.width
. compare both, , scale down font if width of text bigger thant width of label.
i guess use in render()
:
if(yourlabel.getglyphlayout.width > yourlabel.getprefwidth()){ yourlabel.setfontscale(yourlabel.getprefwidth()/yourlabel.getglyphlayout.width); }
Comments
Post a Comment