Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-13-2007, 01:26 AM
orchid's Avatar
Member
 
Join Date: Apr 2007
Location: Midwest
Posts: 60
orchid is on a distinguished road
Font question
I have a question regarding font attributes.
I need to be able to change the width and/or the height of every character I paint on the screen.

Unfortunately Java only seems to allow to set the size of the font. What I am looking for is the possibility to change either the width, or the height. (this means "taller" characters with same width, or "larger" characters with same height).

Any idea on how I can do this?
I'm using this method to paint my characters:

Code:
Graphics2D g2 = (Graphics2D) g; GlyphVector gv; FontRenderContext frc = g2.getFontRenderContext(); int oneGlyph[] = { asciiToArialSymbol[c] }; gv = fontSymbol.createGlyphVector( frc, oneGlyph ); g.setFont(fontSymbol); g.setColor(col); g2.drawGlyphVector( gv, hStart+j*hOffset, vStart+(i+1)*vOffset-vDescent);
thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-01-2007, 03:03 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,054
hardwired is on a distinguished road
If you know the size (width and height) you want for each glyph/letter you can get a pretty good fit by scaling the font with an AffineTransform.
Code:
AffineTransform at = AffineTransform... g2.setFont(font.deriveFont(at)); g2.draw...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set font size for a xml value bala_kj Advanced Java 3 04-01-2008 12:00 PM
Swing - Changing component default font Java Tip Java Tips 0 03-11-2008 11:52 PM
How to change font/ font color etc in a graphic object using JCombobox? JavaInLove AWT / Swing 0 02-07-2008 12:28 PM
JTable with Font Rama Koti Reddy AWT / Swing 1 12-12-2007 06:22 PM
Help with save font information in jtextarea valery New To Java 1 08-06-2007 09:22 PM


All times are GMT +3. The time now is 08:58 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org