Formatting.

This commit is contained in:
Werner Lemberg 2001-12-07 21:56:32 +00:00
parent 145f94cb26
commit e9e130c071
7 changed files with 191 additions and 174 deletions

View File

@ -1,51 +1,47 @@
2001-12-07 David Turner <david@freetype.org> 2001-12-07 David Turner <david@freetype.org>
* include/freetype/cache/ftccmap.h, src/cache/ftccmap.c: added new * include/freetype/cache/ftccmap.h, src/cache/ftccmap.c: Added new
charmap cache charmap cache.
2001-12-06 Leonard Rosenthol <leonardr@lazerware.com> 2001-12-06 Leonard Rosenthol <leonardr@lazerware.com>
* src/base/ftmac.c: Added support for reading .dfont files on Added support for reading .dfont files on Mac OS X. Also added a
Mac OS X. Aldo added a new routine (FT_GetFile_From_Mac_Name()) new routine which looks up a given font by name in the Mac OS and
which looks up a given font by name in the Mac OS and returns returns the disk file where it resides.
the disk file where it resides.
* include/freetype/ftmac.h: Exported FT_GetFile_From_Mac_Name()
* src/base/ftmac.c (is_dfont): New auxiliary function.
(FT_New_Face_From_dfont): New function.
(FT_GetFile_From_Mac_Name): New exported function.
(FT_New_Face): Updated.
* include/freetype/ftmac.h: Updated.
2001-12-06 David Turner <david@freetype.org>
* src/cache/Jamfile: Updated.
2001-12-06 Werner Lemberg <wl@gnu.org> 2001-12-06 Werner Lemberg <wl@gnu.org>
* INSTALL: Small update. * INSTALL: Small update.
2001-12-05 David Turner <david@freetype.org> 2001-12-05 David Turner <david@freetype.org>
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): re-ordered code for debugging * src/base/ftglyph.c (FT_Glyph_To_Bitmap): Re-ordered code for
purposes.. debugging purposes.
* src/smooth/ftsmooth.c (ft_smooth_render): fixed a nasty hidden bug where * src/smooth/ftsmooth.c (ft_smooth_render): Fixed a nasty hidden bug
outline shifting wasn't correctly undone after bitmap rasterization. this where outline shifting wasn't correctly undone after bitmap
created problems with certain glyphs (like '"' of certain fonts..) and rasterization. This created problems with certain glyphs (like '"'
the cache system.. of certain fonts) and the cache system.
* src/pshinter/pshalgo1.c (psh1_hint_table_init): Fix typo.
* src/pshinter/pshalgo2.c (psh2_hint_table_init): Fix typo.
(ps2_hints_apply): Small fix.
2001-12-05 David Turner <david@freetype.org> 2001-12-05 David Turner <david@freetype.org>
First of all, a big thanks to Werner and Antoine for their latest work !!
* src/pshinter/pshalgo2.c (psh2_hint_table_init),
src/pshinter/pshalgo1.c (psh1_hint_table_init): removed compiler
warnings
* include/freetype/cache/*, src/cache/*: yet another massive rewrite of
the caching sub-system, in order to both increase performance and allow
simpler cache sub-classing. As an example, the code for the image and
sbit caches is now much simpler
* src/pshinter/pshalgo2.c (psh2_hint_table_init), * src/pshinter/pshalgo2.c (psh2_hint_table_init),
src/pshinter/pshalgo1.c (psh1_hint_table_init): Removed compiler src/pshinter/pshalgo1.c (psh1_hint_table_init): Removed compiler
warnings warnings.
* include/freetype/cache/*, src/cache/*: Yet another massive rewrite * include/freetype/cache/*, src/cache/*: Yet another massive rewrite
of the caching sub-system in order to both increase performance and of the caching sub-system in order to both increase performance and
@ -280,7 +276,7 @@
2001-10-18 David Turner <david@freetype.org> 2001-10-18 David Turner <david@freetype.org>
* src/psnames/pstables.h, src/tools/glnames.py: Rewrote the * src/psnames/pstables.h, src/tools/glnames.py: Rewrote the
"glnames.py" script used to generate the "pstables.h" header file. "glnames.py" script used to generate the "pstables.h" header file.
The old one contained a serious bug that made FreeType return The old one contained a serious bug that made FreeType return
incorrect glyph names for certain glyphs. incorrect glyph names for certain glyphs.

View File

@ -186,16 +186,15 @@ ADVANCED-COMPOSITES
GLYPH_TO_BITMAP-BUG GLYPH_TO_BITMAP-BUG
Calling FT_Glyph_To_Bitmap sometimes modifies the original glyph outline, Calling FT_Glyph_To_Bitmap() sometimes modifies the original glyph
creating weird alignment artefacts. outline, creating weird alignment artefacts.
this subtle bug was really in the file src/smooth/ftsmooth.c. Basically, This subtle bug was really in the file src/smooth/ftsmooth.c. Basically,
the outline was shifted before rendering it into a new bitmap buffer. the outline was shifted before rendering it into a new bitmap buffer.
However, it wasn't properly un-shifted after that operation.. However, it wasn't properly un-shifted after that operation.
this was only noticeable with certain glyphs or certain fonts and crept This was only noticeable with certain glyphs or certain fonts; it crept in
for a long time here.. a long time ago.
=== end of file === === end of file ===

View File

@ -25,8 +25,8 @@
/***************************************************************************/ /***************************************************************************/
#ifndef __FT_MAC_H__ #ifndef __FTMAC_H__
#define __FT_MAC_H__ #define __FTMAC_H__
#include <ft2build.h> #include <ft2build.h>
@ -95,35 +95,34 @@ FT_BEGIN_HEADER
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
/* FT_GetFile_From_Mac_Name */ /* FT_GetFile_From_Mac_Name */
/* */ /* */
/* <Description> */ /* <Description> */
/* Returns an FSSpec for the disk file containing the named font. */ /* Returns an FSSpec for the disk file containing the named font. */
/* */ /* */
/* <Input> */ /* <Input> */
/* fontName :: Mac OS name of the font (eg. Times New Roman Bold) */ /* fontName :: Mac OS name of the font (eg. Times New Roman Bold). */
/* */ /* */
/* <Output> */ /* <Output> */
/* pathSpec :: FSSpec to the file. For passing to FT_New_Face */ /* pathSpec :: FSSpec to the file. For passing to @FT_New_Face. */
/* */ /* */
/* face_index :: index of the face For passing to FT_New_Face */ /* face_index :: Index of the face. For passing to @FT_New_Face. */
/* */ /* */
/* <Return> */ /* <Return> */
/* FreeType error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
/* */
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_Name( char* fontName, FT_GetFile_From_Mac_Name( char* fontName,
FSSpec* pathSpec, FSSpec* pathSpec,
FT_Long* face_index ); FT_Long* face_index );
/* */ /* */
FT_END_HEADER FT_END_HEADER
#endif /* __FT_MAC_H__ */ #endif /* __FTMAC_H__ */
/* END */ /* END */

