Sorry this is a little hairy to explain...
Open any font chooser in an Apple program -- like TextEdit. As you
select each font family, you'll see at least one style available.
Note many fonts simply do not support italics or bold. On my
computer about 26 fonts support italics, 48 do not.
In Java 1.4.2, we're querying for a list of available font families
with this method:
GraphicsEnvironment.getAvailableFontFamilyNames().
From this list, we create java.awt.Font objects.
Now with any java.awt.Font object, we can say:
myFont = myFont.deriveFont(Font.BOLD);
or
myFont = myFont.deriveFont(Font.ITALIC);
Subsequent calls to myFont.isBold() or myFont.isItalic() will
return true appropriately. However, when you render them on the
screen SOME fonts are identical to their non-bold, non-italic
counterparts. (If you open up the same fonts in TextEdit, you'll
see that these fonts simply don't support an italic and/or bold
attribute -- which would explain why Java is rendering them the way
it is.)
In our program we have a checkbox to toggle the italic attribute
and another checkbox to toggle the bold attribute. We would like
to disable these for the fonts that don't support those attributes.
Now we've figured out a way to tell if a java Font supports italics
or not on Mac:
Font myFont = ...;
boolean supportsItalics = (myFont.deriveFont
(Font.PLAIN).getItalicAngle()!=myFont.deriveFont
(Font.ITALIC).getItalicAngle());
So based on this hack-ish approach, we can correctly disabled our
'italics' checkbox when appropriate.
Does anyone know of a similar approach we can try to see if a font
supports the bold attribute on Mac?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden