Font Scaling Issues

sterlingy

Active Member
Licensed User
Longtime User
For most of my App (2D game) I have resorted to primarily using percentages for the size and placement of views and other graphic elements.

One place I haven't figured out how to program so it translates properly from one device to another is Font Size or Text.Size

Any thoughts?

-Sterling
 

klaus

Expert
Licensed User
Longtime User
I suggest you the AutoScale equation.
B4X:
FontScale = 1 + Rate * ((100%x + 100%y) / (320dip + 430dip) - 1)
Rate can have a value between 0 and 1.
With Rate = 0 no scaling.
With Rate = 1 the font size will be proportionnal to the screen size.
With Rate < 1 the font size will increase less than the screen size ratio.
If you want to use Rate = 1 the equation can be reduced to:
B4X:
FontScale = (100%x + 100%y) / (320dip + 430dip)
Best regards.
 
Upvote 0

sterlingy

Active Member
Licensed User
Longtime User
Thanks Klaus.

I running through the AutoScale tutorials now. I have to say that this screen size and scaling issue is one of the hardest to grasp.

The tutorials use the Designer, which I haven't been using on my current project, so I'm not sure how much I'm going to get out of them.

I've been using my Galaxy S3 as my primary device for testing, and then when I loaded my app onto my Nexus 7, which is almost the same resolution, everything went nuts.

With AUTOSCALE, do you have to do your initial design with specific settings?

If you think there is a better example, please point me in that direction.

-Sterling
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
With AUTOSCALE, do you have to do your initial design with specific settings?
Yes, it's based on the 'standard' screen 320 x 480 x 160.
Did you have a look at chapter 8.10.3 AutoScale more advanced examples in the Beginner's Guide. In the source code of AutoScaleExample4 you find a Scale code module with some different equations than the Designer. It allows to autoscale in the code, also views added in the code which is not possible with the Designer.

Best regards.
 
Upvote 0

sterlingy

Active Member
Licensed User
Longtime User
Klaus,

I'll have a look at Chapter 8. My brain tends to fog over when I try to absorb that section.

I'm playing with the designer now, but I prefer to hand code things, because I learn more that way.

You seem to be very knowledgeable about B4A. I have programmed a fully functional game in one week. It has it quirks, and I intend to take it much further than its current state. In a few more months, I hope to have a very strong handle on B4A, and then I might be able to help out some of the people on this forum.

I have a bizarre issue. If you don't mind taking a look, hit the jump:

http://www.b4x.com/forum/basic4android-updates-questions/27889-animator-setframes.html

The original problem was solved, but some other craziness ensued.

-Sterling
 
Upvote 0
Top