Follow Fantora on Twitter
Fantora Word of Classified Ads and Community Forum
Welcome Guest Search | Active Topics | Members | Log In | Register

drawString font related question

Options
Ruhana
Posted: Monday, March 23, 2009 2:04:07 AM
Rank: Newbie
Groups: Member

Joined: 3/23/2009
Posts: 1
Points: 3
Location: Uk

drawString font related question

hi


i'm trying to write a J2ME app and i'm having some trouble placing text precisely. the problem is that the font and subsequent font metrics on two different phones are different. specifically the getBaselinePosition() and getHeight() methods of the Font object return different values on the different phones and i'm trying to use the drawString method to display text in the exact same relative position on each respective phone.


Then we can safely assume that the two handsets are not using the same font. There's no requirement in the MIDP specification that platforms use fonts with exactly the same metrics for FACE_MONOSPACE, FACE_PROPORTIONAL or FACE_SYSTEM. You have to adapt your application so that it will create its display without depend on any specific font metrics value.


here's what i'm trying to do ...


Font font = Font.getFont (Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_SMALL) ;

int width = getWidth () ;


int refX = 10 ;
int refY = 15 ;



// draw reference line that subsequent text drawing will be relative to ...
g.setColor (0x00,0x99,0xCC) ;
g.drawLine (0, refY + 1, width, refY + 1) ;


StringBuffer buf = new StringBuffer () ;


buf.append ("H = ") ;
buf.append (font.getHeight()) ;
buf.append ("BLP = ") ;
buf.append (font.getBaselinePosition()) ;


g.drawString (buf.toString(),
refX,
refY - font.getBaselinePosition(),
Graphics.LEFT | Graphics.TOP) ;



my goal is to have the text drawn by the 'drawString' method above drawn in the same relative position to the 'reference' line draw above on all phones.


Then you need to set the value for refY programmatically rather than statically. As you can see, the fonts are different on each handset, so you'll have to change your code for drawing the line.




Thanks

T shirts printing
Tee Shirt printing
hightech
Posted: Wednesday, April 29, 2009 3:02:39 AM
Rank: Advanced Member
Groups: Member

Joined: 9/6/2008
Posts: 216
Points: 454

drawString font related question

Hey, thanks for sharing information....how about changing of width font?

Test Management
Users browsing this topic
Guest

 Related
web building primer
i need HTML code
how to convert .jpg to pdf
What is the full form of HTML ?
Free online tool to make flash flip book from pdf
CSS Tutorials
Destination India
is Dreamweaver worth buying?
need help in website designing
How to upload new themes for Wordpress.
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by: YAF.NET
Copyright © AI Logica All rights reserved.
This page was generated in 0.443 seconds.