View File

@ -384,8 +384,8 @@
ah_debug_disable_horz = no_horz_edges; ah_debug_disable_horz = no_horz_edges;
ah_debug_disable_vert = no_vert_edges; ah_debug_disable_vert = no_vert_edges;
#else #else
FT_UNUSED(no_horz_edges); FT_UNUSED( no_horz_edges );
FT_UNUSED(no_vert_edges); FT_UNUSED( no_vert_edges );
#endif #endif
/* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help */ /* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help */
/* reduce the problem of the disappearing eye in the `e' of Times... */ /* reduce the problem of the disappearing eye in the `e' of Times... */

View File

@ -663,7 +663,7 @@
#else /* !FT_DEBUG_MEMORY */ #else /* !FT_DEBUG_MEMORY */
/* ansi C doesn't like empty source files */ /* ANSI C doesn't like empty source files */
extern const FT_Byte _debug_mem_dummy = 0; extern const FT_Byte _debug_mem_dummy = 0;
#endif /* !FT_DEBUG_MEMORY */ #endif /* !FT_DEBUG_MEMORY */

View File

@ -601,10 +601,10 @@
/* create result bitmap glyph */ /* create result bitmap glyph */
error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class, error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class,
(FT_Glyph*)&bitmap ); (FT_Glyph*)&bitmap );
if (error) if ( error )
goto Exit; goto Exit;
#if 0 #if 0
/* if `origin' is set, translate the glyph image */ /* if `origin' is set, translate the glyph image */
if ( origin ) if ( origin )
FT_Glyph_Transform( glyph, 0, origin ); FT_Glyph_Transform( glyph, 0, origin );
@ -627,7 +627,7 @@
} }
#endif #endif
if (error) if ( error )
goto Exit; goto Exit;
/* in case of success, copy the bitmap to the glyph bitmap */ /* in case of success, copy the bitmap to the glyph bitmap */
@ -644,9 +644,9 @@
*the_glyph = FT_GLYPH( bitmap ); *the_glyph = FT_GLYPH( bitmap );
Exit: Exit:
if (error && bitmap) if ( error && bitmap )
FT_Done_Glyph( FT_GLYPH(bitmap) ); FT_Done_Glyph( FT_GLYPH( bitmap ) );
return error; return error;
Bad: Bad:

View File

