Java cannot recognise some fonts

S

simonccui

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?
 
J

Jeffrey H. Coffield

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top