11-23-2012 05:34 AM
Could anyone please let me know the way to get right y for drawing two text with diffrent hight to be in the same X line , that looks like a one line of text (using Graphics object)?
Thank you in advance
11-23-2012 06:01 AM - edited 11-23-2012 06:02 AM
I have never done this, but here are the two options I would try:
1) using this form of drawText
drawText(String aText, int aX, int aY)
Assume you have font A and font B, and font B is bigger. Then when you do the drawText for the string you are outputting using font A, add the difference in height between the two, to the "ay" part of the drawText.
This uses DrawStyle.TOP by default (review the API), which means the y point you specify is the top left hand corner.
2) Using this form of drawText
drawText(String aText, int aX, int aY, int aFlags)
Specify the aY position you want to be at the 'bottom', and use DrawStyle.BOT in the aFlag. So aX and aY will specify the bottom left corner.
I actually suspect that neither of these options will work 100%. I think you will need to factor into the 'y' position, the difference in the "descent" of each of the Font. You should be able to figure this out yourself - look at the API for Font, and especially at getBaseline() and getDescent() methods for Font.