@ -74,7 +74,6 @@
#include FT_MAC_H #include FT_MAC_H
/* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over /* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
TrueType in case *both* are available (this is not common, TrueType in case *both* are available (this is not common,
but it *is* possible). */ but it *is* possible). */
@ -83,7 +82,6 @@
#endif #endif
/* Quick'n'dirty Pascal string to C string converter. /* Quick'n'dirty Pascal string to C string converter.
Warning: this call is not thread safe! Use with caution. */ Warning: this call is not thread safe! Use with caution. */
static char* static char*
@ -134,22 +132,25 @@
return finfo.fdType; return finfo.fdType;
} }
/* is this a Mac OS X .dfont file */
static Boolean is_dfont( FSSpec* spec ) /* is this a Mac OS X .dfont file */
{ static Boolean
int nameLen = spec->name[0]; is_dfont( FSSpec* spec )
{
if ( spec->name[nameLen-5] == '.' && int nameLen = spec->name[0];
spec->name[nameLen-4] == 'd' &&
spec->name[nameLen-3] == 'f' &&
spec->name[nameLen-2] == 'o' && if ( spec->name[nameLen - 5] == '.' &&
spec->name[nameLen-1] == 'n' && spec->name[nameLen - 4] == 'd' &&
spec->name[nameLen] == 't') spec->name[nameLen - 3] == 'f' &&
return true; spec->name[nameLen - 2] == 'o' &&
else spec->name[nameLen - 1] == 'n' &&
return false; spec->name[nameLen ] == 't' )
} return true;
else
return false;
}
/* Given a PostScript font name, create the Macintosh LWFN file name. */ /* Given a PostScript font name, create the Macintosh LWFN file name. */
static void static void
@ -236,9 +237,9 @@
/* Look inside the FOND data, answer whether there should be an SFNT /* Look inside the FOND data, answer whether there should be an SFNT
resource, and answer the name of a possible LWFN Type 1 file. resource, and answer the name of a possible LWFN Type 1 file.
Thanks to Paul Miller (paulm@profoundeffects.com) for the fix Thanks to Paul Miller (paulm@profoundeffects.com) for the fix
to load a face OTHER than the first one in the FOND! to load a face OTHER than the first one in the FOND!
*/ */
static void static void
@ -305,8 +306,8 @@
unsigned char* suffixes = names[style->indexes[0] - 1]; unsigned char* suffixes = names[style->indexes[0] - 1];
for ( i=1; i<=suffixes[0]; i++ ) for ( i = 1; i <= suffixes[0]; i++ )
strcat( ps_name, p2c_str( names[suffixes[i] - 1 ] ) ); strcat( ps_name, p2c_str( names[suffixes[i] - 1] ) );
} }
create_lwfn_name( ps_name, lwfn_file_name ); create_lwfn_name( ps_name, lwfn_file_name );
} }
@ -384,7 +385,6 @@
if ( code != last_code ) if ( code != last_code )
{ {
if ( last_code != -1 ) if ( last_code != -1 )
{ {
/* we're done adding a chunk, fill in the size field */ /* we're done adding a chunk, fill in the size field */
@ -648,48 +648,51 @@
return error; return error;
} }
/* Create a new FT_Face from a file spec to a suitcase file. */ /* Create a new FT_Face from a file spec to a suitcase file. */
static FT_Error static FT_Error
FT_New_Face_From_dfont( FT_Library library, FT_New_Face_From_dfont( FT_Library library,
FSSpec* spec, FSSpec* spec,
FT_Long face_index, FT_Long face_index,
FT_Face* aface ) FT_Face* aface )
{ {
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
short res_ref, res_index; short res_ref, res_index;
Handle fond; Handle fond;
FSRef hostContainerRef; FSRef hostContainerRef;
error = FSpMakeFSRef( spec, &hostContainerRef );
if ( error == noErr )
error = FSOpenResourceFile( &hostContainerRef, 0, NULL, fsRdPerm, &res_ref );
if ( error != noErr ) error = FSpMakeFSRef( spec, &hostContainerRef );
return FT_Err_Cannot_Open_Resource; if ( error == noErr )
error = FSOpenResourceFile( &hostContainerRef,
UseResFile( res_ref ); 0, NULL, fsRdPerm, &res_ref );
/* face_index may be -1, in which case we if ( error != noErr )
just need to do a sanity check */ return FT_Err_Cannot_Open_Resource;
if ( face_index < 0 )
res_index = 1;
else
{
res_index = (short)( face_index + 1 );
face_index = 0;
}
fond = Get1IndResource( 'FOND', res_index );
if ( ResError() )
{
error = FT_Err_Cannot_Open_Resource;
goto Error;
}
error = FT_New_Face_From_FOND( library, fond, face_index, aface ); UseResFile( res_ref );
Error: /* face_index may be -1, in which case we
CloseResFile( res_ref ); just need to do a sanity check */
return error; if ( face_index < 0 )
res_index = 1;
else
{
res_index = (short)( face_index + 1 );
face_index = 0;
}
fond = Get1IndResource( 'FOND', res_index );
if ( ResError() )
{
error = FT_Err_Cannot_Open_Resource;
goto Error;
}
error = FT_New_Face_From_FOND( library, fond, face_index, aface );
Error:
CloseResFile( res_ref );
return error;
} }
@ -740,72 +743,92 @@ Error:
return FT_Err_Unknown_File_Format; return FT_Err_Unknown_File_Format;
} }
/* documentation in ftmac.h */ /* documentation in ftmac.h */
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_Name( char* fontName, FSSpec* pathSpec, FT_Long* face_index ) FT_GetFile_From_Mac_Name( char* fontName,
{ FSSpec* pathSpec,
OptionBits options = kFMUseGlobalScopeOption; FT_Long* face_index )
FMFontFamilyIterator famIter; {
OSStatus status = FMCreateFontFamilyIterator(NULL, NULL, options, &famIter); OptionBits options = kFMUseGlobalScopeOption;
FMFont the_font = NULL;
FMFontFamily family = NULL; FMFontFamilyIterator famIter;
OSStatus status = FMCreateFontFamilyIterator( NULL, NULL,
options,
&famIter );
FMFont the_font = NULL;
FMFontFamily family = NULL;
*face_index = 0; *face_index = 0;
while (status == 0 && !the_font) while ( status == 0 && !the_font )
{ {
status = FMGetNextFontFamily(&famIter, &family); status = FMGetNextFontFamily( &famIter, &family );
if (status == 0) if ( status == 0 )
{
int stat2;
FMFontFamilyInstanceIterator instIter;
Str255 famNameStr;
char famName[256];
/* get the family name */
FMGetFontFamilyName( family, famNameStr );
CopyPascalStringToC( famNameStr, famName );
/* iterate through the styles */
FMCreateFontFamilyInstanceIterator( family, &instIter );
*face_index = 0;
stat2 = 0;
while ( stat2 == 0 && !the_font )
{
FMFontStyle style;
FMFontSize size;
FMFont font;
stat2 = FMGetNextFontFamilyInstance( &instIter, &font,
&style, &size );
if ( stat2 == 0 && size == 0 )
{
char fullName[256];
/* build up a complete face name */
strcpy( fullName, famName );
if ( style & bold )
strcat( fullName, " Bold" );
if ( style & italic )
strcat( fullName, " Italic" );
/* compare with the name we are looking for */
if ( strcmp( fullName, fontName ) == 0 )
{ {
int stat2; /* found it! */
FMFontFamilyInstanceIterator instIter; the_font = font;
/* get the family name */
Str255 famNameStr;
char famName[256];
FMGetFontFamilyName(family, famNameStr);
CopyPascalStringToC(famNameStr, famName);
/* iterate through the styles */
FMCreateFontFamilyInstanceIterator(family, &instIter);
*face_index = 0;
stat2 = 0;
while (stat2 == 0 && !the_font)
{
FMFontStyle style;
FMFontSize size;
FMFont font;
stat2 = FMGetNextFontFamilyInstance(&instIter, &font, &style, &size);
if (stat2 == 0 && size == 0)
{
/* build up a complete face name */
char fullName[256];
strcpy( fullName, famName );
if (style & bold)
strcat( fullName, " Bold" );
if (style & italic)
strcat( fullName, " Italic" );
/* compare with the name we are looking for */
if (strcmp( fullName, fontName ) == 0 )
{
/* found it! */
the_font = font;
}
else
++(*face_index);
}
}
FMDisposeFontFamilyInstanceIterator(&instIter);
} }
else
++(*face_index);
}
}
FMDisposeFontFamilyInstanceIterator( &instIter );
}
} }
FMDisposeFontFamilyIterator(&famIter);
FMDisposeFontFamilyIterator( &famIter );
if ( the_font ) {
FMGetFontContainer(the_font, pathSpec); if ( the_font )
return FT_Err_Ok; {
} else FMGetFontContainer( the_font, pathSpec );
return FT_Err_Unknown_File_Format; return FT_Err_Ok;
}
} else
return FT_Err_Unknown_File_Format;
}
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@ -843,7 +866,7 @@ Error:
return FT_New_Face_From_LWFN( library, &spec, face_index, aface ); return FT_New_Face_From_LWFN( library, &spec, face_index, aface );
else if ( is_dfont( &spec ) ) else if ( is_dfont( &spec ) )
return FT_New_Face_From_dfont( library, &spec, face_index, aface ); return FT_New_Face_From_dfont( library, &spec, face_index, aface );
else /* let it fall through to normal loader (.ttf, .otf, etc.) */ else /* let it fall through to normal loader (.ttf, .otf, etc.) */
{ {
args.flags = ft_open_pathname; args.flags = ft_open_pathname;
args.pathname = (char*)pathname; args.pathname = (char*)pathname;