Character set supported by a font
Character set supported by a font
- Subject: Character set supported by a font
- From: Gideon King <email@hidden>
- Date: Tue, 26 Jul 2005 13:04:22 +1000
Can anybody tell me how to find out what character set is supported
by a font? I have the following information available on windows (see
end of this message), and want to be able to choose a font that will
be able to represent the same characters (also if a user has saved a
file on one Mac and then opens it on another one, I want to be able
to make an informed decision about what font should be used as a
replacement). I see that there is a method called
- (NSStringEncoding)mostCompatibleStringEncoding
Which seems to sort of give similar information about a particular
font, but it doesn't allow me to ask the question "Does this font
support character set X?".
It appears that with 10.4 there are starting to be a few methods that
look as if they are heading towards some sort of font matching
capabilities, with the enhancements to NSFontDescriptor, but we need
to be able to use something that works on 10.3 and 10.4 (and besides,
there appear to be some odd things going on with the font descriptor).
I see that there is also a method called
- (NSCharacterSet *)coveredCharacterSet
which returns a character set identifying all the characters covered
by the font, but I'm not sure how to compare the results of this with
the character sets as below.
Any tips on choosing the best replacement font for a missing font in
both 10.3 and 10.4 would be greatly appreciated.
---------------------------
ANSI_CHARSET
BALTIC_CHARSET
CHINESEBIG5_CHARSET
DEFAULT_CHARSET
EASTEUROPE_CHARSET
GB2312_CHARSET
GREEK_CHARSET
HANGUL_CHARSET
MAC_CHARSET
OEM_CHARSET
RUSSIAN_CHARSET
SHIFTJIS_CHARSET
SYMBOL_CHARSET
TURKISH_CHARSET
VIETNAMESE_CHARSET
Korean language edition of Windows:
JOHAB_CHARSET
Middle East language edition of Windows:
ARABIC_CHARSET
HEBREW_CHARSET
Thai language edition of Windows:
THAI_CHARSET
----------------------------
TIA
Gideon King
email@hidden
On 23/07/2005, at 1:44 AM, Gideon King wrote:
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
_______________________________________________
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