Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Java cannot recognise some fonts

Thread view: 
simonccui@gmail.com - 09 May 2006 05:54 GMT
I installed a few Helvetica Neue fonts on my PC running Windows XP,
JavaRE 1.5.0_06. My code is trying to get the text height according to
the font. However I got hight=0 only for some fonts.

//output*********************************************************************
font=java.awt.Font[family=HelveticaNeue LT 55 Roman,name=HelveticaNeue
LT 55 Roman,style=plain,size=11]ascent=9, descent=2, height=12]
sun.font.FontDesignMetrics[font=java.awt.Font[family=HelveticaNeue LT
55 Roman,name=HelveticaNeue LT 55 Roman,style=bold,size=11]ascent=0,
descent=0, height=0]
sun.font.FontDesignMetrics[font=java.awt.Font[family=HelveticaNeue LT
57 Cn,name=HelveticaNeue LT 57 Cn,style=plain,size=11]ascent=11,
descent=3, height=14]
sun.font.FontDesignMetrics[font=java.awt.Font[family=HelveticaNeue LT
57 Cn,name=HelveticaNeue LT 57 Cn,style=bold,size=11]ascent=11,
descent=3, height=14]
sun.font.FontDesignMetrics[font=java.awt.Font[family=HelveticaNeue LT
65 Medium,name=HelveticaNeue LT 65 Medium,style=plain,size=11]ascent=0,
descent=0, height=0]
sun.font.FontDesignMetrics[font=java.awt.Font[family=HelveticaNeue LT
65 Medium,name=HelveticaNeue LT 65 Medium,style=bold,size=11]ascent=0,
descent=0, height=0]
//output*********************************************************************

The interesting thing is for the same font HelveticaNeue LT 55 Roman,
when the style is plain, the height is 12, but when the style is bold,
the height is 0.

Any thoughts or suggestions?
Jeffrey H. Coffield - 09 May 2006 15:20 GMT
> I installed a few Helvetica Neue fonts on my PC running Windows XP,
> JavaRE 1.5.0_06. My code is trying to get the text height according to
> the font. However I got hight=0 only for some fonts.
...
> Any thoughts or suggestions?

One source of the problem is that Windows and Java by default have an
incomplete model of fonts. The popular view is that a font has
properties of a combination of bold/nobold and italic/noitalic. In
reality a font cannot be changed from not bold to bold, you change to
another font in the same family. Java/Windows assumes there are four
fonts in a family and switches between them based on check boxes.

Where Window loses it is when you have more than four fonts in the same
family. It most likely is adding Helvetica Neue to the Helvetica family
and is having problems. The design department at one of my customers had
this same issue and the actual symptoms changed from system to system
apparently depending on the order the fonts were loaded.

Products like InDesign seem to bypass the o/s and have their own font
handling so you pick a family then get a drop down of the fonts that are
in that family.

One admittedly poor work around is to change the name of the font to
something like "MyHelvetica Neue" so windows/java sees it as a different
family.

We finally rewrote JFontChooser to select fonts from a font server to
solve the problem.

Jeff Coffield


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.