Cross-platform font matching
Cross-platform font matching
- Subject: Cross-platform font matching
- From: Gideon King <email@hidden>
- Date: Sat, 23 Jul 2005 01:44:35 +1000
Hi all, we are developing an application that needs to have user
interfaces that run both on MacOS X and that other operating system,
and have run into a difficult situation with fonts.
Our objective is to be able to match as closely as possible the look
and feel of fonts across the operating systems, and different
machines with the same operating system but different fonts
available. Essentially we need a font fallback mechanism.
On windoze, there is a structure called LOGFONT which has the
following attributes:
LONG lfHeight (font em height);
LONG lfWidth (font average width [sometimes]);
LONG lfEscapement (angle of the characters);
LONG lfOrientation (angle of the characters from their baseline);
LONG lfWeight (weight of the font - from 100=thin to 900=black);
BYTE lfItalic (italic or not);
BYTE lfUnderline (underlined or not);
BYTE lfStrikeOut (strikeout or not);
BYTE lfCharSet (character set used by the font e.g.
CHINESEBIG5_CHARSET);
BYTE lfOutPrecision (output precision);
BYTE lfClipPrecision (clipping control);
BYTE lfQuality (output quality - e.g. ANTIALIASED_QUALITY);
BYTE lfPitchAndFamily (pitch can be default, fixed, or variable,
the family can be: decorative, modern, roman etc);
TCHAR lfFaceName[LF_FACESIZE]; (the typeface name of the font
This structure can be extracted from text and used to find the
closest matching font on another machine that may not have the same
font installed. We can save this information in our file along with
the NSAttributedString that was generated as a result of the editing.
The fonts on the Mac are usually different, and we have been looking
for something that will allow us to store similar traits of the text
or text runs so that we can do good font matching on windows, and
something that will allow us to pick up these attributes and find a
suitable font on the Mac.
The solution we use needs to work on both 10.3 and 10.4. We have been
looking at the NSAttributedString, NSFont, NSFontManager, and
NSFontDescriptor as possible places to start, but we are not sure
that any of these provide what we are looking for, especially as so
much of the API has been deprecated and replaced with new items.
NSFontDescriptor looked promising (at least in 10.4), but when adding
attrbutes by the -fontDescriptorWith... methods didn't allow us to
add each of the characteristics, as it just wiped out other things
that had been explicitly set. Also when I set a transformation
matrix, the program crashed. So maybe it is not the way to go after all.
Our graphics in our program are very tightly fit around the text, so
we would like to wherever possible keep to the same font size to
avoid wrapping at odd places etc.
I'm sure a lot of people have come across this issue, so would
appreciate some pointers as to good approaches to getting the best
matching font when opening on a Mac, and saving the appropriate
information for LOGFONT on windows. I know some of them like size,
face name, italic, underline, strikeout etc are readily available on
both 10.3 and 10.4, but some of the others like the character set
would seem to be very important for font matching, but are not
present anywhere I have looked.
Can anyone help find matching fonts given these attributes ,and
saving the data on the Mac that is needed to do windows font matching?
Thanks
Gideon King
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden