Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mac Fonts: which can be made bold?



Our app has this same kind of functionality. We have a method called getFontsForFamily() - we simply iterate over this list to see if any of font (names) for a given family contain "Bold", which has worked well.

For italic, we check for both "Italic" and "Oblique".

jeff


On Aug 16, 2005, at 3:13 PM, Jeremy Wood wrote:

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


_______________________________________________ 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
References: 
 >Mac Fonts: which can be made bold? (From: Jeremy Wood <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.