[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Freetype] Question on MacOS X
From: |
Changyuan Hu |
Subject: |
RE: [Freetype] Question on MacOS X |
Date: |
Fri, 30 Nov 2001 19:18:49 -0500 |
> >According to the FreeType2 API, the only Mac-specific API is
> >FT_New_Face_From_FOND, which requires a Handle to FOND resource.
>
> True, but the standard FT_New_Face() on the Mac goes through some
> special processing to provide transparent support for Mac OS fonts. I
> would recommend that you use that call instead, so that FT can deal with
> all the complexities for you.
Function FT_New_Face() requires font file path name as input. That is almost
useless for a serious application in Windows or Mac, in which you would allow
user to choose font from family name, style and size, but not from font file
selection. It is the same case in Windows, where you probably use Windows
standard ChooseFont() to open standard font selection dialogue and upon return,
you get the handle to the selected font. Because the Windows ChooseFont()
function uses special algorithm to map user requirement to the font Windows
sees as the best match, using a file dialog to let user choose a font file
directly is not such a nice solution. (That is why I still did not use FreeType
in my Windows application.)
So, I have to use Mac native way to open a font, i.e. passing a FOND resource
handle to FT_New_Face_From_FOND(). Macintosh dev technical note TN2024 has a
detailed explaination on how to open the FOND resource hand from both the
traditional resource-fork font and the new data-fork font (.dfont).
By the way, the patch code in FT2 version ftmac.c to allow parse_font find a
face which is not the first one in FOND resource seems not complete. It still
does not support style (normal, italic, bold and bold-italic). Some FOND
contains sfnt resource of all the four possible styles (such as Times). So, we
should loop into the AsscEntry array to find the best fit. I did this patch for
the FT1.2.2 code locally and of course I added the style argument in the
FT_New_Face_From_FOND() function. Following is my local modification.
void parse_fond( char* fond_data,
short style,
short* have_sfnt,
short* sfnt_id,
Str255 lwfn_file_name )
{
AsscEntry* assoc;
FamRec* fond;
short nb_assoc;
int i;
*sfnt_id = 0;
*have_sfnt = 0;
lwfn_file_name[0] = 0;
fond = (FamRec*)fond_data;
nb_assoc = *(short*)( fond_data + sizeof ( FamRec ) ) + 1;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
for( i = 0; i < nb_assoc; i++ )
{
if ( assoc->fontSize == 0 && assoc->fontStyle == style )
{
*have_sfnt = 1;
*sfnt_id = assoc->fontID;
break;
}
assoc++;
}
.... the rest of this function is not changed.
Good weekend!
Changyuan Hu
>>>www.MindAvenue.com<<<
- [Freetype] Question on MacOS X, Changyuan Hu, 2001/11/28
- Re: [Freetype] Question on MacOS X, Leonard Rosenthol, 2001/11/28
- RE: [Freetype] Question on MacOS X, Changyuan Hu, 2001/11/28
- RE: [Freetype] Question on MacOS X, Changyuan Hu, 2001/11/28
- RE: [Freetype] Question on MacOS X, Leonard Rosenthol, 2001/11/28
- RE: [Freetype] Question on MacOS X, Changyuan Hu, 2001/11/28
- RE: [Freetype] Question on MacOS X, Leonard Rosenthol, 2001/11/28
- RE: [Freetype] Question on MacOS X, Changyuan Hu, 2001/11/29
- RE: [Freetype] Question on MacOS X, Leonard Rosenthol, 2001/11/29
- RE: [Freetype] Question on MacOS X,
Changyuan Hu <=
- RE: [Freetype] Question on MacOS X, Tom Kacvinsky, 2001/11/29
- Re: [Freetype] Question on MacOS X, jwolken, 2001/11/30
- RE: [Freetype] Question on MacOS X, Wenlin Institute, 2001/11/30