ui.label -- align = "right" alignment bug

First, to see it:

As you can see, the “align right” functionality suffers from not being exact. It varies greatly depending on what letters are used and in the end really looks pretty poor when you have labels next to boxed areas in your app (like text areas or a series of buttons).

Here’s the code for the above:

local ui = require("ui");  
  
local label;  
label = ui.newLabel {  
 text = "text1:",  
 textColor = {255, 255, 255, 255},  
 size = 14,  
 align = "right",  
 bounds = {0, 100, 100, 40},  
};  
  
label = ui.newLabel {  
 text = "some text2:",  
 textColor = {255, 255, 255, 255},  
 size = 14,  
 align = "right",  
 bounds = {0, 145, 100, 40},  
};  
  
label = ui.newLabel {  
 text = "TeXt3:",  
 textColor = {255, 255, 255, 255},  
 size = 14,  
 align = "right",  
 bounds = {0, 190, 100, 40},  
};  
  
label = ui.newLabel {  
 text = "TEXTY4:",  
 textColor = {255, 255, 255, 255},  
 size = 14,  
 align = "right",  
 bounds = {0, 235, 100, 40},  
};  
  
local showError = display.newRect(99, 100, 10, 160);  
showError:setFillColor(255, 0, 0, 255);  
showError:setStrokeColor(255, 0, 0, 255);  

BTW, you guys should really consider phpBB or some standard forums for your forums. At the very least, “code” should auto-include a pre tag so tabs show up correctly.

[import]uid: 5659 topic_id: 704 reply_id: 300704[/import]

The problem might be some rounding errors, I fiddled with the ui code a little using math.floor(num + 0.5) to correctly round numbers (and even just trunced them), but I think the problem is upstream from there.

It’s one of those idiosyncracies with lua that always sneaks up on me when I’m not looking… all numbers are floating point. So:

a = 5;
a = a / 2;

does not yield 2. It results in 2.5. This gets further complicated when you auto-convert from a number to a string as a number of “2.0” becomes a string of “2”.

Sorry, don’t mean to ramble. :slight_smile:

Scott [import]uid: 5659 topic_id: 704 reply_id: 1409[/import]

(Logged as bug #136) [import]uid: 3 topic_id: 704 reply_id: 2041[/import]

It almost seems that the font alignment is random. I have some code that the text will align differently while the code is the same. On top of that it always changes once it goes to the iPhone. It’s really frustrating. Does anyone have any tips on how to fix this?
[import]uid: 8192 topic_id: 704 reply_id: 9137[/import]