participate


Java Programming [Archive] - Croos Platform Fonts
<<   Back to Forum  |   Give us Feedback
5 Duke Stars rewarded for this thread
This topic has 5 replies on 1 page.
Adam_Raybone
Posts:13
Registered: 8/18/05
Croos Platform Fonts   
Aug 18, 2005 8:37 AM

 
Hi,
Im currently trying to develope a system which is required to be as portable as possible. In this system I would like to use different font styles, however I am not able to use native system fonts (as it needs to be portable). I know that there are a few true type fonts in java but I wanted something a little more interesting. Are there any fonts that are available in linux\ windows\ solaris and if not can I get custom fonts from anywhere and deploy them with the application (plus if so how)?

Any help with this would be grately appreciated, thanks in advance

Adam
 
tjacobs01
Posts:10,225
Registered: 10/11/01
Re: Croos Platform Fonts   
Aug 18, 2005 8:54 AM (reply 1 of 5)  (In reply to original post )

 
Hi,
Im currently trying to develope a system which is
required to be as portable as possible. In this
system I would like to use different font styles,
however I am not able to use native system fonts (as
it needs to be portable).

True but also not true.

1. As you stated, there are the java generic fonts (ie sanserif, dialog, monospaced, etc) These you should be able to use fairly consistantly in your own code

2. You can provide users with a choice of any of their fonts using GraphicsEnvironment.getAllFontFaces() see http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Font.html

3. You could make fonts available to users, but automatically installing them is going to be a nightmare
 
tjacobs01
Posts:10,225
Registered: 10/11/01
Re: Croos Platform Fonts   
Aug 18, 2005 9:03 AM (reply 2 of 5)  (In reply to #1 )

 
Another thing you should know is that while the definition of point is 1/72nd of an inch (so a font that is 72 pt should be 1 inch tall) this is actually not true on most (all?) windows machines because of the resolution. If you really want something that looks the same on all platforms, you need to make a static font factory and modify font sizes according the the screen resolution (see Toolkit.getScreenResolution())
 
mptech
Posts:1
Registered: 8/18/05
Re: Croos Platform Fonts   
Aug 18, 2005 9:15 AM (reply 3 of 5)  (In reply to original post )

 
Hi Adam,

I'm not sure if there are any fonts that would be available across all platforms, however, you can allow the font type to be configured by the end user. The following link provides sample code to obtain a list of available fonts from the underlying system.

http://javaalmanac.com/egs/java.awt.font/ListFontFam.html

Using this, you can provide the user with a list of available fonts and have them choose the font that they would like to use. Hope this helps.

Regards,
Mike
 
bsampieri
Posts:14,508
Registered: 4/2/99
Re: Croos Platform Fonts      
Aug 18, 2005 9:27 AM (reply 4 of 5)  (In reply to #1 )

 
3. You could make fonts available to users, but automatically
installing them is going to be a nightmare

Not really.
Font f = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(new File("MyFont.ttf")));

or Class.getResourceAsStream() for font files packaged in your Jar files or otherwise in the classpath.

As long as you have TrueType fonts, you can ship then with your app. Keep in mind, that there are legal issues for font distribution... You'd have to check with whoever own the font copyright for that. But the technical issues are pretty minimal.
 
Adam_Raybone
Posts:13
Registered: 8/18/05
Re: Croos Platform Fonts   
Aug 19, 2005 12:55 AM (reply 5 of 5)  (In reply to #1 )

 
Thanks for all your advice, Im not too keen on allowing the users to select their font, but its a possiblity. I think ill have a go at bsampieri's suggestion,

once again thanks all for replying so quikly,

Adam
 
This topic has 5 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 63
  • Guests : 118

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums