Aligning text Courier not working in iOS Simulator

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Curiosity77
Posts: 2
Joined: Wed Jan 01, 2014 10:28 pm

Aligning text Courier not working in iOS Simulator

Post by Curiosity77 » Wed Jan 01, 2014 11:01 pm

Hi.

In IDE (LC 6.5.1) I aligned some text in a field with spaces using monospaced font Courier.
This worked out quite nicely in the IDE but not so in the iOS iPad Simulator (version 7.0) as some text (not all) is not aligned.
E.g. in IDE it looks like:

Code: Select all

TOTAL COST      345
AVG HRS        1200
Where in iOS Simulator the same text is displayed as:

Code: Select all

TOTAL COST      345
AVG HRS       1200
with the second line slightly shifted to the left in this example (but not necessarily the width of one monospaced character) although the number of spaces should align it correctly. It looks like the text looses its monospaced nature (sometimes) in the simulator.

Would this be a simulator 'feature' only?

iMac OS 10.8.4, LC 6.5.1 CE.

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: Aligning text Courier not working in iOS Simulator

Post by endernafi » Wed Jan 01, 2014 11:13 pm

I have no idea about true reason of the issue you've encountered
however I wouldn't rely on alignments using spaces; I mean never 8)

A better solution would be using separate fields,
the label aligned to left and the number aligned to right.

You have to code more, probably, but the results will be reliable and consistent across platforms.

I hope, someone would come up with an answer directly related to inconsistent char width of a monospace font.
But this is my two cents.


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Aligning text Courier not working in iOS Simulator

Post by jacque » Thu Jan 02, 2014 4:53 pm

The most likely reason is that the simulator font characters are a different width and so require a different number of spaces than the desktop font. Every OS uses it's own font metrics. I agree that a better approach would be to use two fields.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Curiosity77
Posts: 2
Joined: Wed Jan 01, 2014 10:28 pm

Re: Aligning text Courier not working in iOS Simulator

Post by Curiosity77 » Sun Jan 05, 2014 5:37 pm

Thanks for your help. Will rewrite and use fields instead.
Reason for text only was the possibility to write the whole field at once to a database as text in addition to writing the entities to dedicated database columns.
I will fix it.

Post Reply