Font larger on device

Joosttt

Member
Licensed User
Hi,

I'm currenly working on an application targeting VGA devices. For this application i'm using the bList and ImageLibEx library. This way I can create a custom layout for the list items as proposed in the bList library thread.

A problem I came across is when i create a bList and customize the layout on desktop the text on the device is larger then on the desktop. The font used is Tahoma and is available on both. I'm not targeting the desktop so I could trial and error to get the right font size for the device, but this is time consuming. Is there any way to test my application on the desktop as it would be shown on the device?

To make myself clear I attached two screenshots from device and desktop. I also attached the source for this little test application.

The device i tested on is a HTC Touch HD (screen resolution 480x800).
 

Attachments

  • fontTest.sbp
    1.4 KB · Views: 215
  • sshotDesktop.jpg
    sshotDesktop.jpg
    14.4 KB · Views: 205
  • sshotDevice.jpg
    sshotDevice.jpg
    15.5 KB · Views: 203

klaus

Expert
Licensed User
Longtime User
If you really want to use the full resolution you must be aware that the font size is not given in pixels but in physical units. This means that on the device you must devide the fontsize by 2.
You can use following code:
B4X:
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Font.New1([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Tahoma"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]20[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]/[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]ScreenScaleX[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT][/SIZE][/FONT]

This is valid for all controls having text.

But as Erel already wrote, AutoScale is much more convenient.

Best regards.
 
Last edited:

Joosttt

Member
Licensed User
Thanks both quick reply's. Very useful.
I do use some pictures/icons in my application and for this reason want to use the full resolution. But since you both opt for autoscale i will try this and see how it looks.

Thanks!
 
Top