Page 1 of 1

Aligning text Courier not working in iOS Simulator

Posted: Wed Jan 01, 2014 11:01 pm
by Curiosity77
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.

Re: Aligning text Courier not working in iOS Simulator

Posted: Wed Jan 01, 2014 11:13 pm
by endernafi
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

Re: Aligning text Courier not working in iOS Simulator

Posted: Thu Jan 02, 2014 4:53 pm
by jacque
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.

Re: Aligning text Courier not working in iOS Simulator

Posted: Sun Jan 05, 2014 5:37 pm
by Curiosity77
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.