10-16-2009 02:41 AM
10-16-2009 04:21 AM
10-16-2009 07:23 AM
04-13-2012 09:43 AM
but this behaves very weired and I never seem to get the right number of characters per display width.....
it always custs me off in between .... and I don't tend to get same look and feel for all of my rows.....
if I tend to use getAdvanceText("W")
and number of chracters = display width / fontWidth ;
and I supply drawText(0,y, displayString.substring(0,nChars) this is the out I see in my rows..... ( I need elipsis at the end of the text to say there is more text...)
this is first line first row....
this is second line second row.....
04-13-2012 12:36 PM
Welcome to the forum.
It is best to start your own question rather than add to a solved question. People like me who are trying to help ,don't generally look at solved Threads because the problem has been solved!
In this case you are assuming that all characters take up the same width as the the "W", which is true for non proportional fonts, but is not true for proportional fonts. And I'm guessing you are using a proportional font.
For example getAdvance("iiiiiiiiii") will be a lot smaller than getAdvance("WWWWWWWWWW"), even though there are 10 characters in both stings.
I hope that explains what you see.
Note that you can use drawText and give it a complete String, tell it how wide the area it has to draw into, and it can put the ellipsis at the end if the entire string does not fit.
I think it goes something like
drawText(<string>, x, y, (DrawStyle.LEFT + DrawStyle.ELLIPSIS + DrawStyle.TOP), width );