2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* ftmac.c
|
|
|
|
*
|
|
|
|
* Mac FOND support. Written by just@letterror.com.
|
|
|
|
* Heavily modified by mpsuzuki, George Williams, and Sean McBride.
|
|
|
|
*
|
|
|
|
* This file is for Mac OS X only; see builds/mac/ftoldmac.c for
|
|
|
|
* classic platforms built by MPW.
|
|
|
|
*
|
2019-02-23 10:07:09 +01:00
|
|
|
* Copyright (C) 1996-2019 by
|
2018-06-03 09:01:17 +02:00
|
|
|
* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
|
|
*
|
|
|
|
* This file is part of the FreeType project, and may only be used,
|
|
|
|
* modified, and distributed under the terms of the FreeType project
|
|
|
|
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
|
|
* this file you indicate that you have read the license and
|
|
|
|
* understand and accept it fully.
|
|
|
|
*
|
|
|
|
*/
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Notes
|
|
|
|
|
2002-04-30 16:26:49 +02:00
|
|
|
Mac suitcase files can (and often do!) contain multiple fonts. To
|
2000-07-28 03:10:35 +02:00
|
|
|
support this I use the face_index argument of FT_(Open|New)_Face()
|
|
|
|
functions, and pretend the suitcase file is a collection.
|
2002-04-30 16:26:49 +02:00
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
Warning: fbit and NFNT bitmap resources are not supported yet. In old
|
|
|
|
sfnt fonts, bitmap glyph data for each size is stored in each `NFNT'
|
|
|
|
resources instead of the `bdat' table in the sfnt resource. Therefore,
|
|
|
|
face->num_fixed_sizes is set to 0, because bitmap data in `NFNT'
|
|
|
|
resource is unavailable at present.
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
The Mac FOND support works roughly like this:
|
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
- Check whether the offered stream points to a Mac suitcase file. This
|
|
|
|
is done by checking the file type: it has to be 'FFIL' or 'tfil'. The
|
|
|
|
stream that gets passed to our init_face() routine is a stdio stream,
|
|
|
|
which isn't usable for us, since the FOND resources live in the
|
|
|
|
resource fork. So we just grab the stream->pathname field.
|
|
|
|
|
|
|
|
- Read the FOND resource into memory, then check whether there is a
|
|
|
|
TrueType font and/or(!) a Type 1 font available.
|
|
|
|
|
|
|
|
- If there is a Type 1 font available (as a separate `LWFN' file), read
|
|
|
|
its data into memory, massage it slightly so it becomes PFB data, wrap
|
|
|
|
it into a memory stream, load the Type 1 driver and delegate the rest
|
|
|
|
of the work to it by calling FT_Open_Face(). (XXX TODO: after this
|
|
|
|
has been done, the kerning data from the FOND resource should be
|
|
|
|
appended to the face: On the Mac there are usually no AFM files
|
|
|
|
available. However, this is tricky since we need to map Mac char
|
|
|
|
codes to ps glyph names to glyph ID's...)
|
|
|
|
|
|
|
|
- If there is a TrueType font (an `sfnt' resource), read it into memory,
|
|
|
|
wrap it into a memory stream, load the TrueType driver and delegate
|
|
|
|
the rest of the work to it, by calling FT_Open_Face().
|
2006-09-19 07:48:02 +02:00
|
|
|
|
|
|
|
- Some suitcase fonts (notably Onyx) might point the `LWFN' file to
|
|
|
|
itself, even though it doesn't contains `POST' resources. To handle
|
|
|
|
this special case without opening the file an extra time, we just
|
|
|
|
ignore errors from the `LWFN' and fallback to the `sfnt' if both are
|
|
|
|
available.
|
2000-07-28 03:10:35 +02:00
|
|
|
*/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_FREETYPE_H
|
2008-10-05 05:08:10 +02:00
|
|
|
#include FT_TRUETYPE_TAGS_H
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_INTERNAL_STREAM_H
|
2008-10-02 03:43:18 +02:00
|
|
|
#include "ftbase.h"
|
2003-05-11 09:12:26 +02:00
|
|
|
|
Improve `make multi'.
* src/autofit/aflatin2.c: Guard file with FT_OPTION_AUTOFIT2.
* src/base/ftmac.c: Guard more parts of the file with FT_MACINTOSH.
* src/psaux/afmparse.c: Guard file with T1_CONFIG_OPTION_NO_AFM.
* src/sfnt/pngshim.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS also.
* src/sfnt/ttbdf.c: Avoid empty source file.
* src/sfnt/ttpost.c: Guard file with
TT_CONFIG_OPTION_POSTSCRIPT_NAMES.
* src/sfnt/ttsbit.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS.
* src/truetype/ttgxvar.c, src/truetype/ttinterp.c: Avoid empty
source file.
* src/truetype/ttsubpix.c: Guard file with
TT_USE_BYTECODE_INTERPRETER also.
* src/type1/t1afm.c: Guard file with T1_CONFIG_OPTION_NO_AFM.
* src/autofit/autofit.c, src/base/ftbase.c, src/cache/ftcache.c,
src/cff/cff.c, src/cid/type1cid.c, src/gxvalid/gxvalid.c,
src/pcf/pcf.c, src/pfr/pfr.c, src/psaux/psaux.c,
src/pshinter/pshinter.c, src/psnames/psnames.c, src/raster/raster.c,
src/sfnt/sfnt.c, src/smooth/smooth.c, src/truetype/truetype.c,
src/type1/type1.c, src/type42/type42.c: Remove conditionals; sort
entries.
2017-03-18 07:06:49 +01:00
|
|
|
|
|
|
|
#ifdef FT_MACINTOSH
|
|
|
|
|
2004-04-14 10:49:11 +02:00
|
|
|
/* This is for Mac OS X. Without redefinition, OS_INLINE */
|
|
|
|
/* expands to `static inline' which doesn't survive the */
|
|
|
|
/* -ansi compilation flag of GCC. */
|
2007-02-05 03:50:45 +01:00
|
|
|
#if !HAVE_ANSI_OS_INLINE
|
2006-06-22 04:34:27 +02:00
|
|
|
#undef OS_INLINE
|
2007-02-08 09:54:09 +01:00
|
|
|
#define OS_INLINE static __inline__
|
2007-02-05 03:50:45 +01:00
|
|
|
#endif
|
2006-01-11 10:28:38 +01:00
|
|
|
|
2008-08-19 06:53:02 +02:00
|
|
|
/* `configure' checks the availability of `ResourceIndex' strictly */
|
|
|
|
/* and sets HAVE_TYPE_RESOURCE_INDEX 1 or 0 always. If it is */
|
|
|
|
/* not set (e.g., a build without `configure'), the availability */
|
|
|
|
/* is guessed from the SDK version. */
|
|
|
|
#ifndef HAVE_TYPE_RESOURCE_INDEX
|
2008-08-18 08:02:07 +02:00
|
|
|
#if !defined( MAC_OS_X_VERSION_10_5 ) || \
|
2008-08-19 06:53:02 +02:00
|
|
|
( MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 )
|
2008-08-18 08:02:07 +02:00
|
|
|
#define HAVE_TYPE_RESOURCE_INDEX 0
|
|
|
|
#else
|
|
|
|
#define HAVE_TYPE_RESOURCE_INDEX 1
|
|
|
|
#endif
|
2008-08-19 06:53:02 +02:00
|
|
|
#endif /* !HAVE_TYPE_RESOURCE_INDEX */
|
2008-08-18 08:02:07 +02:00
|
|
|
|
|
|
|
#if ( HAVE_TYPE_RESOURCE_INDEX == 0 )
|
2008-08-19 06:53:02 +02:00
|
|
|
typedef short ResourceIndex;
|
2006-01-11 10:28:38 +01:00
|
|
|
#endif
|
|
|
|
|
2007-11-16 16:48:58 +01:00
|
|
|
#include <CoreServices/CoreServices.h>
|
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
2008-01-04 02:43:23 +01:00
|
|
|
#include <sys/syslimits.h> /* PATH_MAX */
|
2007-11-16 16:48:58 +01:00
|
|
|
|
2009-01-06 07:59:36 +01:00
|
|
|
/* Don't want warnings about our own use of deprecated functions. */
|
2007-02-05 05:07:46 +01:00
|
|
|
#define FT_DEPRECATED_ATTRIBUTE
|
2006-01-11 10:28:38 +01:00
|
|
|
|
2006-12-15 16:23:21 +01:00
|
|
|
#include FT_MAC_H
|
|
|
|
|
2007-11-16 16:48:58 +01:00
|
|
|
#ifndef kATSOptionFlagsUnRestrictedScope /* since Mac OS X 10.1 */
|
|
|
|
#define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
|
|
|
|
#endif
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
/* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
|
|
|
|
TrueType in case *both* are available (this is not common,
|
|
|
|
but it *is* possible). */
|
|
|
|
#ifndef PREFER_LWFN
|
2006-01-11 11:57:42 +01:00
|
|
|
#define PREFER_LWFN 1
|
2000-07-28 03:10:35 +02:00
|
|
|
#endif
|
|
|
|
|
2004-02-26 22:56:27 +01:00
|
|
|
|
2007-08-29 08:08:59 +02:00
|
|
|
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_GetFile_From_Mac_Name( const char* fontName,
|
|
|
|
FSSpec* pathSpec,
|
|
|
|
FT_Long* face_index )
|
|
|
|
{
|
2007-06-19 05:27:05 +02:00
|
|
|
FT_UNUSED( fontName );
|
|
|
|
FT_UNUSED( pathSpec );
|
|
|
|
FT_UNUSED( face_index );
|
|
|
|
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unimplemented_Feature );
|
2006-01-11 10:28:38 +01:00
|
|
|
}
|
2006-01-11 11:57:42 +01:00
|
|
|
|
|
|
|
|
2007-02-05 04:28:29 +01:00
|
|
|
/* Private function. */
|
|
|
|
/* The FSSpec type has been discouraged for a long time, */
|
2007-11-16 16:48:58 +01:00
|
|
|
/* unfortunately an FSRef replacement API for */
|
|
|
|
/* ATSFontGetFileSpecification() is only available in */
|
|
|
|
/* Mac OS X 10.5 and later. */
|
2007-02-05 04:28:29 +01:00
|
|
|
static OSStatus
|
|
|
|
FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
|
|
|
|
FSRef* ats_font_ref )
|
|
|
|
{
|
2007-11-16 16:48:58 +01:00
|
|
|
#if defined( MAC_OS_X_VERSION_10_5 ) && \
|
2008-06-24 19:13:58 +02:00
|
|
|
( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
|
2012-01-16 18:00:24 +01:00
|
|
|
|
2007-11-16 16:48:58 +01:00
|
|
|
OSStatus err;
|
|
|
|
|
|
|
|
err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
|
2008-01-04 02:43:23 +01:00
|
|
|
|
2007-11-16 16:48:58 +01:00
|
|
|
return err;
|
|
|
|
#elif __LP64__ /* No 64bit Carbon API on legacy platforms */
|
2007-06-19 05:27:05 +02:00
|
|
|
FT_UNUSED( ats_font_id );
|
|
|
|
FT_UNUSED( ats_font_ref );
|
|
|
|
|
2007-11-16 16:48:58 +01:00
|
|
|
|
2007-06-19 05:27:05 +02:00
|
|
|
return fnfErr;
|
2007-11-16 16:48:58 +01:00
|
|
|
#else /* 32bit Carbon API on legacy platforms */
|
2007-02-08 09:54:09 +01:00
|
|
|
OSStatus err;
|
|
|
|
FSSpec spec;
|
|
|
|
|
2007-02-05 04:28:29 +01:00
|
|
|
|
|
|
|
err = ATSFontGetFileSpecification( ats_font_id, &spec );
|
|
|
|
if ( noErr == err )
|
|
|
|
err = FSpMakeFSRef( &spec, ats_font_ref );
|
|
|
|
|
|
|
|
return err;
|
2007-06-19 05:27:05 +02:00
|
|
|
#endif
|
2007-02-05 04:28:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
FT_GetFileRef_From_Mac_ATS_Name( const char* fontName,
|
|
|
|
FSRef* ats_font_ref,
|
|
|
|
FT_Long* face_index )
|
2006-01-11 10:28:38 +01:00
|
|
|
{
|
|
|
|
CFStringRef cf_fontName;
|
|
|
|
ATSFontRef ats_font_id;
|
2006-01-11 11:57:42 +01:00
|
|
|
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
*face_index = 0;
|
2006-01-11 11:57:42 +01:00
|
|
|
|
|
|
|
cf_fontName = CFStringCreateWithCString( NULL, fontName,
|
|
|
|
kCFStringEncodingMacRoman );
|
|
|
|
ats_font_id = ATSFontFindFromName( cf_fontName,
|
|
|
|
kATSOptionFlagsUnRestrictedScope );
|
2007-02-20 03:37:36 +01:00
|
|
|
CFRelease( cf_fontName );
|
2006-01-11 11:57:42 +01:00
|
|
|
|
|
|
|
if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unknown_File_Format );
|
2006-01-11 11:57:42 +01:00
|
|
|
|
2007-02-05 04:28:29 +01:00
|
|
|
if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unknown_File_Format );
|
2006-01-11 11:57:42 +01:00
|
|
|
|
|
|
|
/* face_index calculation by searching preceding fontIDs */
|
|
|
|
/* with same FSRef */
|
2006-01-11 10:28:38 +01:00
|
|
|
{
|
2007-02-05 04:28:29 +01:00
|
|
|
ATSFontRef id2 = ats_font_id - 1;
|
|
|
|
FSRef ref2;
|
2006-01-11 11:57:42 +01:00
|
|
|
|
|
|
|
|
2007-02-05 04:28:29 +01:00
|
|
|
while ( id2 > 0 )
|
2006-01-11 10:28:38 +01:00
|
|
|
{
|
2007-02-05 04:28:29 +01:00
|
|
|
if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
|
|
|
|
break;
|
|
|
|
if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
|
2006-01-11 10:28:38 +01:00
|
|
|
break;
|
2007-02-05 04:28:29 +01:00
|
|
|
|
|
|
|
id2 --;
|
2006-01-11 10:28:38 +01:00
|
|
|
}
|
2007-02-05 04:28:29 +01:00
|
|
|
*face_index = ats_font_id - ( id2 + 1 );
|
2006-01-11 10:28:38 +01:00
|
|
|
}
|
2007-02-05 04:28:29 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
2006-01-11 11:57:42 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
|
2007-02-05 04:28:29 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
|
|
|
|
UInt8* path,
|
|
|
|
UInt32 maxPathSize,
|
|
|
|
FT_Long* face_index )
|
|
|
|
{
|
|
|
|
FSRef ref;
|
|
|
|
FT_Error err;
|
|
|
|
|
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
if ( !fontName || !face_index )
|
2016-02-15 12:54:40 +01:00
|
|
|
return FT_THROW( Invalid_Argument);
|
2014-11-26 21:59:21 +01:00
|
|
|
|
2007-02-05 04:28:29 +01:00
|
|
|
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( err )
|
2007-02-05 04:28:29 +01:00
|
|
|
return err;
|
|
|
|
|
|
|
|
if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unknown_File_Format );
|
2007-02-05 04:28:29 +01:00
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
|
|
|
|
FSSpec* pathSpec,
|
|
|
|
FT_Long* face_index )
|
|
|
|
{
|
2007-11-16 16:48:58 +01:00
|
|
|
#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
|
2008-06-24 19:13:58 +02:00
|
|
|
( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
|
2007-06-19 05:27:05 +02:00
|
|
|
FT_UNUSED( fontName );
|
|
|
|
FT_UNUSED( pathSpec );
|
|
|
|
FT_UNUSED( face_index );
|
2007-02-08 09:54:09 +01:00
|
|
|
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unimplemented_Feature );
|
2007-02-05 04:28:29 +01:00
|
|
|
#else
|
|
|
|
FSRef ref;
|
|
|
|
FT_Error err;
|
|
|
|
|
2007-02-08 09:54:09 +01:00
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
if ( !fontName || !face_index )
|
|
|
|
return FT_THROW( Invalid_Argument );
|
|
|
|
|
2007-02-05 04:28:29 +01:00
|
|
|
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( err )
|
2007-02-05 04:28:29 +01:00
|
|
|
return err;
|
|
|
|
|
|
|
|
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
|
|
|
|
pathSpec, NULL ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unknown_File_Format );
|
2007-02-05 04:28:29 +01:00
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
static OSErr
|
2007-08-29 08:08:59 +02:00
|
|
|
FT_FSPathMakeRes( const UInt8* pathname,
|
|
|
|
ResFileRefNum* res )
|
2006-01-11 10:28:38 +01:00
|
|
|
{
|
|
|
|
OSErr err;
|
|
|
|
FSRef ref;
|
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Cannot_Open_Resource );
|
2006-01-11 10:28:38 +01:00
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
/* at present, no support for dfont format */
|
2006-01-11 10:28:38 +01:00
|
|
|
err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res );
|
|
|
|
if ( noErr == err )
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* fallback to original resource-fork font */
|
|
|
|
*res = FSOpenResFile( &ref, fsRdPerm );
|
|
|
|
err = ResError();
|
2006-01-11 11:57:42 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
return err;
|
2000-07-28 03:10:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
/* Return the file type for given pathname */
|
2001-06-27 18:18:10 +02:00
|
|
|
static OSType
|
2006-01-11 10:28:38 +01:00
|
|
|
get_file_type_from_path( const UInt8* pathname )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
2006-01-11 10:28:38 +01:00
|
|
|
FSRef ref;
|
|
|
|
FSCatalogInfo info;
|
|
|
|
|
|
|
|
|
|
|
|
if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
|
|
|
|
return ( OSType ) 0;
|
|
|
|
|
|
|
|
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoFinderInfo, &info,
|
|
|
|
NULL, NULL, NULL ) )
|
|
|
|
return ( OSType ) 0;
|
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
return ((FInfo *)(info.finderInfo))->fdType;
|
2000-07-28 03:10:35 +02:00
|
|
|
}
|
|
|
|
|
2001-12-07 22:56:32 +01:00
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
/* Given a PostScript font name, create the Macintosh LWFN file name. */
|
2001-06-27 18:18:10 +02:00
|
|
|
static void
|
|
|
|
create_lwfn_name( char* ps_name,
|
|
|
|
Str255 lwfn_file_name )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
int max = 5, count = 0;
|
|
|
|
FT_Byte* p = lwfn_file_name;
|
|
|
|
FT_Byte* q = (FT_Byte*)ps_name;
|
|
|
|
|
|
|
|
|
|
|
|
lwfn_file_name[0] = 0;
|
|
|
|
|
|
|
|
while ( *q )
|
|
|
|
{
|
2003-05-21 09:39:42 +02:00
|
|
|
if ( ft_isupper( *q ) )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
if ( count )
|
|
|
|
max = 3;
|
|
|
|
count = 0;
|
|
|
|
}
|
* README.UNX: updated the Unix-specific quick-compilation guide to
warn about the GNU Make requirement at compile time..
* include/freetype/config/ftstdlib.h,
include/freetype/config/ftconfig.h,
include/freetype/config/ftheader.h,
include/freetype/internal/ftmemory.h,
include/freetype/internal/ftobjs.h,
src/autohint/ahoptim.c,
src/base/ftdbgmem.c, src/base/ftdebug.c,
src/base/ftmac.c, src/base/ftobjs.c,
src/base/ftsystem.c,
src/cache/ftcimage.c, src/cache/ftcsbits.c,
src/cff/cffdriver.c, src/cff/cffload.c, src/cff/cffobjs.c,
src/cid/cidload.c, src/cid/cidparse.c, src/cid/cidriver.c,
src/pcf/pcfdriver.c, src/pcf/pcfread.c,
src/psaux/t1cmap.c, src/psaux/t1decode.c,
src/pshinter/pshalgo1.c, src/pshinter/pshalgo2.c,
src/pshinter/pshrec.c,
src/psnames/psmodule.c,
src/raster/ftraster.c,
src/sfnt/sfdriver.c, src/sfnt/ttload.c, src/sfnt/ttpost.c,
src/smooth/ftgrays.c,
src/type1/t1afm.c, src/type1/t1driver.c, src/type1/t1gload.c,
src/type1/t1load.c, src/type1/t1objs.c, src/type1/t1parse.c:
added the new configuration file "ftstdlib.h" used to define
aliases for all ISO C library functions used by the engine
(e.g. strlen, qsort, setjmp, etc...)
this eases the porting of FreeType 2 to exotic environments like
XFree86 modules/extensions..
also removed many #include <string.h>, #include <stdlib.h>, etc...
from the engine's sources where they're not needed..
2002-04-12 11:31:48 +02:00
|
|
|
if ( count < max && ( ft_isalnum( *q ) || *q == '_' ) )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
*++p = *q;
|
|
|
|
lwfn_file_name[0]++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
q++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-26 22:56:27 +01:00
|
|
|
static short
|
2005-12-23 16:10:54 +01:00
|
|
|
count_faces_sfnt( char* fond_data )
|
2004-02-26 22:56:27 +01:00
|
|
|
{
|
|
|
|
/* The count is 1 greater than the value in the FOND. */
|
|
|
|
/* Isn't that cute? :-) */
|
|
|
|
|
2006-06-25 08:07:14 +02:00
|
|
|
return EndianS16_BtoN( *( (short*)( fond_data +
|
|
|
|
sizeof ( FamRec ) ) ) ) + 1;
|
2004-02-26 22:56:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-23 13:22:46 +01:00
|
|
|
static short
|
2005-12-23 16:10:54 +01:00
|
|
|
count_faces_scalable( char* fond_data )
|
2005-12-23 13:22:46 +01:00
|
|
|
{
|
|
|
|
AsscEntry* assoc;
|
|
|
|
short i, face, face_all;
|
|
|
|
|
|
|
|
|
2006-06-25 08:07:14 +02:00
|
|
|
face_all = EndianS16_BtoN( *( (short *)( fond_data +
|
|
|
|
sizeof ( FamRec ) ) ) ) + 1;
|
2006-01-11 11:57:42 +01:00
|
|
|
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
|
|
|
|
face = 0;
|
2005-12-23 13:22:46 +01:00
|
|
|
|
|
|
|
for ( i = 0; i < face_all; i++ )
|
|
|
|
{
|
2006-06-22 04:34:27 +02:00
|
|
|
if ( 0 == EndianS16_BtoN( assoc[i].fontSize ) )
|
2005-12-23 16:10:54 +01:00
|
|
|
face++;
|
2005-12-23 13:22:46 +01:00
|
|
|
}
|
|
|
|
return face;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
/* Look inside the FOND data, answer whether there should be an SFNT
|
2001-12-07 22:56:32 +01:00
|
|
|
resource, and answer the name of a possible LWFN Type 1 file.
|
|
|
|
|
|
|
|
Thanks to Paul Miller (paulm@profoundeffects.com) for the fix
|
2001-10-26 15:24:39 +02:00
|
|
|
to load a face OTHER than the first one in the FOND!
|
|
|
|
*/
|
2004-02-26 22:56:27 +01:00
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static void
|
|
|
|
parse_fond( char* fond_data,
|
|
|
|
short* have_sfnt,
|
2007-08-29 08:08:59 +02:00
|
|
|
ResID* sfnt_id,
|
2001-10-26 15:24:39 +02:00
|
|
|
Str255 lwfn_file_name,
|
|
|
|
short face_index )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
AsscEntry* assoc;
|
2001-10-26 15:24:39 +02:00
|
|
|
AsscEntry* base_assoc;
|
2000-07-28 03:10:35 +02:00
|
|
|
FamRec* fond;
|
|
|
|
|
|
|
|
|
|
|
|
*sfnt_id = 0;
|
|
|
|
*have_sfnt = 0;
|
|
|
|
lwfn_file_name[0] = 0;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
fond = (FamRec*)fond_data;
|
|
|
|
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
|
2001-10-26 15:24:39 +02:00
|
|
|
base_assoc = assoc;
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2008-02-21 19:46:07 +01:00
|
|
|
/* the maximum faces in a FOND is 48, size of StyleTable.indexes[] */
|
|
|
|
if ( 47 < face_index )
|
|
|
|
return;
|
|
|
|
|
2004-02-26 22:56:27 +01:00
|
|
|
/* Let's do a little range checking before we get too excited here */
|
|
|
|
if ( face_index < count_faces_sfnt( fond_data ) )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
2004-02-26 22:56:27 +01:00
|
|
|
assoc += face_index; /* add on the face_index! */
|
|
|
|
|
|
|
|
/* if the face at this index is not scalable,
|
|
|
|
fall back to the first one (old behavior) */
|
2006-06-22 04:34:27 +02:00
|
|
|
if ( EndianS16_BtoN( assoc->fontSize ) == 0 )
|
2004-02-26 22:56:27 +01:00
|
|
|
{
|
|
|
|
*have_sfnt = 1;
|
2006-06-22 04:34:27 +02:00
|
|
|
*sfnt_id = EndianS16_BtoN( assoc->fontID );
|
2004-02-26 22:56:27 +01:00
|
|
|
}
|
|
|
|
else if ( base_assoc->fontSize == 0 )
|
|
|
|
{
|
|
|
|
*have_sfnt = 1;
|
2006-06-22 04:34:27 +02:00
|
|
|
*sfnt_id = EndianS16_BtoN( base_assoc->fontID );
|
2004-02-26 22:56:27 +01:00
|
|
|
}
|
2001-10-26 15:24:39 +02:00
|
|
|
}
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2006-06-22 04:34:27 +02:00
|
|
|
if ( EndianS32_BtoN( fond->ffStylOff ) )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
unsigned char* p = (unsigned char*)fond_data;
|
|
|
|
StyleTable* style;
|
|
|
|
unsigned short string_count;
|
|
|
|
char ps_name[256];
|
|
|
|
unsigned char* names[64];
|
|
|
|
int i;
|
|
|
|
|
2000-07-29 22:38:19 +02:00
|
|
|
|
2006-06-22 04:34:27 +02:00
|
|
|
p += EndianS32_BtoN( fond->ffStylOff );
|
2000-07-28 03:10:35 +02:00
|
|
|
style = (StyleTable*)p;
|
2000-07-29 22:38:19 +02:00
|
|
|
p += sizeof ( StyleTable );
|
2006-06-22 04:34:27 +02:00
|
|
|
string_count = EndianS16_BtoN( *(short*)(p) );
|
2014-11-26 08:11:38 +01:00
|
|
|
string_count = FT_MIN( 64, string_count );
|
2000-07-29 22:38:19 +02:00
|
|
|
p += sizeof ( short );
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2014-11-26 08:11:38 +01:00
|
|
|
for ( i = 0; i < string_count; i++ )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
names[i] = p;
|
2006-01-11 11:57:42 +01:00
|
|
|
p += names[i][0];
|
2000-07-28 03:10:35 +02:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2002-04-30 16:26:49 +02:00
|
|
|
size_t ps_name_len = (size_t)names[0][0];
|
|
|
|
|
|
|
|
|
|
|
|
if ( ps_name_len != 0 )
|
|
|
|
{
|
2003-05-21 09:39:42 +02:00
|
|
|
ft_memcpy(ps_name, names[0] + 1, ps_name_len);
|
2002-04-30 16:26:49 +02:00
|
|
|
ps_name[ps_name_len] = 0;
|
|
|
|
}
|
2008-02-21 19:46:07 +01:00
|
|
|
if ( style->indexes[face_index] > 1 &&
|
2014-11-26 08:11:38 +01:00
|
|
|
style->indexes[face_index] <= string_count )
|
2002-04-30 16:26:49 +02:00
|
|
|
{
|
2008-02-21 19:46:07 +01:00
|
|
|
unsigned char* suffixes = names[style->indexes[face_index] - 1];
|
2002-04-30 16:26:49 +02:00
|
|
|
|
|
|
|
|
2003-04-23 20:10:19 +02:00
|
|
|
for ( i = 1; i <= suffixes[0]; i++ )
|
2002-04-30 16:26:49 +02:00
|
|
|
{
|
|
|
|
unsigned char* s;
|
|
|
|
size_t j = suffixes[i] - 1;
|
|
|
|
|
|
|
|
|
|
|
|
if ( j < string_count && ( s = names[j] ) != NULL )
|
|
|
|
{
|
|
|
|
size_t s_len = (size_t)s[0];
|
2000-07-29 22:38:19 +02:00
|
|
|
|
|
|
|
|
2002-04-30 16:26:49 +02:00
|
|
|
if ( s_len != 0 && ps_name_len + s_len < sizeof ( ps_name ) )
|
|
|
|
{
|
2003-05-21 09:39:42 +02:00
|
|
|
ft_memcpy( ps_name + ps_name_len, s + 1, s_len );
|
2002-04-30 16:26:49 +02:00
|
|
|
ps_name_len += s_len;
|
|
|
|
ps_name[ps_name_len] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-07-28 03:10:35 +02:00
|
|
|
}
|
2002-04-30 16:26:49 +02:00
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
create_lwfn_name( ps_name, lwfn_file_name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
static FT_Error
|
2007-06-19 05:27:05 +02:00
|
|
|
lookup_lwfn_by_fond( const UInt8* path_fond,
|
|
|
|
ConstStr255Param base_lwfn,
|
|
|
|
UInt8* path_lwfn,
|
|
|
|
size_t path_size )
|
2006-01-11 10:28:38 +01:00
|
|
|
{
|
2007-08-29 08:08:59 +02:00
|
|
|
FSRef ref, par_ref;
|
|
|
|
size_t dirname_len;
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
/* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
|
|
|
|
/* We should not extract parent directory by string manipulation. */
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
|
|
|
|
NULL, NULL, NULL, &par_ref ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2006-01-11 10:28:38 +01:00
|
|
|
|
2007-06-19 05:27:05 +02:00
|
|
|
/* now we have absolute dirname in path_lwfn */
|
|
|
|
ft_strcat( (char *)path_lwfn, "/" );
|
2006-01-11 10:28:38 +01:00
|
|
|
dirname_len = ft_strlen( (char *)path_lwfn );
|
|
|
|
ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 );
|
2006-01-11 11:57:42 +01:00
|
|
|
path_lwfn[dirname_len + base_lwfn[0]] = '\0';
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Cannot_Open_Resource );
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
|
|
|
|
NULL, NULL, NULL, NULL ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Cannot_Open_Resource );
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-26 22:56:27 +01:00
|
|
|
static short
|
2006-01-11 10:28:38 +01:00
|
|
|
count_faces( Handle fond,
|
|
|
|
const UInt8* pathname )
|
2004-02-26 22:56:27 +01:00
|
|
|
{
|
2007-08-29 08:08:59 +02:00
|
|
|
ResID sfnt_id;
|
2006-01-11 10:28:38 +01:00
|
|
|
short have_sfnt, have_lwfn;
|
2006-01-11 11:57:42 +01:00
|
|
|
Str255 lwfn_file_name;
|
2007-11-16 16:48:58 +01:00
|
|
|
UInt8 buff[PATH_MAX];
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_Error err;
|
2006-06-22 04:34:27 +02:00
|
|
|
short num_faces;
|
2006-01-11 10:28:38 +01:00
|
|
|
|
2004-02-26 22:56:27 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
have_sfnt = have_lwfn = 0;
|
2004-02-26 22:56:27 +01:00
|
|
|
|
|
|
|
parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, 0 );
|
|
|
|
|
|
|
|
if ( lwfn_file_name[0] )
|
|
|
|
{
|
2006-01-11 10:28:38 +01:00
|
|
|
err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
|
2006-01-11 11:57:42 +01:00
|
|
|
buff, sizeof ( buff ) );
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( !err )
|
2006-01-11 10:28:38 +01:00
|
|
|
have_lwfn = 1;
|
2004-02-26 22:56:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
|
2006-06-22 04:34:27 +02:00
|
|
|
num_faces = 1;
|
2004-02-26 22:56:27 +01:00
|
|
|
else
|
2006-06-22 04:34:27 +02:00
|
|
|
num_faces = count_faces_scalable( *fond );
|
|
|
|
|
|
|
|
return num_faces;
|
2004-02-26 22:56:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
/* Read Type 1 data from the POST resources inside the LWFN file,
|
2006-01-11 11:57:42 +01:00
|
|
|
return a PFB buffer. This is somewhat convoluted because the FT2
|
2000-07-28 03:10:35 +02:00
|
|
|
PFB parser wants the ASCII header as one chunk, and the LWFN
|
2006-01-11 11:57:42 +01:00
|
|
|
chunks are often not organized that way, so we glue chunks
|
2000-07-28 03:10:35 +02:00
|
|
|
of the same type together. */
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
2007-08-29 08:08:59 +02:00
|
|
|
read_lwfn( FT_Memory memory,
|
|
|
|
ResFileRefNum res,
|
|
|
|
FT_Byte** pfb_data,
|
|
|
|
FT_ULong* size )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
FT_Error error = FT_Err_Ok;
|
2007-08-29 08:08:59 +02:00
|
|
|
ResID res_id;
|
2002-04-30 16:26:49 +02:00
|
|
|
unsigned char *buffer, *p, *size_p = NULL;
|
2000-07-28 03:10:35 +02:00
|
|
|
FT_ULong total_size = 0;
|
2006-05-02 11:00:29 +02:00
|
|
|
FT_ULong old_total_size = 0;
|
2000-07-28 03:10:35 +02:00
|
|
|
FT_ULong post_size, pfb_chunk_size;
|
|
|
|
Handle post_data;
|
|
|
|
char code, last_code;
|
|
|
|
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
UseResFile( res );
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2004-02-26 22:56:27 +01:00
|
|
|
/* First pass: load all POST resources, and determine the size of */
|
|
|
|
/* the output buffer. */
|
2002-04-30 16:26:49 +02:00
|
|
|
res_id = 501;
|
2000-07-28 03:10:35 +02:00
|
|
|
last_code = -1;
|
2000-07-29 22:38:19 +02:00
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
2008-10-04 20:10:28 +02:00
|
|
|
post_data = Get1Resource( TTAG_POST, res_id++ );
|
2016-12-26 17:08:17 +01:00
|
|
|
if ( !post_data )
|
2006-01-11 11:57:42 +01:00
|
|
|
break; /* we are done */
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
code = (*post_data)[0];
|
|
|
|
|
|
|
|
if ( code != last_code )
|
|
|
|
{
|
|
|
|
if ( code == 5 )
|
|
|
|
total_size += 2; /* just the end code */
|
|
|
|
else
|
|
|
|
total_size += 6; /* code + 4 bytes chunk length */
|
|
|
|
}
|
|
|
|
|
2015-09-27 18:40:21 +02:00
|
|
|
total_size += (FT_ULong)GetHandleSize( post_data ) - 2;
|
2000-07-28 03:10:35 +02:00
|
|
|
last_code = code;
|
2006-05-02 11:00:29 +02:00
|
|
|
|
2015-09-21 16:07:22 +02:00
|
|
|
/* detect resource fork overflow */
|
|
|
|
if ( FT_MAC_RFORK_MAX_LEN < total_size )
|
2006-05-02 11:00:29 +02:00
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Array_Too_Large );
|
2006-05-02 11:00:29 +02:00
|
|
|
goto Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
old_total_size = total_size;
|
2000-07-28 03:10:35 +02:00
|
|
|
}
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_ALLOC( buffer, (FT_Long)total_size ) )
|
2000-07-28 03:10:35 +02:00
|
|
|
goto Error;
|
|
|
|
|
2004-02-26 22:56:27 +01:00
|
|
|
/* Second pass: append all POST data to the buffer, add PFB fields. */
|
|
|
|
/* Glue all consecutive chunks of the same type together. */
|
2002-04-30 16:26:49 +02:00
|
|
|
p = buffer;
|
|
|
|
res_id = 501;
|
|
|
|
last_code = -1;
|
2000-07-28 03:10:35 +02:00
|
|
|
pfb_chunk_size = 0;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2008-10-04 20:10:28 +02:00
|
|
|
post_data = Get1Resource( TTAG_POST, res_id++ );
|
2016-12-26 17:08:17 +01:00
|
|
|
if ( !post_data )
|
2006-01-11 11:57:42 +01:00
|
|
|
break; /* we are done */
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
post_size = (FT_ULong)GetHandleSize( post_data ) - 2;
|
|
|
|
code = (*post_data)[0];
|
|
|
|
|
|
|
|
if ( code != last_code )
|
|
|
|
{
|
|
|
|
if ( last_code != -1 )
|
|
|
|
{
|
2006-01-11 11:57:42 +01:00
|
|
|
/* we are done adding a chunk, fill in the size field */
|
2016-12-26 17:08:17 +01:00
|
|
|
if ( size_p )
|
2002-04-30 16:26:49 +02:00
|
|
|
{
|
|
|
|
*size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF );
|
|
|
|
*size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8 ) & 0xFF );
|
|
|
|
*size_p++ = (FT_Byte)( ( pfb_chunk_size >> 16 ) & 0xFF );
|
|
|
|
*size_p++ = (FT_Byte)( ( pfb_chunk_size >> 24 ) & 0xFF );
|
|
|
|
}
|
2000-07-28 03:10:35 +02:00
|
|
|
pfb_chunk_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p++ = 0x80;
|
|
|
|
if ( code == 5 )
|
|
|
|
*p++ = 0x03; /* the end */
|
|
|
|
else if ( code == 2 )
|
|
|
|
*p++ = 0x02; /* binary segment */
|
|
|
|
else
|
|
|
|
*p++ = 0x01; /* ASCII segment */
|
|
|
|
|
|
|
|
if ( code != 5 )
|
|
|
|
{
|
|
|
|
size_p = p; /* save for later */
|
|
|
|
p += 4; /* make space for size field */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* README.UNX: updated the Unix-specific quick-compilation guide to
warn about the GNU Make requirement at compile time..
* include/freetype/config/ftstdlib.h,
include/freetype/config/ftconfig.h,
include/freetype/config/ftheader.h,
include/freetype/internal/ftmemory.h,
include/freetype/internal/ftobjs.h,
src/autohint/ahoptim.c,
src/base/ftdbgmem.c, src/base/ftdebug.c,
src/base/ftmac.c, src/base/ftobjs.c,
src/base/ftsystem.c,
src/cache/ftcimage.c, src/cache/ftcsbits.c,
src/cff/cffdriver.c, src/cff/cffload.c, src/cff/cffobjs.c,
src/cid/cidload.c, src/cid/cidparse.c, src/cid/cidriver.c,
src/pcf/pcfdriver.c, src/pcf/pcfread.c,
src/psaux/t1cmap.c, src/psaux/t1decode.c,
src/pshinter/pshalgo1.c, src/pshinter/pshalgo2.c,
src/pshinter/pshrec.c,
src/psnames/psmodule.c,
src/raster/ftraster.c,
src/sfnt/sfdriver.c, src/sfnt/ttload.c, src/sfnt/ttpost.c,
src/smooth/ftgrays.c,
src/type1/t1afm.c, src/type1/t1driver.c, src/type1/t1gload.c,
src/type1/t1load.c, src/type1/t1objs.c, src/type1/t1parse.c:
added the new configuration file "ftstdlib.h" used to define
aliases for all ISO C library functions used by the engine
(e.g. strlen, qsort, setjmp, etc...)
this eases the porting of FreeType 2 to exotic environments like
XFree86 modules/extensions..
also removed many #include <string.h>, #include <stdlib.h>, etc...
from the engine's sources where they're not needed..
2002-04-12 11:31:48 +02:00
|
|
|
ft_memcpy( p, *post_data + 2, post_size );
|
2000-07-28 03:10:35 +02:00
|
|
|
pfb_chunk_size += post_size;
|
|
|
|
p += post_size;
|
|
|
|
last_code = code;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pfb_data = buffer;
|
|
|
|
*size = total_size;
|
|
|
|
|
2000-07-29 22:38:19 +02:00
|
|
|
Error:
|
2006-01-11 10:28:38 +01:00
|
|
|
CloseResFile( res );
|
2000-07-28 03:10:35 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-06 07:59:36 +01:00
|
|
|
/* Create a new FT_Face from a file path to an LWFN file. */
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_New_Face_From_LWFN( FT_Library library,
|
2006-01-11 10:28:38 +01:00
|
|
|
const UInt8* pathname,
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_Long face_index,
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_Face* aface )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
2007-08-29 08:08:59 +02:00
|
|
|
FT_Byte* pfb_data;
|
|
|
|
FT_ULong pfb_size;
|
|
|
|
FT_Error error;
|
|
|
|
ResFileRefNum res;
|
2004-02-26 22:56:27 +01:00
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
if ( noErr != FT_FSPathMakeRes( pathname, &res ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Cannot_Open_Resource );
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
pfb_data = NULL;
|
|
|
|
pfb_size = 0;
|
|
|
|
error = read_lwfn( library->memory, res, &pfb_data, &pfb_size );
|
|
|
|
CloseResFile( res ); /* PFB is already loaded, useless anymore */
|
2000-07-28 03:10:35 +02:00
|
|
|
if ( error )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return open_face_from_buffer( library,
|
|
|
|
pfb_data,
|
|
|
|
pfb_size,
|
|
|
|
face_index,
|
|
|
|
"type1",
|
|
|
|
aface );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Create a new FT_Face from an SFNT resource, specified by res ID. */
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
|
|
|
FT_New_Face_From_SFNT( FT_Library library,
|
2007-08-29 08:08:59 +02:00
|
|
|
ResID sfnt_id,
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_Long face_index,
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_Face* aface )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
2000-07-29 22:38:19 +02:00
|
|
|
Handle sfnt = NULL;
|
|
|
|
FT_Byte* sfnt_data;
|
|
|
|
size_t sfnt_size;
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2000-07-29 22:38:19 +02:00
|
|
|
FT_Memory memory = library->memory;
|
2008-09-19 19:46:01 +02:00
|
|
|
int is_cff, is_sfnt_ps;
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
|
2008-10-04 20:10:28 +02:00
|
|
|
sfnt = GetResource( TTAG_sfnt, sfnt_id );
|
2016-12-26 17:08:17 +01:00
|
|
|
if ( !sfnt )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Handle );
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
sfnt_size = (FT_ULong)GetHandleSize( sfnt );
|
2015-09-21 16:07:22 +02:00
|
|
|
|
|
|
|
/* detect resource fork overflow */
|
|
|
|
if ( FT_MAC_RFORK_MAX_LEN < sfnt_size )
|
|
|
|
return FT_THROW( Array_Too_Large );
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
ReleaseResource( sfnt );
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
* README.UNX: updated the Unix-specific quick-compilation guide to
warn about the GNU Make requirement at compile time..
* include/freetype/config/ftstdlib.h,
include/freetype/config/ftconfig.h,
include/freetype/config/ftheader.h,
include/freetype/internal/ftmemory.h,
include/freetype/internal/ftobjs.h,
src/autohint/ahoptim.c,
src/base/ftdbgmem.c, src/base/ftdebug.c,
src/base/ftmac.c, src/base/ftobjs.c,
src/base/ftsystem.c,
src/cache/ftcimage.c, src/cache/ftcsbits.c,
src/cff/cffdriver.c, src/cff/cffload.c, src/cff/cffobjs.c,
src/cid/cidload.c, src/cid/cidparse.c, src/cid/cidriver.c,
src/pcf/pcfdriver.c, src/pcf/pcfread.c,
src/psaux/t1cmap.c, src/psaux/t1decode.c,
src/pshinter/pshalgo1.c, src/pshinter/pshalgo2.c,
src/pshinter/pshrec.c,
src/psnames/psmodule.c,
src/raster/ftraster.c,
src/sfnt/sfdriver.c, src/sfnt/ttload.c, src/sfnt/ttpost.c,
src/smooth/ftgrays.c,
src/type1/t1afm.c, src/type1/t1driver.c, src/type1/t1gload.c,
src/type1/t1load.c, src/type1/t1objs.c, src/type1/t1parse.c:
added the new configuration file "ftstdlib.h" used to define
aliases for all ISO C library functions used by the engine
(e.g. strlen, qsort, setjmp, etc...)
this eases the porting of FreeType 2 to exotic environments like
XFree86 modules/extensions..
also removed many #include <string.h>, #include <stdlib.h>, etc...
from the engine's sources where they're not needed..
2002-04-12 11:31:48 +02:00
|
|
|
ft_memcpy( sfnt_data, *sfnt, sfnt_size );
|
2000-07-28 03:10:35 +02:00
|
|
|
ReleaseResource( sfnt );
|
|
|
|
|
2008-09-19 19:46:01 +02:00
|
|
|
is_cff = sfnt_size > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
|
|
|
|
is_sfnt_ps = sfnt_size > 4 && !ft_memcmp( sfnt_data, "typ1", 4 );
|
2003-05-15 08:44:09 +02:00
|
|
|
|
2008-09-19 19:46:01 +02:00
|
|
|
if ( is_sfnt_ps )
|
|
|
|
{
|
2008-10-04 09:11:58 +02:00
|
|
|
FT_Stream stream;
|
2008-09-19 19:46:01 +02:00
|
|
|
|
|
|
|
|
2008-10-04 09:11:58 +02:00
|
|
|
if ( FT_NEW( stream ) )
|
2008-09-19 19:46:01 +02:00
|
|
|
goto Try_OpenType;
|
|
|
|
|
2008-10-04 09:11:58 +02:00
|
|
|
FT_Stream_OpenMemory( stream, sfnt_data, sfnt_size );
|
|
|
|
if ( !open_face_PS_from_sfnt_stream( library,
|
|
|
|
stream,
|
|
|
|
face_index,
|
|
|
|
0, NULL,
|
|
|
|
aface ) )
|
2008-09-19 19:46:01 +02:00
|
|
|
{
|
2008-10-04 09:11:58 +02:00
|
|
|
FT_Stream_Close( stream );
|
|
|
|
FT_FREE( stream );
|
2008-09-19 19:46:01 +02:00
|
|
|
FT_FREE( sfnt_data );
|
|
|
|
goto Exit;
|
|
|
|
}
|
2008-09-20 14:20:21 +02:00
|
|
|
|
2008-10-04 09:11:58 +02:00
|
|
|
FT_FREE( stream );
|
|
|
|
}
|
2008-09-19 19:46:01 +02:00
|
|
|
Try_OpenType:
|
|
|
|
error = open_face_from_buffer( library,
|
|
|
|
sfnt_data,
|
|
|
|
sfnt_size,
|
|
|
|
face_index,
|
|
|
|
is_cff ? "cff" : "truetype",
|
|
|
|
aface );
|
|
|
|
Exit:
|
|
|
|
return error;
|
2000-07-28 03:10:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-06 07:59:36 +01:00
|
|
|
/* Create a new FT_Face from a file path to a suitcase file. */
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_New_Face_From_Suitcase( FT_Library library,
|
2006-01-11 10:28:38 +01:00
|
|
|
const UInt8* pathname,
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_Long face_index,
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_Face* aface )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
2013-03-14 17:50:49 +01:00
|
|
|
FT_Error error = FT_ERR( Cannot_Open_Resource );
|
2007-08-29 08:08:59 +02:00
|
|
|
ResFileRefNum res_ref;
|
2007-11-16 16:48:58 +01:00
|
|
|
ResourceIndex res_index;
|
2007-08-29 08:08:59 +02:00
|
|
|
Handle fond;
|
2013-06-04 10:30:48 +02:00
|
|
|
short num_faces_in_res;
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Cannot_Open_Resource );
|
2006-01-11 10:28:38 +01:00
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
UseResFile( res_ref );
|
2006-01-11 10:28:38 +01:00
|
|
|
if ( ResError() )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Cannot_Open_Resource );
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2005-12-23 13:22:46 +01:00
|
|
|
num_faces_in_res = 0;
|
2016-12-26 23:57:45 +01:00
|
|
|
for ( res_index = 1; ; res_index++ )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
2013-06-04 10:30:48 +02:00
|
|
|
short num_faces_in_fond;
|
|
|
|
|
|
|
|
|
2008-10-04 20:10:28 +02:00
|
|
|
fond = Get1IndResource( TTAG_FOND, res_index );
|
2004-02-26 22:56:27 +01:00
|
|
|
if ( ResError() )
|
|
|
|
break;
|
2001-12-07 22:56:32 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
num_faces_in_fond = count_faces( fond, pathname );
|
2005-12-23 13:22:46 +01:00
|
|
|
num_faces_in_res += num_faces_in_fond;
|
2001-12-07 22:56:32 +01:00
|
|
|
|
2005-12-23 13:22:46 +01:00
|
|
|
if ( 0 <= face_index && face_index < num_faces_in_fond && error )
|
|
|
|
error = FT_New_Face_From_FOND( library, fond, face_index, aface );
|
2006-01-11 11:57:42 +01:00
|
|
|
|
2005-12-23 13:22:46 +01:00
|
|
|
face_index -= num_faces_in_fond;
|
2001-12-07 22:56:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CloseResFile( res_ref );
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( !error && aface && *aface )
|
2005-12-23 13:22:46 +01:00
|
|
|
(*aface)->num_faces = num_faces_in_res;
|
2001-12-07 22:56:32 +01:00
|
|
|
return error;
|
2001-12-06 18:52:06 +01:00
|
|
|
}
|
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2002-04-30 16:26:49 +02:00
|
|
|
/* documentation is in ftmac.h */
|
2000-11-07 18:21:11 +01:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_New_Face_From_FOND( FT_Library library,
|
|
|
|
Handle fond,
|
|
|
|
FT_Long face_index,
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_Face* aface )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
2007-08-29 08:08:59 +02:00
|
|
|
short have_sfnt, have_lwfn = 0;
|
|
|
|
ResID sfnt_id, fond_id;
|
2006-01-11 11:57:42 +01:00
|
|
|
OSType fond_type;
|
|
|
|
Str255 fond_name;
|
2006-01-11 10:28:38 +01:00
|
|
|
Str255 lwfn_file_name;
|
2007-11-16 16:48:58 +01:00
|
|
|
UInt8 path_lwfn[PATH_MAX];
|
2006-01-11 10:28:38 +01:00
|
|
|
OSErr err;
|
2006-10-15 09:15:28 +02:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
/* check of `library' and `aface' delayed to `FT_New_Face_From_XXX' */
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
GetResInfo( fond, &fond_id, &fond_type, fond_name );
|
2008-10-04 20:10:28 +02:00
|
|
|
if ( ResError() != noErr || fond_type != TTAG_FOND )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_File_Format );
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2001-10-26 15:24:39 +02:00
|
|
|
parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
if ( lwfn_file_name[0] )
|
|
|
|
{
|
2007-08-29 08:08:59 +02:00
|
|
|
ResFileRefNum res;
|
2001-12-07 22:56:32 +01:00
|
|
|
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
res = HomeResFile( fond );
|
|
|
|
if ( noErr != ResError() )
|
|
|
|
goto found_no_lwfn_file;
|
2001-12-07 22:56:32 +01:00
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
{
|
2007-11-16 16:48:58 +01:00
|
|
|
UInt8 path_fond[PATH_MAX];
|
2006-01-11 10:28:38 +01:00
|
|
|
FSRef ref;
|
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
err = FSGetForkCBInfo( res, kFSInvalidVolumeRefNum,
|
|
|
|
NULL, NULL, NULL, &ref, NULL );
|
|
|
|
if ( noErr != err )
|
|
|
|
goto found_no_lwfn_file;
|
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
err = FSRefMakePath( &ref, path_fond, sizeof ( path_fond ) );
|
2006-01-11 10:28:38 +01:00
|
|
|
if ( noErr != err )
|
|
|
|
goto found_no_lwfn_file;
|
|
|
|
|
|
|
|
error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
|
2006-01-11 11:57:42 +01:00
|
|
|
path_lwfn, sizeof ( path_lwfn ) );
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( !error )
|
2006-01-11 10:28:38 +01:00
|
|
|
have_lwfn = 1;
|
|
|
|
}
|
2006-01-11 11:57:42 +01:00
|
|
|
}
|
2001-12-07 22:56:32 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
|
2006-09-19 07:48:02 +02:00
|
|
|
error = FT_New_Face_From_LWFN( library,
|
|
|
|
path_lwfn,
|
|
|
|
face_index,
|
|
|
|
aface );
|
|
|
|
else
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Unknown_File_Format );
|
2001-12-07 22:56:32 +01:00
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
found_no_lwfn_file:
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( have_sfnt && error )
|
2006-09-19 07:48:02 +02:00
|
|
|
error = FT_New_Face_From_SFNT( library,
|
|
|
|
sfnt_id,
|
|
|
|
face_index,
|
|
|
|
aface );
|
2001-12-07 22:56:32 +01:00
|
|
|
|
2006-09-19 07:48:02 +02:00
|
|
|
return error;
|
2001-12-07 22:56:32 +01:00
|
|
|
}
|
|
|
|
|
2004-02-28 20:12:01 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
/* Common function to load a new FT_Face from a resource file. */
|
2004-02-28 20:12:01 +01:00
|
|
|
static FT_Error
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_New_Face_From_Resource( FT_Library library,
|
2006-01-11 10:28:38 +01:00
|
|
|
const UInt8* pathname,
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_Long face_index,
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_Face* aface )
|
2004-02-28 20:12:01 +01:00
|
|
|
{
|
|
|
|
OSType file_type;
|
|
|
|
FT_Error error;
|
|
|
|
|
|
|
|
|
2006-01-11 11:57:42 +01:00
|
|
|
/* LWFN is a (very) specific file format, check for it explicitly */
|
2006-01-11 10:28:38 +01:00
|
|
|
file_type = get_file_type_from_path( pathname );
|
2008-10-04 20:10:28 +02:00
|
|
|
if ( file_type == TTAG_LWFN )
|
2006-01-11 10:28:38 +01:00
|
|
|
return FT_New_Face_From_LWFN( library, pathname, face_index, aface );
|
2006-01-11 11:57:42 +01:00
|
|
|
|
|
|
|
/* Otherwise the file type doesn't matter (there are more than */
|
|
|
|
/* `FFIL' and `tfil'). Just try opening it as a font suitcase; */
|
|
|
|
/* if it works, fine. */
|
2004-02-28 20:12:01 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface );
|
2016-12-17 20:47:42 +01:00
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
/* let it fall through to normal loader (.ttf, .otf, etc.); */
|
|
|
|
/* we signal this by returning no error and no FT_Face */
|
|
|
|
*aface = NULL;
|
|
|
|
}
|
2004-02-28 20:12:01 +01:00
|
|
|
|
2016-12-17 20:47:42 +01:00
|
|
|
return FT_Err_Ok;
|
2004-02-28 20:12:01 +01:00
|
|
|
}
|
|
|
|
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @Function:
|
|
|
|
* FT_New_Face
|
|
|
|
*
|
|
|
|
* @Description:
|
|
|
|
* This is the Mac-specific implementation of FT_New_Face. In
|
|
|
|
* addition to the standard FT_New_Face() functionality, it also
|
|
|
|
* accepts pathnames to Mac suitcase files. For further
|
|
|
|
* documentation see the original FT_New_Face() in freetype.h.
|
|
|
|
*/
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_New_Face( FT_Library library,
|
|
|
|
const char* pathname,
|
|
|
|
FT_Long face_index,
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_Face* aface )
|
2000-07-28 03:10:35 +02:00
|
|
|
{
|
|
|
|
FT_Open_Args args;
|
2004-02-28 20:12:01 +01:00
|
|
|
FT_Error error;
|
2000-07-28 03:10:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
|
|
|
|
if ( !pathname )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
*aface = NULL;
|
2000-07-28 03:10:35 +02:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
/* try resourcefork based font: LWFN, FFIL */
|
2006-01-11 11:57:42 +01:00
|
|
|
error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
|
|
|
|
face_index, aface );
|
2016-12-17 20:47:42 +01:00
|
|
|
if ( error || *aface )
|
2004-02-28 20:12:01 +01:00
|
|
|
return error;
|
2002-04-30 16:26:49 +02:00
|
|
|
|
|
|
|
/* let it fall through to normal loader (.ttf, .otf, etc.) */
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
args.flags = FT_OPEN_PATHNAME;
|
2002-04-30 16:26:49 +02:00
|
|
|
args.pathname = (char*)pathname;
|
2016-12-17 20:47:42 +01:00
|
|
|
|
2002-04-30 16:26:49 +02:00
|
|
|
return FT_Open_Face( library, &args, face_index, aface );
|
2000-07-28 03:10:35 +02:00
|
|
|
}
|
|
|
|
|
2000-07-29 22:38:19 +02:00
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @Function:
|
|
|
|
* FT_New_Face_From_FSRef
|
|
|
|
*
|
|
|
|
* @Description:
|
|
|
|
* FT_New_Face_From_FSRef is identical to FT_New_Face except it
|
|
|
|
* accepts an FSRef instead of a path.
|
|
|
|
*
|
|
|
|
* This function is deprecated because Carbon data types (FSRef)
|
2018-06-04 15:12:29 +02:00
|
|
|
* are not cross-platform, and thus not suitable for the FreeType API.
|
2018-06-03 09:01:17 +02:00
|
|
|
*/
|
2004-02-26 22:56:27 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_New_Face_From_FSRef( FT_Library library,
|
|
|
|
const FSRef* ref,
|
2006-01-11 11:57:42 +01:00
|
|
|
FT_Long face_index,
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_Face* aface )
|
2004-02-26 22:56:27 +01:00
|
|
|
{
|
2004-08-28 10:02:46 +02:00
|
|
|
FT_Error error;
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_Open_Args args;
|
2014-11-26 21:59:21 +01:00
|
|
|
|
|
|
|
OSErr err;
|
|
|
|
UInt8 pathname[PATH_MAX];
|
2004-02-26 22:56:27 +01:00
|
|
|
|
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
/* check of `library' and `aface' delayed to */
|
|
|
|
/* `FT_New_Face_From_Resource' */
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
if ( !ref )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2004-02-26 22:56:27 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
|
|
|
|
if ( err )
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Cannot_Open_Resource );
|
2004-02-26 22:56:27 +01:00
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
|
2016-12-17 21:05:54 +01:00
|
|
|
if ( error || *aface )
|
2004-02-26 22:56:27 +01:00
|
|
|
return error;
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
/* fallback to datafork font */
|
|
|
|
args.flags = FT_OPEN_PATHNAME;
|
|
|
|
args.pathname = (char*)pathname;
|
|
|
|
return FT_Open_Face( library, &args, face_index, aface );
|
|
|
|
}
|
2004-02-26 22:56:27 +01:00
|
|
|
|
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @Function:
|
|
|
|
* FT_New_Face_From_FSSpec
|
|
|
|
*
|
|
|
|
* @Description:
|
|
|
|
* FT_New_Face_From_FSSpec is identical to FT_New_Face except it
|
|
|
|
* accepts an FSSpec instead of a path.
|
|
|
|
*
|
2018-06-04 15:12:29 +02:00
|
|
|
* This function is deprecated because FSSpec is deprecated in Mac OS X
|
2018-06-03 09:01:17 +02:00
|
|
|
*/
|
2006-01-11 10:28:38 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_New_Face_From_FSSpec( FT_Library library,
|
|
|
|
const FSSpec* spec,
|
|
|
|
FT_Long face_index,
|
|
|
|
FT_Face* aface )
|
2006-01-11 11:57:42 +01:00
|
|
|
{
|
2007-11-16 16:48:58 +01:00
|
|
|
#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
|
2008-06-24 19:13:58 +02:00
|
|
|
( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
|
2007-06-19 05:27:05 +02:00
|
|
|
FT_UNUSED( library );
|
|
|
|
FT_UNUSED( spec );
|
|
|
|
FT_UNUSED( face_index );
|
|
|
|
FT_UNUSED( aface );
|
|
|
|
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unimplemented_Feature );
|
2007-06-19 05:27:05 +02:00
|
|
|
#else
|
2006-01-11 11:57:42 +01:00
|
|
|
FSRef ref;
|
2006-01-11 10:28:38 +01:00
|
|
|
|
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
/* check of `library' and `aface' delayed to `FT_New_Face_From_FSRef' */
|
|
|
|
|
2006-01-11 10:28:38 +01:00
|
|
|
if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2006-01-11 10:28:38 +01:00
|
|
|
else
|
|
|
|
return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
|
2007-06-19 05:27:05 +02:00
|
|
|
#endif
|
2004-02-26 22:56:27 +01:00
|
|
|
}
|
|
|
|
|
Improve `make multi'.
* src/autofit/aflatin2.c: Guard file with FT_OPTION_AUTOFIT2.
* src/base/ftmac.c: Guard more parts of the file with FT_MACINTOSH.
* src/psaux/afmparse.c: Guard file with T1_CONFIG_OPTION_NO_AFM.
* src/sfnt/pngshim.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS also.
* src/sfnt/ttbdf.c: Avoid empty source file.
* src/sfnt/ttpost.c: Guard file with
TT_CONFIG_OPTION_POSTSCRIPT_NAMES.
* src/sfnt/ttsbit.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS.
* src/truetype/ttgxvar.c, src/truetype/ttinterp.c: Avoid empty
source file.
* src/truetype/ttsubpix.c: Guard file with
TT_USE_BYTECODE_INTERPRETER also.
* src/type1/t1afm.c: Guard file with T1_CONFIG_OPTION_NO_AFM.
* src/autofit/autofit.c, src/base/ftbase.c, src/cache/ftcache.c,
src/cff/cff.c, src/cid/type1cid.c, src/gxvalid/gxvalid.c,
src/pcf/pcf.c, src/pfr/pfr.c, src/psaux/psaux.c,
src/pshinter/pshinter.c, src/psnames/psnames.c, src/raster/raster.c,
src/sfnt/sfnt.c, src/smooth/smooth.c, src/truetype/truetype.c,
src/type1/type1.c, src/type42/type42.c: Remove conditionals; sort
entries.
2017-03-18 07:06:49 +01:00
|
|
|
#else /* !FT_MACINTOSH */
|
|
|
|
|
|
|
|
/* ANSI C doesn't like empty source files */
|
|
|
|
typedef int _ft_mac_dummy;
|
|
|
|
|
|
|
|
#endif /* !FT_MACINTOSH */
|
2011-12-02 13:14:18 +01:00
|
|
|
|
2004-02-26 22:56:27 +01:00
|
|
|
|
2000-07-29 22:38:19 +02:00
|
|
|
/* END */
|