03-12-2009 02:38 PM
How can I set the font size to a system font size. For example, if I wanted to set the font to the same size as it appears when you set the size to 10 under the Options screen.
Solved! Go to Solution.
03-12-2009 03:46 PM
03-12-2009 03:54 PM
Not quite, unless from Font.getDefault() I can get the size (again, not in pixels).
I want to allow the user to select the font size for use within my program:
ie: 7,8,9,10... or System font size
And since the screen resolution is different for various devices, I can't just set the height using the setHeight(int pixels) method, since a size 10 on one device will require a different height than a size 10 on another device.
I'd like for my font heights (7,8,9, etc) to match up with the devices...
03-24-2009 03:50 PM - edited 03-24-2009 03:55 PM
Okay so i have just spent the past 2 hours googling and searching including this forum on a simple example on how to set the font size for a handheld application and ran across this forum posting several times. I am not clear on how to implement the Font on the handheld.
Could you clarify exactly how to use the Font.derive please.
I tried the following but eclipse is yelling at me.
Font f = new Font();
Font.derive(Font.PLAIN, 10, Ui.UNITS_pt);
Current time is 3:55pm EST. I am online for chat at PowerMountain Chat just enter in any user name to connect or post response to this forum please.
03-30-2009 01:04 PM
04-26-2009 04:46 PM
Hey, just in case someone else is wondering, here is the solution:
// First, derive the default font and modify it to be PLAIN and 10 pt
Font myFont = Font.getDefault().derive(Font.PLAIN, 10);
// Then, set the font to what you derived above
// Then draw the text
graphics.drawText("Hello World", xpos, ypos);