Remove FreeType.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13538 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-01-13 14:44:42 +00:00
parent 36e80997f5
commit 9c135b1ec7
93 changed files with 0 additions and 45670 deletions

View File

@@ -1,168 +0,0 @@
/* ftconfig.h. Generated automatically by configure. */
/***************************************************************************/
/* */
/* ftconfig.in */
/* */
/* UNIX-specific configuration file (specification only). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This header file contains a number of macro definitions that are used */
/* by the rest of the engine. Most of the macros here are automatically */
/* determined at compile time, and you should not need to change it to */
/* port FreeType, except to compile the library with a non-ANSI */
/* compiler. */
/* */
/* Note however that if some specific modifications are needed, we */
/* advise you to place a modified copy in your build directory. */
/* */
/* The build directory is usually `freetype/builds/<system>', and */
/* contains system-specific files that are always included first when */
/* building the library. */
/* */
/*************************************************************************/
#ifndef FTCONFIG_H
#define FTCONFIG_H
/* Include the header file containing all developer build options */
#include <freetype/config/ftoption.h>
/*************************************************************************/
/* */
/* PLATFORM-SPECIFIC CONFIGURATION MACROS */
/* */
/* These macros can be toggled to suit a specific system. The current */
/* ones are defaults used to compile FreeType in an ANSI C environment */
/* (16bit compilers are also supported). Copy this file to your own */
/* `freetype/builds/<system>' directory, and edit it to port the engine. */
/* */
/*************************************************************************/
#include "wx/setup.h"
#define FT_SIZEOF_INT SIZEOF_INT
#define FT_SIZEOF_LONG SIZEOF_LONG
/* Preferred alignment of data */
#define FT_ALIGNMENT 8
/* UNUSED is a macro used to indicate that a given parameter is not used */
/* -- this is only used to get rid of unpleasant compiler warnings */
#ifndef FT_UNUSED
#define FT_UNUSED( arg ) ( (arg) = (arg) )
#endif
/*************************************************************************/
/* */
/* AUTOMATIC CONFIGURATION MACROS */
/* */
/* These macros are computed from the ones defined above. Don't touch */
/* their definition, unless you know precisely what you are doing. No */
/* porter should need to mess with them. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* IntN types */
/* */
/* Used to guarantee the size of some specific integers. */
/* */
typedef signed short FT_Int16;
typedef unsigned short FT_UInt16;
#if FT_SIZEOF_INT == 4
typedef signed int FT_Int32;
typedef unsigned int FT_UInt32;
#elif FT_SIZEOF_LONG == 4
typedef signed long FT_Int32;
typedef unsigned long FT_UInt32;
#else
#error "no 32bit type found -- please check your configuration files"
#endif
#if FT_SIZEOF_LONG == 8
/* FT_LONG64 must be defined if a 64-bit type is available */
#define FT_LONG64
#define FT_INT64 long
#else
/*************************************************************************/
/* */
/* Many compilers provide the non-ANSI `long long' 64-bit type. You can */
/* activate it by defining the FTCALC_USE_LONG_LONG macro in */
/* `ftoption.h'. */
/* */
/* Note that this will produce many -ansi warnings during library */
/* compilation, and that in many cases, the generated code will be */
/* neither smaller nor faster! */
/* */
#ifdef FTCALC_USE_LONG_LONG
#define FT_LONG64
#define FT_INT64 long long
#endif /* FTCALC_USE_LONG_LONG */
#endif /* FT_SIZEOF_LONG == 8 */
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
#define LOCAL_DEF static
#define LOCAL_FUNC static
#else
#define LOCAL_DEF extern
#define LOCAL_FUNC /* nothing */
#endif
#ifdef FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT
#define BASE_DEF( x ) static x
#define BASE_FUNC( x ) static x
#else
#define BASE_DEF( x ) extern x
#define BASE_FUNC( x ) extern x
#endif
#ifndef FT_EXPORT_DEF
#define FT_EXPORT_DEF( x ) extern x
#endif
#ifndef FT_EXPORT_FUNC
#define FT_EXPORT_FUNC( x ) extern x
#endif
#ifndef FT_EXPORT_VAR
#define FT_EXPORT_VAR( x ) extern x
#endif
#endif /* FTCONFIG_H */
/* END */

View File

@@ -1,616 +0,0 @@
/***************************************************************************/
/* */
/* fonddrvr.c */
/* */
/* Mac FOND font driver. Written by just@letterror.com. */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
/*
Notes
Mac suitcase files can (and often do!) contain multiple fonts. To
support this I use the face_index argument of FT_(Open|New)_Face()
functions, and pretend the suitcase file is a collection.
Warning: although the FOND driver sets face->num_faces field to the
number of available fonts, but the Type 1 driver sets it to 1 anyway.
So this field is currently not reliable, and I don't see a clean way
to resolve that. The face_index argument translates to
Get1IndResource( 'FOND', face_index + 1 );
so clients should figure out the resource index of the FOND.
(I'll try to provide some example code for this at some point.)
The Mac FOND driver works roughly like this:
- 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 the init_face()
method of the Type 1 driver.
(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 the init_face()
method if the TrueType driver.
- In both cases, the original stream gets closed and *reinitialized*
to become a memory stream. Additionally, the face->driver field --
which is set to the FOND driver upon entering our init_face() --
gets *reset* to either the TT or the T1 driver. I had to make a minor
change to ftobjs.c to make this work.
- We might consider creating an FT_New_Face_Mac() API call, as this
would avoid some of the mess described above.
*/
#include <truetype/ttobjs.h>
#include <type1z/z1objs.h>
#include <Resources.h>
#include <Fonts.h>
#include <Errors.h>
#include <ctype.h> /* for isupper() and isalnum() */
#include <stdlib.h> /* for malloc() and free() */
/* set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
TrueType in case *both* are available */
#ifndef PREFER_LWFN
#define PREFER_LWFN 1
#endif
static
FT_Error init_driver( FT_Driver driver )
{
/* we don't keep no stinkin' state ;-) */
return FT_Err_Ok;
}
static
FT_Error done_driver( FT_Driver driver )
{
return FT_Err_Ok;
}
/* MacRoman glyph names, needed for FOND kerning support. */
/* XXX which is not implemented yet! */
static const char* mac_roman_glyph_names[256] = {
".null",
};
/* The FOND face object is just a union of TT and T1: both is possible,
and we don't need anything else. We still need to be able to hold
either, as the face object is not allocated by us. Again, creating
an FT_New_Face_Mac() would avoid this kludge. */
typedef union FOND_FaceRec_
{
TT_FaceRec tt;
T1_FaceRec t1;
} FOND_FaceRec, *FOND_Face;
/* given a pathname, fill in a File Spec */
static
int make_file_spec( char* pathname, FSSpec *spec )
{
Str255 p_path;
int path_len;
/* convert path to a pascal string */
path_len = strlen( pathname );
if ( path_len > 255 )
return -1;
p_path[0] = path_len;
strncpy( (char*)p_path+1, pathname, path_len );
if ( FSMakeFSSpec( 0, 0, p_path, spec ) != noErr )
return -1;
else
return 0;
}
/* is_suitcase() returns true if the file specified by 'pathname'
is a Mac suitcase file, and false if it ain't. */
static
int is_suitcase( FSSpec *spec )
{
FInfo finfo;
if ( FSpGetFInfo( spec, &finfo ) != noErr )
return 0;
if ( finfo.fdType == 'FFIL' || finfo.fdType == 'tfil' )
return 1;
else
return 0;
}
/* Quick 'n' Dirty Pascal string to C string converter.
Warning: this call is not thread safe! Use with caution. */
static
char * p2c_str( unsigned char *pstr )
{
static char cstr[256];
strncpy( cstr, (char*)pstr+1, pstr[0] );
cstr[pstr[0]] = '\0';
return cstr;
}
/* Given a PostScript font name, create the Macintosh LWFN file name */
static
void create_lwfn_name( char* ps_name, Str255 lwfn_file_name )
{
int max = 5, count = 0;
unsigned char* p = lwfn_file_name;
char* q = ps_name;
lwfn_file_name[0] = 0;
while ( *q )
{
if ( isupper(*q) )
{
if ( count )
max = 3;
count = 0;
}
if ( count < max && (isalnum(*q) || *q == '_' ) )
{
*++p = *q;
lwfn_file_name[0]++;
count++;
}
q++;
}
}
/* Suck the relevant info out of the FOND data */
static
FT_Error parse_fond( char* fond_data,
short *have_sfnt,
short *sfnt_id,
Str255 lwfn_file_name )
{
AsscEntry* assoc;
FamRec* fond;
*sfnt_id = *have_sfnt = 0;
lwfn_file_name[0] = 0;
fond = (FamRec*)fond_data;
assoc = (AsscEntry*)(fond_data + sizeof(FamRec) + 2);
if ( assoc->fontSize == 0 )
{
*have_sfnt = 1;
*sfnt_id = assoc->fontID;
}
if ( fond->ffStylOff )
{
unsigned char* p = (unsigned char*)fond_data;
StyleTable* style;
unsigned short string_count;
unsigned char* name_table = 0;
char ps_name[256];
unsigned char* names[64];
int i;
p += fond->ffStylOff;
style = (StyleTable*)p;
p += sizeof(StyleTable);
string_count = *(unsigned short*)(p);
p += sizeof(short);
for ( i=0 ; i<string_count && i<64; i++ )
{
names[i] = p;
p += names[i][0];
p++;
}
strcpy(ps_name, p2c_str(names[0])); /* Family name */
if ( style->indexes[0] > 1 )
{
unsigned char* suffixes = names[style->indexes[0]-1];
for ( i=1; i<=suffixes[0]; i++ )
strcat( ps_name, p2c_str(names[suffixes[i]-1]) );
}
create_lwfn_name( ps_name, lwfn_file_name );
}
return FT_Err_Ok;
}
/* Read Type 1 data from the POST resources inside the LWFN file, return a
PFB buffer -- apparently FT doesn't like a pure binary T1 stream. */
static
unsigned char* read_type1_data( FT_Memory memory, FSSpec* lwfn_spec, unsigned long *size )
{
short res_ref, res_id;
unsigned char *buffer, *p, *size_p;
unsigned long total_size = 0;
unsigned long post_size, pfb_chunk_size;
Handle post_data;
char code, last_code;
res_ref = FSpOpenResFile( lwfn_spec, fsRdPerm );
if ( ResError() )
return NULL;
UseResFile( res_ref );
/* first pass: load all POST resources, and determine the size of
the output buffer */
res_id = 501;
last_code = -1;
for (;;)
{
post_data = Get1Resource( 'POST', res_id++ );
if ( post_data == NULL )
break;
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 */
}
total_size += GetHandleSize( post_data ) - 2;
last_code = code;
}
buffer = memory->alloc( memory, total_size );
if ( !buffer )
goto error;
/* second pass: append all POST data to the buffer, add PFB fields */
p = buffer;
res_id = 501;
last_code = -1;
pfb_chunk_size = 0;
for (;;)
{
post_data = Get1Resource( 'POST', res_id++ );
if ( post_data == NULL )
break;
post_size = GetHandleSize( post_data ) - 2;
code = (*post_data)[0];
if ( code != last_code )
{
if ( last_code != -1 )
{
/* we're done adding a chunk, fill in the size field */
*size_p++ = pfb_chunk_size & 0xFF;
*size_p++ = (pfb_chunk_size >> 8) & 0xFF;
*size_p++ = (pfb_chunk_size >> 16) & 0xFF;
*size_p++ = (pfb_chunk_size >> 24) & 0xFF;
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 */
}
}
memcpy( p, *post_data + 2, post_size );
pfb_chunk_size += post_size;
p += post_size;
last_code = code;
}
CloseResFile( res_ref );
*size = total_size;
/* printf( "XXX %d %d\n", p - buffer, total_size ); */
return buffer;
error:
CloseResFile( res_ref );
return NULL;
}
/* Finalizer for the sfnt stream */
static
void sfnt_stream_close( FT_Stream stream )
{
Handle sfnt_data = stream->descriptor.pointer;
HUnlock( sfnt_data );
DisposeHandle( sfnt_data );
stream->descriptor.pointer = NULL;
stream->size = 0;
stream->base = 0;
stream->close = 0;
}
/* Finalizer for the LWFN stream */
static
void lwfn_stream_close( FT_Stream stream )
{
stream->memory->free( stream->memory, stream->base );
stream->descriptor.pointer = NULL;
stream->size = 0;
stream->base = 0;
stream->close = 0;
}
/* Main entry point. Determine whether we're dealing with a Mac
suitcase or not; then determine if we're dealing with Type 1
or TrueType; delegate the work to the proper driver. */
static
FT_Error init_face( FT_Stream stream,
FT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* parameters )
{
FT_Error err;
FSSpec suit_spec, lwfn_spec;
short res_ref;
Handle fond_data, sfnt_data;
short res_index, sfnt_id, have_sfnt;
Str255 lwfn_file_name;
if ( !stream->pathname.pointer )
return FT_Err_Unknown_File_Format;
if ( make_file_spec( stream->pathname.pointer, &suit_spec ) )
return FT_Err_Invalid_Argument;
if ( !is_suitcase( &suit_spec ) )
return FT_Err_Unknown_File_Format;
res_ref = FSpOpenResFile( &suit_spec, fsRdPerm );
if ( ResError() )
return FT_Err_Invalid_File_Format;
UseResFile( res_ref );
/* face_index may be -1, in which case we
just need to do a sanity check */
if ( face_index < 0)
res_index = 1;
else
{
res_index = face_index + 1;
face_index = 0;
}
fond_data = Get1IndResource( 'FOND', res_index );
if ( ResError() )
{
CloseResFile( res_ref );
return FT_Err_Invalid_File_Format;
}
/* Set the number of faces. Not that it helps much: the t1 driver
just sets it to 1 anyway :-( */
face->num_faces = Count1Resources('FOND');
HLock( fond_data );
err = parse_fond( *fond_data, &have_sfnt, &sfnt_id, lwfn_file_name );
HUnlock( fond_data );
if ( err )
{
CloseResFile( res_ref );
return FT_Err_Invalid_Handle;
}
if ( lwfn_file_name[0] )
{
/* We look for the LWFN file in the same directory as the suitcase
file. ATM would look in other places, too, but this is the usual
situation. */
err = FSMakeFSSpec( suit_spec.vRefNum, suit_spec.parID, lwfn_file_name, &lwfn_spec );
if ( err != noErr )
lwfn_file_name[0] = 0; /* no LWFN file found */
}
if ( lwfn_file_name[0] && ( !have_sfnt || PREFER_LWFN ) )
{
FT_Driver t1_driver;
unsigned char* type1_data;
unsigned long size;
CloseResFile( res_ref ); /* XXX still need to read kerning! */
type1_data = read_type1_data( stream->memory, &lwfn_spec, &size );
if ( !type1_data )
{
return FT_Err_Out_Of_Memory;
}
#if 0
{
FILE* f;
char * path;
path = p2c_str( lwfn_file_name );
strcat( path, ".PFB" );
f = fopen(path, "wb");
if ( f )
{
fwrite( type1_data, 1, size, f );
fclose( f );
}
}
#endif
/* reinitialize the stream */
if ( stream->close )
stream->close( stream );
stream->close = lwfn_stream_close;
stream->read = 0; /* it's now memory based */
stream->base = type1_data;
stream->size = size;
stream->pos = 0; /* just in case */
/* delegate the work to the Type 1 module */
t1_driver = (FT_Driver)FT_Get_Module( face->driver->root.library, "type1z" );
if ( t1_driver )
{
face->driver = t1_driver;
return t1_driver->clazz->init_face( stream, face, face_index, 0, NULL );
}
else
return FT_Err_Invalid_Driver_Handle;
}
else if ( have_sfnt )
{
FT_Driver tt_driver;
sfnt_data = Get1Resource( 'sfnt', sfnt_id );
if ( ResError() )
{
CloseResFile( res_ref );
return FT_Err_Invalid_Handle;
}
DetachResource( sfnt_data );
CloseResFile( res_ref );
HLockHi( sfnt_data );
/* reinitialize the stream */
if ( stream->close )
stream->close( stream );
stream->close = sfnt_stream_close;
stream->descriptor.pointer = sfnt_data;
stream->read = 0; /* it's now memory based */
stream->base = (unsigned char *)*sfnt_data;
stream->size = GetHandleSize( sfnt_data );
stream->pos = 0; /* just in case */
/* delegate the work to the TrueType driver */
tt_driver = (FT_Driver)FT_Get_Module( face->driver->root.library, "truetype" );
if ( tt_driver )
{
face->driver = tt_driver;
return tt_driver->clazz->init_face( stream, face, face_index, 0, NULL );
}
else
return FT_Err_Invalid_Driver_Handle;
}
else
{
CloseResFile( res_ref );
}
return FT_Err_Invalid_File_Format;
}
static
void done_face( FT_Face face )
{
/* nothing to do */
}
/* The FT_DriverInterface structure is defined in ftdriver.h. */
const FT_Driver_Class fond_driver_class =
{
{
ft_module_font_driver | ft_module_driver_scalable,
sizeof ( FT_DriverRec ),
"fond", /* driver name */
0x10000L, /* driver version == 1.0 */
0x20000L, /* driver requires FreeType 2.0 or above */
(void*)0,
(FT_Module_Constructor) init_driver,
(FT_Module_Destructor) done_driver,
(FT_Module_Requester) 0
},
sizeof ( FOND_FaceRec ),
0,
0,
(FTDriver_initFace) init_face,
(FTDriver_doneFace) done_face,
(FTDriver_initSize) 0,
(FTDriver_doneSize) 0,
(FTDriver_initGlyphSlot) 0,
(FTDriver_doneGlyphSlot) 0,
(FTDriver_setCharSizes) 0,
(FTDriver_setPixelSizes) 0,
(FTDriver_loadGlyph) 0,
(FTDriver_getCharIndex) 0,
(FTDriver_getKerning) 0,
(FTDriver_attachFile) 0,
(FTDriver_getAdvances) 0
};
/*************************************************************************/
/* */
/* <Function> */
/* getDriverInterface */
/* */
/* <Description> */
/* This function is used when compiling the FOND driver as a */
/* shared library (`.DLL' or `.so'). It will be used by the */
/* high-level library of FreeType to retrieve the address of the */
/* driver's generic interface. */
/* */
/* It shouldn't be implemented in a static build, as each driver must */
/* have the same function as an exported entry point. */
/* */
/* <Return> */
/* The address of the TrueType's driver generic interface. The */
/* format-specific interface can then be retrieved through the method */
/* interface->get_format_interface. */
/* */
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
FT_EXPORT_FUNC(const FT_Driver_Class*) getDriverClass( void )
{
return &fond_driver_class;
}
#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
/* END */

View File

@@ -1,614 +0,0 @@
#include <oltypes.h>
LOCAL_FUNC
TT_Error OTL_Table_Init( OTL_Table* table,
FT_Memory memory )
{
MEM_Set( table, 0, sizeof(*table) );
table->memory = memory;
}
/* read a script list table */
/* use with any table */
LOCAL_FUNC
TT_Error OTL_Table_Set_Scripts( OTL_Table* table,
TT_Byte* bytes,
TT_Long len,
OTL_Type otl_type )
{
TT_Byte* p;
TT_Byte* start = bytes;
TT_UInt count, max_langs;
TT_Error error;
/* skip version of the JSTF table */
if (otl_type == otl_jstf)
start += 4;
p = start;
/* we must allocate the script_tags and language_tags arrays */
/* this requires that we compute the maximum number of languages */
/* per script.. */
count = table->num_scripts = OTL_UShort(p);
max_langs = 0;
for ( ; count > 0; count++ )
{
TT_Byte* script;
TT_UInt num_langs;
p += 4; /* skip tag */
script = bytes + OTL_UShort(p);
/* skip the baseValues or extenders field of the BASE and JSTF table */
if (otl_type == otl_type_base || otl_type == otl_type_jstf)
script += 2;
/* test if there is a default language system */
if ( OTL_UShort(script) )
num_langs++;
/* test other language systems */
num_langs += OTL_UShort(script); /* add other lang sys */
if (num_langs > max_langs)
max_langs = num_langs;
}
/* good, now allocate the tag arrays */
if ( !ALLOC_ARRAY( table->script_tags,
table->num_scripts + max_langs,
TT_ULong ) )
{
table->language_tags = table->script_tags + table->num_scripts;
table->max_languages = max_langs;
table->num_languages = 0;
table->otl_type = otl_type;
table->scripts_table = bytes;
table->scripts_len = len;
/* fill the script_tags array */
{
TT_UInt n;
TT_Byte* p = start + 2; /* skip count */
for ( n = 0; n < table->num_scripts; n++ )
{
table->script_tags[n] = OTL_ULong(p);
p += 2; /* skip offset */
}
}
}
return error;
}
/* add a features list to the table */
/* use only with a GSUB or GPOS table */
LOCAL_FUNC
TT_Error OTL_Table_Set_Features( OTL_Table* table,
TT_Byte* bytes,
TT_Long len )
{
TT_Error error;
TT_Byte* p = bytes;
TT_UInt count;
table->max_features = count = OTL_UShort(p);
if ( !ALLOC_ARRAY( table->feature_tags, count, TT_ULong ) &&
!ALLOC_ARRAY( table->features, count, TT_Bool ) )
{
table->features_table = bytes;
table->features_len = len;
}
return error;
}
/* add a lookup list to the table */
/* use only with a GSUB or GPOS table */
LOCAL_FUNC
TT_Error OTL_Table_Set_Lookups( OTL_Table* table,
TT_Byte* bytes,
TT_Long len )
{
TT_Error error;
TT_Byte* p = bytes;
TT_UInt count;
table->max_lookups = count = OTL_UShort(p);
if ( !ALLOC_ARRAY( table->lookups, count, TT_Bool ) )
{
table->lookups_table = bytes;
table->lookups_len = len;
}
return error;
}
/* discard table arrays */
LOCAL_FUNC
void OTL_Table_Done( OTL_Table* table )
{
FREE( table->scrip_tags );
FREE( table->language_tags );
FREE( table->feature_tags );
FREE( table->lookups );
}
/* return the list of available languages for a given script */
/* use with any table.. */
LOCAL_FUNC
void OTL_Get_Languages_List( OTL_Table* table,
TT_ULong script_tag )
{
TT_UInt n;
TT_Byte* p;
TT_Byte* script = 0;
TT_Byte* start = table->scripts_table;
if ( table->otl_type == otl_type_jstf ) /* skip version for JSTF */
start += 4;
p = start + 6; /* skip count+first tag */
for ( n = 0; n < table->num_scripts; n++, p += 6 )
{
if ( table->script_tags[n] == script_tag )
{
script = table->scripts_table + OTL_UShort(p);
break;
}
}
table->cur_script = script;
if (!script)
table->num_languages = 0;
else
{
/* now fill the language_tags array with the appropriate values */
/* not that we put a '0' tag in front of the list to indicate that */
/* there is a default language for this script.. */
TT_ULong* tags = table->language_tags;
switch (table->otl_type)
{
case otl_type_base:
case otl_type_jstf:
script += 2; /* skip basevalue or extenders */
/* fall-through */
default:
if ( OTL_UShort(script) )
*tags++ = 0;
}
count = OTL_UShort(script);
for ( ; count > 0; count-- )
{
*tags++ = OTL_ULong(script);
script += 2; /* skip offset */
}
table->num_langs = tags - table->language_tags;
}
}
/* return the list of available features for the current script/language */
/* use with a GPOS or GSUB script table */
LOCAL_FUNC
void OTL_Get_Features_List( OTL_Table* table,
TT_ULong language_tag )
{
TT_UInt n;
TT_Byte* script = table->cur_script;
TT_Byte* language = 0;
TT_UShort offset;
/* clear feature selection table */
for ( n = 0; n < table->max_features; n++ )
table->features[n] = 0;
/* now, look for the current language */
if ( language_tag == 0 )
{
offset = OTL_UShort(script);
if (!offset) return; /* if there is no default language, exit */
language = script - 2 + offset;
}
else
{
TT_Byte* p = script + 8; /* skip default+count+1st tag */
TT_UShort index;
for ( n = 0; n < table->num_languages; n++, p+=6 )
{
if ( table->language_tags[n] == language_tag )
{
language = script + OTL_UShort(p);
break;
}
}
table->cur_language = language;
if (!language) return;
p = language + 2; /* skip lookup order */
index = OTL_UShort(p); /* required feature index */
if (index != 0xFFFF)
{
if (index < table->max_features)
table->features[index] = 1;
}
count = OTL_UShort(p);
for ( ; count > 0; count-- )
{
index = OTL_UShort(p);
if (index < table->max_features)
table->features[index] = 1;
}
}
}
/* return the list of lookups for the current features list */
/* use only with a GSUB or GPOS table */
LOCAL_FUNC
void OTL_Get_Lookups_List( OTL_Table* table )
{
TT_UInt n;
TT_Byte* features = table->features_table;
TT_Byte* p = features + 6; /* skip count+1st tag */
/* clear lookup list */
for ( n = 0; n < table->max_lookups; n++ )
table->lookups[n] = 0;
/* now, parse the features list */
for ( n = 0; n < table->features; n++ )
{
if (table->features[n])
{
TT_UInt count;
TT_UShort index;
TT_Byte* feature;
feature = features + OTL_UShort(p);
p += 4; /* skip tag */
/* now, select all lookups from this feature */
count = OTL_UShort(feature);
for ( ; count > 0; count-- )
{
index = OTL_UShort(feature);
if (index < table->max_lookups)
table->lookups[index] = 1;
}
}
}
}
/* find the basevalues and minmax for the current script/language */
/* only use it with a BASE table.. */
LOCAL_FUNC
void OTL_Get_Baseline_Values( OTL_Table* table,
TT_ULong language_tag )
{
TT_Byte* script = table->cur_script;
TT_Byte* p = script;
TT_UShort offset, count;
table->cur_basevalues = 0;
table->cur_minmax = 0;
/* read basevalues */
offset = OTL_UShort(p);
if (offset)
table->cur_basevalues = script + offset;
offset = OTL_UShort(p);
if (offset)
table->cur_minmax = script + offset;
count = OTL_UShort(p);
for ( ; count > 0; count-- )
{
TT_ULong tag;
tag = OTL_ULong(p);
if ( language_tag == tag )
{
table->cur_minmax = script + OTL_UShort(p);
break;
}
p += 2; /* skip offset */
}
}
/* compute the coverage value of a given glyph id */
LOCAL_FUNC
TT_Long OTL_Get_Coverage_Index( TT_Byte* coverage,
TT_UInt glyph_id )
{
TT_Long result = -1;
TT_UInt count, index, start, end;
TT_Byte* p = coverage;
switch ( OTL_UShort(p) )
{
case 1: /* coverage format 1 - array of glyph indices */
{
count = OTL_UShort(p);
for ( index = 0; index < count; index++ )
{
if ( OTL_UShort(p) == glyph_id )
{
result = index;
break;
}
}
}
break;
case 2:
{
count = OTL_UShort(p);
for ( ; count > 0; count-- )
{
start = OTL_UShort(p);
end = OTL_UShort(p);
index = OTL_UShort(p);
if (start <= glyph_id && glyph_id <= end)
{
result = glyph_id - start + index;
break;
}
}
}
break;
}
return result;
}
/* compute the class value of a given glyph_id */
LOCAL_FUNC
TT_UInt OTL_Get_Glyph_Class( TT_Byte* class_def,
TT_UInt glyph_id )
{
TT_Byte* p = class_def;
TT_UInt result = 0;
TT_UInt start, end, count, index;
switch ( OTL_UShort(p) )
{
case 1:
{
start = OTL_UShort(p);
count = OTL_UShort(p);
glyph_id -= start;
if (glyph_id < count)
{
p += 2*glyph_id;
result = OTL_UShort(p);
}
}
break;
case 2:
{
count = OTL_UShort(p);
for ( ; count > 0; count-- )
{
start = OTL_UShort(p);
end = OTL_UShort(p);
index = OTL_UShort(p);
if ( start <= glyph_id && glyph_id <= end )
{
result = index;
break;
}
}
}
break;
}
return result;
}
/* compute the adjustement necessary for a given device size */
LOCAL_FUNC
TT_Int OTL_Get_Device_Adjustment( TT_Byte* device,
TT_UInt size )
{
TT_Byte* p = device;
TT_Int result = 0;
TT_UInt start, end;
TT_Short value;
start = OTL_UShort(p);
end = OTL_UShort(p);
if (size >= start && size <= end)
{
/* I know we could do all of this without a switch, with */
/* clever shifts and everything, but it makes the code */
/* really difficult to understand.. */
size -= start;
switch ( OTL_UShort(p) )
{
case 1: /* 2-bits per value */
{
p += 2*(size >> 3);
size = (size & 7) << 1;
value = (TT_Short)((TT_Short)OTL_UShort(p) << size);
result = value >> 14;
}
break;
case 2: /* 4-bits per value */
{
p += 2*(size >> 2);
size = (size & 3) << 2;
value = (TT_Short)((TT_Short)OTL_UShort(p) << size);
result = value >> 12;
}
break;
case 3: /* 8-bits per value */
{
p += 2*(size >> 1);
size = (size & 1) << 3;
value = (TT_Short)((TT_Short)OTL_UShort(p) << size);
result = value >> 8;
}
break;
}
}
return result;
}
/* extract a BaseCoord value */
LOCAL_FUNC
void OTL_Get_Base_Coordinate( TT_Byte* base_coord,
OTL_ValueRecord* coord )
{
TT_Byte* p = base_coord;
TT_Int result = 0;
coord->format = OTL_UShort(p);
coord->coordinate = OTL_Short(p);
coord->device = 0;
switch (coord->format)
{
case 2: /* format 2 */
coord->ref_glyph = OTL_UShort(p);
coord->ref_point = OTL_UShort(p);
break;
case 3: /* format 3 */
coord->device = p - 4 + OTL_UShort(p);
break;
default:
;
}
}
/* compute size of ValueRecord */
LOCAL_FUNC
TT_Int OTL_ValueRecord_Size( TT_UShort format )
{
TT_Int count;
/* each bit in the value format corresponds to a single ushort */
/* we thus count the bits, and multiply the result by 2 */
count = (TT_Int)(format & 0xFF);
count = ((count & 0xAA) >> 1) + (count & 0x55);
count = ((count & 0xCC) >> 2) + (count & 0x33);
count = ((count & 0xF0) >> 4) + (count & 0x0F);
return count*2;
}
/* extract ValueRecord */
LOCAL_FUNC
void OTL_Get_ValueRecord( TT_Byte* value_record,
TT_UShort value_format,
TT_Byte* pos_table,
OTL_ValueRecord* record )
{
TT_Byte* p = value_record;
/* clear vectors */
record->placement.x = 0;
record->placement.y = 0;
record->advance.x = 0;
record->advance.y = 0;
record->device_pla_x = 0;
record->device_pla_y = 0;
record->device_adv_x = 0;
record->device_adv_y = 0;
if (value_format & 1) record->placement.x = NEXT_Short(p);
if (value_format & 2) record->placement.y = NEXT_Short(p);
if (value_format & 4) record->advance.x = NEXT_Short(p);
if (value_format & 8) record->advance.y = NEXT_Short(p);
if (value_format & 16) record->device_pla_x = pos_table + NEXT_UShort(p);
if (value_format & 32) record->device_pla_y = pos_table + NEXT_UShort(p);
if (value_format & 64) record->device_adv_x = pos_table + NEXT_UShort(p);
if (value_format & 128) record->device_adv_y = pos_table + NEXT_UShort(p);
}
/* extract Anchor */
LOCAL_FUNC
void OTL_Get_Anchor( TT_Byte* anchor_table,
OTL_Anchor* anchor )
{
TT_Byte* p = anchor_table;
anchor->format = NEXT_UShort(p);
anchor->coord.x = NEXT_Short(p);
anchor->coord.y = NEXT_Short(p);
anchor->point = 0;
anchor->device_x = 0;
anchor->device_y = 0;
switch (anchor->format)
{
case 2:
anchor->point = NEXT_UShort(p);
break;
case 3:
anchor->device_x = anchor_table + NEXT_UShort(p);
anchor->device_y = anchor_table + NEXT_UShort(p);
break;
default:
;
}
}
/* extract Mark from MarkArray */
LOCAL_FUNC
void OTL_Get_Mark( TT_Byte* mark_array,
TT_UInt index,
TT_UShort* clazz,
OTL_Anchor* anchor )
{
TT_Byte* p = mark_array;
TT_UInt count;
*clazz = 0;
MEM_Set( anchor, 0, sizeof(*anchor) );
count = NEXT_UShort(p);
if (index < count)
{
p += 4*index;
*clazz = NEXT_UShort(p);
OTL_Get_Anchor( mark_array + NEXT_UShort(p), anchor );
}
}

View File

@@ -1,310 +0,0 @@
#ifndef OLTYPES_H
#define OLTYPES_H
#include <ftobjs.h>
#include <tttypes.h>
/*************************************************************
*
* <Struct> OTL_Table
*
* <Description>
* The base table of most OpenType Layout sub-tables.
* Provides a simple way to scan a table for script,
* languages, features and lookups..
*
* <Fields>
* num_scripts :: number of scripts in table's script list
* script_tags :: array of tags for each table script
*
* max_languages :: max number of languages for any script in
* the table.
* num_languages :: number of languages available for current script
* language_tags :: tags of all languages available for current script.
*
* max_features :: total number of features in table
* feature_tags :: tags of all features for current script/language
* features :: selection flags for all features in current script/lang
*
* max_lookups :: total number of lookups in table
* lookups :: selection flags for all lookups for current
* feature list.
*
****************************************************************/
typedef enum OTL_Type_
{
otl_type_none = 0,
otl_type_base,
otl_type_gdef,
otl_type_gpos,
otl_type_gsub,
otl_type_jstf
} OTL_Type;
typedef struct OTL_Table_
{
FT_Memory memory;
TT_Int num_scripts;
TT_Tag* script_tags;
TT_Int max_languages;
TT_Int num_languages;
TT_Tag* language_tags;
TT_Int max_features;
TT_Tag* feature_tags;
TT_Bool* features;
TT_Int max_lookups;
TT_Bool* lookups;
TT_Byte* scripts_table;
TT_Long scripts_len;
TT_Byte* features_table;
TT_Long* features_len;
TT_Byte* lookups_table;
TT_Byte* lookups_len;
TT_Byte* cur_script; /* current script */
TT_Byte* cur_language; /* current language */
TT_Byte* cur_base_values;
TT_Byte* cur_min_max;
OTL_Type otl_type;
} OTL_Table;
typedef struct OTL_BaseCoord_
{
TT_UShort format;
TT_Short coordinate;
TT_UShort ref_glyph;
TT_UShort ref_point;
TT_Byte* device;
} OTL_BaseCoord;
typedef struct OTL_ValueRecord_
{
TT_Vector placement;
TT_Vector advance;
TT_Byte* device_pla_x;
TT_Byte* device_pla_y;
TT_Byte* device_adv_x;
TT_Byte* device_adv_y;
} OTL_ValueRecord;
typedef struct OTL_Anchor_
{
TT_UInt format;
TT_Vector coord;
TT_UInt anchor_point;
TT_Byte* device_x;
TT_Byte* device_y;
} OTL_Anchor;
LOCAL_DEF
TT_Error OTL_Table_Init( OTL_Table* table,
FT_Memory memory );
LOCAL_DEF
TT_Error OTL_Table_Set_Scripts( OTL_Table* table,
TT_Byte* bytes,
TT_Long len,
OTL_Type otl_type );
LOCAL_DEF
TT_Error OTL_Table_Set_Features( OTL_Table* table,
TT_Byte* bytes,
TT_Long len );
LOCAL_DEF
TT_Error OTL_Table_Set_Lookups( OTL_Table* table,
TT_Byte* bytes,
TT_Long len );
LOCAL_DEF
void OTL_Table_Done( OTL_Table* table );
/*****************************************************
*
* Typical uses:
*
* - after OTL_Table_Set_Scripts have been called :
*
* table->script_tags contains the list of tags of all
* scripts defined for this table.
*
* table->num_scripts is the number of scripts
*
*/
/********************************************************
*
* - after calling OTL_Table_Set_Features:
*
* table->max_features is the number of all features
* in the table
*
* table->feature_tags is the list of tags of all
* features in the table
*
* table->features[] is an array of boolean used to
* indicate which feature is active for a given script/language
* it is empty (zero-filled) by default.
*
*/
/*******************************************************************
*
* - after calling OTL_Get_Languages_List(script_tag):
*
* table->num_languages is the number of language systems
* available for the script, including the default
* langsys if there is one
*
* table->language_tags contains the list of tags of all
* languages for the script. Note that the default langsys
* has tag "0" and is always placed first in "language_tags".
*
*
*
*/
LOCAL_DEF
void OTL_Get_Languages_List( OTL_Table* table,
TT_ULong script_tag );
/*******************************************************************
*
* - after calling OTL_Get_Features_List(language_tag):
*
* table->features[] is an array of booleans used to indicate
* which features are active for the current script/language
*
* note that this function must be called after OTL_Get_Languages
* which remembers the last "script_tag" used..
*
* A client application can change the table->features[] array
* to add or remove features from the list.
*
*
*
*/
LOCAL_DEF
void OTL_Get_Features_List( OTL_Table* table,
TT_ULong language_tag );
LOCAL_DEF
void OTL_Get_Baseline_Values( OTL_Table* table,
TT_ULong language_tag );
LOCAL_DEF
void OTL_Get_Justification( OTL_Table* table,
TT_ULong language_tag );
/*******************************************************************
*
* - after calling OTL_Get_Lookups_List():
*
* The function uses the table->features[] array of boolean
* to determine which lookups must be processed.
*
* It fills the table->lookups[] array accordingly. It is also
* an array of booleans (one for each lookup).
*
*
*/
LOCAL_DEF
void OTL_Get_Lookups_List( OTL_Table* table );
/***************************************************************
*
* So the whole thing looks like:
*
*
* 1. A client specifies a given script and requests available
* language through OTL_Get_Languages_List()
*
* 2. It selects the language tag it needs, then calls
* OTL_Get_Features_List()
*
* 3. It updates the list of active features if it needs to
*
* 4. It calls OTL_Get_Lookups_List()
* It now has a list of active lookups in "table->lookups[]"
*
* 5. The lookups are processed according to the table's type..
*
*/
LOCAL_DEF
TT_Long OTL_Get_Coverage_Index( TT_Byte* coverage,
TT_UInt glyph_id );
LOCAL_DEF
TT_UInt OTL_Get_Glyph_Class( TT_Byte* class_def,
TT_UInt glyph_id );
LOCAL_DEF
TT_Int OTL_Get_Device_Adjustment( TT_Byte* device,
TT_UInt size );
LOCAL_DEF
void OTL_Get_Base_Coordinate( TT_Byte* base_coord,
OTL_BaseCoord* coord );
LOCAL_DEF
TT_Int OTL_ValueRecord_Size( TT_UShort value_format );
LOCAL_DEF
void OTL_Get_ValueRecord( TT_Byte* value_record,
TT_UShort value_format,
TT_Byte* pos_table,
OTL_ValueRecord* record );
LOCAL_DEF
void OTL_Get_Anchor( TT_Byte* anchor_table,
OTL_Anchor* anchor );
LOCAL_DEF
void OTL_Get_Mark( TT_Byte* mark_array,
TT_UInt index,
TT_UShort* clazz,
OTL_Anchor* anchor );
#define OTL_Byte(p) (p++, p[-1])
#define OTL_UShort(p) (p+=2, ((TT_UShort)p[-2] << 8) | p[-1])
#define OTL_ULong(p) (p+=4, ((TT_ULong)p[-4] << 24) | \
((TT_ULong)p[-3] << 16) | \
((TT_ULong)p[-2] << 8 ) | p[-1] )
#endif /* OLTYPES_H */

View File

@@ -1,7 +0,0 @@
make_module_list: add_psnames_module
add_psnames_module:
$(OPEN_DRIVER)psnames_module_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)psnames $(ECHO_DRIVER_DESC)Postscript & Unicode Glyph name handling$(ECHO_DRIVER_DONE)
# EOF

View File

@@ -1,320 +0,0 @@
/***************************************************************************/
/* */
/* psmodule.c */
/* */
/* PSNames module implementation (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/psnames.h>
#include <freetype/internal/ftobjs.h>
#ifdef FT_FLAT_COMPILE
#include "psmodule.h"
#include "pstables.h"
#else
#include <psnames/psmodule.h>
#include <psnames/pstables.h>
#endif
#include <stdlib.h> /* for qsort() */
#include <string.h> /* for strcmp(), strncpy() */
#ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
/* return the Unicode value corresponding to a given glyph. Note that */
/* we do deal with glyph variants by detecting a non-initial dot in */
/* the name, as in `A.swash' or `e.final', etc. */
/* */
static
FT_ULong PS_Unicode_Value( const char* glyph_name )
{
FT_Int n;
char first = glyph_name[0];
char temp[64];
/* if the name begins with `uni', then the glyph name may be a */
/* hard-coded unicode character code. */
if ( glyph_name[0] == 'u' &&
glyph_name[1] == 'n' &&
glyph_name[2] == 'i' )
{
/* determine whether the next four characters following are */
/* hexadecimal. */
/* XXX: Add code to deal with ligatures, i.e. glyph names like */
/* `uniXXXXYYYYZZZZ'... */
FT_Int count;
FT_ULong value = 0;
const char* p = glyph_name + 4;
for ( count = 4; count > 0; count--, p++ )
{
char c = *p;
unsigned char d;
d = (unsigned char)c - '0';
if ( d >= 10 )
{
d = (unsigned char)c - 'A';
if ( d >= 6 )
d = 16;
else
d += 10;
}
/* exit if a non-uppercase hexadecimal character was found */
if ( d >= 16 )
break;
value = ( value << 4 ) + d;
if ( count == 0 )
return value;
}
}
/* look for a non-initial dot in the glyph name in order to */
/* sort-out variants like `A.swash', `e.final', etc. */
{
const char* p;
int len;
p = glyph_name;
while ( *p && *p != '.' )
p++;
len = p - glyph_name;
if ( *p && len < 64 )
{
strncpy( temp, glyph_name, len );
temp[len] = 0;
glyph_name = temp;
}
}
/* now, look up the glyph in the Adobe Glyph List */
for ( n = 0; n < NUM_ADOBE_GLYPHS; n++ )
{
const char* name = t1_standard_glyphs[n];
if ( first == name[0] && strcmp( glyph_name, name ) == 0 )
return names_to_unicode[n];
}
/* not found, there is probably no Unicode value for this glyph name */
return 0;
}
/* qsort callback to sort the unicode map */
static
int compare_uni_maps( const void* a,
const void* b )
{
PS_UniMap* map1 = (PS_UniMap*)a;
PS_UniMap* map2 = (PS_UniMap*)b;
return ( map1->unicode - map2->unicode );
}
/* Builds a table that maps Unicode values to glyph indices */
static
FT_Error PS_Build_Unicode_Table( FT_Memory memory,
FT_UInt num_glyphs,
const char** glyph_names,
PS_Unicodes* table )
{
FT_Error error;
/* we first allocate the table */
table->num_maps = 0;
table->maps = 0;
if ( !ALLOC_ARRAY( table->maps, num_glyphs, PS_UniMap ) )
{
FT_UInt n;
FT_UInt count;
PS_UniMap* map;
FT_ULong uni_char;
map = table->maps;
for ( n = 0; n < num_glyphs; n++ )
{
const char* gname = glyph_names[n];
if ( gname )
{
uni_char = PS_Unicode_Value( gname );
if ( uni_char && uni_char != 0xFFFF )
{
map->unicode = uni_char;
map->glyph_index = n;
map++;
}
}
}
/* now, compress the table a bit */
count = map - table->maps;
if ( count > 0 && REALLOC( table->maps,
num_glyphs * sizeof ( PS_UniMap ),
count * sizeof ( PS_UniMap ) ) )
count = 0;
if ( count == 0 )
{
FREE( table->maps );
if ( !error )
error = FT_Err_Invalid_Argument; /* no unicode chars here! */
}
else
/* sort the table in increasing order of unicode values */
qsort( table->maps, count, sizeof ( PS_UniMap ), compare_uni_maps );
table->num_maps = count;
}
return error;
}
static
FT_UInt PS_Lookup_Unicode( PS_Unicodes* table,
FT_ULong unicode )
{
PS_UniMap *min, *max, *mid;
/* perform a binary search on the table */
min = table->maps;
max = min + table->num_maps - 1;
while ( min <= max )
{
mid = min + ( max - min ) / 2;
if ( mid->unicode == unicode )
return mid->glyph_index;
if ( min == max )
break;
if ( mid->unicode < unicode )
min = mid + 1;
else
max = mid - 1;
}
return 0xFFFF;
}
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
static
const char* PS_Macintosh_Name( FT_UInt name_index )
{
if ( name_index >= 258 )
name_index = 0;
return standard_glyph_names[mac_standard_names[name_index]];
}
static
const char* PS_Standard_Strings( FT_UInt sid )
{
return ( sid < NUM_STD_GLYPHS ? t1_standard_glyphs[sid] : 0 );
}
static const PSNames_Interface psnames_interface =
{
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
(PS_Unicode_Value_Func) PS_Unicode_Value,
(PS_Build_Unicodes_Func) PS_Build_Unicode_Table,
(PS_Lookup_Unicode_Func) PS_Lookup_Unicode,
#else
0,
0,
0,
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
(PS_Macintosh_Name_Func) PS_Macintosh_Name,
(PS_Adobe_Std_Strings_Func)PS_Standard_Strings,
t1_standard_encoding,
t1_expert_encoding
};
#endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */
const FT_Module_Class psnames_module_class =
{
0, /* this is not a font driver, nor a renderer */
sizeof( FT_ModuleRec ),
"psnames", /* driver name */
0x10000L, /* driver version */
0x20000L, /* driver requires FreeType 2 or above */
#ifdef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
0,
#else
(void*)&psnames_interface, /* module specific interface */
#endif
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
};
/* END */

View File

@@ -1,29 +0,0 @@
/***************************************************************************/
/* */
/* psmodule.h */
/* */
/* High-level PSNames module interface (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef PSDRIVER_H
#define PSDRIVER_H
#include <freetype/ftmodule.h>
FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class;
#endif /* PSDRIVER_H */
/* END */

View File

@@ -1,24 +0,0 @@
/***************************************************************************/
/* */
/* psnames.c */
/* */
/* FreeType PSNames module component (body only). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <psmodule.c>
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,70 +0,0 @@
#
# FreeType 2 PSNames driver configuration rules
#
# Copyright 1996-2000 by
# 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.
# PSNames driver directory
#
PSNAMES_DIR := $(SRC_)psnames
PSNAMES_DIR_ := $(PSNAMES_DIR)$(SEP)
# compilation flags for the driver
#
PSNAMES_COMPILE := $(FT_COMPILE)
# PSNames driver sources (i.e., C files)
#
PSNAMES_DRV_SRC := $(PSNAMES_DIR_)psmodule.c
# PSNames driver headers
#
PSNAMES_DRV_H := $(PSNAMES_DRV_SRC:%.c=%.h) \
$(PSNAMES_DIR_)pstables.h
# PSNames driver object(s)
#
# PSNAMES_DRV_OBJ_M is used during `multi' builds
# PSNAMES_DRV_OBJ_S is used during `single' builds
#
PSNAMES_DRV_OBJ_M := $(PSNAMES_DRV_SRC:$(PSNAMES_DIR_)%.c=$(OBJ_)%.$O)
PSNAMES_DRV_OBJ_S := $(OBJ_)psnames.$O
# PSNames driver source file for single build
#
PSNAMES_DRV_SRC_S := $(PSNAMES_DIR_)psmodule.c
# PSNames driver - single object
#
$(PSNAMES_DRV_OBJ_S): $(PSNAMES_DRV_SRC_S) $(PSNAMES_DRV_SRC) \
$(FREETYPE_H) $(PSNAMES_DRV_H)
$(PSNAMES_COMPILE) $T$@ $(PSNAMES_DRV_SRC_S)
# PSNames driver - multiple objects
#
$(OBJ_)%.$O: $(PSNAMES_DIR_)%.c $(FREETYPE_H) $(PSNAMES_DRV_H)
$(PSNAMES_COMPILE) $T$@ $<
# update main driver object lists
#
DRV_OBJS_S += $(PSNAMES_DRV_OBJ_S)
DRV_OBJS_M += $(PSNAMES_DRV_OBJ_M)
# EOF

File diff suppressed because it is too large Load Diff

View File

@@ -1,50 +0,0 @@
/***************************************************************************/
/* */
/* ftraster.h */
/* */
/* The FreeType glyph rasterizer (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef FTRASTER_H
#define FTRASTER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <freetype/ftimage.h>
/*************************************************************************/
/* */
/* Uncomment the following line if you are using ftraster.c as a */
/* standalone module, fully independent of FreeType. */
/* */
/* #define _STANDALONE_ */
#ifndef FT_EXPORT_VAR
#define FT_EXPORT_VAR( x ) extern x
#endif
FT_EXPORT_VAR( FT_Raster_Funcs ) ft_standard_raster;
#ifdef __cplusplus
}
#endif
#endif /* FTRASTER_H */
/* END */

View File

@@ -1,275 +0,0 @@
/***************************************************************************/
/* */
/* ftrend1.c */
/* */
/* The FreeType glyph rasterizer interface (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftobjs.h>
#include <freetype/ftoutln.h>
#ifdef FT_FLAT_COMPILE
#include "ftrend1.h"
#include "ftraster.h"
#else
#include <raster1/ftrend1.h>
#include <raster1/ftraster.h>
#endif
/* initialize renderer -- init its raster */
static
FT_Error ft_raster1_init( FT_Renderer render )
{
FT_Library library = FT_MODULE_LIBRARY( render );
render->clazz->raster_class->raster_reset( render->raster,
library->raster_pool,
library->raster_pool_size );
return FT_Err_Ok;
}
/* set render-specific mode */
static
FT_Error ft_raster1_set_mode( FT_Renderer render,
FT_ULong mode_tag,
FT_Pointer data )
{
/* we simply pass it to the raster */
return render->clazz->raster_class->raster_set_mode( render->raster,
mode_tag,
data );
}
/* transform a given glyph image */
static
FT_Error ft_raster1_transform( FT_Renderer render,
FT_GlyphSlot slot,
FT_Matrix* matrix,
FT_Vector* delta )
{
FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
if ( matrix )
FT_Outline_Transform( &slot->outline, matrix );
if ( delta )
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
Exit:
return error;
}
/* return the glyph's control box */
static
void ft_raster1_get_cbox( FT_Renderer render,
FT_GlyphSlot slot,
FT_BBox* cbox )
{
MEM_Set( cbox, 0, sizeof ( *cbox ) );
if ( slot->format == render->glyph_format )
FT_Outline_Get_CBox( &slot->outline, cbox );
}
/* convert a slot's glyph image into a bitmap */
static
FT_Error ft_raster1_render( FT_Renderer render,
FT_GlyphSlot slot,
FT_UInt mode,
FT_Vector* origin )
{
FT_Error error;
FT_Outline* outline;
FT_BBox cbox;
FT_UInt width, height, pitch;
FT_Bitmap* bitmap;
FT_Memory memory;
FT_Raster_Params params;
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
/* check rendering mode */
if ( mode != ft_render_mode_mono )
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz == &ft_raster1_renderer_class )
return FT_Err_Cannot_Render_Glyph;
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz == &ft_raster5_renderer_class )
return FT_Err_Cannot_Render_Glyph;
}
outline = &slot->outline;
/* translate the outline to the new origin if needed */
if ( origin )
FT_Outline_Translate( outline, origin->x, origin->y );
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox );
cbox.xMin &= -64;
cbox.yMin &= -64;
cbox.xMax = ( cbox.xMax + 63 ) & -64;
cbox.yMax = ( cbox.yMax + 63 ) & -64;
width = ( cbox.xMax - cbox.xMin ) >> 6;
height = ( cbox.yMax - cbox.yMin ) >> 6;
bitmap = &slot->bitmap;
memory = render->root.memory;
/* release old bitmap buffer */
if ( slot->flags & ft_glyph_own_bitmap )
{
FREE( bitmap->buffer );
slot->flags &= ~ft_glyph_own_bitmap;
}
/* allocate new one, depends on pixel format */
if ( !( mode & ft_render_mode_mono ) )
{
/* we pad to 32 bits, only for backwards compatibility with FT 1.x */
pitch = ( width + 3 ) & -4;
bitmap->pixel_mode = ft_pixel_mode_grays;
bitmap->num_grays = 256;
}
else
{
pitch = ( width + 7 ) >> 3;
bitmap->pixel_mode = ft_pixel_mode_mono;
}
bitmap->width = width;
bitmap->rows = height;
bitmap->pitch = pitch;
if ( ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
goto Exit;
slot->flags |= ft_glyph_own_bitmap;
/* translate outline to render it into the bitmap */
FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin );
/* set up parameters */
params.target = bitmap;
params.source = outline;
params.flags = 0;
if ( bitmap->pixel_mode == ft_pixel_mode_grays )
params.flags |= ft_raster_flag_aa;
/* render outline into the bitmap */
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
slot->format = ft_glyph_format_bitmap;
slot->bitmap_left = cbox.xMin >> 6;
slot->bitmap_top = cbox.yMax >> 6;
Exit:
return error;
}
const FT_Renderer_Class ft_raster1_renderer_class =
{
{
ft_module_renderer,
sizeof( FT_RendererRec ),
"raster1",
0x10000L,
0x20000L,
0, /* module specific interface */
(FT_Module_Constructor)ft_raster1_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
},
ft_glyph_format_outline,
(FTRenderer_render) ft_raster1_render,
(FTRenderer_transform)ft_raster1_transform,
(FTRenderer_getCBox) ft_raster1_get_cbox,
(FTRenderer_setMode) ft_raster1_set_mode,
(FT_Raster_Funcs*) &ft_standard_raster
};
/* this renderer is _NOT_ part of the default modules, you'll need */
/* to register it by hand in your application. It should only be */
/* used for backwards-compatibility with FT 1.x anyway. */
const FT_Renderer_Class ft_raster5_renderer_class =
{
{
ft_module_renderer,
sizeof( FT_RendererRec ),
"raster5",
0x10000L,
0x20000L,
0, /* module specific interface */
(FT_Module_Constructor)ft_raster1_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
},
ft_glyph_format_outline,
(FTRenderer_render) ft_raster1_render,
(FTRenderer_transform)ft_raster1_transform,
(FTRenderer_getCBox) ft_raster1_get_cbox,
(FTRenderer_setMode) ft_raster1_set_mode,
(FT_Raster_Funcs*) &ft_standard_raster
};
/* END */

View File

@@ -1,37 +0,0 @@
/***************************************************************************/
/* */
/* ftrend1.h */
/* */
/* The FreeType glyph rasterizer interface (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef FTREND1_H
#define FTREND1_H
#include <freetype/ftrender.h>
FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster1_renderer_class;
/* this renderer is _NOT_ part of the default modules, you'll need */
/* to register it by hand in your application. It should only be */
/* used for backwards-compatibility with FT 1.x anyway. */
/* */
FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster5_renderer_class;
#endif /* FTREND1_H */
/* END */

View File

@@ -1,7 +0,0 @@
make_module_list: add_raster1_module
add_raster1_module:
$(OPEN_DRIVER)ft_raster1_renderer_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)raster1 $(ECHO_DRIVER_DESC)monochrome bitmap renderer$(ECHO_DRIVER_DONE)
# EOF

View File

@@ -1,35 +0,0 @@
/***************************************************************************/
/* */
/* raster1.c */
/* */
/* FreeType monochrome rasterer module component (body only). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
#include "ftraster.c"
#include "ftrend1.c"
#else
#include <raster1/ftraster.c>
#include <raster1/ftrend1.c>
#endif
/* END */

View File

@@ -1,69 +0,0 @@
#
# FreeType 2 renderer module build rules
#
# Copyright 1996-2000 by
# 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.
# raster1 driver directory
#
RAS1_DIR := $(SRC_)raster1
RAS1_DIR_ := $(RAS1_DIR)$(SEP)
# compilation flags for the driver
#
RAS1_COMPILE := $(FT_COMPILE)
# raster1 driver sources (i.e., C files)
#
RAS1_DRV_SRC := $(RAS1_DIR_)ftraster.c \
$(RAS1_DIR_)ftrend1.c
# raster1 driver headers
#
RAS1_DRV_H := $(RAS1_DRV_SRC:%.c=%.h)
# raster1 driver object(s)
#
# RAS1_DRV_OBJ_M is used during `multi' builds.
# RAS1_DRV_OBJ_S is used during `single' builds.
#
RAS1_DRV_OBJ_M := $(RAS1_DRV_SRC:$(RAS1_DIR_)%.c=$(OBJ_)%.$O)
RAS1_DRV_OBJ_S := $(OBJ_)raster1.$O
# raster1 driver source file for single build
#
RAS1_DRV_SRC_S := $(RAS1_DIR_)raster1.c
# raster1 driver - single object
#
$(RAS1_DRV_OBJ_S): $(RAS1_DRV_SRC_S) $(RAS1_DRV_SRC) \
$(FREETYPE_H) $(RAS1_DRV_H)
$(RAS1_COMPILE) $T$@ $(RAS1_DRV_SRC_S)
# raster1 driver - multiple objects
#
$(OBJ_)%.$O: $(RAS1_DIR_)%.c $(FREETYPE_H) $(RAS1_DRV_H)
$(RAS1_COMPILE) $T$@ $<
# update main driver object lists
#
DRV_OBJS_S += $(RAS1_DRV_OBJ_S)
DRV_OBJS_M += $(RAS1_DRV_OBJ_M)
# EOF

View File

@@ -1,7 +0,0 @@
make_module_list: add_sfnt_module
add_sfnt_module:
$(OPEN_DRIVER)sfnt_module_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)sfnt $(ECHO_DRIVER_DESC)helper module for TrueType & OpenType formats$(ECHO_DRIVER_DONE)
# EOF

View File

@@ -1,73 +0,0 @@
#
# FreeType 2 SFNT driver configuration rules
#
# Copyright 1996-2000 by
# 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.
# SFNT driver directory
#
SFNT_DIR := $(SRC_)sfnt
SFNT_DIR_ := $(SFNT_DIR)$(SEP)
# compilation flags for the driver
#
SFNT_COMPILE := $(FT_COMPILE)
# SFNT driver sources (i.e., C files)
#
SFNT_DRV_SRC := $(SFNT_DIR_)ttload.c \
$(SFNT_DIR_)ttcmap.c \
$(SFNT_DIR_)ttsbit.c \
$(SFNT_DIR_)ttpost.c \
$(SFNT_DIR_)sfobjs.c \
$(SFNT_DIR_)sfdriver.c
# SFNT driver headers
#
SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h)
# SFNT driver object(s)
#
# SFNT_DRV_OBJ_M is used during `multi' builds.
# SFNT_DRV_OBJ_S is used during `single' builds.
#
SFNT_DRV_OBJ_M := $(SFNT_DRV_SRC:$(SFNT_DIR_)%.c=$(OBJ_)%.$O)
SFNT_DRV_OBJ_S := $(OBJ_)sfnt.$O
# SFNT driver source file for single build
#
SFNT_DRV_SRC_S := $(SFNT_DIR_)sfnt.c
# SFNT driver - single object
#
$(SFNT_DRV_OBJ_S): $(SFNT_DRV_SRC_S) $(SFNT_DRV_SRC) \
$(FREETYPE_H) $(SFNT_DRV_H)
$(SFNT_COMPILE) $T$@ $(SFNT_DRV_SRC_S)
# SFNT driver - multiple objects
#
$(OBJ_)%.$O: $(SFNT_DIR_)%.c $(FREETYPE_H) $(SFNT_DRV_H)
$(SFNT_COMPILE) $T$@ $<
# update main driver object lists
#
DRV_OBJS_S += $(SFNT_DRV_OBJ_S)
DRV_OBJS_M += $(SFNT_DRV_OBJ_M)
# EOF

View File

@@ -1,225 +0,0 @@
/***************************************************************************/
/* */
/* sfdriver.c */
/* */
/* High-level SFNT driver interface (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/sfnt.h>
#include <freetype/internal/ftobjs.h>
#ifdef FT_FLAT_COMPILE
#include "sfdriver.h"
#include "ttload.h"
#include "ttsbit.h"
#include "ttpost.h"
#include "ttcmap.h"
#include "sfobjs.h"
#else
#include <sfnt/sfdriver.h>
#include <sfnt/ttload.h>
#include <sfnt/ttsbit.h>
#include <sfnt/ttpost.h>
#include <sfnt/ttcmap.h>
#include <sfnt/sfobjs.h>
#endif
#include <string.h> /* for strcmp() */
static
void* get_sfnt_table( TT_Face face,
FT_Sfnt_Tag tag )
{
void* table;
switch ( tag )
{
case ft_sfnt_head:
table = &face->header;
break;
case ft_sfnt_hhea:
table = &face->horizontal;
break;
case ft_sfnt_vhea:
table = face->vertical_info ? &face->vertical : 0;
break;
case ft_sfnt_os2:
table = face->os2.version == 0xFFFF ? 0 : &face->os2;
break;
case ft_sfnt_post:
table = &face->postscript;
break;
case ft_sfnt_maxp:
table = &face->max_profile;
break;
case ft_sfnt_pclt:
table = face->pclt.Version ? &face->pclt : 0;
break;
default:
table = 0;
}
return table;
}
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
static
FT_Error get_sfnt_glyph_name( TT_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_String* gname;
FT_Error error;
error = TT_Get_PS_Name( face, glyph_index, &gname );
if ( !error && buffer_max > 0 )
{
FT_UInt len = strlen( gname );
if ( len >= buffer_max )
len = buffer_max - 1;
MEM_Copy( buffer, gname, len );
((FT_Byte*)buffer)[len] = 0;
}
return error;
}
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
static
FT_Module_Interface SFNT_Get_Interface( FT_Module module,
const char* interface )
{
FT_UNUSED( module );
if ( strcmp( interface, "get_sfnt" ) == 0 )
return (FT_Module_Interface)get_sfnt_table;
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
if ( strcmp( interface, "glyph_name" ) == 0 )
return (FT_Module_Interface)get_sfnt_glyph_name;
#endif
return 0;
}
static
const SFNT_Interface sfnt_interface =
{
TT_Goto_Table,
SFNT_Init_Face,
SFNT_Load_Face,
SFNT_Done_Face,
SFNT_Get_Interface,
TT_Load_Any,
TT_Load_SFNT_Header,
TT_Load_Directory,
TT_Load_Header,
TT_Load_Metrics_Header,
TT_Load_CMap,
TT_Load_MaxProfile,
TT_Load_OS2,
TT_Load_PostScript,
TT_Load_Names,
TT_Free_Names,
TT_Load_Hdmx,
TT_Free_Hdmx,
TT_Load_Kern,
TT_Load_Gasp,
TT_Load_PCLT,
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* see `ttsbit.h' */
TT_Load_SBit_Strikes,
TT_Load_SBit_Image,
TT_Free_SBit_Strikes,
#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
0,
0,
0,
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
/* see `ttpost.h' */
TT_Get_PS_Name,
TT_Free_Post_Names,
#else /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
0,
0,
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
/* see `ttcmap.h' */
TT_CharMap_Load,
TT_CharMap_Free,
};
const
FT_Module_Class sfnt_module_class =
{
0, /* not a font driver or renderer */
sizeof( FT_ModuleRec ),
"sfnt", /* driver name */
0x10000L, /* driver version 1.0 */
0x20000L, /* driver requires FreeType 2.0 or higher */
(const void*)&sfnt_interface, /* module specific interface */
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) SFNT_Get_Interface
};
/* END */

View File

@@ -1,29 +0,0 @@
/***************************************************************************/
/* */
/* sfdriver.h */
/* */
/* High-level SFNT driver interface (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef SFDRIVER_H
#define SFDRIVER_H
#include <freetype/ftmodule.h>
FT_EXPORT_VAR( const FT_Module_Class ) sfnt_module_class;
#endif /* SFDRIVER_H */
/* END */

View File

@@ -1,57 +0,0 @@
/***************************************************************************/
/* */
/* sfnt.c */
/* */
/* Single object library component. */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
#include "ttload.c"
#include "ttcmap.c"
#include "sfobjs.c"
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#include "ttsbit.c"
#endif
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include "ttpost.c"
#endif
#include "sfdriver.c"
#else /* FT_FLAT_COMPILE */
#include <sfnt/ttload.c>
#include <sfnt/ttcmap.c>
#include <sfnt/sfobjs.c>
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#include <sfnt/ttsbit.c>
#endif
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include <sfnt/ttpost.c>
#endif
#include <sfnt/sfdriver.c>
#endif /* FT_FLAT_COMPILE */
/* END */

View File

@@ -1,561 +0,0 @@
/***************************************************************************/
/* */
/* sfobjs.c */
/* */
/* SFNT object management (base). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifdef FT_FLAT_COMPILE
#include "sfobjs.h"
#else
#include <sfnt/sfobjs.h>
#endif
#include <freetype/internal/sfnt.h>
#include <freetype/internal/psnames.h>
#include <freetype/ttnameid.h>
#include <freetype/internal/tterrors.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_sfobjs
/*************************************************************************/
/* */
/* <Function> */
/* Get_Name */
/* */
/* <Description> */
/* Returns a given ENGLISH name record in ASCII. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* nameid :: The name id of the name record to return. */
/* */
/* <Return> */
/* Character string. NULL if no name is present. */
/* */
static
FT_String* Get_Name( TT_Face face,
FT_UShort nameid )
{
FT_Memory memory = face->root.memory;
FT_UShort n;
TT_NameRec* rec;
FT_Bool wide_chars = 1;
rec = face->name_table.names;
for ( n = 0; n < face->name_table.numNameRecords; n++, rec++ )
{
if ( rec->nameID == nameid )
{
/* found the name -- now create an ASCII string from it */
FT_Bool found = 0;
/* test for Microsoft English language */
if ( rec->platformID == TT_PLATFORM_MICROSOFT &&
rec->encodingID <= TT_MS_ID_UNICODE_CS &&
( rec->languageID & 0x3FF ) == 0x009 )
found = 1;
/* test for Apple Unicode encoding */
else if ( rec->platformID == TT_PLATFORM_APPLE_UNICODE )
found = 1;
/* test for Apple Roman */
else if ( rec->platformID == TT_PLATFORM_MACINTOSH &&
rec->languageID == TT_MAC_ID_ROMAN )
{
found = 1;
wide_chars = 0;
}
/* found a Unicode name */
if ( found )
{
FT_String* string;
FT_UInt len;
if ( wide_chars )
{
FT_UInt m;
len = (FT_UInt)rec->stringLength / 2;
if ( MEM_Alloc( string, len + 1 ) )
return NULL;
for ( m = 0; m < len; m ++ )
string[m] = rec->string[2 * m + 1];
}
else
{
len = rec->stringLength;
if ( MEM_Alloc( string, len + 1 ) )
return NULL;
MEM_Copy( string, rec->string, len );
}
string[len] = '\0';
return string;
}
}
}
return NULL;
}
static
FT_Encoding find_encoding( int platform_id,
int encoding_id )
{
typedef struct TEncoding
{
int platform_id;
int encoding_id;
FT_Encoding encoding;
} TEncoding;
static
const TEncoding tt_encodings[] =
{
{ TT_PLATFORM_ISO, -1, ft_encoding_unicode },
{ TT_PLATFORM_APPLE_UNICODE, -1, ft_encoding_unicode },
{ TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, ft_encoding_apple_roman },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, ft_encoding_unicode },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, ft_encoding_sjis },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, ft_encoding_gb2312 },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, ft_encoding_big5 },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, ft_encoding_wansung },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, ft_encoding_johab }
};
const TEncoding *cur, *limit;
cur = tt_encodings;
limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
for ( ; cur < limit; cur++ )
{
if ( cur->platform_id == platform_id )
{
if ( cur->encoding_id == encoding_id ||
cur->encoding_id == -1 )
return cur->encoding;
}
}
return ft_encoding_none;
}
LOCAL_FUNC
FT_Error SFNT_Init_Face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
FT_Library library = face->root.driver->root.library;
SFNT_Interface* sfnt;
SFNT_Header sfnt_header;
/* for now, parameters are unused */
FT_UNUSED( num_params );
FT_UNUSED( params );
sfnt = (SFNT_Interface*)face->sfnt;
if ( !sfnt )
{
sfnt = (SFNT_Interface*)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
{
error = FT_Err_Invalid_File_Format;
goto Exit;
}
face->sfnt = sfnt;
face->goto_table = sfnt->goto_table;
}
if ( !face->psnames )
{
face->psnames = (PSNames_Interface*)
FT_Get_Module_Interface( library, "psnames" );
}
/* check that we have a valid TrueType file */
error = sfnt->load_sfnt_header( face, stream, face_index, &sfnt_header );
if ( error )
goto Exit;
face->format_tag = sfnt_header.format_tag;
face->num_tables = sfnt_header.num_tables;
/* Load font directory */
error = sfnt->load_directory( face, stream, &sfnt_header );
if ( error )
goto Exit;
face->root.num_faces = face->ttc_header.count;
if ( face->root.num_faces < 1 )
face->root.num_faces = 1;
Exit:
return error;
}
#undef LOAD_
#define LOAD_( x ) ( ( error = sfnt->load_##x( face, stream ) ) \
!= TT_Err_Ok )
LOCAL_FUNC
FT_Error SFNT_Load_Face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
FT_UNUSED( face_index );
FT_UNUSED( num_params );
FT_UNUSED( params );
/* Load tables */
if ( LOAD_( header ) ||
LOAD_( max_profile ) ||
/* load the `hhea' & `hmtx' tables at once */
( error = sfnt->load_metrics( face, stream, 0 ) ) != TT_Err_Ok ||
/* try to load the `vhea' & `vmtx' at once if present */
( error = sfnt->load_metrics( face, stream, 1 ) ) != TT_Err_Ok ||
LOAD_( charmaps ) ||
LOAD_( names ) ||
LOAD_( os2 ) ||
LOAD_( psnames ) )
goto Exit;
/* the optional tables */
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* embedded bitmap support. */
if ( sfnt->load_sbits && LOAD_( sbits ) )
goto Exit;
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
if ( LOAD_( hdmx ) ||
LOAD_( gasp ) ||
LOAD_( kerning ) ||
LOAD_( pclt ) )
goto Exit;
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
if ( ( error = TT_Extension_Create( face ) ) != TT_Err_Ok )
goto Exit;
#endif
face->root.family_name = Get_Name( face, TT_NAME_ID_FONT_FAMILY );
face->root.style_name = Get_Name( face, TT_NAME_ID_FONT_SUBFAMILY );
/* now set up root fields */
{
FT_Face root = &face->root;
FT_Int flags;
TT_CharMap charmap;
FT_Int n;
FT_Memory memory;
memory = root->memory;
/*********************************************************************/
/* */
/* Compute face flags. */
/* */
flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
FT_FACE_FLAG_SFNT | /* SFNT file format */
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
/* might need more polish to detect the presence of a Postscript */
/* name table in the font */
flags |= FT_FACE_FLAG_GLYPH_NAMES;
#endif
/* fixed width font? */
if ( face->postscript.isFixedPitch )
flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* vertical information? */
if ( face->vertical_info )
flags |= FT_FACE_FLAG_VERTICAL;
/* kerning available ? */
if ( face->kern_pairs )
flags |= FT_FACE_FLAG_KERNING;
root->face_flags = flags;
/*********************************************************************/
/* */
/* Compute style flags. */
/* */
flags = 0;
if ( face->os2.version != 0xFFFF )
{
/* we have an OS/2 table; use the `fsSelection' field */
if ( face->os2.fsSelection & 1 )
flags |= FT_STYLE_FLAG_ITALIC;
if ( face->os2.fsSelection & 32 )
flags |= FT_STYLE_FLAG_BOLD;
}
else
{
/* this is an old Mac font, use the header field */
if ( face->header.Mac_Style & 1 )
flags |= FT_STYLE_FLAG_BOLD;
if ( face->header.Mac_Style & 2 )
flags |= FT_STYLE_FLAG_ITALIC;
}
root->style_flags = flags;
/*********************************************************************/
/* */
/* Polish the charmaps. */
/* */
/* Try to set the charmap encoding according to the platform & */
/* encoding ID of each charmap. */
/* */
charmap = face->charmaps;
root->num_charmaps = face->num_charmaps;
/* allocate table of pointers */
if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) )
goto Exit;
for ( n = 0; n < root->num_charmaps; n++, charmap++ )
{
FT_Int platform = charmap->cmap.platformID;
FT_Int encoding = charmap->cmap.platformEncodingID;
charmap->root.face = (FT_Face)face;
charmap->root.platform_id = platform;
charmap->root.encoding_id = encoding;
charmap->root.encoding = find_encoding( platform, encoding );
/* now, set root->charmap with a unicode charmap */
/* wherever available */
if ( !root->charmap &&
charmap->root.encoding == ft_encoding_unicode )
root->charmap = (FT_CharMap)charmap;
root->charmaps[n] = (FT_CharMap)charmap;
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
if ( face->num_sbit_strikes )
{
root->num_fixed_sizes = face->num_sbit_strikes;
if ( ALLOC_ARRAY( root->available_sizes,
face->num_sbit_strikes,
FT_Bitmap_Size ) )
return error;
for ( n = 0 ; n < face->num_sbit_strikes ; n++ )
{
root->available_sizes[n].width =
face->sbit_strikes[n].x_ppem;
root->available_sizes[n].height =
face->sbit_strikes[n].y_ppem;
}
}
else
#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
{
root->num_fixed_sizes = 0;
root->available_sizes = 0;
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/*********************************************************************/
/* */
/* Set up metrics. */
/* */
root->bbox.xMin = face->header.xMin;
root->bbox.yMin = face->header.yMin;
root->bbox.xMax = face->header.xMax;
root->bbox.yMax = face->header.yMax;
root->units_per_EM = face->header.Units_Per_EM;
/* The ascender/descender/height are computed from the OS/2 table */
/* when found. Otherwise, they're taken from the horizontal header. */
if ( face->os2.version != 0xFFFF )
{
root->ascender = face->os2.sTypoAscender;
root->descender = -face->os2.sTypoDescender;
root->height = root->ascender + root->descender +
face->os2.sTypoLineGap;
}
else
{
root->ascender = face->horizontal.Ascender;
root->descender = face->horizontal.Descender;
root->height = root->ascender + root->descender +
face->horizontal.Line_Gap;
}
root->max_advance_width = face->horizontal.advance_Width_Max;
root->max_advance_height = face->vertical_info
? face->vertical.advance_Height_Max
: root->height;
root->underline_position = face->postscript.underlinePosition;
root->underline_thickness = face->postscript.underlineThickness;
/* root->max_points -- already set up */
/* root->max_contours -- already set up */
}
Exit:
return error;
}
#undef LOAD_
LOCAL_FUNC
void SFNT_Done_Face( TT_Face face )
{
FT_Memory memory = face->root.memory;
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
if ( sfnt )
{
/* destroy the postscript names table if it is loaded */
if ( sfnt->free_psnames )
sfnt->free_psnames( face );
/* destroy the embedded bitmaps table if it is loaded */
if ( sfnt->free_sbits )
sfnt->free_sbits( face );
}
/* freeing the kerning table */
FREE( face->kern_pairs );
face->num_kern_pairs = 0;
/* freeing the collection table */
FREE( face->ttc_header.offsets );
face->ttc_header.count = 0;
/* freeing table directory */
FREE( face->dir_tables );
face->num_tables = 0;
/* freeing the character mapping tables */
if ( sfnt && sfnt->load_charmaps )
{
FT_UShort n;
for ( n = 0; n < face->num_charmaps; n++ )
sfnt->free_charmap( face, &face->charmaps[n].cmap );
}
FREE( face->charmaps );
face->num_charmaps = 0;
FREE( face->root.charmaps );
face->root.num_charmaps = 0;
face->root.charmap = 0;
/* freeing the horizontal metrics */
FREE( face->horizontal.long_metrics );
FREE( face->horizontal.short_metrics );
/* freeing the vertical ones, if any */
if ( face->vertical_info )
{
FREE( face->vertical.long_metrics );
FREE( face->vertical.short_metrics );
face->vertical_info = 0;
}
/* freeing the gasp table */
FREE( face->gasp.gaspRanges );
face->gasp.numRanges = 0;
/* freeing the name table */
sfnt->free_names( face );
/* freeing the hdmx table */
sfnt->free_hdmx( face );
/* freeing family and style name */
FREE( face->root.family_name );
FREE( face->root.style_name );
/* freeing sbit size table */
face->root.num_fixed_sizes = 0;
if ( face->root.available_sizes )
FREE( face->root.available_sizes );
face->sfnt = 0;
}
/* END */

View File

@@ -1,57 +0,0 @@
/***************************************************************************/
/* */
/* sfobjs.h */
/* */
/* SFNT object management (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef SFOBJS_H
#define SFOBJS_H
#include <freetype/internal/sfnt.h>
#include <freetype/internal/ftobjs.h>
#ifdef __cplusplus
extern "C" {
#endif
LOCAL_DEF
FT_Error SFNT_Init_Face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
LOCAL_DEF
FT_Error SFNT_Load_Face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
LOCAL_DEF
void SFNT_Done_Face( TT_Face face );
#ifdef __cplusplus
}
#endif
#endif /* SFDRIVER_H */
/* END */

View File

@@ -1,550 +0,0 @@
/***************************************************************************/
/* */
/* ttcmap.c */
/* */
/* TrueType character mapping table (cmap) support (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/tterrors.h>
#ifdef FT_FLAT_COMPILE
#include "ttload.h"
#include "ttcmap.h"
#else
#include <sfnt/ttload.h>
#include <sfnt/ttcmap.h>
#endif
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_ttcmap
static FT_UInt code_to_index0( TT_CMapTable* charmap,
FT_ULong char_code );
static FT_UInt code_to_index2( TT_CMapTable* charmap,
FT_ULong char_code );
static FT_UInt code_to_index4( TT_CMapTable* charmap,
FT_ULong char_code );
static FT_UInt code_to_index6( TT_CMapTable* charmap,
FT_ULong char_code );
/*************************************************************************/
/* */
/* <Function> */
/* TT_CharMap_Load */
/* */
/* <Description> */
/* Loads a given TrueType character map into memory. */
/* */
/* <Input> */
/* face :: A handle to the parent face object. */
/* stream :: A handle to the current stream object. */
/* */
/* <InOut> */
/* table :: A pointer to a cmap object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The function assumes that the stream is already in use (i.e., */
/* opened). In case of error, all partially allocated tables are */
/* released. */
/* */
LOCAL_FUNC
FT_Error TT_CharMap_Load( TT_Face face,
TT_CMapTable* cmap,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory;
FT_UShort num_SH, num_Seg, i;
FT_UShort u, l;
TT_CMap0* cmap0;
TT_CMap2* cmap2;
TT_CMap4* cmap4;
TT_CMap6* cmap6;
TT_CMap2SubHeader* cmap2sub;
TT_CMap4Segment* segments;
if ( cmap->loaded )
return TT_Err_Ok;
memory = stream->memory;
if ( FILE_Seek( cmap->offset ) )
return error;
switch ( cmap->format )
{
case 0:
cmap0 = &cmap->c.cmap0;
if ( ALLOC( cmap0->glyphIdArray, 256L ) ||
FILE_Read( cmap0->glyphIdArray, 256L ) )
goto Fail;
cmap->get_index = code_to_index0;
break;
case 2:
num_SH = 0;
cmap2 = &cmap->c.cmap2;
/* allocate subheader keys */
if ( ALLOC_ARRAY( cmap2->subHeaderKeys, 256, FT_UShort ) ||
ACCESS_Frame( 512L ) )
goto Fail;
for ( i = 0; i < 256; i++ )
{
u = GET_UShort() / 8;
cmap2->subHeaderKeys[i] = u;
if ( num_SH < u )
num_SH = u;
}
FORGET_Frame();
/* load subheaders */
cmap2->numGlyphId = l =
( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFF ) / 2;
if ( ALLOC_ARRAY( cmap2->subHeaders,
num_SH + 1,
TT_CMap2SubHeader ) ||
ACCESS_Frame( ( num_SH + 1 ) * 8L ) )
goto Fail;
cmap2sub = cmap2->subHeaders;
for ( i = 0; i <= num_SH; i++ )
{
cmap2sub->firstCode = GET_UShort();
cmap2sub->entryCount = GET_UShort();
cmap2sub->idDelta = GET_Short();
/* we apply the location offset immediately */
cmap2sub->idRangeOffset = GET_UShort() - ( num_SH - i ) * 8 - 2;
cmap2sub++;
}
FORGET_Frame();
/* load glyph IDs */
if ( ALLOC_ARRAY( cmap2->glyphIdArray, l, FT_UShort ) ||
ACCESS_Frame( l * 2L ) )
goto Fail;
for ( i = 0; i < l; i++ )
cmap2->glyphIdArray[i] = GET_UShort();
FORGET_Frame();
cmap->get_index = code_to_index2;
break;
case 4:
cmap4 = &cmap->c.cmap4;
/* load header */
if ( ACCESS_Frame( 8L ) )
goto Fail;
cmap4->segCountX2 = GET_UShort();
cmap4->searchRange = GET_UShort();
cmap4->entrySelector = GET_UShort();
cmap4->rangeShift = GET_UShort();
num_Seg = cmap4->segCountX2 / 2;
FORGET_Frame();
/* load segments */
if ( ALLOC_ARRAY( cmap4->segments,
num_Seg,
TT_CMap4Segment ) ||
ACCESS_Frame( ( num_Seg * 4 + 1 ) * 2L ) )
goto Fail;
segments = cmap4->segments;
for ( i = 0; i < num_Seg; i++ )
segments[i].endCount = GET_UShort();
(void)GET_UShort();
for ( i = 0; i < num_Seg; i++ )
segments[i].startCount = GET_UShort();
for ( i = 0; i < num_Seg; i++ )
segments[i].idDelta = GET_Short();
for ( i = 0; i < num_Seg; i++ )
segments[i].idRangeOffset = GET_UShort();
FORGET_Frame();
cmap4->numGlyphId = l =
( ( cmap->length - ( 16L + 8L * num_Seg ) ) & 0xFFFF ) / 2;
/* load IDs */
if ( ALLOC_ARRAY( cmap4->glyphIdArray, l, FT_UShort ) ||
ACCESS_Frame( l * 2L ) )
goto Fail;
for ( i = 0; i < l; i++ )
cmap4->glyphIdArray[i] = GET_UShort();
FORGET_Frame();
cmap->get_index = code_to_index4;
cmap4->last_segment = cmap4->segments;
break;
case 6:
cmap6 = &cmap->c.cmap6;
if ( ACCESS_Frame( 4L ) )
goto Fail;
cmap6->firstCode = GET_UShort();
cmap6->entryCount = GET_UShort();
FORGET_Frame();
l = cmap6->entryCount;
if ( ALLOC_ARRAY( cmap6->glyphIdArray,
cmap6->entryCount,
FT_Short ) ||
ACCESS_Frame( l * 2L ) )
goto Fail;
for ( i = 0; i < l; i++ )
cmap6->glyphIdArray[i] = GET_UShort();
FORGET_Frame();
cmap->get_index = code_to_index6;
break;
default: /* corrupt character mapping table */
return TT_Err_Invalid_CharMap_Format;
}
return TT_Err_Ok;
Fail:
TT_CharMap_Free( face, cmap );
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_CharMap_Free */
/* */
/* <Description> */
/* Destroys a character mapping table. */
/* */
/* <Input> */
/* face :: A handle to the parent face object. */
/* cmap :: A handle to a cmap object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_CharMap_Free( TT_Face face,
TT_CMapTable* cmap )
{
FT_Memory memory;
if ( !cmap )
return TT_Err_Ok;
memory = face->root.driver->root.memory;
switch ( cmap->format )
{
case 0:
FREE( cmap->c.cmap0.glyphIdArray );
break;
case 2:
FREE( cmap->c.cmap2.subHeaderKeys );
FREE( cmap->c.cmap2.subHeaders );
FREE( cmap->c.cmap2.glyphIdArray );
break;
case 4:
FREE( cmap->c.cmap4.segments );
FREE( cmap->c.cmap4.glyphIdArray );
cmap->c.cmap4.segCountX2 = 0;
break;
case 6:
FREE( cmap->c.cmap6.glyphIdArray );
cmap->c.cmap6.entryCount = 0;
break;
default:
/* invalid table format, do nothing */
;
}
cmap->loaded = FALSE;
return TT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* code_to_index0 */
/* */
/* <Description> */
/* Converts the character code into a glyph index. Uses format 0. */
/* `charCode' must be in the range 0x00-0xFF (otherwise 0 is */
/* returned). */
/* */
/* <Input> */
/* charCode :: The wanted character code. */
/* cmap0 :: A pointer to a cmap table in format 0. */
/* */
/* <Return> */
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
static
FT_UInt code_to_index0( TT_CMapTable* cmap,
FT_ULong charCode )
{
TT_CMap0* cmap0 = &cmap->c.cmap0;
return ( charCode <= 0xFF ? cmap0->glyphIdArray[charCode] : 0 );
}
/*************************************************************************/
/* */
/* <Function> */
/* code_to_index2 */
/* */
/* <Description> */
/* Converts the character code into a glyph index. Uses format 2. */
/* */
/* <Input> */
/* charCode :: The wanted character code. */
/* cmap2 :: A pointer to a cmap table in format 2. */
/* */
/* <Return> */
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
static
FT_UInt code_to_index2( TT_CMapTable* cmap,
FT_ULong charCode )
{
FT_UInt result, index1, offset;
FT_UInt char_lo;
FT_ULong char_hi;
TT_CMap2SubHeader* sh2;
TT_CMap2* cmap2;
cmap2 = &cmap->c.cmap2;
result = 0;
char_lo = (FT_UInt)( charCode & 0xFF );
char_hi = charCode >> 8;
if ( char_hi == 0 )
{
/* an 8-bit character code -- we use the subHeader 0 in this case */
/* to test whether the character code is in the charmap */
if ( cmap2->subHeaderKeys[char_lo] == 0 )
result = cmap2->glyphIdArray[char_lo];
}
else
{
/* a 16-bit character code */
index1 = cmap2->subHeaderKeys[char_hi & 0xFF];
if ( index1 )
{
sh2 = cmap2->subHeaders + index1;
char_lo -= sh2->firstCode;
if ( char_lo < sh2->entryCount )
{
offset = sh2->idRangeOffset / 2 + char_lo;
if ( offset < cmap2->numGlyphId )
{
result = cmap2->glyphIdArray[offset];
if ( result )
result = ( result + sh2->idDelta ) & 0xFFFF;
}
}
}
}
return result;
}
/*************************************************************************/
/* */
/* <Function> */
/* code_to_index4 */
/* */
/* <Description> */
/* Converts the character code into a glyph index. Uses format 4. */
/* */
/* <Input> */
/* charCode :: The wanted character code. */
/* cmap4 :: A pointer to a cmap table in format 4. */
/* */
/* <Return> */
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
static
FT_UInt code_to_index4( TT_CMapTable* cmap,
FT_ULong charCode )
{
FT_UInt result, index1, segCount;
TT_CMap4* cmap4;
TT_CMap4Segment *seg4, *limit;
cmap4 = &cmap->c.cmap4;
result = 0;
segCount = cmap4->segCountX2 / 2;
seg4 = cmap4->segments;
limit = seg4 + segCount;
/* check against the last segment */
seg4 = cmap4->last_segment;
/* the following is equivalent to performing two tests, as in */
/* */
/* if ( charCode >= seg4->startCount && charCode <= seg4->endCount ) */
/* */
/* Yes, that's a bit strange, but it's faster, and the idea behind */
/* the cache is to significantly speed up charcode to glyph index */
/* conversion. */
if ( (FT_ULong)(charCode - seg4->startCount) <
(FT_ULong)(seg4->endCount - seg4->startCount) )
goto Found;
for ( seg4 = cmap4->segments; seg4 < limit; seg4++ )
{
/* the ranges are sorted in increasing order. If we are out of */
/* the range here, the char code isn't in the charmap, so exit. */
if ( charCode > seg4->endCount )
continue;
if ( charCode >= seg4->startCount )
goto Found;
}
return 0;
Found:
cmap4->last_segment = seg4;
/* if the idRangeOffset is 0, we can compute the glyph index */
/* directly */
if ( seg4->idRangeOffset == 0 )
result = ( charCode + seg4->idDelta ) & 0xFFFF;
else
{
/* otherwise, we must use the glyphIdArray to do it */
index1 = seg4->idRangeOffset / 2
+ ( charCode - seg4->startCount )
+ ( seg4 - cmap4->segments )
- segCount;
if ( index1 < cmap4->numGlyphId &&
cmap4->glyphIdArray[index1] != 0 )
result = ( cmap4->glyphIdArray[index1] + seg4->idDelta ) & 0xFFFF;
}
return result;
}
/*************************************************************************/
/* */
/* <Function> */
/* code_to_index6 */
/* */
/* <Description> */
/* Converts the character code into a glyph index. Uses format 6. */
/* */
/* <Input> */
/* charCode :: The wanted character code. */
/* cmap6 :: A pointer to a cmap table in format 6. */
/* */
/* <Return> */
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
static
FT_UInt code_to_index6( TT_CMapTable* cmap,
FT_ULong charCode )
{
TT_CMap6* cmap6;
FT_UInt result = 0;
cmap6 = &cmap->c.cmap6;
result = 0;
charCode -= cmap6->firstCode;
if ( charCode < cmap6->entryCount )
result = cmap6->glyphIdArray[charCode];
return result;
}
/* END */

View File

@@ -1,45 +0,0 @@
/***************************************************************************/
/* */
/* ttcmap.h */
/* */
/* TrueType character mapping table (cmap) support (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTCMAP_H
#define TTCMAP_H
#include <freetype/internal/tttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
LOCAL_DEF
FT_Error TT_CharMap_Load( TT_Face face,
TT_CMapTable* cmap,
FT_Stream input );
LOCAL_DEF
FT_Error TT_CharMap_Free( TT_Face face,
TT_CMapTable* cmap );
#ifdef __cplusplus
}
#endif
#endif /* TTCMAP_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,132 +0,0 @@
/***************************************************************************/
/* */
/* ttload.h */
/* */
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTLOAD_H
#define TTLOAD_H
#include <freetype/internal/ftstream.h>
#include <freetype/internal/tttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
LOCAL_DEF
TT_Table* TT_LookUp_Table( TT_Face face,
FT_ULong tag );
LOCAL_DEF
FT_Error TT_Goto_Table( TT_Face face,
FT_ULong tag,
FT_Stream stream,
FT_ULong* length );
LOCAL_DEF
FT_Error TT_Load_SFNT_Header( TT_Face face,
FT_Stream stream,
FT_Long face_index,
SFNT_Header* sfnt );
LOCAL_DEF
FT_Error TT_Load_Directory( TT_Face face,
FT_Stream stream,
SFNT_Header* sfnt );
LOCAL_DEF
FT_Error TT_Load_Any( TT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte* buffer,
FT_ULong* length );
LOCAL_DEF
FT_Error TT_Load_Header( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_Metrics_Header( TT_Face face,
FT_Stream stream,
FT_Bool vertical );
LOCAL_DEF
FT_Error TT_Load_CMap( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_MaxProfile( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_Names( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_OS2( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_PostScript( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_Hdmx( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_PCLT( TT_Face face,
FT_Stream stream );
LOCAL_DEF
void TT_Free_Names( TT_Face face );
LOCAL_DEF
void TT_Free_Hdmx ( TT_Face face );
LOCAL_DEF
FT_Error TT_Load_Kern( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_Gasp( TT_Face face,
FT_Stream stream );
#ifdef __cplusplus
}
#endif
#endif /* TTLOAD_H */
/* END */

View File

@@ -1,536 +0,0 @@
/***************************************************************************/
/* */
/* ttpost.c */
/* */
/* Postcript name table processing for TrueType and OpenType fonts */
/* (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* The post table is not completely loaded by the core engine. This */
/* file loads the missing PS glyph names and implements an API to access */
/* them. */
/* */
/*************************************************************************/
#include <freetype/internal/ftstream.h>
#include <freetype/internal/tterrors.h>
#include <freetype/tttags.h>
#ifdef FT_FLAT_COMPILE
#include "ttpost.h"
#include "ttload.h"
#else
#include <sfnt/ttpost.h>
#include <sfnt/ttload.h>
#endif
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_ttpost
/* If this configuration macro is defined, we rely on the `PSNames' */
/* module to grab the glyph names. */
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include <freetype/internal/psnames.h>
#define MAC_NAME( x ) ( (FT_String*)psnames->macintosh_name( x ) )
#else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
/* Otherwise, we ignore the `PSNames' module, and provide our own */
/* table of Mac names. Thus, it is possible to build a version of */
/* FreeType without the Type 1 driver & PSNames module. */
#define MAC_NAME( x ) TT_Post_Default_Names[x]
/* the 258 default Mac PS glyph names */
FT_String* TT_Post_Default_Names[258] =
{
/* 0 */
".notdef", ".null", "CR", "space", "exclam",
"quotedbl", "numbersign", "dollar", "percent", "ampersand",
/* 10 */
"quotesingle", "parenleft", "parenright", "asterisk", "plus",
"comma", "hyphen", "period", "slash", "zero",
/* 20 */
"one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "colon",
/* 30 */
"semicolon", "less", "equal", "greater", "question",
"at", "A", "B", "C", "D",
/* 40 */
"E", "F", "G", "H", "I",
"J", "K", "L", "M", "N",
/* 50 */
"O", "P", "Q", "R", "S",
"T", "U", "V", "W", "X",
/* 60 */
"Y", "Z", "bracketleft", "backslash", "bracketright",
"asciicircum", "underscore", "grave", "a", "b",
/* 70 */
"c", "d", "e", "f", "g",
"h", "i", "j", "k", "l",
/* 80 */
"m", "n", "o", "p", "q",
"r", "s", "t", "u", "v",
/* 90 */
"w", "x", "y", "z", "braceleft",
"bar", "braceright", "asciitilde", "Adieresis", "Aring",
/* 100 */
"Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis",
"aacute", "agrave", "acircumflex", "adieresis", "atilde",
/* 110 */
"aring", "ccedilla", "eacute", "egrave", "ecircumflex",
"edieresis", "iacute", "igrave", "icircumflex", "idieresis",
/* 120 */
"ntilde", "oacute", "ograve", "ocircumflex", "odieresis",
"otilde", "uacute", "ugrave", "ucircumflex", "udieresis",
/* 130 */
"dagger", "degree", "cent", "sterling", "section",
"bullet", "paragraph", "germandbls", "registered", "copyright",
/* 140 */
"trademark", "acute", "dieresis", "notequal", "AE",
"Oslash", "infinity", "plusminus", "lessequal", "greaterequal",
/* 150 */
"yen", "mu", "partialdiff", "summation", "product",
"pi", "integral", "ordfeminine", "ordmasculine", "Omega",
/* 160 */
"ae", "oslash", "questiondown", "exclamdown", "logicalnot",
"radical", "florin", "approxequal", "Delta", "guillemotleft",
/* 170 */
"guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde",
"Otilde", "OE", "oe", "endash", "emdash",
/* 180 */
"quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide",
"lozenge", "ydieresis", "Ydieresis", "fraction", "currency",
/* 190 */
"guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl",
"periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex",
/* 200 */
"Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute",
"Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",
/* 210 */
"apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave",
"dotlessi", "circumflex", "tilde", "macron", "breve",
/* 220 */
"dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek",
"caron", "Lslash", "lslash", "Scaron", "scaron",
/* 230 */
"Zcaron", "zcaron", "brokenbar", "Eth", "eth",
"Yacute", "yacute", "Thorn", "thorn", "minus",
/* 240 */
"multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf",
"onequarter", "threequarters", "franc", "Gbreve", "gbreve",
/* 250 */
"Idot", "Scedilla", "scedilla", "Cacute", "cacute",
"Ccaron", "ccaron", "dmacron",
};
#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
static
FT_Error Load_Format_20( TT_Face face,
FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_Int num_glyphs;
FT_Int num_names;
FT_UShort* glyph_indices = 0;
FT_Char** name_strings = 0;
if ( READ_UShort( num_glyphs ) )
goto Exit;
/* UNDOCUMENTED! The number of glyphs in this table can be smaller */
/* than the value in the maxp table (cf. cyberbit.ttf). */
/* There already exist fonts which have more than 32768 glyph names */
/* in this table, so the test for this threshold has been dropped. */
if ( num_glyphs > face->root.num_glyphs )
{
error = TT_Err_Invalid_File_Format;
goto Exit;
}
/* load the indices */
{
FT_Int n;
if ( ALLOC_ARRAY ( glyph_indices, num_glyphs, FT_UShort ) ||
ACCESS_Frame( num_glyphs * 2L ) )
goto Fail;
for ( n = 0; n < num_glyphs; n++ )
glyph_indices[n] = GET_UShort();
FORGET_Frame();
}
/* compute number of names stored in table */
{
FT_Int n;
num_names = 0;
for ( n = 0; n < num_glyphs; n++ )
{
FT_Int index;
index = glyph_indices[n];
if ( index >= 258 )
{
index -= 257;
if ( index > num_names )
num_names = index;
}
}
}
/* now load the name strings */
{
FT_Int n;
if ( ALLOC_ARRAY( name_strings, num_names, FT_Char* ) )
goto Fail;
for ( n = 0; n < num_names; n++ )
{
FT_UInt len;
if ( READ_Byte ( len ) ||
ALLOC_ARRAY( name_strings[n], len + 1, FT_Char ) ||
FILE_Read ( name_strings[n], len ) )
goto Fail1;
name_strings[n][len] = '\0';
}
}
/* all right, set table fields and exit successfuly */
{
TT_Post_20* table = &face->postscript_names.names.format_20;
table->num_glyphs = num_glyphs;
table->num_names = num_names;
table->glyph_indices = glyph_indices;
table->glyph_names = name_strings;
}
return TT_Err_Ok;
Fail1:
{
FT_Int n;
for ( n = 0; n < num_names; n++ )
FREE( name_strings[n] );
}
Fail:
FREE( name_strings );
FREE( glyph_indices );
Exit:
return error;
}
static
FT_Error Load_Format_25( TT_Face face,
FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_Int num_glyphs;
FT_Char* offset_table = 0;
/* UNDOCUMENTED! This value appears only in the Apple TT specs. */
if ( READ_UShort( num_glyphs ) )
goto Exit;
/* check the number of glyphs */
if ( num_glyphs > face->root.num_glyphs || num_glyphs > 258 )
{
error = TT_Err_Invalid_File_Format;
goto Exit;
}
if ( ALLOC ( offset_table, num_glyphs ) ||
FILE_Read( offset_table, num_glyphs ) )
goto Fail;
/* now check the offset table */
{
FT_Int n;
for ( n = 0; n < num_glyphs; n++ )
{
FT_Long index = (FT_Long)n + offset_table[n];
if ( index < 0 || index > num_glyphs )
{
error = TT_Err_Invalid_File_Format;
goto Fail;
}
}
}
/* OK, set table fields and exit successfuly */
{
TT_Post_25* table = &face->postscript_names.names.format_25;
table->num_glyphs = num_glyphs;
table->offsets = offset_table;
}
return TT_Err_Ok;
Fail:
FREE( offset_table );
Exit:
return error;
}
static
FT_Error Load_Post_Names( TT_Face face )
{
FT_Stream stream;
FT_Error error;
/* get a stream for the face's resource */
stream = face->root.stream;
/* seek to the beginning of the PS names table */
error = face->goto_table( face, TTAG_post, stream, 0 );
if ( error )
goto Exit;
/* now read postscript table */
switch ( face->postscript.FormatType )
{
case 0x00020000L:
error = Load_Format_20( face, stream );
break;
case 0x00028000L:
error = Load_Format_25( face, stream );
break;
default:
error = TT_Err_Invalid_File_Format;
}
face->postscript_names.loaded = 1;
Exit:
return error;
}
LOCAL_FUNC
void TT_Free_Post_Names( TT_Face face )
{
FT_Memory memory = face->root.memory;
TT_Post_Names* names = &face->postscript_names;
if ( names->loaded )
{
switch ( face->postscript.FormatType )
{
case 0x00020000L:
{
TT_Post_20* table = &names->names.format_20;
FT_UInt n;
FREE( table->glyph_indices );
table->num_glyphs = 0;
for ( n = 0; n < table->num_names; n++ )
FREE( table->glyph_names[n] );
FREE( table->glyph_names );
table->num_names = 0;
}
break;
case 0x00028000L:
{
TT_Post_25* table = &names->names.format_25;
FREE( table->offsets );
table->num_glyphs = 0;
}
break;
}
}
names->loaded = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Get_PS_Name */
/* */
/* <Description> */
/* Gets the PostScript glyph name of a glyph. */
/* */
/* <Input> */
/* face :: A handle to the parent face. */
/* */
/* index :: The glyph index. */
/* */
/* PSname :: The address of a string pointer. Will be NULL in case */
/* of error, otherwise it is a pointer to the glyph name. */
/* */
/* You must not modify the returned string! */
/* */
/* <Output> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Get_PS_Name( TT_Face face,
FT_UInt index,
FT_String** PSname )
{
FT_Error error;
TT_Post_Names* names;
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
PSNames_Interface* psnames;
#endif
if ( !face )
return TT_Err_Invalid_Face_Handle;
if ( index >= (FT_UInt)face->root.num_glyphs )
return TT_Err_Invalid_Glyph_Index;
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
psnames = (PSNames_Interface*)face->psnames;
if ( !psnames )
return TT_Err_Unimplemented_Feature;
#endif
names = &face->postscript_names;
/* `.notdef' by default */
*PSname = MAC_NAME( 0 );
switch ( face->postscript.FormatType )
{
case 0x00010000L:
if ( index < 258 ) /* paranoid checking */
*PSname = MAC_NAME( index );
break;
case 0x00020000L:
{
TT_Post_20* table = &names->names.format_20;
if ( !names->loaded )
{
error = Load_Post_Names( face );
if ( error )
break;
}
if ( index < table->num_glyphs )
{
FT_UShort name_index = table->glyph_indices[index];
if ( name_index < 258 )
*PSname = MAC_NAME( name_index );
else
*PSname = (FT_String*)table->glyph_names[name_index - 258];
}
}
break;
case 0x00028000L:
{
TT_Post_25* table = &names->names.format_25;
if ( !names->loaded )
{
error = Load_Post_Names( face );
if ( error )
break;
}
if ( index < table->num_glyphs ) /* paranoid checking */
{
index += table->offsets[index];
*PSname = MAC_NAME( index );
}
}
break;
case 0x00030000L:
break; /* nothing to do */
}
return TT_Err_Ok;
}
/* END */

View File

@@ -1,52 +0,0 @@
/***************************************************************************/
/* */
/* ttpost.h */
/* */
/* Postcript name table processing for TrueType and OpenType fonts */
/* (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTPOST_H
#define TTPOST_H
#include <freetype/config/ftconfig.h>
#include <freetype/internal/tttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TT_Err_Invalid_Post_Table_Format 0x0B00
#define TT_Err_Invalid_Post_Table 0x0B01
LOCAL_DEF
FT_Error TT_Get_PS_Name( TT_Face face,
FT_UInt index,
FT_String** PSname );
LOCAL_DEF
void TT_Free_Post_Names( TT_Face face );
#ifdef __cplusplus
}
#endif
#endif /* TTPOST_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,65 +0,0 @@
/***************************************************************************/
/* */
/* ttsbit.h */
/* */
/* TrueType and OpenType embedded bitmap support (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTSBIT_H
#define TTSBIT_H
#ifdef FT_FLAT_COMPILE
#include "ttload.h"
#else
#include <sfnt/ttload.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
LOCAL_DEF
FT_Error TT_Load_SBit_Strikes( TT_Face face,
FT_Stream stream );
LOCAL_DEF
void TT_Free_SBit_Strikes( TT_Face face );
LOCAL_DEF
FT_Error TT_Load_SBit_Image( TT_Face face,
FT_Int x_ppem,
FT_Int y_ppem,
FT_UInt glyph_index,
FT_UInt load_flags,
FT_Stream stream,
FT_Bitmap* map,
TT_SBit_Metrics* metrics );
#ifdef __cplusplus
}
#endif
#endif /* TTSBIT_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +0,0 @@
/***************************************************************************/
/* */
/* ftgrays.h */
/* */
/* FreeType smooth renderer declaration */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef FTGRAYS_H
#define FTGRAYS_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _STANDALONE_
#include "ftimage.h"
#else
#include <freetype/ftimage.h>
#endif
/*************************************************************************/
/* */
/* To make ftgrays.h independent from configuration files we check */
/* whether FT_EXPORT_DEF has been defined already. */
/* */
/* On some systems and compilers (Win32 mostly), an extra keyword is */
/* necessary to compile the library as a DLL. */
/* */
#ifndef FT_EXPORT_VAR
#define FT_EXPORT_VAR( x ) extern x
#endif
FT_EXPORT_VAR( FT_Raster_Funcs ) ft_grays_raster;
#ifdef __cplusplus
}
#endif
#endif /* FTGRAYS_H */
/* END */

View File

@@ -1,220 +0,0 @@
/***************************************************************************/
/* */
/* ftsmooth.c */
/* */
/* Anti-aliasing renderer interface (body). */
/* */
/* Copyright 2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftobjs.h>
#include <freetype/ftoutln.h>
#ifdef FT_FLAT_COMPILE
#include "ftsmooth.h"
#include "ftgrays.h"
#else
#include <smooth/ftsmooth.h>
#include <smooth/ftgrays.h>
#endif
/* initialize renderer -- init its raster */
static
FT_Error ft_smooth_init( FT_Renderer render )
{
FT_Library library = FT_MODULE_LIBRARY( render );
render->clazz->raster_class->raster_reset( render->raster,
library->raster_pool,
library->raster_pool_size );
return 0;
}
/* sets render-specific mode */
static
FT_Error ft_smooth_set_mode( FT_Renderer render,
FT_ULong mode_tag,
FT_Pointer data )
{
/* we simply pass it to the raster */
return render->clazz->raster_class->raster_set_mode( render->raster,
mode_tag,
data );
}
/* transform a given glyph image */
static
FT_Error ft_smooth_transform( FT_Renderer render,
FT_GlyphSlot slot,
FT_Matrix* matrix,
FT_Vector* delta )
{
FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
if ( matrix )
FT_Outline_Transform( &slot->outline, matrix );
if ( delta )
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
Exit:
return error;
}
/* return the glyph's control box */
static
void ft_smooth_get_cbox( FT_Renderer render,
FT_GlyphSlot slot,
FT_BBox* cbox )
{
MEM_Set( cbox, 0, sizeof ( *cbox ) );
if ( slot->format == render->glyph_format )
FT_Outline_Get_CBox( &slot->outline, cbox );
}
/* convert a slot's glyph image into a bitmap */
static
FT_Error ft_smooth_render( FT_Renderer render,
FT_GlyphSlot slot,
FT_UInt mode,
FT_Vector* origin )
{
FT_Error error;
FT_Outline* outline;
FT_BBox cbox;
FT_UInt width, height, pitch;
FT_Bitmap* bitmap;
FT_Memory memory;
FT_Raster_Params params;
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
/* check mode */
if ( mode != ft_render_mode_normal )
return FT_Err_Cannot_Render_Glyph;
outline = &slot->outline;
/* translate the outline to the new origin if needed */
if ( origin )
FT_Outline_Translate( outline, origin->x, origin->y );
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox );
cbox.xMin &= -64;
cbox.yMin &= -64;
cbox.xMax = ( cbox.xMax + 63 ) & -64;
cbox.yMax = ( cbox.yMax + 63 ) & -64;
width = ( cbox.xMax - cbox.xMin ) >> 6;
height = ( cbox.yMax - cbox.yMin ) >> 6;
bitmap = &slot->bitmap;
memory = render->root.memory;
/* release old bitmap buffer */
if ( slot->flags & ft_glyph_own_bitmap )
{
FREE( bitmap->buffer );
slot->flags &= ~ft_glyph_own_bitmap;
}
/* allocate new one, depends on pixel format */
pitch = width;
bitmap->pixel_mode = ft_pixel_mode_grays;
bitmap->num_grays = 256;
bitmap->width = width;
bitmap->rows = height;
bitmap->pitch = pitch;
if ( ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
goto Exit;
slot->flags |= ft_glyph_own_bitmap;
/* translate outline to render it into the bitmap */
FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin );
/* set up parameters */
params.target = bitmap;
params.source = outline;
params.flags = ft_raster_flag_aa;
/* render outline into the bitmap */
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
slot->format = ft_glyph_format_bitmap;
slot->bitmap_left = cbox.xMin >> 6;
slot->bitmap_top = cbox.yMax >> 6;
Exit:
return error;
}
const FT_Renderer_Class ft_smooth_renderer_class =
{
{
ft_module_renderer,
sizeof( FT_RendererRec ),
"smooth",
0x10000L,
0x20000L,
0, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
},
ft_glyph_format_outline,
(FTRenderer_render) ft_smooth_render,
(FTRenderer_transform)ft_smooth_transform,
(FTRenderer_getCBox) ft_smooth_get_cbox,
(FTRenderer_setMode) ft_smooth_set_mode,
(FT_Raster_Funcs*) &ft_grays_raster
};
/* END */

View File

@@ -1,35 +0,0 @@
/***************************************************************************/
/* */
/* ftsmooth.h */
/* */
/* Anti-aliasing renderer interface (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef FTSMOOTH_H
#define FTSMOOTH_H
#include <freetype/ftrender.h>
#ifndef FT_CONFIG_OPTION_NO_STD_RASTER
FT_EXPORT_VAR( const FT_Renderer_Class ) ft_std_renderer_class;
#endif
#ifndef FT_CONFIG_OPTION_NO_SMOOTH_RASTER
FT_EXPORT_VAR( const FT_Renderer_Class ) ft_smooth_renderer_class;
#endif
#endif /* FTSMOOTH_H */
/* END */

View File

@@ -1,7 +0,0 @@
make_module_list: add_smooth_renderer
add_smooth_renderer:
$(OPEN_DRIVER)ft_smooth_renderer_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)smooth $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer$(ECHO_DRIVER_DONE)
# EOF

View File

@@ -1,69 +0,0 @@
#
# FreeType 2 renderer module build rules
#
# Copyright 1996-2000 by
# 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.
# smooth driver directory
#
SMOOTH_DIR := $(SRC_)smooth
SMOOTH_DIR_ := $(SMOOTH_DIR)$(SEP)
# compilation flags for the driver
#
SMOOTH_COMPILE := $(FT_COMPILE)
# smooth driver sources (i.e., C files)
#
SMOOTH_DRV_SRC := $(SMOOTH_DIR_)ftgrays.c \
$(SMOOTH_DIR_)ftsmooth.c
# smooth driver headers
#
SMOOTH_DRV_H := $(SMOOTH_DRV_SRC:%c=%h)
# smooth driver object(s)
#
# SMOOTH_DRV_OBJ_M is used during `multi' builds.
# SMOOTH_DRV_OBJ_S is used during `single' builds.
#
SMOOTH_DRV_OBJ_M := $(SMOOTH_DRV_SRC:$(SMOOTH_DIR_)%.c=$(OBJ_)%.$O)
SMOOTH_DRV_OBJ_S := $(OBJ_)smooth.$O
# smooth driver source file for single build
#
SMOOTH_DRV_SRC_S := $(SMOOTH_DIR_)smooth.c
# smooth driver - single object
#
$(SMOOTH_DRV_OBJ_S): $(SMOOTH_DRV_SRC_S) $(SMOOTH_DRV_SRC) \
$(FREETYPE_H) $(SMOOTH_DRV_H)
$(SMOOTH_COMPILE) $T$@ $(SMOOTH_DRV_SRC_S)
# smooth driver - multiple objects
#
$(OBJ_)%.$O: $(SMOOTH_DIR_)%.c $(FREETYPE_H) $(SMOOTH_DRV_H)
$(SMOOTH_COMPILE) $T$@ $<
# update main driver object lists
#
DRV_OBJS_S += $(SMOOTH_DRV_OBJ_S)
DRV_OBJS_M += $(SMOOTH_DRV_OBJ_M)
# EOF

View File

@@ -1,35 +0,0 @@
/***************************************************************************/
/* */
/* smooth.c */
/* */
/* FreeType anti-aliasing rasterer module component (body only). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
#include "ftgrays.c"
#include "ftsmooth.c"
#else
#include <smooth/ftgrays.c>
#include <smooth/ftsmooth.c>
#endif
/* END */

View File

@@ -1,7 +0,0 @@
make_module_list: add_truetype_driver
add_truetype_driver:
$(OPEN_DRIVER)tt_driver_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)truetype $(ECHO_DRIVER_DESC)Windows/Mac font files with extension *.ttf or *.ttc$(ECHO_DRIVER_DONE)
# EOF

View File

@@ -1,70 +0,0 @@
#
# FreeType 2 TrueType driver configuration rules
#
# Copyright 1996-2000 by
# 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.
# TrueType driver directory
#
TT_DIR := $(SRC_)truetype
TT_DIR_ := $(TT_DIR)$(SEP)
# compilation flags for the driver
#
TT_COMPILE := $(FT_COMPILE)
# TrueType driver sources (i.e., C files)
#
TT_DRV_SRC := $(TT_DIR_)ttobjs.c \
$(TT_DIR_)ttpload.c \
$(TT_DIR_)ttgload.c \
$(TT_DIR_)ttinterp.c \
$(TT_DIR_)ttdriver.c
# TrueType driver headers
#
TT_DRV_H := $(TT_DRV_SRC:%.c=%.h)
# TrueType driver object(s)
#
# TT_DRV_OBJ_M is used during `multi' builds
# TT_DRV_OBJ_S is used during `single' builds
#
TT_DRV_OBJ_M := $(TT_DRV_SRC:$(TT_DIR_)%.c=$(OBJ_)%.$O)
TT_DRV_OBJ_S := $(OBJ_)truetype.$O
# TrueType driver source file for single build
#
TT_DRV_SRC_S := $(TT_DIR_)truetype.c
# TrueType driver - single object
#
$(TT_DRV_OBJ_S): $(TT_DRV_SRC_S) $(TT_DRV_SRC) $(FREETYPE_H) $(TT_DRV_H)
$(TT_COMPILE) $T$@ $(TT_DRV_SRC_S)
# driver - multiple objects
#
$(OBJ_)%.$O: $(TT_DIR_)%.c $(FREETYPE_H) $(TT_DRV_H)
$(TT_COMPILE) $T$@ $<
# update main driver object lists
#
DRV_OBJS_S += $(TT_DRV_OBJ_S)
DRV_OBJS_M += $(TT_DRV_OBJ_M)
# EOF

View File

@@ -1,47 +0,0 @@
/***************************************************************************/
/* */
/* truetype.c */
/* */
/* FreeType TrueType driver component (body only). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
#include "ttdriver.c" /* driver interface */
#include "ttpload.c" /* tables loader */
#include "ttgload.c" /* glyph loader */
#include "ttobjs.c" /* object manager */
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include "ttinterp.c" /* bytecode interpreter */
#endif
#else /* FT_FLAT_COMPILE */
#include <truetype/ttdriver.c> /* driver interface */
#include <truetype/ttpload.c> /* tables loader */
#include <truetype/ttgload.c> /* glyph loader */
#include <truetype/ttobjs.c> /* object manager */
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include <truetype/ttinterp.c> /* bytecode interpreter */
#endif
#endif /* FT_FLAT_COMPILE */
/* END */

View File

@@ -1,511 +0,0 @@
/***************************************************************************/
/* */
/* ttdriver.c */
/* */
/* TrueType font driver implementation (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/sfnt.h>
#include <freetype/ttnameid.h>
#ifdef FT_FLAT_COMPILE
#include "ttdriver.h"
#include "ttgload.h"
#else
#include <truetype/ttdriver.h>
#include <truetype/ttgload.h>
#endif
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_ttdriver
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** F A C E S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#undef PAIR_TAG
#define PAIR_TAG( left, right ) ( ( (FT_ULong)left << 16 ) | \
(FT_ULong)right )
/*************************************************************************/
/* */
/* <Function> */
/* Get_Kerning */
/* */
/* <Description> */
/* A driver method used to return the kerning vector between two */
/* glyphs of the same face. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* left_glyph :: The index of the left glyph in the kern pair. */
/* */
/* right_glyph :: The index of the right glyph in the kern pair. */
/* */
/* <Output> */
/* kerning :: The kerning vector. This is in font units for */
/* scalable formats, and in pixels for fixed-sizes */
/* formats. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only horizontal layouts (left-to-right & right-to-left) are */
/* supported by this function. Other layouts, or more sophisticated */
/* kernings, are out of scope of this method (the basic driver */
/* interface is meant to be simple). */
/* */
/* They can be implemented by format-specific interfaces. */
/* */
static
FT_Error Get_Kerning( TT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
{
TT_Kern_0_Pair* pair;
if ( !face )
return TT_Err_Invalid_Face_Handle;
kerning->x = 0;
kerning->y = 0;
if ( face->kern_pairs )
{
/* there are some kerning pairs in this font file! */
FT_ULong search_tag = PAIR_TAG( left_glyph, right_glyph );
FT_Long left, right;
left = 0;
right = face->num_kern_pairs - 1;
while ( left <= right )
{
FT_Int middle = left + ( ( right - left ) >> 1 );
FT_ULong cur_pair;
pair = face->kern_pairs + middle;
cur_pair = PAIR_TAG( pair->left, pair->right );
if ( cur_pair == search_tag )
goto Found;
if ( cur_pair < search_tag )
left = middle + 1;
else
right = middle - 1;
}
}
Exit:
return TT_Err_Ok;
Found:
kerning->x = pair->value;
goto Exit;
}
#undef PAIR_TAG
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** S I Z E S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* Set_Char_Sizes */
/* */
/* <Description> */
/* A driver method used to reset a size's character sizes (horizontal */
/* and vertical) expressed in fractional points. */
/* */
/* <Input> */
/* char_width :: The character width expressed in 26.6 */
/* fractional points. */
/* */
/* char_height :: The character height expressed in 26.6 */
/* fractional points. */
/* */
/* horz_resolution :: The horizontal resolution of the output device. */
/* */
/* vert_resolution :: The vertical resolution of the output device. */
/* */
/* <InOut> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static
FT_Error Set_Char_Sizes( TT_Size size,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
FT_UInt horz_resolution,
FT_UInt vert_resolution )
{
FT_Size_Metrics* metrics = &size->root.metrics;
TT_Face face = (TT_Face)size->root.face;
FT_Long dim_x, dim_y;
/* This bit flag, when set, indicates that the pixel size must be */
/* truncated to an integer. Nearly all TrueType fonts have this */
/* bit set, as hinting won't work really well otherwise. */
/* */
/* However, for those rare fonts who do not set it, we override */
/* the default computations performed by the base layer. I */
/* really don't know whether this is useful, but hey, that's the */
/* spec :-) */
/* */
if ( ( face->header.Flags & 8 ) == 0 )
{
/* Compute pixel sizes in 26.6 units */
dim_x = ( char_width * horz_resolution ) / 72;
dim_y = ( char_height * vert_resolution ) / 72;
metrics->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
metrics->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
metrics->x_ppem = (FT_UShort)( dim_x >> 6 );
metrics->y_ppem = (FT_UShort)( dim_y >> 6 );
}
size->ttmetrics.valid = FALSE;
return TT_Reset_Size( size );
}
/*************************************************************************/
/* */
/* <Function> */
/* Set_Pixel_Sizes */
/* */
/* <Description> */
/* A driver method used to reset a size's character sizes (horizontal */
/* and vertical) expressed in integer pixels. */
/* */
/* <Input> */
/* pixel_width :: The character width expressed in integer pixels. */
/* */
/* pixel_height :: The character height expressed in integer pixels. */
/* */
/* <InOut> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static
FT_Error Set_Pixel_Sizes( TT_Size size,
FT_UInt pixel_width,
FT_UInt pixel_height )
{
FT_UNUSED( pixel_width );
FT_UNUSED( pixel_height );
/* many things have been pre-computed by the base layer */
size->ttmetrics.valid = FALSE;
return TT_Reset_Size( size );
}
/*************************************************************************/
/* */
/* <Function> */
/* Load_Glyph */
/* */
/* <Description> */
/* A driver method used to load a glyph within a given glyph slot. */
/* */
/* <Input> */
/* slot :: A handle to the target slot object where the glyph */
/* will be loaded. */
/* */
/* size :: A handle to the source face size at which the glyph */
/* must be scaled, loaded, etc. */
/* */
/* glyph_index :: The index of the glyph in the font file. */
/* */
/* load_flags :: A flag indicating what to load for this glyph. The */
/* FTLOAD_??? constants can be used to control the */
/* glyph loading process (e.g., whether the outline */
/* should be scaled, whether to load bitmaps or not, */
/* whether to hint the outline, etc). */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static
FT_Error Load_Glyph( TT_GlyphSlot slot,
TT_Size size,
FT_UShort glyph_index,
FT_UInt load_flags )
{
FT_Error error;
if ( !slot )
return TT_Err_Invalid_Glyph_Handle;
/* check whether we want a scaled outline or bitmap */
if ( !size )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
if ( load_flags & FT_LOAD_NO_SCALE )
size = NULL;
/* reset the size object if necessary */
if ( size )
{
/* these two object must have the same parent */
if ( size->root.face != slot->face )
return TT_Err_Invalid_Face_Handle;
if ( !size->ttmetrics.valid )
{
if ( FT_SET_ERROR( TT_Reset_Size( size ) ) )
return error;
}
}
/* now load the glyph outline if necessary */
error = TT_Load_Glyph( size, slot, glyph_index, load_flags );
/* force drop-out mode to 2 - irrelevant now */
/* slot->outline.dropout_mode = 2; */
return error;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** C H A R A C T E R M A P P I N G S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* Get_Char_Index */
/* */
/* <Description> */
/* Uses a charmap to return a given character code's glyph index. */
/* */
/* <Input> */
/* charmap :: A handle to the source charmap object. */
/* charcode :: The character code. */
/* */
/* <Return> */
/* Glyph index. 0 means `undefined character code'. */
/* */
static
FT_UInt Get_Char_Index( TT_CharMap charmap,
FT_Long charcode )
{
FT_Error error;
TT_Face face;
TT_CMapTable* cmap;
cmap = &charmap->cmap;
face = (TT_Face)charmap->root.face;
/* Load table if needed */
if ( !cmap->loaded )
{
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
error = sfnt->load_charmap( face, cmap, face->root.stream );
if ( error )
return 0;
cmap->loaded = TRUE;
}
if ( cmap->get_index )
return cmap->get_index( cmap, charcode );
else
return 0;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** D R I V E R I N T E R F A C E ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
static
FT_Module_Interface tt_get_interface( TT_Driver driver,
const char* interface )
{
FT_Module sfntd = FT_Get_Module( driver->root.root.library,
"sfnt" );
SFNT_Interface* sfnt;
/* only return the default interface from the SFNT module */
if ( sfntd )
{
sfnt = (SFNT_Interface*)( sfntd->clazz->module_interface );
if ( sfnt )
return sfnt->get_interface( FT_MODULE( driver ), interface );
}
return 0;
}
/* The FT_DriverInterface structure is defined in ftdriver.h. */
const FT_Driver_Class tt_driver_class =
{
{
ft_module_font_driver |
ft_module_driver_scalable |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
ft_module_driver_has_hinter,
#else
0,
#endif
sizeof ( TT_DriverRec ),
"truetype", /* driver name */
0x10000L, /* driver version == 1.0 */
0x20000L, /* driver requires FreeType 2.0 or above */
(void*)0, /* driver specific interface */
(FT_Module_Constructor)TT_Init_Driver,
(FT_Module_Destructor) TT_Done_Driver,
(FT_Module_Requester) tt_get_interface,
},
sizeof ( TT_FaceRec ),
sizeof ( TT_SizeRec ),
sizeof ( FT_GlyphSlotRec ),
(FTDriver_initFace) TT_Init_Face,
(FTDriver_doneFace) TT_Done_Face,
(FTDriver_initSize) TT_Init_Size,
(FTDriver_doneSize) TT_Done_Size,
(FTDriver_initGlyphSlot)0,
(FTDriver_doneGlyphSlot)0,
(FTDriver_setCharSizes) Set_Char_Sizes,
(FTDriver_setPixelSizes)Set_Pixel_Sizes,
(FTDriver_loadGlyph) Load_Glyph,
(FTDriver_getCharIndex) Get_Char_Index,
(FTDriver_getKerning) Get_Kerning,
(FTDriver_attachFile) 0,
(FTDriver_getAdvances) 0
};
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
/*************************************************************************/
/* */
/* <Function> */
/* getDriverInterface */
/* */
/* <Description> */
/* This function is used when compiling the TrueType driver as a */
/* shared library (`.DLL' or `.so'). It will be used by the */
/* high-level library of FreeType to retrieve the address of the */
/* driver's generic interface. */
/* */
/* It shouldn't be implemented in a static build, as each driver must */
/* have the same function as an exported entry point. */
/* */
/* <Return> */
/* The address of the TrueType's driver generic interface. The */
/* format-specific interface can then be retrieved through the method */
/* interface->get_format_interface. */
/* */
EXPORT_FUNC( const FT_Driver_Class* ) getDriverClass( void )
{
return &tt_driver_class;
}
#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
/* END */

View File

@@ -1,31 +0,0 @@
/***************************************************************************/
/* */
/* ttdriver.h */
/* */
/* High-level TrueType driver interface (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTDRIVER_H
#define TTDRIVER_H
#include <freetype/internal/ftdriver.h>
FT_EXPORT_VAR( const FT_Driver_Class ) tt_driver_class;
#endif /* TTDRIVER_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,69 +0,0 @@
/***************************************************************************/
/* */
/* ttgload.h */
/* */
/* TrueType Glyph Loader (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTGLOAD_H
#define TTGLOAD_H
#ifdef FT_FLAT_COMPILE
#include "ttobjs.h"
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include "ttinterp.h"
#endif
#else /* FT_FLAT_COMPILE */
#include <truetype/ttobjs.h>
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include <truetype/ttinterp.h>
#endif
#endif /* FT_FLAT_COMPILE */
#ifdef __cplusplus
extern "C" {
#endif
LOCAL_DEF
void TT_Get_Metrics( TT_HoriHeader* header,
FT_UInt index,
FT_Short* bearing,
FT_UShort* advance );
LOCAL_DEF
void TT_Init_Glyph_Loading( TT_Face face );
LOCAL_DEF
FT_Error TT_Load_Glyph( TT_Size size,
TT_GlyphSlot glyph,
FT_UShort glyph_index,
FT_UInt load_flags );
#ifdef __cplusplus
}
#endif
#endif /* TTGLOAD_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,278 +0,0 @@
/***************************************************************************/
/* */
/* ttinterp.h */
/* */
/* TrueType bytecode interpreter (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTINTERP_H
#define TTINTERP_H
#ifdef FT_FLAT_COMPILE
#include "ttobjs.h"
#else
#include <truetype/ttobjs.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef TT_CONFIG_OPTION_STATIC_INTEPRETER /* indirect implementation */
#define EXEC_OP_ TT_ExecContext exc,
#define EXEC_OP TT_ExecContext exc
#define EXEC_ARG_ exc,
#define EXEC_ARG exc
#else /* static implementation */
#define EXEC_OP_ /* void */
#define EXEC_OP /* void */
#define EXEC_ARG_ /* void */
#define EXEC_ARG /* void */
#endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */
/*************************************************************************/
/* */
/* Rounding mode constants. */
/* */
#define TT_Round_Off 5
#define TT_Round_To_Half_Grid 0
#define TT_Round_To_Grid 1
#define TT_Round_To_Double_Grid 2
#define TT_Round_Up_To_Grid 4
#define TT_Round_Down_To_Grid 3
#define TT_Round_Super 6
#define TT_Round_Super_45 7
/*************************************************************************/
/* */
/* Function types used by the interpreter, depending on various modes */
/* (e.g. the rounding mode, whether to render a vertical or horizontal */
/* line etc). */
/* */
/*************************************************************************/
/* Rounding function */
typedef FT_F26Dot6 (*TT_Round_Func)( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation );
/* Point displacement along the freedom vector routine */
typedef void (*TT_Move_Func)( EXEC_OP_ TT_GlyphZone* zone,
FT_UInt point,
FT_F26Dot6 distance );
/* Distance projection along one of the projection vectors */
typedef FT_F26Dot6 (*TT_Project_Func)( EXEC_OP_ FT_Vector* v1,
FT_Vector* v2 );
/* reading a cvt value. Take care of non-square pixels if necessary */
typedef FT_F26Dot6 (*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong index );
/* setting or moving a cvt value. Take care of non-square pixels */
/* if necessary */
typedef void (*TT_Set_CVT_Func)( EXEC_OP_ FT_ULong index,
FT_F26Dot6 value );
/*************************************************************************/
/* */
/* This structure defines a call record, used to manage function calls. */
/* */
typedef struct TT_CallRec_
{
FT_Int Caller_Range;
FT_Long Caller_IP;
FT_Long Cur_Count;
FT_Long Cur_Restart;
} TT_CallRec, *TT_CallStack;
/*************************************************************************/
/* */
/* The main structure for the interpreter which collects all necessary */
/* variables and states. */
/* */
typedef struct TT_ExecContextRec_
{
TT_Face face;
TT_Size size;
FT_Memory memory;
/* instructions state */
FT_Error error; /* last execution error */
FT_Long top; /* top of exec. stack */
FT_UInt stackSize; /* size of exec. stack */
FT_Long* stack; /* current exec. stack */
FT_Long args;
FT_UInt new_top; /* new top after exec. */
TT_GlyphZone zp0, /* zone records */
zp1,
zp2,
pts,
twilight;
FT_Size_Metrics metrics;
TT_Size_Metrics tt_metrics; /* size metrics */
TT_GraphicsState GS; /* current graphics state */
FT_Int curRange; /* current code range number */
FT_Byte* code; /* current code range */
FT_Long IP; /* current instruction pointer */
FT_Long codeSize; /* size of current range */
FT_Byte opcode; /* current opcode */
FT_Int length; /* length of current opcode */
FT_Bool step_ins; /* true if the interpreter must */
/* increment IP after ins. exec */
FT_Long cvtSize;
FT_Long* cvt;
FT_UInt glyphSize; /* glyph instructions buffer size */
FT_Byte* glyphIns; /* glyph instructions buffer */
FT_UInt numFDefs; /* number of function defs */
FT_UInt maxFDefs; /* maximum number of function defs */
TT_DefArray FDefs; /* table of FDefs entries */
FT_UInt numIDefs; /* number of instruction defs */
FT_UInt maxIDefs; /* maximum number of ins defs */
TT_DefArray IDefs; /* table of IDefs entries */
FT_UInt maxFunc; /* maximum function index */
FT_UInt maxIns; /* maximum instruction index */
FT_Int callTop, /* top of call stack during execution */
callSize; /* size of call stack */
TT_CallStack callStack; /* call stack */
FT_UShort maxPoints; /* capacity of this context's `pts' */
FT_Short maxContours; /* record, expressed in points and */
/* contours. */
TT_CodeRangeTable codeRangeTable; /* table of valid code ranges */
/* useful for the debugger */
FT_UShort storeSize; /* size of current storage */
FT_Long* storage; /* storage area */
FT_F26Dot6 period; /* values used for the */
FT_F26Dot6 phase; /* `SuperRounding' */
FT_F26Dot6 threshold;
#if 0
/* this seems to be unused */
FT_Int cur_ppem; /* ppem along the current proj vector */
#endif
FT_Bool instruction_trap; /* If `True', the interpreter will */
/* exit after each instruction */
TT_GraphicsState default_GS; /* graphics state resulting from */
/* the prep program */
FT_Bool is_composite; /* true if the glyph is composite */
FT_Bool pedantic_hinting; /* true for pedantic interpretation */
/* latest interpreter additions */
FT_Long F_dot_P; /* dot product of freedom and projection */
/* vectors */
TT_Round_Func func_round; /* current rounding function */
TT_Project_Func func_project, /* current projection function */
func_dualproj, /* current dual proj. function */
func_freeProj; /* current freedom proj. func */
TT_Move_Func func_move; /* current point move function */
TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */
TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
FT_ULong loadSize;
TT_SubGlyph_Stack loadStack; /* loading subglyph stack */
} TT_ExecContextRec;
extern const TT_GraphicsState tt_default_graphics_state;
LOCAL_DEF
FT_Error TT_Goto_CodeRange( TT_ExecContext exec,
FT_Int range,
FT_Long IP );
LOCAL_DEF
FT_Error TT_Set_CodeRange( TT_ExecContext exec,
FT_Int range,
void* base,
FT_Long length );
LOCAL_DEF
FT_Error TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range );
FT_EXPORT_DEF( TT_ExecContext ) TT_New_Context( TT_Face face );
LOCAL_DEF
FT_Error TT_Done_Context( TT_ExecContext exec );
LOCAL_DEF
FT_Error TT_Destroy_Context( TT_ExecContext exec,
FT_Memory memory );
LOCAL_DEF
FT_Error TT_Load_Context( TT_ExecContext exec,
TT_Face face,
TT_Size size );
LOCAL_DEF
FT_Error TT_Save_Context( TT_ExecContext exec,
TT_Size ins );
LOCAL_DEF
FT_Error TT_Run_Context( TT_ExecContext exec,
FT_Bool debug );
FT_EXPORT_DEF( FT_Error ) TT_RunIns( TT_ExecContext exec );
#ifdef __cplusplus
}
#endif
#endif /* TTINTERP_H */
/* END */

View File

@@ -1,734 +0,0 @@
/***************************************************************************/
/* */
/* ttobjs.c */
/* */
/* Objects manager (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftstream.h>
#include <freetype/ttnameid.h>
#include <freetype/tttags.h>
#include <freetype/internal/sfnt.h>
#include <freetype/internal/psnames.h>
#ifdef FT_FLAT_COMPILE
#include "ttgload.h"
#include "ttpload.h"
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include "ttinterp.h"
#endif
#else /* FT_FLAT_COMPILE */
#include <truetype/ttgload.h>
#include <truetype/ttpload.h>
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include <truetype/ttinterp.h>
#endif
#endif /* FT_FLAT_COMPILE */
#include <freetype/internal/tterrors.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_ttobjs
/*************************************************************************/
/* */
/* GLYPH ZONE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_GlyphZone */
/* */
/* <Description> */
/* Deallocates a glyph zone. */
/* */
/* <Input> */
/* zone :: A pointer to the target glyph zone. */
/* */
LOCAL_FUNC
void TT_Done_GlyphZone( TT_GlyphZone* zone )
{
FT_Memory memory = zone->memory;
FREE( zone->contours );
FREE( zone->tags );
FREE( zone->cur );
FREE( zone->org );
zone->max_points = zone->n_points = 0;
zone->max_contours = zone->n_contours = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_New_GlyphZone */
/* */
/* <Description> */
/* Allocates a new glyph zone. */
/* */
/* <Input> */
/* memory :: A handle to the current memory object. */
/* */
/* maxPoints :: The capacity of glyph zone in points. */
/* */
/* maxContours :: The capacity of glyph zone in contours. */
/* */
/* <Output> */
/* zone :: A pointer to the target glyph zone record. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_New_GlyphZone( FT_Memory memory,
FT_UShort maxPoints,
FT_Short maxContours,
TT_GlyphZone* zone )
{
FT_Error error;
if ( maxPoints > 0 )
maxPoints += 2;
MEM_Set( zone, 0, sizeof ( *zone ) );
zone->memory = memory;
if ( ALLOC_ARRAY( zone->org, maxPoints * 2, FT_F26Dot6 ) ||
ALLOC_ARRAY( zone->cur, maxPoints * 2, FT_F26Dot6 ) ||
ALLOC_ARRAY( zone->tags, maxPoints, FT_Byte ) ||
ALLOC_ARRAY( zone->contours, maxContours, FT_UShort ) )
{
TT_Done_GlyphZone( zone );
}
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Init_Face */
/* */
/* <Description> */
/* Initializes a given TrueType face object. */
/* */
/* <Input> */
/* stream :: The source font stream. */
/* */
/* face_index :: The index of the font face in the resource. */
/* */
/* num_params :: Number of additional generic parameters. Ignored. */
/* */
/* params :: Additional generic parameters. Ignored. */
/* */
/* <InOut> */
/* face :: The newly built face object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_DEF
FT_Error TT_Init_Face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
FT_Library library;
SFNT_Interface* sfnt;
library = face->root.driver->root.library;
sfnt = (SFNT_Interface*)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
goto Bad_Format;
/* create input stream from resource */
if ( FILE_Seek( 0 ) )
goto Exit;
/* check that we have a valid TrueType file */
error = sfnt->init_face( stream, face, face_index, num_params, params );
if ( error )
goto Exit;
/* We must also be able to accept Mac/GX fonts, as well as OT ones */
if ( face->format_tag != 0x00010000L && /* MS fonts */
face->format_tag != TTAG_true ) /* Mac fonts */
{
FT_TRACE2(( "[not a valid TTF font]\n" ));
goto Bad_Format;
}
/* If we are performing a simple font format check, exit immediately */
if ( face_index < 0 )
return TT_Err_Ok;
/* Load font directory */
error = sfnt->load_face( stream, face, face_index, num_params, params );
if ( error )
goto Exit;
error = TT_Load_Locations( face, stream ) ||
TT_Load_CVT ( face, stream ) ||
TT_Load_Programs ( face, stream );
/* initialize standard glyph loading routines */
TT_Init_Glyph_Loading( face );
Exit:
return error;
Bad_Format:
error = FT_Err_Unknown_File_Format;
goto Exit;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_Face */
/* */
/* <Description> */
/* Finalizes a given face object. */
/* */
/* <Input> */
/* face :: A pointer to the face object to destroy. */
/* */
LOCAL_DEF
void TT_Done_Face( TT_Face face )
{
FT_Memory memory = face->root.memory;
FT_Stream stream = face->root.stream;
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
/* for `extended TrueType formats' (i.e. compressed versions) */
if ( face->extra.finalizer )
face->extra.finalizer( face->extra.data );
if ( sfnt )
sfnt->done_face( face );
/* freeing the locations table */
FREE( face->glyph_locations );
face->num_locations = 0;
/* freeing the CVT */
FREE( face->cvt );
face->cvt_size = 0;
/* freeing the programs */
RELEASE_Frame( face->font_program );
RELEASE_Frame( face->cvt_program );
face->font_program_size = 0;
face->cvt_program_size = 0;
}
/*************************************************************************/
/* */
/* SIZE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* TT_Init_Size */
/* */
/* <Description> */
/* Initializes a new TrueType size object. */
/* */
/* <InOut> */
/* size :: A handle to the size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_DEF
FT_Error TT_Init_Size( TT_Size size )
{
FT_Error error = TT_Err_Ok;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
TT_Face face = (TT_Face)size->root.face;
FT_Memory memory = face->root.memory;
FT_Int i;
TT_ExecContext exec;
FT_UShort n_twilight;
TT_MaxProfile* maxp = &face->max_profile;
size->ttmetrics.valid = FALSE;
size->max_function_defs = maxp->maxFunctionDefs;
size->max_instruction_defs = maxp->maxInstructionDefs;
size->num_function_defs = 0;
size->num_instruction_defs = 0;
size->max_func = 0;
size->max_ins = 0;
size->cvt_size = face->cvt_size;
size->storage_size = maxp->maxStorage;
/* Set default metrics */
{
FT_Size_Metrics* metrics = &size->root.metrics;
TT_Size_Metrics* metrics2 = &size->ttmetrics;
metrics->x_ppem = 0;
metrics->y_ppem = 0;
metrics2->rotated = FALSE;
metrics2->stretched = FALSE;
/* set default compensation (all 0) */
for ( i = 0; i < 4; i++ )
metrics2->compensations[i] = 0;
}
/* allocate function defs, instruction defs, cvt, and storage area */
if ( ALLOC_ARRAY( size->function_defs,
size->max_function_defs,
TT_DefRecord ) ||
ALLOC_ARRAY( size->instruction_defs,
size->max_instruction_defs,
TT_DefRecord ) ||
ALLOC_ARRAY( size->cvt,
size->cvt_size, FT_Long ) ||
ALLOC_ARRAY( size->storage,
size->storage_size, FT_Long ) )
goto Fail_Memory;
/* reserve twilight zone */
n_twilight = maxp->maxTwilightPoints;
error = TT_New_GlyphZone( memory, n_twilight, 0, &size->twilight );
if ( error )
goto Fail_Memory;
size->twilight.n_points = n_twilight;
/* set `face->interpreter' according to the debug hook present */
{
FT_Library library = face->root.driver->root.library;
face->interpreter = (TT_Interpreter)
library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
if ( !face->interpreter )
face->interpreter = (TT_Interpreter)TT_RunIns;
}
/* Fine, now execute the font program! */
exec = size->context;
/* size objects used during debugging have their own context */
if ( !size->debug )
exec = TT_New_Context( face );
if ( !exec )
{
error = TT_Err_Could_Not_Find_Context;
goto Fail_Memory;
}
size->GS = tt_default_graphics_state;
TT_Load_Context( exec, face, size );
exec->callTop = 0;
exec->top = 0;
exec->period = 64;
exec->phase = 0;
exec->threshold = 0;
{
FT_Size_Metrics* metrics = &exec->metrics;
TT_Size_Metrics* tt_metrics = &exec->tt_metrics;
metrics->x_ppem = 0;
metrics->y_ppem = 0;
metrics->x_scale = 0;
metrics->y_scale = 0;
tt_metrics->ppem = 0;
tt_metrics->scale = 0;
tt_metrics->ratio = 0x10000L;
}
exec->instruction_trap = FALSE;
exec->cvtSize = size->cvt_size;
exec->cvt = size->cvt;
exec->F_dot_P = 0x10000L;
/* allow font program execution */
TT_Set_CodeRange( exec,
tt_coderange_font,
face->font_program,
face->font_program_size );
/* disable CVT and glyph programs coderange */
TT_Clear_CodeRange( exec, tt_coderange_cvt );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
if ( face->font_program_size > 0 )
{
error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
if ( !error )
error = face->interpreter( exec );
if ( error )
goto Fail_Exec;
}
else
error = TT_Err_Ok;
TT_Save_Context( exec, size );
if ( !size->debug )
TT_Done_Context( exec );
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
size->ttmetrics.valid = FALSE;
return error;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
Fail_Exec:
if ( !size->debug )
TT_Done_Context( exec );
Fail_Memory:
#endif
TT_Done_Size( size );
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_Size */
/* */
/* <Description> */
/* The TrueType size object finalizer. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
LOCAL_FUNC
void TT_Done_Size( TT_Size size )
{
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
FT_Memory memory = size->root.face->memory;
if ( size->debug )
{
/* the debug context must be deleted by the debugger itself */
size->context = NULL;
size->debug = FALSE;
}
FREE( size->cvt );
size->cvt_size = 0;
/* free storage area */
FREE( size->storage );
size->storage_size = 0;
/* twilight zone */
TT_Done_GlyphZone( &size->twilight );
FREE( size->function_defs );
FREE( size->instruction_defs );
size->num_function_defs = 0;
size->max_function_defs = 0;
size->num_instruction_defs = 0;
size->max_instruction_defs = 0;
size->max_func = 0;
size->max_ins = 0;
#endif
size->ttmetrics.valid = FALSE;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Reset_Size */
/* */
/* <Description> */
/* Resets a TrueType size when resolutions and character dimensions */
/* have been changed. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
LOCAL_DEF
FT_Error TT_Reset_Size( TT_Size size )
{
TT_Face face;
FT_Error error = TT_Err_Ok;
FT_Size_Metrics* metrics;
if ( size->ttmetrics.valid )
return TT_Err_Ok;
face = (TT_Face)size->root.face;
metrics = &size->root.metrics;
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
return TT_Err_Invalid_PPem;
/* compute new transformation */
if ( metrics->x_ppem >= metrics->y_ppem )
{
size->ttmetrics.scale = metrics->x_scale;
size->ttmetrics.ppem = metrics->x_ppem;
size->ttmetrics.x_ratio = 0x10000L;
size->ttmetrics.y_ratio = FT_MulDiv( metrics->y_ppem,
0x10000L,
metrics->x_ppem );
}
else
{
size->ttmetrics.scale = metrics->y_scale;
size->ttmetrics.ppem = metrics->y_ppem;
size->ttmetrics.x_ratio = FT_MulDiv( metrics->x_ppem,
0x10000L,
metrics->y_ppem );
size->ttmetrics.y_ratio = 0x10000L;
}
/* Compute root ascender, descender, test height, and max_advance */
metrics->ascender = ( FT_MulFix( face->root.ascender,
metrics->y_scale ) + 32 ) & -64;
metrics->descender = ( FT_MulFix( face->root.descender,
metrics->y_scale ) + 32 ) & -64;
metrics->height = ( FT_MulFix( face->root.height,
metrics->y_scale ) + 32 ) & -64;
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
metrics->x_scale ) + 32 ) & -64;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
{
TT_ExecContext exec;
FT_UInt i, j;
/* Scale the cvt values to the new ppem. */
/* We use by default the y ppem to scale the CVT. */
for ( i = 0; i < size->cvt_size; i++ )
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
/* All twilight points are originally zero */
for ( j = 0; j < size->twilight.n_points; j++ )
{
size->twilight.org[j].x = 0;
size->twilight.org[j].y = 0;
size->twilight.cur[j].x = 0;
size->twilight.cur[j].y = 0;
}
/* clear storage area */
for ( i = 0; i < size->storage_size; i++ )
size->storage[i] = 0;
size->GS = tt_default_graphics_state;
/* get execution context and run prep program */
if ( size->debug )
exec = size->context;
else
exec = TT_New_Context( face );
/* debugging instances have their own context */
if ( !exec )
return TT_Err_Could_Not_Find_Context;
TT_Load_Context( exec, face, size );
TT_Set_CodeRange( exec,
tt_coderange_cvt,
face->cvt_program,
face->cvt_program_size );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
exec->instruction_trap = FALSE;
exec->top = 0;
exec->callTop = 0;
if ( face->cvt_program_size > 0 )
{
error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
if ( error )
goto End;
if ( !size->debug )
error = face->interpreter( exec );
}
else
error = TT_Err_Ok;
size->GS = exec->GS;
/* save default graphics state */
End:
TT_Save_Context( exec, size );
if ( !size->debug )
TT_Done_Context( exec );
/* debugging instances keep their context */
}
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
if ( !error )
size->ttmetrics.valid = TRUE;
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Init_Driver */
/* */
/* <Description> */
/* Initializes a given TrueType driver object. */
/* */
/* <Input> */
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Init_Driver( TT_Driver driver )
{
FT_Error error;
/* set `extra' in glyph loader */
error = FT_GlyphLoader_Create_Extra( FT_DRIVER( driver )->glyph_loader );
/* init extension registry if needed */
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
if ( !error )
return TT_Init_Extensions( driver );
#endif
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_Driver */
/* */
/* <Description> */
/* Finalizes a given TrueType driver. */
/* */
/* <Input> */
/* driver :: A handle to the target TrueType driver. */
/* */
LOCAL_FUNC
void TT_Done_Driver( TT_Driver driver )
{
/* destroy extensions registry if needed */
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
TT_Done_Extensions( driver );
#endif
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
/* destroy the execution context */
if ( driver->context )
{
TT_Destroy_Context( driver->context, driver->root.root.memory );
driver->context = NULL;
}
#endif
}
/* END */

View File

@@ -1,412 +0,0 @@
/***************************************************************************/
/* */
/* ttobjs.h */
/* */
/* Objects manager (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTOBJS_H
#define TTOBJS_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/tttypes.h>
#include <freetype/internal/tterrors.h>
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************/
/* */
/* <Type> */
/* TT_Driver */
/* */
/* <Description> */
/* A handle to a TrueType driver object. */
/* */
typedef struct TT_DriverRec_* TT_Driver;
/*************************************************************************/
/* */
/* <Type> */
/* TT_Instance */
/* */
/* <Description> */
/* A handle to a TrueType size object. */
/* */
typedef struct TT_SizeRec_* TT_Size;
/*************************************************************************/
/* */
/* <Type> */
/* TT_GlyphSlot */
/* */
/* <Description> */
/* A handle to a TrueType glyph slot object. */
/* */
/* <Note> */
/* This is a direct typedef of FT_GlyphSlot, as there is nothing */
/* specific about the TrueType glyph slot. */
/* */
typedef FT_GlyphSlot TT_GlyphSlot;
/*************************************************************************/
/* */
/* <Struct> */
/* TT_GraphicsState */
/* */
/* <Description> */
/* The TrueType graphics state used during bytecode interpretation. */
/* */
typedef struct TT_GraphicsState_
{
FT_UShort rp0;
FT_UShort rp1;
FT_UShort rp2;
FT_UnitVector dualVector;
FT_UnitVector projVector;
FT_UnitVector freeVector;
FT_Long loop;
FT_F26Dot6 minimum_distance;
FT_Int round_state;
FT_Bool auto_flip;
FT_F26Dot6 control_value_cutin;
FT_F26Dot6 single_width_cutin;
FT_F26Dot6 single_width_value;
FT_Short delta_base;
FT_Short delta_shift;
FT_Byte instruct_control;
FT_Bool scan_control;
FT_Int scan_type;
FT_UShort gep0;
FT_UShort gep1;
FT_UShort gep2;
} TT_GraphicsState;
LOCAL_DEF void TT_Done_GlyphZone( TT_GlyphZone* zone );
LOCAL_DEF FT_Error TT_New_GlyphZone( FT_Memory memory,
FT_UShort maxPoints,
FT_Short maxContours,
TT_GlyphZone* zone );
/*************************************************************************/
/* */
/* EXECUTION SUBTABLES */
/* */
/* These sub-tables relate to instruction execution. */
/* */
/*************************************************************************/
#define TT_MAX_CODE_RANGES 3
/*************************************************************************/
/* */
/* There can only be 3 active code ranges at once: */
/* - the Font Program */
/* - the CVT Program */
/* - a glyph's instructions set */
/* */
typedef enum TT_CodeRange_Tag_
{
tt_coderange_none = 0,
tt_coderange_font,
tt_coderange_cvt,
tt_coderange_glyph
} TT_CodeRange_Tag;
typedef struct TT_CodeRange_
{
FT_Byte* base;
FT_ULong size;
} TT_CodeRange;
typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
/*************************************************************************/
/* */
/* Defines a function/instruction definition record. */
/* */
typedef struct TT_DefRecord_
{
FT_Int range; /* in which code range is it located? */
FT_Long start; /* where does it start? */
FT_UInt opc; /* function #, or instruction code */
FT_Bool active; /* is it active? */
} TT_DefRecord, *TT_DefArray;
/*************************************************************************/
/* */
/* Subglyph transformation record. */
/* */
typedef struct TT_Transform_
{
FT_Fixed xx, xy; /* transformation matrix coefficients */
FT_Fixed yx, yy;
FT_F26Dot6 ox, oy; /* offsets */
} TT_Transform;
/*************************************************************************/
/* */
/* Subglyph loading record. Used to load composite components. */
/* */
typedef struct TT_SubglyphRec_
{
FT_Long index; /* subglyph index; initialized with -1 */
FT_Bool is_scaled; /* is the subglyph scaled? */
FT_Bool is_hinted; /* should it be hinted? */
FT_Bool preserve_pps; /* preserve phantom points? */
FT_Long file_offset;
FT_BBox bbox;
FT_Pos left_bearing;
FT_Pos advance;
TT_GlyphZone zone;
FT_Long arg1; /* first argument */
FT_Long arg2; /* second argument */
FT_UShort element_flag; /* current load element flag */
TT_Transform transform; /* transformation matrix */
FT_Vector pp1, pp2; /* phantom points */
} TT_SubGlyphRec, *TT_SubGlyph_Stack;
/*************************************************************************/
/* */
/* A note regarding non-squared pixels: */
/* */
/* (This text will probably go into some docs at some time; for now, it */
/* is kept here to explain some definitions in the TIns_Metrics */
/* record). */
/* */
/* The CVT is a one-dimensional array containing values that control */
/* certain important characteristics in a font, like the height of all */
/* capitals, all lowercase letter, default spacing or stem width/height. */
/* */
/* These values are found in FUnits in the font file, and must be scaled */
/* to pixel coordinates before being used by the CVT and glyph programs. */
/* Unfortunately, when using distinct x and y resolutions (or distinct x */
/* and y pointsizes), there are two possible scalings. */
/* */
/* A first try was to implement a `lazy' scheme where all values were */
/* scaled when first used. However, while some values are always used */
/* in the same direction, some others are used under many different */
/* circumstances and orientations. */
/* */
/* I have found a simpler way to do the same, and it even seems to work */
/* in most of the cases: */
/* */
/* - All CVT values are scaled to the maximum ppem size. */
/* */
/* - When performing a read or write in the CVT, a ratio factor is used */
/* to perform adequate scaling. Example: */
/* */
/* x_ppem = 14 */
/* y_ppem = 10 */
/* */
/* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
/* entries are scaled to it. */
/* */
/* x_ratio = 1.0 */
/* y_ratio = y_ppem/ppem (< 1.0) */
/* */
/* We compute the current ratio like: */
/* */
/* - If projVector is horizontal, */
/* ratio = x_ratio = 1.0 */
/* */
/* - if projVector is vertical, */
/* ratio = y_ratio */
/* */
/* - else, */
/* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
/* */
/* Reading a cvt value returns */
/* ratio * cvt[index] */
/* */
/* Writing a cvt value in pixels: */
/* cvt[index] / ratio */
/* */
/* The current ppem is simply */
/* ratio * ppem */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* Metrics used by the TrueType size and context objects. */
/* */
typedef struct TT_Size_Metrics_
{
/* for non-square pixels */
FT_Long x_ratio;
FT_Long y_ratio;
FT_UShort ppem; /* maximum ppem size */
FT_Long ratio; /* current ratio */
FT_Fixed scale;
FT_F26Dot6 compensations[4]; /* device-specific compensations */
FT_Bool valid;
FT_Bool rotated; /* `is the glyph rotated?'-flag */
FT_Bool stretched; /* `is the glyph stretched?'-flag */
} TT_Size_Metrics;
/*************************************************************************/
/* */
/* TrueType size class. */
/* */
typedef struct TT_SizeRec_
{
FT_SizeRec root;
TT_Size_Metrics ttmetrics;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
FT_UInt num_function_defs; /* number of function definitions */
FT_UInt max_function_defs;
TT_DefArray function_defs; /* table of function definitions */
FT_UInt num_instruction_defs; /* number of ins. definitions */
FT_UInt max_instruction_defs;
TT_DefArray instruction_defs; /* table of ins. definitions */
FT_UInt max_func;
FT_UInt max_ins;
TT_CodeRangeTable codeRangeTable;
TT_GraphicsState GS;
FT_ULong cvt_size; /* the scaled control value table */
FT_Long* cvt;
FT_UShort storage_size; /* The storage area is now part of */
FT_Long* storage; /* the instance */
TT_GlyphZone twilight; /* The instance's twilight zone */
/* debugging variables */
/* When using the debugger, we must keep the */
/* execution context tied to the instance */
/* object rather than asking it on demand. */
FT_Bool debug;
TT_ExecContext context;
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
} TT_SizeRec;
/*************************************************************************/
/* */
/* TrueType driver class. */
/* */
typedef struct TT_DriverRec_
{
FT_DriverRec root;
TT_ExecContext context; /* execution context */
TT_GlyphZone zone; /* glyph loader points zone */
void* extension_component;
} TT_DriverRec;
/*************************************************************************/
/* */
/* Face functions */
/* */
LOCAL_DEF
FT_Error TT_Init_Face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
LOCAL_DEF
void TT_Done_Face( TT_Face face );
/*************************************************************************/
/* */
/* Size functions */
/* */
LOCAL_DEF
FT_Error TT_Init_Size( TT_Size size );
LOCAL_DEF
void TT_Done_Size( TT_Size size );
LOCAL_DEF
FT_Error TT_Reset_Size( TT_Size size );
/*************************************************************************/
/* */
/* Driver functions */
/* */
LOCAL_DEF
FT_Error TT_Init_Driver( TT_Driver driver );
LOCAL_DEF
void TT_Done_Driver( TT_Driver driver );
#ifdef __cplusplus
}
#endif
#endif /* TTOBJS_H */
/* END */

View File

@@ -1,273 +0,0 @@
/***************************************************************************/
/* */
/* ttpload.h */
/* */
/* TrueType glyph data/program tables loader (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftstream.h>
#include <freetype/tttags.h>
#ifdef FT_FLAT_COMPILE
#include "ttpload.h"
#else
#include <truetype/ttpload.h>
#endif
#include <freetype/internal/tterrors.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_ttpload
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_Locations */
/* */
/* <Description> */
/* Loads the locations table. */
/* */
/* <InOut> */
/* face :: A handle to the target face object. */
/* */
/* <Input> */
/* stream :: The input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Locations( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_Short LongOffsets;
FT_ULong table_len;
FT_TRACE2(( "Locations " ));
LongOffsets = face->header.Index_To_Loc_Format;
error = face->goto_table( face, TTAG_loca, stream, &table_len );
if ( error )
{
error = TT_Err_Locations_Missing;
goto Exit;
}
if ( LongOffsets != 0 )
{
face->num_locations = (FT_UShort)( table_len >> 2 );
FT_TRACE2(( "(32bit offsets): %12d ", face->num_locations ));
if ( ALLOC_ARRAY( face->glyph_locations,
face->num_locations,
FT_Long ) )
goto Exit;
if ( ACCESS_Frame( face->num_locations * 4L ) )
goto Exit;
{
FT_Long* loc = face->glyph_locations;
FT_Long* limit = loc + face->num_locations;
for ( ; loc < limit; loc++ )
*loc = GET_Long();
}
FORGET_Frame();
}
else
{
face->num_locations = (FT_UShort)( table_len >> 1 );
FT_TRACE2(( "(16bit offsets): %12d ", face->num_locations ));
if ( ALLOC_ARRAY( face->glyph_locations,
face->num_locations,
FT_Long ) )
goto Exit;
if ( ACCESS_Frame( face->num_locations * 2L ) )
goto Exit;
{
FT_Long* loc = face->glyph_locations;
FT_Long* limit = loc + face->num_locations;
for ( ; loc < limit; loc++ )
*loc = (FT_Long)( (FT_ULong)GET_UShort() * 2 );
}
FORGET_Frame();
}
FT_TRACE2(( "loaded\n" ));
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_CVT */
/* */
/* <Description> */
/* Loads the control value table into a face object. */
/* */
/* <InOut> */
/* face :: A handle to the target face object. */
/* */
/* <Input> */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_CVT( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_ULong table_len;
FT_TRACE2(( "CVT " ));
error = face->goto_table( face, TTAG_cvt, stream, &table_len );
if ( error )
{
FT_TRACE2(( "is missing!\n" ));
face->cvt_size = 0;
face->cvt = NULL;
error = TT_Err_Ok;
goto Exit;
}
face->cvt_size = table_len / 2;
if ( ALLOC_ARRAY( face->cvt,
face->cvt_size,
FT_Short ) )
goto Exit;
if ( ACCESS_Frame( face->cvt_size * 2L ) )
goto Exit;
{
FT_Short* cur = face->cvt;
FT_Short* limit = cur + face->cvt_size;
for ( ; cur < limit; cur++ )
*cur = GET_Short();
}
FORGET_Frame();
FT_TRACE2(( "loaded\n" ));
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_Progams */
/* */
/* <Description> */
/* Loads the font program and the cvt program. */
/* */
/* <InOut> */
/* face :: A handle to the target face object. */
/* */
/* <Input> */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Programs( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_ULong table_len;
FT_TRACE2(( "Font program " ));
/* The font program is optional */
error = face->goto_table( face, TTAG_fpgm, stream, &table_len );
if ( error )
{
face->font_program = NULL;
face->font_program_size = 0;
FT_TRACE2(( "is missing!\n" ));
}
else
{
face->font_program_size = table_len;
if ( EXTRACT_Frame( table_len, face->font_program ) )
goto Exit;
FT_TRACE2(( "loaded, %12d bytes\n", face->font_program_size ));
}
FT_TRACE2(( "Prep program " ));
error = face->goto_table( face, TTAG_prep, stream, &table_len );
if ( error )
{
face->cvt_program = NULL;
face->cvt_program_size = 0;
error = TT_Err_Ok;
FT_TRACE2(( "is missing!\n" ));
}
else
{
face->cvt_program_size = table_len;
if ( EXTRACT_Frame( table_len, face->cvt_program ) )
goto Exit;
FT_TRACE2(( "loaded, %12d bytes\n", face->cvt_program_size ));
}
Exit:
return error;
}
/* END */

View File

@@ -1,51 +0,0 @@
/***************************************************************************/
/* */
/* ttpload.h */
/* */
/* TrueType glyph data/program tables loader (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef TTPLOAD_H
#define TTPLOAD_H
#include <freetype/internal/tttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
LOCAL_DEF
FT_Error TT_Load_Locations( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_CVT( TT_Face face,
FT_Stream stream );
LOCAL_DEF
FT_Error TT_Load_Programs( TT_Face face,
FT_Stream stream );
#ifdef __cplusplus
}
#endif
#endif /* TTPLOAD_H */
/* END */

View File

@@ -1,6 +0,0 @@
make_module_list: add_type1_driver
add_type1_driver:
$(OPEN_DRIVER)t1_driver_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE)

View File

@@ -1,74 +0,0 @@
#
# FreeType 2 Type 1 driver configuration rules
#
# Copyright 1996-2000 by
# 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.
# Type1 driver directory
#
T1_DIR := $(SRC_)type1
T1_DIR_ := $(T1_DIR)$(SEP)
# compilation flags for the driver
#
T1_COMPILE := $(FT_COMPILE)
# Type1 driver sources (i.e., C files)
#
T1_DRV_SRC := $(T1_DIR_)t1objs.c \
$(T1_DIR_)t1load.c \
$(T1_DIR_)t1parse.c \
$(T1_DIR_)t1tokens.c \
$(T1_DIR_)t1driver.c \
$(T1_DIR_)t1hinter.c \
$(T1_DIR_)t1afm.c \
$(T1_DIR_)t1gload.c
# Type1 driver headers
#
T1_DRV_H := $(T1_DRV_SRC:%.c=%.h)
# Type1 driver object(s)
#
# T1_DRV_OBJ_M is used during `multi' builds
# T1_DRV_OBJ_S is used during `single' builds
#
T1_DRV_OBJ_M := $(T1_DRV_SRC:$(T1_DIR_)%.c=$(OBJ_)%.$O)
T1_DRV_OBJ_S := $(OBJ_)type1.$O
# Type1 driver source file for single build
#
T1_DRV_SRC_S := $(T1_DIR_)type1.c
# Type1 driver - single object
#
$(T1_DRV_OBJ_S): $(T1_DRV_SRC_S) $(T1_DRV_SRC) $(FREETYPE_H) $(T1_DRV_H)
$(T1_COMPILE) $T$@ $(T1_DRV_SRC_S)
# Type1 driver - multiple objects
#
$(OBJ_)%.$O: $(T1_DIR_)%.c $(FREETYPE_H) $(T1_DRV_H)
$(T1_COMPILE) $T$@ $<
# update main driver object lists
#
DRV_OBJS_S += $(T1_DRV_OBJ_S)
DRV_OBJS_M += $(T1_DRV_OBJ_M)
# EOF

View File

@@ -1,293 +0,0 @@
/***************************************************************************/
/* */
/* t1afm.c */
/* */
/* AFM support for Type 1 fonts (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifdef FT_FLAT_COMPILE
#include "t1afm.h"
#else
#include <type1/t1afm.h>
#endif
#include <freetype/internal/ftstream.h>
#include <freetype/internal/t1types.h>
#include <stdlib.h> /* for qsort() */
#include <string.h> /* for strcmp() */
#include <ctype.h> /* for isalnum() */
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_t1afm
LOCAL_FUNC
void T1_Done_AFM( FT_Memory memory,
T1_AFM* afm )
{
FREE( afm->kern_pairs );
afm->num_pairs = 0;
}
#undef IS_KERN_PAIR
#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' )
#define IS_ALPHANUM( c ) ( isalnum( c ) || \
c == '_' || \
c == '.' )
/* read a glyph name and return the equivalent glyph index */
static
FT_UInt afm_atoindex( FT_Byte** start,
FT_Byte* limit,
T1_Font* type1 )
{
FT_Byte* p = *start;
FT_Int len;
FT_UInt result = 0;
char temp[64];
/* skip whitespace */
while ( ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) &&
p < limit )
p++;
*start = p;
/* now, read glyph name */
while ( IS_ALPHANUM( *p ) && p < limit )
p++;
len = p - *start;
if ( len > 0 && len < 64 )
{
FT_Int n;
/* copy glyph name to intermediate array */
MEM_Copy( temp, *start, len );
temp[len] = 0;
/* lookup glyph name in face array */
for ( n = 0; n < type1->num_glyphs; n++ )
{
char* gname = (char*)type1->glyph_names[n];
if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 )
{
result = n;
break;
}
}
}
*start = p;
return result;
}
/* read an integer */
static
int afm_atoi( FT_Byte** start,
FT_Byte* limit )
{
FT_Byte* p = *start;
int sum = 0;
int sign = 1;
/* skip everything that is not a number */
while ( p < limit && !isdigit( *p ) )
{
sign = 1;
if ( *p == '-' )
sign = -1;
p++;
}
while ( p < limit && isdigit( *p ) )
{
sum = sum * 10 + ( *p - '0' );
p++;
}
*start = p;
return sum * sign;
}
#undef KERN_INDEX
#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
/* compare two kerning pairs */
static
int compare_kern_pairs( const void* a,
const void* b )
{
T1_Kern_Pair* pair1 = (T1_Kern_Pair*)a;
T1_Kern_Pair* pair2 = (T1_Kern_Pair*)b;
FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 );
FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 );
return ( index1 - index2 );
}
/* parse an AFM file -- for now, only read the kerning pairs */
LOCAL_FUNC
FT_Error T1_Read_AFM( FT_Face t1_face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_Byte* start;
FT_Byte* limit;
FT_Byte* p;
FT_Int count = 0;
T1_Kern_Pair* pair;
T1_Font* type1 = &((T1_Face)t1_face)->type1;
T1_AFM* afm = 0;
if ( ACCESS_Frame( stream->size ) )
return error;
start = (FT_Byte*)stream->cursor;
limit = (FT_Byte*)stream->limit;
p = start;
/* we are now going to count the occurences of `KP' or `KPX' in */
/* the AFM file */
count = 0;
for ( p = start; p < limit - 3; p++ )
{
if ( IS_KERN_PAIR( p ) )
count++;
}
/* Actually, kerning pairs are simply optional! */
if ( count == 0 )
goto Exit;
/* allocate the pairs */
if ( ALLOC( afm, sizeof ( *afm ) ) ||
ALLOC_ARRAY( afm->kern_pairs, count, T1_Kern_Pair ) )
goto Exit;
/* now, read each kern pair */
pair = afm->kern_pairs;
afm->num_pairs = count;
/* save in face object */
((T1_Face)t1_face)->afm_data = afm;
for ( p = start; p < limit - 3; p++ )
{
if ( IS_KERN_PAIR( p ) )
{
FT_Byte* q;
/* skip keyword (KP or KPX) */
q = p + 2;
if ( *q == 'X' )
q++;
pair->glyph1 = afm_atoindex( &q, limit, type1 );
pair->glyph2 = afm_atoindex( &q, limit, type1 );
pair->kerning.x = afm_atoi( &q, limit );
pair->kerning.y = 0;
if ( p[2] != 'X' )
pair->kerning.y = afm_atoi( &q, limit );
pair++;
}
}
/* now, sort the kern pairs according to their glyph indices */
qsort( afm->kern_pairs, count, sizeof ( T1_Kern_Pair ),
compare_kern_pairs );
Exit:
if ( error )
FREE( afm );
FORGET_Frame();
return error;
}
/* find the kerning for a given glyph pair */
LOCAL_FUNC
void T1_Get_Kerning( T1_AFM* afm,
FT_UInt glyph1,
FT_UInt glyph2,
FT_Vector* kerning )
{
T1_Kern_Pair *min, *mid, *max;
FT_ULong index = KERN_INDEX( glyph1, glyph2 );
/* simple binary search */
min = afm->kern_pairs;
max = min + afm->num_pairs - 1;
while ( min <= max )
{
FT_ULong midi;
mid = min + ( max - min ) / 2;
midi = KERN_INDEX( mid->glyph1, mid->glyph2 );
if ( midi == index )
{
*kerning = mid->kerning;
return;
}
if ( midi < index )
min = mid + 1;
else
max = mid - 1;
}
kerning->x = 0;
kerning->y = 0;
}
/* END */

View File

@@ -1,70 +0,0 @@
/***************************************************************************/
/* */
/* t1afm.h */
/* */
/* AFM support for Type 1 fonts (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef T1AFM_H
#define T1AFM_H
#include <freetype/internal/ftobjs.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct T1_Kern_Pair_
{
FT_UInt glyph1;
FT_UInt glyph2;
FT_Vector kerning;
} T1_Kern_Pair;
typedef struct T1_AFM_
{
FT_Int num_pairs;
T1_Kern_Pair* kern_pairs;
} T1_AFM;
LOCAL_DEF
FT_Error T1_Read_AFM( FT_Face face,
FT_Stream stream );
LOCAL_DEF
void T1_Done_AFM( FT_Memory memory,
T1_AFM* afm );
LOCAL_DEF
void T1_Get_Kerning( T1_AFM* afm,
FT_UInt glyph1,
FT_UInt glyph2,
FT_Vector* kerning );
#ifdef __cplusplus
}
#endif
#endif /* T1AFM_H */
/* END */

View File

@@ -1,381 +0,0 @@
/***************************************************************************/
/* */
/* t1driver.c */
/* */
/* Type 1 driver interface (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifdef FT_FLAT_COMPILE
#include "t1driver.h"
#include "t1gload.h"
#include "t1afm.h"
#else
#include <type1/t1driver.h>
#include <type1/t1gload.h>
#include <type1/t1afm.h>
#endif
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/psnames.h>
#include <string.h> /* for strcmp() */
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_t1driver
#ifndef T1_CONFIG_OPTION_NO_AFM
/*************************************************************************/
/* */
/* <Function> */
/* Get_Kerning */
/* */
/* <Description> */
/* A driver method used to return the kerning vector between two */
/* glyphs of the same face. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* left_glyph :: The index of the left glyph in the kern pair. */
/* */
/* right_glyph :: The index of the right glyph in the kern pair. */
/* */
/* <Output> */
/* kerning :: The kerning vector. This is in font units for */
/* scalable formats, and in pixels for fixed-sizes */
/* formats. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only horizontal layouts (left-to-right & right-to-left) are */
/* supported by this function. Other layouts, or more sophisticated */
/* kernings are out of scope of this method (the basic driver */
/* interface is meant to be simple). */
/* */
/* They can be implemented by format-specific interfaces. */
/* */
static
FT_Error Get_Kerning( T1_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
{
T1_AFM* afm;
kerning->x = 0;
kerning->y = 0;
afm = (T1_AFM*)face->afm_data;
if ( afm )
T1_Get_Kerning( afm, left_glyph, right_glyph, kerning );
return T1_Err_Ok;
}
#endif /* T1_CONFIG_OPTION_NO_AFM */
static
FT_Error get_t1_glyph_name( T1_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_String* gname;
gname = face->type1.glyph_names[glyph_index];
if ( buffer_max > 0 )
{
FT_UInt len = strlen( gname );
if ( len >= buffer_max )
len = buffer_max - 1;
MEM_Copy( buffer, gname, len );
((FT_Byte*)buffer)[len] = 0;
}
return T1_Err_Ok;
}
static
FT_Module_Interface T1_Get_Interface( FT_Module module,
const char* interface )
{
FT_UNUSED( module );
if ( strcmp( interface, "glyph_name" ) == 0 )
return (FT_Module_Interface)get_t1_glyph_name;
return 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* Set_Char_Sizes */
/* */
/* <Description> */
/* A driver method used to reset a size's character sizes (horizontal */
/* and vertical) expressed in fractional points. */
/* */
/* <Input> */
/* char_width :: The character width expressed in 26.6 */
/* fractional points. */
/* */
/* char_height :: The character height expressed in 26.6 */
/* fractional points. */
/* */
/* horz_resolution :: The horizontal resolution of the output device. */
/* */
/* vert_resolution :: The vertical resolution of the output device. */
/* */
/* <InOut> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static
FT_Error Set_Char_Sizes( T1_Size size,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
FT_UInt horz_resolution,
FT_UInt vert_resolution )
{
FT_UNUSED( char_width );
FT_UNUSED( char_height );
FT_UNUSED( horz_resolution );
FT_UNUSED( vert_resolution );
size->valid = FALSE;
return T1_Reset_Size( size );
}
/*************************************************************************/
/* */
/* <Function> */
/* Set_Pixel_Sizes */
/* */
/* <Description> */
/* A driver method used to reset a size's character sizes (horizontal */
/* and vertical) expressed in integer pixels. */
/* */
/* <Input> */
/* pixel_width :: The character width expressed in integer pixels. */
/* */
/* pixel_height :: The character height expressed in integer pixels. */
/* */
/* <InOut> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static
FT_Error Set_Pixel_Sizes( T1_Size size,
FT_Int pixel_width,
FT_Int pixel_height )
{
FT_UNUSED( pixel_width );
FT_UNUSED( pixel_height );
size->valid = FALSE;
return T1_Reset_Size( size );
}
/*************************************************************************/
/* */
/* <Function> */
/* Get_Char_Index */
/* */
/* <Description> */
/* Uses a charmap to return a given character code's glyph index. */
/* */
/* <Input> */
/* charmap :: A handle to the source charmap object. */
/* charcode :: The character code. */
/* */
/* <Return> */
/* Glyph index. 0 means `undefined character code'. */
/* */
static
FT_UInt Get_Char_Index( FT_CharMap charmap,
FT_Long charcode )
{
T1_Face face;
FT_UInt result = 0;
PSNames_Interface* psnames;
face = (T1_Face)charmap->face;
psnames = (PSNames_Interface*)face->psnames;
if ( psnames )
switch ( charmap->encoding )
{
/*******************************************************************/
/* */
/* Unicode encoding support */
/* */
case ft_encoding_unicode:
/* use the `PSNames' module to synthetize the Unicode charmap */
result = psnames->lookup_unicode( &face->unicode_map,
(FT_ULong)charcode );
/* the function returns 0xFFFF if the Unicode charcode has */
/* no corresponding glyph */
if ( result == 0xFFFF )
result = 0;
goto Exit;
/*******************************************************************/
/* */
/* Custom Type 1 encoding */
/* */
case ft_encoding_adobe_custom:
{
T1_Encoding* encoding = &face->type1.encoding;
if ( charcode >= encoding->code_first &&
charcode <= encoding->code_last )
result = encoding->char_index[charcode];
goto Exit;
}
/*******************************************************************/
/* */
/* Adobe Standard & Expert encoding support */
/* */
default:
if ( charcode < 256 )
{
FT_UInt code;
FT_Int n;
const char* glyph_name;
code = psnames->adobe_std_encoding[charcode];
if ( charmap->encoding == ft_encoding_adobe_expert )
code = psnames->adobe_expert_encoding[charcode];
glyph_name = psnames->adobe_std_strings( code );
if ( !glyph_name )
break;
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
const char* gname = face->type1.glyph_names[n];
if ( gname && gname[0] == glyph_name[0] &&
strcmp( gname, glyph_name ) == 0 )
{
result = n;
break;
}
}
}
}
Exit:
return result;
}
const FT_Driver_Class t1_driver_class =
{
{
ft_module_font_driver | ft_module_driver_scalable,
sizeof( FT_DriverRec ),
"type1", /* driver name */
0x10000L, /* driver version 1.0 */
0x20000L, /* driver requires FreeType 2.0 or above */
0, /* module specific interface */
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) T1_Get_Interface
},
sizeof( T1_FaceRec ),
sizeof( T1_SizeRec ),
sizeof( T1_GlyphSlotRec ),
(FTDriver_initFace) T1_Init_Face,
(FTDriver_doneFace) T1_Done_Face,
(FTDriver_initSize) T1_Init_Size,
(FTDriver_doneSize) T1_Done_Size,
(FTDriver_initGlyphSlot)T1_Init_GlyphSlot,
(FTDriver_doneGlyphSlot)T1_Done_GlyphSlot,
(FTDriver_setCharSizes) Set_Char_Sizes,
(FTDriver_setPixelSizes)Set_Pixel_Sizes,
(FTDriver_loadGlyph) T1_Load_Glyph,
(FTDriver_getCharIndex) Get_Char_Index,
#ifdef T1_CONFIG_OPTION_NO_AFM
(FTDriver_getKerning) 0,
(FTDriver_attachFile) 0,
#else
(FTDriver_getKerning) Get_Kerning,
(FTDriver_attachFile) T1_Read_AFM,
#endif
(FTDriver_getAdvances) 0
};
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
EXPORT_FUNC( const FT_Driver_Class* ) getDriverClass( void )
{
return &t1_driver_class;
}
#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */
/* END */

View File

@@ -1,30 +0,0 @@
/***************************************************************************/
/* */
/* t1driver.h */
/* */
/* High-level Type 1 driver interface (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef T1DRIVER_H
#define T1DRIVER_H
#include <freetype/internal/ftdriver.h>
FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class;
#endif /* T1DRIVER_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,326 +0,0 @@
/***************************************************************************/
/* */
/* t1gload.h */
/* */
/* Type 1 Glyph Loader (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef T1GLOAD_H
#define T1GLOAD_H
#ifdef FT_FLAT_COMPILE
#include "t1objs.h"
#else
#include <type1/t1objs.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct T1_Builder_ T1_Builder;
typedef FT_Error (*T1_Builder_EndChar)( T1_Builder* loader );
typedef FT_Error (*T1_Builder_Sbw)( T1_Builder* loader,
FT_Pos sbx,
FT_Pos sby,
FT_Pos wx,
FT_Pos wy );
typedef FT_Error (*T1_Builder_ClosePath)( T1_Builder* loader );
typedef FT_Error (*T1_Builder_RLineTo)( T1_Builder* loader,
FT_Pos dx,
FT_Pos dy );
typedef FT_Error (*T1_Builder_RMoveTo)( T1_Builder* loader,
FT_Pos dx,
FT_Pos dy );
typedef FT_Error (*T1_Builder_RCurveTo)( T1_Builder* loader,
FT_Pos dx1,
FT_Pos dy1,
FT_Pos dx2,
FT_Pos dy2,
FT_Pos dx3,
FT_Pos dy3 );
/*************************************************************************/
/* */
/* <Structure> */
/* T1_Builder_Funcs */
/* */
/* <Description> */
/* A structure to store the address of various functions used by a */
/* glyph builder to implement the outline's `path construction'. */
/* */
typedef struct T1_Builder_Funcs_
{
T1_Builder_EndChar end_char;
T1_Builder_Sbw set_bearing_point;
T1_Builder_ClosePath close_path;
T1_Builder_RLineTo rline_to;
T1_Builder_RMoveTo rmove_to;
T1_Builder_RCurveTo rcurve_to;
} T1_Builder_Funcs;
/*************************************************************************/
/* */
/* <Structure> */
/* T1_Builder */
/* */
/* <Description> */
/* A structure used during glyph loading to store its outline. */
/* */
/* <Fields> */
/* memory :: The current memory object. */
/* */
/* face :: The current face object. */
/* */
/* size :: The current size object. */
/* */
/* glyph :: The current glyph slot. */
/* */
/* loader :: The current glyph loader. */
/* */
/* current :: The current glyph outline. */
/* */
/* base :: The base glyph outline. */
/* */
/* last :: The last point position. */
/* */
/* scale_x :: The horizontal scale (FUnits to sub-pixels). */
/* */
/* scale_y :: The vertical scale (FUnits to sub-pixels). */
/* */
/* pos_x :: The horizontal translation (for composite glyphs). */
/* */
/* pos_y :: The vertical translation (for composite glyphs). */
/* */
/* left_bearing :: The left side bearing point. */
/* */
/* advance :: The horizontal advance vector. */
/* */
/* no_recurse :: */
/* */
/* bbox :: The glyph's bounding box. */
/* */
/* path_begun :: A flag which indicates that a new path has begun. */
/* */
/* load_points :: A flag which indicates, if not set, that no points */
/* are loaded. */
/* */
/* pass :: The pass number for multi-pass hinters. */
/* */
/* hint_point :: The index of the next point to hint. */
/* */
/* funcs :: A table of builder functions used to perform the */
/* outline's path construction. */
/* */
struct T1_Builder_
{
FT_Memory memory;
T1_Face face;
T1_Size size;
T1_GlyphSlot glyph;
FT_GlyphLoader* loader;
FT_Outline* current; /* the current glyph outline */
FT_Outline* base; /* the composite glyph outline */
FT_Vector last;
FT_Fixed scale_x;
FT_Fixed scale_y;
FT_Pos pos_x;
FT_Pos pos_y;
FT_Vector left_bearing;
FT_Vector advance;
FT_Bool no_recurse;
FT_BBox bbox; /* bounding box */
FT_Bool path_begun;
FT_Bool load_points;
FT_Int pass;
FT_Int hint_point;
/* path construction function interface */
T1_Builder_Funcs funcs;
};
typedef FT_Error (*T1_Hinter_ChangeHints)( T1_Builder* builder );
typedef FT_Error (*T1_Hinter_DotSection)( T1_Builder* builder );
typedef FT_Error (*T1_Hinter_Stem)( T1_Builder* builder,
FT_Pos pos,
FT_Pos width,
FT_Bool vertical );
typedef FT_Error (*T1_Hinter_Stem3)( T1_Builder* builder,
FT_Pos pos0,
FT_Pos width0,
FT_Pos pos1,
FT_Pos width1,
FT_Pos pos2,
FT_Pos width2,
FT_Bool vertical );
/*************************************************************************/
/* */
/* <Structure> */
/* T1_Hinter_Funcs */
/* */
/* <Description> */
/* A structure to store the address of various functions used by a */
/* Type 1 hinter to perform outline hinting. */
/* */
typedef struct T1_Hinter_Func_
{
T1_Hinter_ChangeHints change_hints;
T1_Hinter_DotSection dot_section;
T1_Hinter_Stem stem;
T1_Hinter_Stem3 stem3;
} T1_Hinter_Funcs;
typedef enum T1_Operator_
{
op_none = 0,
op_endchar,
op_hsbw,
op_seac,
op_sbw,
op_closepath,
op_hlineto,
op_hmoveto,
op_hvcurveto,
op_rlineto,
op_rmoveto,
op_rrcurveto,
op_vhcurveto,
op_vlineto,
op_vmoveto,
op_dotsection,
op_hstem,
op_hstem3,
op_vstem,
op_vstem3,
op_div,
op_callothersubr,
op_callsubr,
op_pop,
op_return,
op_setcurrentpoint,
op_max /* never remove this one */
} T1_Operator;
/* execution context charstring zone */
typedef struct T1_Decoder_Zone_
{
FT_Byte* base;
FT_Byte* limit;
FT_Byte* cursor;
} T1_Decoder_Zone;
typedef struct T1_Decoder_
{
T1_Builder builder;
T1_Hinter_Funcs hinter;
FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
FT_Int* top;
T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
T1_Decoder_Zone* zone;
FT_Int flex_state;
FT_Int num_flex_vectors;
FT_Vector flex_vectors[7];
} T1_Decoder;
LOCAL_DEF
void T1_Init_Builder( T1_Builder* builder,
T1_Face face,
T1_Size size,
T1_GlyphSlot glyph,
const T1_Builder_Funcs* funcs );
LOCAL_DEF
void T1_Done_Builder( T1_Builder* builder );
LOCAL_DEF
void T1_Init_Decoder( T1_Decoder* decoder,
const T1_Hinter_Funcs* funcs );
LOCAL_DEF
FT_Error T1_Compute_Max_Advance( T1_Face face,
FT_Int* max_advance );
LOCAL_DEF
FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
FT_Byte* charstring_base,
FT_Int charstring_len,
FT_Int num_subrs,
FT_Byte** subrs_base,
FT_Int* subrs_len );
LOCAL_DEF
FT_Error T1_Add_Points( T1_Builder* builder,
FT_Int num_points );
LOCAL_DEF
FT_Error T1_Add_Contours( T1_Builder* builder,
FT_Int num_contours );
LOCAL_DEF
FT_Error T1_Load_Glyph( T1_GlyphSlot glyph,
T1_Size size,
FT_Int glyph_index,
FT_Int load_flags );
#ifdef __cplusplus
}
#endif
#endif /* T1GLOAD_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,273 +0,0 @@
/***************************************************************************/
/* */
/* t1hinter.h */
/* */
/* Type 1 hinter (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef T1HINTER_H
#define T1HINTER_H
#ifdef FT_FLAT_COMPILE
#include "t1objs.h"
#include "t1gload.h"
#else
#include <type1/t1objs.h>
#include <type1/t1gload.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Snap_Zone */
/* */
/* <Description> */
/* A `snap zone' is used to model either a blue zone or a stem width */
/* at a given character size. It is made of a minimum and maximum */
/* edge, defined in 26.6 pixels, as well as an `original' and */
/* `scaled' position. */
/* */
/* The position corresponds to the stem width (for stem snap zones) */
/* or to the blue position (for blue zones). */
/* */
/* <Fields> */
/* orus :: The original position in font units. */
/* */
/* pix :: The current position in sub-pixel units. */
/* */
/* min :: The minimum boundary in sub-pixel units. */
/* */
/* max :: The maximum boundary in sub-pixel units. */
/* */
typedef struct T1_Snap_Zone_
{
FT_Pos orus;
FT_Pos pix;
FT_Pos min;
FT_Pos max;
} T1_Snap_Zone;
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Edge */
/* */
/* <Description> */
/* A very simple structure used to model a stem edge. */
/* */
/* <Fields> */
/* orus :: The original edge position in font units. */
/* */
/* pix :: The scaled edge position in sub-pixel units. */
/* */
typedef struct T1_Edge_
{
FT_Pos orus;
FT_Pos pix;
} T1_Edge;
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Stem_Hint */
/* */
/* <Description> */
/* A simple structure used to model a stem hint. */
/* */
/* <Fields> */
/* min_edge :: The hint's minimum edge. */
/* */
/* max_edge :: The hint's maximum edge. */
/* */
/* hint_flags :: Some flags describing the stem properties. */
/* */
/* <Note> */
/* The min and max edges of a ghost stem have the same position, even */
/* if they are coded in a weird way in the charstrings. */
/* */
typedef struct T1_Stem_Hint_
{
T1_Edge min_edge;
T1_Edge max_edge;
FT_Int hint_flags;
} T1_Stem_Hint;
#define T1_HINT_FLAG_ACTIVE 1 /* indicates an active stem */
#define T1_HINT_FLAG_MIN_BORDER 2 /* unused for now */
#define T1_HINT_FLAG_MAX_BORDER 4 /* unused for now */
/* hinter's configuration constants */
#define T1_HINTER_MAX_BLUES 24 /* maximum number of blue zones */
#define T1_HINTER_MAX_SNAPS 16 /* maximum number of stem snap zones */
#define T1_HINTER_MAX_EDGES 64 /* maximum number of stem hints */
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Size_Hints */
/* */
/* <Description> */
/* A structure used to model the hinting information related to a size */
/* object. */
/* */
/* <Fields> */
/* supress_overshoots :: A boolean flag to tell whether overshoot */
/* supression should occur. */
/* */
/* num_blue_zones :: The total number of blue zones (top+bottom). */
/* */
/* num_bottom_zones :: The number of bottom zones. */
/* */
/* blue_zones :: The blue zones table. Bottom zones are */
/* stored first in the table, followed by all */
/* top zones. */
/* */
/* num_snap_widths :: The number of horizontal stem snap zones. */
/* */
/* snap_widths :: An array of horizontal stem snap zones. */
/* */
/* num_snap_heights :: The number of vertical stem snap zones. */
/* */
/* snap_heights :: An array of vertical stem snap zones. */
/* */
struct T1_Size_Hints_
{
FT_Bool supress_overshoots;
FT_Int num_blue_zones;
FT_Int num_bottom_zones;
T1_Snap_Zone blue_zones[T1_HINTER_MAX_BLUES];
FT_Int num_snap_widths;
T1_Snap_Zone snap_widths[T1_HINTER_MAX_SNAPS];
FT_Int num_snap_heights;
T1_Snap_Zone snap_heights[T1_HINTER_MAX_SNAPS];
};
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Stem_Table */
/* */
/* <Description> */
/* A simple structure used to model a set of stem hints in a single */
/* direction during the loading of a given glyph outline. Not all */
/* stem hints are active at a time. Moreover, stems must be sorted */
/* regularly. */
/* */
/* <Fields> */
/* num_stems :: The total number of stems in the table. */
/* */
/* num_active :: The number of active stems in the table. */
/* */
/* stems :: A table of all stems. */
/* */
/* sort :: A table of indices into the stems table, used to */
/* keep a sorted list of the active stems. */
/* */
typedef struct T1_Stem_Table_
{
FT_Int num_stems;
FT_Int num_active;
T1_Stem_Hint stems[T1_HINTER_MAX_EDGES];
FT_Int sort [T1_HINTER_MAX_EDGES];
} T1_Stem_Table;
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Glyph_Hints */
/* */
/* <Description> */
/* A structure used to model the stem hints of a given glyph outline */
/* during glyph loading. */
/* */
/* <Fields> */
/* hori_stems :: The horizontal stem hints table. */
/* vert_stems :: The vertical stem hints table. */
/* */
struct T1_Glyph_Hints_
{
T1_Stem_Table hori_stems;
T1_Stem_Table vert_stems;
};
/*************************************************************************/
/* */
/* <Data> */
/* t1_hinter_funcs */
/* */
/* <Description> */
/* A table containing the address of various functions used during */
/* the loading of an hinted scaled outline. */
/* */
extern const T1_Hinter_Funcs t1_hinter_funcs;
LOCAL_DEF
FT_Error T1_New_Size_Hinter( T1_Size size );
LOCAL_DEF
void T1_Done_Size_Hinter( T1_Size size );
LOCAL_DEF
FT_Error T1_Reset_Size_Hinter( T1_Size size );
LOCAL_DEF
FT_Error T1_New_Glyph_Hinter( T1_GlyphSlot glyph );
LOCAL_DEF
void T1_Done_Glyph_Hinter( T1_GlyphSlot glyph );
LOCAL_DEF
void T1_Hint_Points( T1_Builder* builder );
LOCAL_DEF
void T1_Hint_Stems( T1_Builder* builder );
#ifdef __cplusplus
}
#endif
#endif /* T1HINTER_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,57 +0,0 @@
/***************************************************************************/
/* */
/* t1load.h */
/* */
/* Type 1 font loader (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef T1LOAD_H
#define T1LOAD_H
#include <freetype/internal/ftstream.h>
#ifdef FT_FLAT_COMPILE
#include "t1parse.h"
#else
#include <type1/t1parse.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
LOCAL_DEF
void Init_T1_Parser( T1_Parser* parser,
T1_Face face,
T1_Tokenizer tokenizer );
LOCAL_DEF
FT_Error Parse_T1_FontProgram( T1_Parser* parser );
#ifdef __cplusplus
}
#endif
#endif /* T1LOAD_H */
/* END */

View File

@@ -1,544 +0,0 @@
/***************************************************************************/
/* */
/* t1objs.c */
/* */
/* Type 1 objects manager (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#ifdef FT_FLAT_COMPILE
#include "t1gload.h"
#include "t1load.h"
#include "t1afm.h"
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include "t1hinter.h"
#endif
#else /* FT_FLAT_COMPILE */
#include <type1/t1gload.h>
#include <type1/t1load.h>
#include <type1/t1afm.h>
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include <type1/t1hinter.h>
#endif
#endif /* FT_FLAT_COMPILE */
#include <freetype/internal/psnames.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_t1objs
/*************************************************************************/
/* */
/* SIZE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* T1_Done_Size */
/* */
/* <Description> */
/* The Type 1 size object destructor. Used to discard a given size */
/* object. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
LOCAL_FUNC
void T1_Done_Size( T1_Size size )
{
if ( size )
{
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
T1_Done_Size_Hinter( size );
#endif
size->valid = 0;
}
}
/*************************************************************************/
/* */
/* <Function> */
/* T1_Init_Size */
/* */
/* <Description> */
/* The size object initializer. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* FreeTrue error code. 0 means success. */
/* */
LOCAL_DEF
FT_Error T1_Init_Size( T1_Size size )
{
FT_Error error;
size->valid = 0;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
error = T1_New_Size_Hinter( size );
return error;
#else
FT_UNUSED( error );
return T1_Err_Ok;
#endif
}
/*************************************************************************/
/* */
/* <Function> */
/* T1_Reset_Size */
/* */
/* <Description> */
/* Resets an instance to a new pointsize/transform. This function is */
/* in charge of resetting the blue zones,a s well as the stem snap */
/* tables for a given size. */
/* */
/* <Input> */
/* size :: The target size object. */
/* */
/* <Output> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Reset_Size( T1_Size size )
{
/* recompute ascender, descender, etc. */
T1_Face face = (T1_Face)size->root.face;
FT_Size_Metrics* metrics = &size->root.metrics;
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
return FT_Err_Invalid_Argument;
/* Compute root ascender, descender, test height, and max_advance */
metrics->ascender = ( FT_MulFix( face->root.ascender,
metrics->y_scale ) + 32 ) & -64;
metrics->descender = ( FT_MulFix( face->root.descender,
metrics->y_scale ) + 32 ) & -64;
metrics->height = ( FT_MulFix( face->root.height,
metrics->y_scale ) + 32 ) & -64;
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
metrics->x_scale ) + 32 ) & -64;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
return T1_Reset_Size_Hinter( size );
#else
return 0;
#endif
}
/*************************************************************************/
/* */
/* FACE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* T1_Done_Face */
/* */
/* <Description> */
/* The face object destructor. */
/* */
/* <Input> */
/* face :: A typeless pointer to the face object to destroy. */
/* */
LOCAL_FUNC
void T1_Done_Face( T1_Face face )
{
FT_Memory memory;
T1_Font* type1 = &face->type1;
if ( face )
{
memory = face->root.memory;
/* release font info strings */
{
T1_FontInfo* info = &type1->font_info;
FREE( info->version );
FREE( info->notice );
FREE( info->full_name );
FREE( info->family_name );
FREE( info->weight );
}
/* release top dictionary */
FREE( type1->charstrings_len );
FREE( type1->charstrings );
FREE( type1->glyph_names );
FREE( type1->subrs );
FREE( type1->subrs_len );
FREE( type1->subrs_block );
FREE( type1->charstrings_block );
FREE( type1->glyph_names_block );
FREE( type1->encoding.char_index );
FREE( type1->font_name );
#ifndef T1_CONFIG_OPTION_NO_AFM
/* release afm data if present */
if ( face->afm_data )
T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
#endif
/* release unicode map, if any */
FREE( face->unicode_map.maps );
face->unicode_map.num_maps = 0;
face->root.family_name = 0;
face->root.style_name = 0;
}
}
/*************************************************************************/
/* */
/* <Function> */
/* T1_Init_Face */
/* */
/* <Description> */
/* The face object constructor. */
/* */
/* <Input> */
/* stream :: input stream where to load font data. */
/* */
/* face_index :: The index of the font face in the resource. */
/* */
/* num_params :: Number of additional generic parameters. Ignored. */
/* */
/* params :: Additional generic parameters. Ignored. */
/* */
/* <InOut> */
/* face :: The face record to build. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Init_Face( FT_Stream stream,
T1_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
T1_Tokenizer tokenizer;
FT_Error error;
PSNames_Interface* psnames;
FT_UNUSED( num_params );
FT_UNUSED( params );
FT_UNUSED( face_index );
FT_UNUSED( face );
face->root.num_faces = 1;
psnames = (PSNames_Interface*)face->psnames;
if ( !psnames )
{
psnames = (PSNames_Interface*)
FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psnames" );
face->psnames = psnames;
}
/* open the tokenizer, this will also check the font format */
error = New_Tokenizer( stream, &tokenizer );
if ( error )
goto Fail;
/* if we just wanted to check the format, leave successfully now */
if ( face_index < 0 )
goto Leave;
/* check the face index */
if ( face_index != 0 )
{
FT_ERROR(( "T1_Init_Face: invalid face index\n" ));
error = T1_Err_Invalid_Argument;
goto Leave;
}
/* Now, load the font program into the face object */
{
T1_Parser parser;
Init_T1_Parser( &parser, face, tokenizer );
error = Parse_T1_FontProgram( &parser );
if ( error )
goto Leave;
/* Init the face object fields */
/* Now set up root face fields */
{
FT_Face root = (FT_Face)&face->root;
T1_Font* type1 = &face->type1;
root->num_glyphs = type1->num_glyphs;
root->num_charmaps = 1;
root->face_index = face_index;
root->face_flags = FT_FACE_FLAG_SCALABLE;
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
if ( type1->font_info.is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* XXX: TODO -- add kerning with .afm support */
/* get style name - be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
root->family_name = type1->font_info.family_name;
if ( root->family_name )
{
char* full = type1->font_info.full_name;
char* family = root->family_name;
while ( *family && *full == *family )
{
family++;
full++;
}
root->style_name = ( *full == ' ' ? full + 1
: (char *)"Regular" );
}
else
{
/* do we have a `/FontName'? */
if (type1->font_name)
{
root->family_name = type1->font_name;
root->style_name = "Regular";
}
}
/* no embedded bitmap support */
root->num_fixed_sizes = 0;
root->available_sizes = 0;
root->bbox = type1->font_bbox;
root->units_per_EM = 1000;
root->ascender = (FT_Short)type1->font_bbox.yMax;
root->descender = -(FT_Short)type1->font_bbox.yMin;
root->height = ( ( root->ascender + root->descender) * 12 )
/ 10;
/* now compute the maximum advance width */
root->max_advance_width = type1->private_dict.standard_width[0];
/* compute max advance width for proportional fonts */
if ( !type1->font_info.is_fixed_pitch )
{
FT_Int max_advance;
error = T1_Compute_Max_Advance( face, &max_advance );
/* in case of error, keep the standard width */
if ( !error )
root->max_advance_width = max_advance;
else
error = 0; /* clear error */
}
root->max_advance_height = root->height;
root->underline_position = type1->font_info.underline_position;
root->underline_thickness = type1->font_info.underline_thickness;
root->max_points = 0;
root->max_contours = 0;
}
}
/* charmap support - synthetize unicode charmap when possible */
{
FT_Face root = &face->root;
FT_CharMap charmap = face->charmaprecs;
/* synthesize a Unicode charmap if there is support in the `PSNames' */
/* module.. */
if ( face->psnames )
{
PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
if ( psnames->unicode_value )
{
error = psnames->build_unicodes(
root->memory,
face->type1.num_glyphs,
(const char**)face->type1.glyph_names,
&face->unicode_map );
if ( !error )
{
root->charmap = charmap;
charmap->face = (FT_Face)face;
charmap->encoding = ft_encoding_unicode;
charmap->platform_id = 3;
charmap->encoding_id = 1;
charmap++;
}
/* simply clear the error in case of failure (which really) */
/* means that out of memory or no unicode glyph names */
error = 0;
}
}
/* now, support either the standard, expert, or custom encodings */
charmap->face = (FT_Face)face;
charmap->platform_id = 7; /* a new platform id for Adobe fonts ?? */
switch ( face->type1.encoding_type )
{
case t1_encoding_standard:
charmap->encoding = ft_encoding_adobe_standard;
charmap->encoding_id = 0;
break;
case t1_encoding_expert:
charmap->encoding = ft_encoding_adobe_expert;
charmap->encoding_id = 1;
break;
default:
charmap->encoding = ft_encoding_adobe_custom;
charmap->encoding_id = 2;
break;
}
root->charmaps = face->charmaps;
root->num_charmaps = charmap - face->charmaprecs + 1;
face->charmaps[0] = &face->charmaprecs[0];
face->charmaps[1] = &face->charmaprecs[1];
}
Leave:
Done_Tokenizer( tokenizer );
Fail:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* T1_Done_GlyphSlot */
/* */
/* <Description> */
/* The glyph slot object destructor. */
/* */
/* <Input> */
/* glyph :: The glyph slot handle to destroy. */
/* */
LOCAL_FUNC
void T1_Done_GlyphSlot( T1_GlyphSlot glyph )
{
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
T1_Done_Glyph_Hinter( glyph );
#else
FT_UNUSED( glyph );
#endif
}
/*************************************************************************/
/* */
/* <Function> */
/* T1_Init_GlyphSlot */
/* */
/* <Description> */
/* The glyph slot object constructor. */
/* */
/* <Input> */
/* glyph :: The glyph slot handle to initialize. */
/* */
LOCAL_FUNC
FT_Error T1_Init_GlyphSlot( T1_GlyphSlot glyph )
{
FT_Error error = FT_Err_Ok;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
error = T1_New_Glyph_Hinter( glyph );
#else
FT_UNUSED( glyph );
#endif
return error;
}
/* END */

View File

@@ -1,172 +0,0 @@
/***************************************************************************/
/* */
/* t1objs.h */
/* */
/* Type 1 objects manager (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef T1OBJS_H
#define T1OBJS_H
#include <freetype/config/ftconfig.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/t1types.h>
#include <freetype/internal/t1errors.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The following structures must be defined by the hinter */
typedef struct T1_Size_Hints_ T1_Size_Hints;
typedef struct T1_Glyph_Hints_ T1_Glyph_Hints;
/*************************************************************************/
/* */
/* <Type> */
/* T1_Driver */
/* */
/* <Description> */
/* A handle to a Type 1 driver object. */
/* */
typedef struct T1_DriverRec_* T1_Driver;
/*************************************************************************/
/* */
/* <Type> */
/* T1_Size */
/* */
/* <Description> */
/* A handle to a Type 1 size object. */
/* */
typedef struct T1_SizeRec_* T1_Size;
/*************************************************************************/
/* */
/* <Type> */
/* T1_GlyphSlot */
/* */
/* <Description> */
/* A handle to a Type 1 glyph slot object. */
/* */
typedef struct T1_GlyphSlotRec_* T1_GlyphSlot;
/*************************************************************************/
/* */
/* <Type> */
/* T1_CharMap */
/* */
/* <Description> */
/* A handle to a Type 1 character mapping object. */
/* */
/* <Note> */
/* The Type 1 format doesn't use a charmap but an encoding table. */
/* The driver is responsible for making up charmap objects */
/* corresponding to these tables. */
/* */
typedef struct T1_CharMapRec_* T1_CharMap;
/*************************************************************************/
/* */
/* HERE BEGINS THE TYPE1 SPECIFIC STUFF */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Type> */
/* T1_SizeRec */
/* */
/* <Description> */
/* Type 1 size record. */
/* */
typedef struct T1_SizeRec_
{
FT_SizeRec root;
FT_Bool valid;
T1_Size_Hints* hints; /* defined in the hinter. This allows */
/* us to experiment with different */
/* hinting schemes without having to */
/* change `t1objs' each time. */
} T1_SizeRec;
/*************************************************************************/
/* */
/* <Type> */
/* T1_GlyphSlotRec */
/* */
/* <Description> */
/* Type 1 glyph slot record. */
/* */
typedef struct T1_GlyphSlotRec_
{
FT_GlyphSlotRec root;
FT_Bool hint;
FT_Bool scaled;
FT_Int max_points;
FT_Int max_contours;
FT_Fixed x_scale;
FT_Fixed y_scale;
T1_Glyph_Hints* hints; /* defined in the hinter */
} T1_GlyphSlotRec;
LOCAL_DEF
FT_Error T1_Init_Face( FT_Stream stream,
T1_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
LOCAL_DEF
void T1_Done_Face( T1_Face face );
LOCAL_DEF
FT_Error T1_Init_Size( T1_Size size );
LOCAL_DEF
void T1_Done_Size( T1_Size size );
LOCAL_DEF
FT_Error T1_Reset_Size( T1_Size size );
LOCAL_DEF
FT_Error T1_Init_GlyphSlot( T1_GlyphSlot slot );
LOCAL_DEF
void T1_Done_GlyphSlot( T1_GlyphSlot slot );
#ifdef __cplusplus
}
#endif
#endif /* T1OBJS_H */
/* END */

View File

@@ -1,761 +0,0 @@
/***************************************************************************/
/* */
/* t1parse.c */
/* */
/* Type 1 parser (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/t1types.h>
#ifdef FT_FLAT_COMPILE
#include "t1parse.h"
#else
#include <type1/t1parse.h>
#endif
#include <stdio.h> /* for sscanf() */
#include <string.h> /* for strncpy() */
/*************************************************************************/
/* */
/* <Function> */
/* T1_New_Table */
/* */
/* <Description> */
/* Initializes a T1_Table structure. */
/* */
/* <InOut> */
/* table :: The address of the target table. */
/* */
/* <Input> */
/* count :: The table size (i.e. maximum number of elements). */
/* memory :: The memory object to use for all subsequent */
/* reallocations. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_New_Table( T1_Table* table,
FT_Int count,
FT_Memory memory )
{
FT_Error error;
table->memory = memory;
if ( ALLOC_ARRAY( table->elements, count, FT_Byte* ) )
return error;
if ( ALLOC_ARRAY( table->lengths, count, FT_Byte* ) )
{
FREE( table->elements );
return error;
}
table->max_elems = count;
table->num_elems = 0;
table->block = 0;
table->capacity = 0;
table->cursor = 0;
return error;
}
static
FT_Error reallocate_t1_table( T1_Table* table,
FT_Int new_size )
{
FT_Memory memory = table->memory;
FT_Byte* old_base = table->block;
FT_Error error;
/* reallocate the base block */
if ( REALLOC( table->block, table->capacity, new_size ) )
return error;
table->capacity = new_size;
/* shift all offsets if necessary */
if ( old_base )
{
FT_Long delta = table->block - old_base;
FT_Byte** offset = table->elements;
FT_Byte** limit = offset + table->max_elems;
if ( delta )
for ( ; offset < limit; offset ++ )
if (offset[0])
offset[0] += delta;
}
return T1_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* T1_Add_Table */
/* */
/* <Description> */
/* Adds an object to a T1_Table, possibly growing its memory block. */
/* */
/* <InOut> */
/* table :: The target table. */
/* */
/* <Input> */
/* index :: The index of the object in the table. */
/* */
/* object :: The address of the object to copy in memory. */
/* */
/* length :: The length in bytes of the source object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. An error is returned if a */
/* reallocation failed. */
/* */
LOCAL_FUNC
FT_Error T1_Add_Table( T1_Table* table,
FT_Int index,
void* object,
FT_Int length )
{
if ( index < 0 || index > table->max_elems )
{
FT_ERROR(( "T1_Add_Table: invalid index\n" ));
return T1_Err_Syntax_Error;
}
/* grow the base block if needed */
if ( table->cursor + length > table->capacity )
{
FT_Error error;
FT_Int new_size = table->capacity;
while ( new_size < table->cursor + length )
new_size += 1024;
error = reallocate_t1_table( table, new_size );
if ( error )
return error;
}
/* add the object to the base block and adjust offset */
table->elements[index] = table->block + table->cursor;
table->lengths [index] = length;
MEM_Copy( table->block + table->cursor, object, length );
table->cursor += length;
return T1_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* T1_Done_Table */
/* */
/* <Description> */
/* Finalize a T1_Table (reallocate it to its current cursor). */
/* */
/* <Input> */
/* table :: The target table. */
/* */
/* <Note> */
/* This function does NOT release the heap's memory block. It is up */
/* to the caller to clean it, or reference it in its own structures. */
/* */
LOCAL_FUNC
void T1_Done_Table( T1_Table* table )
{
FT_Memory memory = table->memory;
FT_Error error;
FT_Byte* old_base;
/* should never fail, as rec.cursor <= rec.size */
old_base = table->block;
if ( !old_base )
return;
(void)REALLOC( table->block, table->capacity, table->cursor );
table->capacity = table->cursor;
if ( old_base != table->block )
{
FT_Long delta = table->block - old_base;
FT_Byte** element = table->elements;
FT_Byte** limit = element + table->max_elems;
for ( ; element < limit; element++ )
if ( element[0] )
element[0] += delta;
}
}
LOCAL_FUNC
FT_String* CopyString( T1_Parser* parser )
{
FT_String* string = NULL;
T1_Token* token = parser->args++;
FT_Memory memory = parser->tokenizer->memory;
FT_Error error;
if ( token->kind == tok_string )
{
FT_Int len = token->len - 2;
if ( ALLOC( string, len + 1 ) )
{
parser->error = error;
return 0;
}
MEM_Copy( string, parser->tokenizer->base + token->start + 1, len );
string[len] = '\0';
parser->error = T1_Err_Ok;
}
else
{
FT_ERROR(( "T1_CopyString: syntax error, string token expected!\n" ));
parser->error = T1_Err_Syntax_Error;
}
return string;
}
static
FT_Error parse_int( FT_Byte* base,
FT_Byte* limit,
FT_Long* result )
{
FT_Bool sign = 0;
FT_Long sum = 0;
if ( base >= limit )
goto Fail;
/* check sign */
if ( *base == '+' )
base++;
else if ( *base == '-' )
{
sign++;
base++;
}
/* parse digits */
if ( base >= limit )
goto Fail;
do
{
sum = ( 10 * sum + ( *base++ - '0' ) );
} while ( base < limit );
if ( sign )
sum = -sum;
*result = sum;
return T1_Err_Ok;
Fail:
FT_ERROR(( "parse_int: integer expected\n" ));
*result = 0;
return T1_Err_Syntax_Error;
}
static
FT_Error parse_float( FT_Byte* base,
FT_Byte* limit,
FT_Long scale,
FT_Long* result )
{
#if 1
/* XXX: We are simply much too lazy to code this function */
/* properly for now. We will do that when the rest of */
/* the driver works properly. */
char temp[32];
int len = limit - base;
double value;
if ( len > 31 )
goto Fail;
strncpy( temp, (char*)base, len );
temp[len] = '\0';
if ( sscanf( temp, "%lf", &value ) != 1 )
goto Fail;
*result = (FT_Long)( scale * value );
return 0;
#else
FT_Byte* cur;
FT_Bool sign = 0; /* sign */
FT_Long number_int = 0; /* integer part */
FT_Long number_frac = 0; /* fractional part */
FT_Long exponent = 0; /* exponent value */
FT_Int num_frac = 0; /* number of fractional digits */
/* check sign */
if ( *base == '+' )
base++;
else if ( *base == '-' )
{
sign++;
base++;
}
/* find integer part */
cur = base;
while ( cur < limit )
{
FT_Byte c = *cur;
if ( c == '.' || c == 'e' || c == 'E' )
break;
cur++;
}
if ( cur > base )
{
error = parse_integer( base, cur, &number_int );
if ( error )
goto Fail;
}
/* read fractional part, if any */
if ( *cur == '.' )
{
cur++;
base = cur;
while ( cur < limit )
{
FT_Byte c = *cur;
if ( c == 'e' || c == 'E' )
break;
cur++;
}
num_frac = cur - base;
if ( cur > base )
{
error = parse_integer( base, cur, &number_frac );
if ( error )
goto Fail;
base = cur;
}
}
/* read exponent, if any */
if ( *cur == 'e' || *cur == 'E' )
{
cur++;
base = cur;
error = parse_integer( base, limit, &exponent );
if ( error )
goto Fail;
/* now check that exponent is within `correct bounds' */
/* i.e. between -6 and 6 */
if ( exponent < -6 || exponent > 6 )
goto Fail;
}
/* now adjust integer value and exponent for fractional part */
while ( num_frac > 0 )
{
number_int *= 10;
exponent--;
num_frac--;
}
number_int += num_frac;
/* skip point if any, read fractional part */
if ( cur + 1 < limit )
{
if (*cur..
}
/* now compute scaled float value */
/* XXX: incomplete! */
#endif /* 1 */
Fail:
FT_ERROR(( "parse_float: syntax error!\n" ));
return T1_Err_Syntax_Error;
}
static
FT_Error parse_integer( FT_Byte* base,
FT_Byte* limit,
FT_Long* result )
{
FT_Byte* cur;
/* the lexical analyser accepts floats as well as integers */
/* now; check that we really have an int in this token */
cur = base;
while ( cur < limit )
{
FT_Byte c = *cur++;
if ( c == '.' || c == 'e' || c == 'E' )
goto Float_Number;
}
/* now read the number's value */
return parse_int( base, limit, result );
Float_Number:
/* we really have a float there; simply call parse_float in this */
/* case with a scale of `10' to perform round */
{
FT_Error error;
error = parse_float( base, limit, 10, result );
if ( !error )
{
if ( *result >= 0 )
*result = ( *result + 5 ) / 10; /* round value */
else
*result = -( ( 5 - *result ) / 10 );
}
return error;
}
}
LOCAL_FUNC
FT_Long CopyInteger( T1_Parser* parser )
{
FT_Long sum = 0;
T1_Token* token = parser->args++;
if ( token->kind == tok_number )
{
FT_Byte* base = parser->tokenizer->base + token->start;
FT_Byte* limit = base + token->len;
/* now read the number's value */
parser->error = parse_integer( base, limit, &sum );
return sum;
}
FT_ERROR(( "CopyInteger: number expected\n" ));
parser->args--;
parser->error = T1_Err_Syntax_Error;
return 0;
}
LOCAL_FUNC
FT_Bool CopyBoolean( T1_Parser* parser )
{
FT_Error error = T1_Err_Ok;
FT_Bool result = 0;
T1_Token* token = parser->args++;
if ( token->kind == tok_keyword )
{
if ( token->kind2 == key_false )
result = 0;
else if ( token->kind2 == key_true )
result = !0;
else
goto Fail;
}
else
{
Fail:
FT_ERROR(( "CopyBoolean:" ));
FT_ERROR(( " syntax error; `false' or `true' expected\n" ));
error = T1_Err_Syntax_Error;
}
parser->error = error;
return result;
}
LOCAL_FUNC
FT_Long CopyFloat( T1_Parser* parser,
FT_Int scale )
{
FT_Error error;
FT_Long sum = 0;
T1_Token* token = parser->args++;
if ( token->kind == tok_number )
{
FT_Byte* base = parser->tokenizer->base + token->start;
FT_Byte* limit = base + token->len;
error = parser->error = parse_float( base, limit, scale, &sum );
if ( error )
goto Fail;
return sum;
}
Fail:
FT_ERROR(( "CopyFloat: syntax error!\n" ));
parser->error = T1_Err_Syntax_Error;
return 0;
}
LOCAL_FUNC
void CopyBBox( T1_Parser* parser,
FT_BBox* bbox )
{
T1_Token* token = parser->args++;
FT_Int n;
FT_Error error;
if ( token->kind == tok_program ||
token->kind == tok_array )
{
/* get rid of `['/`]', or `{'/`}' */
FT_Byte* base = parser->tokenizer->base + token->start + 1;
FT_Byte* limit = base + token->len - 2;
FT_Byte* cur;
FT_Byte* start;
/* read each parameter independently */
cur = base;
for ( n = 0; n < 4; n++ )
{
FT_Long* result;
/* skip whitespace */
while ( cur < limit && *cur == ' ' )
cur++;
/* skip numbers */
start = cur;
while ( cur < limit && *cur != ' ' )
cur++;
/* compute result address */
switch ( n )
{
case 0:
result = &bbox->xMin;
break;
case 1:
result = &bbox->yMin;
break;
case 2:
result = &bbox->xMax;
break;
default:
result = &bbox->yMax;
}
error = parse_integer( start, cur, result );
if ( error )
goto Fail;
}
parser->error = 0;
return;
}
Fail:
FT_ERROR(( "CopyBBox: syntax error!\n" ));
parser->error = T1_Err_Syntax_Error;
}
LOCAL_FUNC
void CopyMatrix( T1_Parser* parser,
FT_Matrix* matrix )
{
T1_Token* token = parser->args++;
FT_Error error;
if ( token->kind == tok_array )
{
/* get rid of `[' and `]' */
FT_Byte* base = parser->tokenizer->base + token->start + 1;
FT_Byte* limit = base + token->len - 2;
FT_Byte* cur;
FT_Byte* start;
FT_Int n;
/* read each parameter independently */
cur = base;
for ( n = 0; n < 4; n++ )
{
FT_Long* result;
/* skip whitespace */
while ( cur < limit && *cur == ' ' )
cur++;
/* skip numbers */
start = cur;
while ( cur < limit && *cur != ' ')
cur++;
/* compute result address */
switch ( n )
{
case 0:
result = &matrix->xx;
break;
case 1:
result = &matrix->yx;
break;
case 2:
result = &matrix->xy;
break;
default:
result = &matrix->yy;
}
error = parse_float( start, cur, 65536000L, result );
if ( error )
goto Fail;
}
parser->error = 0;
return;
}
Fail:
FT_ERROR(( "CopyMatrix: syntax error!\n" ));
parser->error = T1_Err_Syntax_Error;
}
LOCAL_FUNC
void CopyArray( T1_Parser* parser,
FT_Byte* num_elements,
FT_Short* elements,
FT_Int max_elements )
{
T1_Token* token = parser->args++;
FT_Error error;
if ( token->kind == tok_array ||
token->kind == tok_program ) /* in the case of MinFeature */
{
/* get rid of `['/`]', or `{'/`}' */
FT_Byte* base = parser->tokenizer->base + token->start + 1;
FT_Byte* limit = base + token->len - 2;
FT_Byte* cur;
FT_Byte* start;
FT_Int n;
/* read each parameter independently */
cur = base;
for ( n = 0; n < max_elements; n++ )
{
FT_Long result;
/* test end of string */
if ( cur >= limit )
break;
/* skip whitespace */
while ( cur < limit && *cur == ' ' )
cur++;
/* end of list? */
if ( cur >= limit )
break;
/* skip numbers */
start = cur;
while ( cur < limit && *cur != ' ' )
cur++;
error = parse_integer( start, cur, &result );
if ( error )
goto Fail;
*elements++ = (FT_Short)result;
}
if ( num_elements )
*num_elements = (FT_Byte)n;
parser->error = 0;
return;
}
Fail:
FT_ERROR(( "CopyArray: syntax error!\n" ));
parser->error = T1_Err_Syntax_Error;
}
/* END */

View File

@@ -1,261 +0,0 @@
/***************************************************************************/
/* */
/* t1parse.h */
/* */
/* Type 1 parser (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* The Type1 parser component is in charge of simply parsing the font */
/* input stream and convert simple tokens and elements into integers, */
/* floats, matrices, strings, etc. */
/* */
/* It is used by the Type1 loader. */
/* */
/*************************************************************************/
#ifndef T1PARSE_H
#define T1PARSE_H
#include <freetype/internal/ftstream.h>
#ifdef FT_FLAT_COMPILE
#include "t1tokens.h"
#else
#include <type1/t1tokens.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************/
/* */
/* <Enum> */
/* T1_DictState */
/* */
/* <Description> */
/* An enumeration used to describe the Type 1 parser's state, i.e. */
/* which dictionary (or array) it is scanning and processing at the */
/* current moment. */
/* */
typedef enum T1_DictState_
{
dict_none = 0,
dict_font, /* parsing the font dictionary */
dict_fontinfo, /* parsing the font info dictionary */
dict_none2, /* beginning to parse the encrypted section */
dict_private, /* parsing the private dictionary */
dict_encoding, /* parsing the encoding array */
dict_subrs, /* parsing the subrs array */
dict_othersubrs, /* parsing the othersubrs array (?) */
dict_charstrings, /* parsing the charstrings dictionary */
dict_unknown_array, /* parsing/ignoring an unknown array */
dict_unknown_dict, /* parsing/ignoring an unknown dictionary */
dict_max /* do not remove from list */
} T1_DictState;
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Table */
/* */
/* <Description> */
/* A T1_Table is a simple object used to store an array of objects in */
/* a single memory block. */
/* */
/* <Fields> */
/* block :: The address in memory of the growheap's block. This */
/* can change between two object adds, due to */
/* reallocation. */
/* */
/* cursor :: The current top of the grow heap within its block. */
/* */
/* capacity :: The current size of the heap block. Increments by */
/* 1kByte chunks. */
/* */
/* max_elems :: The maximum number of elements in table. */
/* */
/* num_elems :: The current number of elements in table. */
/* */
/* elements :: A table of element addresses within the block. */
/* */
/* lengths :: A table of element sizes within the block. */
/* */
/* memory :: The object used for memory operations */
/* (alloc/realloc). */
/* */
typedef struct T1_Table_
{
FT_Byte* block; /* current memory block */
FT_Int cursor; /* current cursor in memory block */
FT_Int capacity; /* current size of memory block */
FT_Int max_elems;
FT_Int num_elems;
FT_Byte** elements; /* addresses of table elements */
FT_Int* lengths; /* lengths of table elements */
FT_Memory memory;
} T1_Table;
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Parser */
/* */
/* <Description> */
/* A Type 1 parser. This object is in charge of parsing Type 1 ASCII */
/* streams and builds dictionaries for a T1_Face object. */
/* */
/* <Fields> */
/* error :: The current error code. 0 means success. */
/* */
/* face :: The target T1_Face object being built. */
/* */
/* tokenizer :: The tokenizer (lexical analyser) used for */
/* processing the input stream. */
/* */
/* dump_tokens :: XXX */
/* */
/* stack :: The current token stack. Note that we don't */
/* use intermediate Postscript objects here! */
/* */
/* top :: The current top of token stack. */
/* */
/* limit :: The current upper bound of the token stack. */
/* Used for overflow checks. */
/* */
/* args :: The arguments of a given operator. Used and */
/* increased by the various CopyXXX() functions. */
/* */
/* state_index :: The index of the top of the dictionary state */
/* stack. */
/* */
/* state_stack :: The dictionary states stack. */
/* */
/* table :: A T1_Table object used to record various kinds */
/* of dictionaries or arrays (like `/Encoding', */
/* `/Subrs', `/CharStrings'). */
/* */
/* cur_name :: XXX */
/* */
/* encoding_type :: XXX */
/* */
/* encoding_names :: XXX */
/* */
/* encoding_lengths :: XXX */
/* */
/* encoding_offsets :: XXX */
/* */
/* subrs :: XXX */
/* */
/* charstrings :: XXX */
/* */
typedef struct T1_Parser_
{
FT_Error error;
T1_Face face;
T1_Tokenizer tokenizer;
FT_Bool dump_tokens;
T1_Token stack[T1_MAX_STACK_DEPTH];
T1_Token* top;
T1_Token* limit;
T1_Token* args;
FT_Int state_index;
T1_DictState state_stack[T1_MAX_DICT_DEPTH];
T1_Table table;
FT_Int cur_name;
T1_EncodingType encoding_type;
FT_Byte* encoding_names;
FT_Int* encoding_lengths;
FT_Byte** encoding_offsets;
FT_Byte* subrs;
FT_Byte* charstrings;
} T1_Parser;
LOCAL_DEF
FT_Error T1_New_Table( T1_Table* table,
FT_Int count,
FT_Memory memory );
LOCAL_DEF
FT_Error T1_Add_Table( T1_Table* table,
FT_Int index,
void* object,
FT_Int length );
LOCAL_DEF
void T1_Done_Table( T1_Table* table );
LOCAL_DEF
FT_String* CopyString( T1_Parser* parser );
LOCAL_DEF
FT_Long CopyInteger( T1_Parser* parser );
LOCAL_DEF
FT_Bool CopyBoolean( T1_Parser* parser );
LOCAL_DEF
FT_Long CopyFloat( T1_Parser* parser,
FT_Int scale );
LOCAL_DEF
void CopyBBox( T1_Parser* parser,
FT_BBox* bbox );
LOCAL_DEF
void CopyMatrix( T1_Parser* parser,
FT_Matrix* matrix );
LOCAL_DEF
void CopyArray( T1_Parser* parser,
FT_Byte* num_elements,
FT_Short* elements,
FT_Int max_elements );
#ifdef __cplusplus
}
#endif
#endif /* T1PARSE_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,258 +0,0 @@
/***************************************************************************/
/* */
/* t1tokens.h */
/* */
/* Type 1 tokenizer (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef T1TOKENS_H
#define T1TOKENS_H
#ifdef FT_FLAT_COMPILE
#include "t1objs.h"
#else
#include <type1/t1objs.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* enum value of first keyword */
#define key_first_ 100
/* enum value of first immediate name */
#define imm_first_ 200
typedef enum T1_TokenType_
{
tok_error = 0,
tok_eof, /* end of file */
/* simple token types */
tok_keyword, /* keyword */
tok_number, /* number (integer or real) */
tok_string, /* postscript string */
tok_program, /* postscript program */
tok_immediate, /* any immediate name */
tok_array, /* matrix, array, etc.. */
tok_hexarray, /* array of hexadecimal nibbles */
tok_any, /* anything else */
/* Postscript keywords -- placed in lexicographical order */
key_RD_alternate = key_first_, /* `-|' = alternate form of RD */
key_ExpertEncoding,
key_ND,
key_NP,
key_RD,
key_StandardEncoding,
key_array,
key_begin,
key_closefile,
key_currentdict,
key_currentfile,
key_def,
key_dict,
key_dup,
key_eexec,
key_end,
key_execonly,
key_false,
key_for,
key_index,
key_noaccess,
key_put,
key_readonly,
key_true,
key_userdict,
key_NP_alternate, /* `|' = alternate form of NP */
key_ND_alternate, /* `|-' = alternate form of ND */
key_max, /* always keep this value there */
/* Postscript immediate names -- other names will be ignored, except */
/* in charstrings */
imm_RD_alternate = imm_first_, /* `-|' = alternate form of RD */
imm_notdef, /* `/.notdef' immediate */
imm_BlendAxisTypes,
imm_BlueFuzz,
imm_BlueScale,
imm_BlueShift,
imm_BlueValues,
imm_CharStrings,
imm_Encoding,
imm_FamilyBlues,
imm_FamilyName,
imm_FamilyOtherBlues,
imm_FID,
imm_FontBBox,
imm_FontID,
imm_FontInfo,
imm_FontMatrix,
imm_FontName,
imm_FontType,
imm_ForceBold,
imm_FullName,
imm_ItalicAngle,
imm_LanguageGroup,
imm_Metrics,
imm_MinFeature,
imm_ND,
imm_NP,
imm_Notice,
imm_OtherBlues,
imm_OtherSubrs,
imm_PaintType,
imm_Private,
imm_RD,
imm_RndStemUp,
imm_StdHW,
imm_StdVW,
imm_StemSnapH,
imm_StemSnapV,
imm_StrokeWidth,
imm_Subrs,
imm_UnderlinePosition,
imm_UnderlineThickness,
imm_UniqueID,
imm_Weight,
imm_isFixedPitch,
imm_lenIV,
imm_password,
imm_version,
imm_NP_alternate, /* `|' = alternate form of NP */
imm_ND_alternate, /* `|-' = alternate form of ND */
imm_max /* always keep this value here */
} T1_TokenType;
/* these arrays are visible for debugging purposes */
extern const char* t1_keywords[];
extern const char* t1_immediates[];
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Token */
/* */
/* <Description> */
/* A structure used to describe a token in the current input stream. */
/* Note that the Type1 driver doesn't try to interpret tokens until */
/* it really needs to. */
/* */
/* <Fields> */
/* kind :: The token type. Describes the token to the loader. */
/* */
/* kind2 :: Detailed token type. */
/* */
/* start :: The index of the first character of token in the input */
/* stream. */
/* */
/* len :: The length of the token in characters. */
/* */
typedef struct T1_Token_
{
T1_TokenType kind; /* simple type */
T1_TokenType kind2; /* detailed type */
FT_Int start; /* index of first token character */
FT_Int len; /* length of token in chars */
} T1_Token;
typedef struct T1_TokenParser_
{
FT_Memory memory;
FT_Stream stream;
FT_Bool in_pfb; /* true if PFB file, PFA otherwise */
FT_Bool in_private; /* true if in private dictionary */
FT_Byte* base; /* base address of current read buffer */
FT_Long cursor; /* current position in read buffer */
FT_Long limit; /* limit of current read buffer */
FT_Long max; /* maximum size of read buffer */
FT_Error error; /* last error */
T1_Token token; /* last token read */
} T1_TokenParser;
/*************************************************************************/
/* */
/* <Type> */
/* T1_Tokenizer */
/* */
/* <Description> */
/* A handle to an object used to extract tokens from the input. The */
/* object is able to perform PFA/PFB recognition, eexec decryption of */
/* the private dictionary, as well as eexec decryption of the */
/* charstrings. */
/* */
typedef T1_TokenParser* T1_Tokenizer;
LOCAL_DEF
FT_Error New_Tokenizer( FT_Stream stream,
T1_Tokenizer* tokenizer );
LOCAL_DEF
FT_Error Done_Tokenizer( T1_Tokenizer tokenizer );
LOCAL_DEF
FT_Error Open_PrivateDict( T1_Tokenizer tokenizer );
LOCAL_DEF
FT_Error Read_Token( T1_Tokenizer tokenizer );
#if 0
LOCAL_DEF
FT_Error Read_CharStrings( T1_Tokenizer tokenizer,
FT_Int num_chars,
FT_Byte* buffer );
#endif /* 0 */
LOCAL_DEF
void t1_decrypt( FT_Byte* buffer,
FT_Int length,
FT_UShort seed );
#ifdef __cplusplus
}
#endif
#endif /* T1TOKENS_H */
/* END */

View File

@@ -1,59 +0,0 @@
/***************************************************************************/
/* */
/* type1.c */
/* */
/* FreeType Type 1 driver component (body only). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
#include "t1driver.c"
#include "t1objs.c"
#include "t1load.c"
#include "t1gload.c"
#include "t1tokens.c"
#include "t1parse.c"
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include "t1hinter.c"
#endif
#ifndef T1_CONFIG_OPTION_NO_AFM
#include "t1afm.c"
#endif
#else /* FT_FLAT_COMPILE */
#include <type1/t1driver.c>
#include <type1/t1objs.c>
#include <type1/t1load.c>
#include <type1/t1gload.c>
#include <type1/t1tokens.c>
#include <type1/t1parse.c>
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include <type1/t1hinter.c>
#endif
#ifndef T1_CONFIG_OPTION_NO_AFM
#include <type1/t1afm.c>
#endif
#endif /* FT_FLAT_COMPILE */
/* END */

View File

@@ -1,10 +0,0 @@
This directory contains an experimental Type 1 driver that will ultimately
replace the "official" one in "src/type1".
This driver doesn't provide a mini Postscript interpreter, but uses
pattern matching in order to load data from fonts. It works better and
faster than the official driver, but will replace it only when we finish
the auto-hinting module..
You don't need to compile it to support Type 1 fonts, the driver should
co-exist peacefully with the rest of the engine however..

View File

@@ -1,7 +0,0 @@
make_module_list: add_type1_driver
add_type1_driver:
$(OPEN_DRIVER)t1_driver_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE)
# EOF

View File

@@ -1,72 +0,0 @@
#
# FreeType 2 Type1z driver configuration rules
#
# Copyright 1996-2000 by
# 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.
# Type1z driver directory
#
T1Z_DIR := $(SRC_)type1z
T1Z_DIR_ := $(T1Z_DIR)$(SEP)
# compilation flags for the driver
#
T1Z_COMPILE := $(FT_COMPILE)
# Type1 driver sources (i.e., C files)
#
T1Z_DRV_SRC := $(T1Z_DIR_)z1parse.c \
$(T1Z_DIR_)z1load.c \
$(T1Z_DIR_)z1driver.c \
$(T1Z_DIR_)z1afm.c \
$(T1Z_DIR_)z1gload.c \
$(T1Z_DIR_)z1objs.c
# Type1 driver headers
#
T1Z_DRV_H := $(T1Z_DRV_SRC:%.c=%.h) \
$(T1Z_DIR_)z1tokens.h
# Type1z driver object(s)
#
# T1Z_DRV_OBJ_M is used during `multi' builds
# T1Z_DRV_OBJ_S is used during `single' builds
#
T1Z_DRV_OBJ_M := $(T1Z_DRV_SRC:$(T1Z_DIR_)%.c=$(OBJ_)%.$O)
T1Z_DRV_OBJ_S := $(OBJ_)type1z.$O
# Type1z driver source file for single build
#
T1Z_DRV_SRC_S := $(T1Z_DIR_)type1z.c
# Type1z driver - single object
#
$(T1Z_DRV_OBJ_S): $(T1Z_DRV_SRC_S) $(T1Z_DRV_SRC) $(FREETYPE_H) $(T1Z_DRV_H)
$(T1Z_COMPILE) $T$@ $(T1Z_DRV_SRC_S)
# Type1z driver - multiple objects
#
$(OBJ_)%.$O: $(T1Z_DIR_)%.c $(FREETYPE_H) $(T1Z_DRV_H)
$(T1Z_COMPILE) $T$@ $<
# update main driver object lists
#
DRV_OBJS_S += $(T1Z_DRV_OBJ_S)
DRV_OBJS_M += $(T1Z_DRV_OBJ_M)
# EOF

View File

@@ -1,49 +0,0 @@
/***************************************************************************/
/* */
/* type1z.c */
/* */
/* FreeType experimental Type 1 driver component (body only). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef FT_FLAT_COMPILE
#include "z1parse.c"
#include "z1load.c"
#include "z1objs.c"
#include "z1driver.c"
#include "z1gload.c"
#ifndef Z1_CONFIG_OPTION_NO_AFM
#include "z1afm.c"
#endif
#else /* FT_FLAT_COMPILE */
#include <type1z/z1parse.c>
#include <type1z/z1load.c>
#include <type1z/z1objs.c>
#include <type1z/z1driver.c>
#include <type1z/z1gload.c>
#ifndef Z1_CONFIG_OPTION_NO_AFM
#include <type1z/z1afm.c>
#endif
#endif /* FT_FLAT_COMPILE */
/* END */

View File

@@ -1,293 +0,0 @@
/***************************************************************************/
/* */
/* z1afm.c */
/* */
/* AFM support for Type 1 fonts (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifdef FT_FLAT_COMPILE
#include "z1afm.h"
#else
#include <type1z/z1afm.h>
#endif
#include <freetype/internal/ftstream.h>
#include <freetype/internal/t1types.h>
#include <stdlib.h> /* for qsort() */
#include <string.h> /* for strcmp() */
#include <ctype.h> /* for isalnum() */
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_z1afm
LOCAL_FUNC
void Z1_Done_AFM( FT_Memory memory,
Z1_AFM* afm )
{
FREE( afm->kern_pairs );
afm->num_pairs = 0;
}
#undef IS_KERN_PAIR
#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' )
#define IS_ALPHANUM( c ) ( isalnum( c ) || \
c == '_' || \
c == '.' )
/* read a glyph name and return the equivalent glyph index */
static
FT_UInt afm_atoindex( FT_Byte** start,
FT_Byte* limit,
T1_Font* type1 )
{
FT_Byte* p = *start;
FT_Int len;
FT_UInt result = 0;
char temp[64];
/* skip whitespace */
while ( ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) &&
p < limit )
p++;
*start = p;
/* now, read glyph name */
while ( IS_ALPHANUM( *p ) && p < limit )
p++;
len = p - *start;
if ( len > 0 && len < 64 )
{
FT_Int n;
/* copy glyph name to intermediate array */
MEM_Copy( temp, *start, len );
temp[len] = 0;
/* lookup glyph name in face array */
for ( n = 0; n < type1->num_glyphs; n++ )
{
char* gname = (char*)type1->glyph_names[n];
if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 )
{
result = n;
break;
}
}
}
*start = p;
return result;
}
/* read an integer */
static
int afm_atoi( FT_Byte** start,
FT_Byte* limit )
{
FT_Byte* p = *start;
int sum = 0;
int sign = 1;
/* skip everything that is not a number */
while ( p < limit && !isdigit( *p ) )
{
sign = 1;
if ( *p == '-' )
sign = -1;
p++;
}
while ( p < limit && isdigit( *p ) )
{
sum = sum * 10 + ( *p - '0' );
p++;
}
*start = p;
return sum * sign;
}
#undef KERN_INDEX
#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
/* compare two kerning pairs */
static
int compare_kern_pairs( const void* a,
const void* b )
{
Z1_Kern_Pair* pair1 = (Z1_Kern_Pair*)a;
Z1_Kern_Pair* pair2 = (Z1_Kern_Pair*)b;
FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 );
FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 );
return ( index1 - index2 );
}
/* parse an AFM file -- for now, only read the kerning pairs */
LOCAL_FUNC
FT_Error Z1_Read_AFM( FT_Face t1_face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_Byte* start;
FT_Byte* limit;
FT_Byte* p;
FT_Int count = 0;
Z1_Kern_Pair* pair;
T1_Font* type1 = &((T1_Face)t1_face)->type1;
Z1_AFM* afm = 0;
if ( ACCESS_Frame( stream->size ) )
return error;
start = (FT_Byte*)stream->cursor;
limit = (FT_Byte*)stream->limit;
p = start;
/* we are now going to count the occurences of `KP' or `KPX' in */
/* the AFM file */
count = 0;
for ( p = start; p < limit - 3; p++ )
{
if ( IS_KERN_PAIR( p ) )
count++;
}
/* Actually, kerning pairs are simply optional! */
if ( count == 0 )
goto Exit;
/* allocate the pairs */
if ( ALLOC( afm, sizeof ( *afm ) ) ||
ALLOC_ARRAY( afm->kern_pairs, count, Z1_Kern_Pair ) )
goto Exit;
/* now, read each kern pair */
pair = afm->kern_pairs;
afm->num_pairs = count;
/* save in face object */
((T1_Face)t1_face)->afm_data = afm;
for ( p = start; p < limit - 3; p++ )
{
if ( IS_KERN_PAIR( p ) )
{
FT_Byte* q;
/* skip keyword (KP or KPX) */
q = p + 2;
if ( *q == 'X' )
q++;
pair->glyph1 = afm_atoindex( &q, limit, type1 );
pair->glyph2 = afm_atoindex( &q, limit, type1 );
pair->kerning.x = afm_atoi( &q, limit );
pair->kerning.y = 0;
if ( p[2] != 'X' )
pair->kerning.y = afm_atoi( &q, limit );
pair++;
}
}
/* now, sort the kern pairs according to their glyph indices */
qsort( afm->kern_pairs, count, sizeof ( Z1_Kern_Pair ),
compare_kern_pairs );
Exit:
if ( error )
FREE( afm );
FORGET_Frame();
return error;
}
/* find the kerning for a given glyph pair */
LOCAL_FUNC
void Z1_Get_Kerning( Z1_AFM* afm,
FT_UInt glyph1,
FT_UInt glyph2,
FT_Vector* kerning )
{
Z1_Kern_Pair *min, *mid, *max;
FT_ULong index = KERN_INDEX( glyph1, glyph2 );
/* simple binary search */
min = afm->kern_pairs;
max = min + afm->num_pairs - 1;
while ( min <= max )
{
FT_ULong midi;
mid = min + ( max - min ) / 2;
midi = KERN_INDEX( mid->glyph1, mid->glyph2 );
if ( midi == index )
{
*kerning = mid->kerning;
return;
}
if ( midi < index )
min = mid + 1;
else
max = mid - 1;
}
kerning->x = 0;
kerning->y = 0;
}
/* END */

View File

@@ -1,79 +0,0 @@
/***************************************************************************/
/* */
/* z1afm.h */
/* */
/* AFM support for Type 1 fonts (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef Z1AFM_H
#define Z1AFM_H
#ifdef FT_FLAT_COMPILE
#include "z1objs.h"
#else
#include <type1z/z1objs.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Z1_Kern_Pair_
{
FT_UInt glyph1;
FT_UInt glyph2;
FT_Vector kerning;
} Z1_Kern_Pair;
typedef struct Z1_AFM_
{
FT_Int num_pairs;
Z1_Kern_Pair* kern_pairs;
} Z1_AFM;
LOCAL_DEF
FT_Error Z1_Read_AFM( FT_Face face,
FT_Stream stream );
LOCAL_DEF
void Z1_Done_AFM( FT_Memory memory,
Z1_AFM* afm );
LOCAL_DEF
void Z1_Get_Kerning( Z1_AFM* afm,
FT_UInt glyph1,
FT_UInt glyph2,
FT_Vector* kerning );
#ifdef __cplusplus
}
#endif
#endif /* Z1AFM_H */
/* END */

View File

@@ -1,340 +0,0 @@
/***************************************************************************/
/* */
/* z1driver.c */
/* */
/* Experimental Type 1 driver interface (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifdef FT_FLAT_COMPILE
#include "z1driver.h"
#include "z1gload.h"
#include "z1load.h"
#include "z1afm.h"
#else
#include <type1z/z1driver.h>
#include <type1z/z1gload.h>
#include <type1z/z1load.h>
#include <type1z/z1afm.h>
#endif
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/psnames.h>
#include <string.h> /* for strcmp() */
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_z1driver
static
FT_Error get_z1_glyph_name( T1_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_String* gname;
gname = face->type1.glyph_names[glyph_index];
if ( buffer_max > 0 )
{
FT_UInt len = strlen( gname );
if (len >= buffer_max)
len = buffer_max - 1;
MEM_Copy( buffer, gname, len );
((FT_Byte*)buffer)[len] = 0;
}
return T1_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* Get_Interface */
/* */
/* <Description> */
/* Each driver can provide one or more extensions to the base */
/* FreeType API. These can be used to access format specific */
/* features (e.g., all TrueType/OpenType resources share a common */
/* file structure and common tables which can be accessed through the */
/* `sfnt' interface), or more simply generic ones (e.g., the */
/* `postscript names' interface which can be used to retrieve the */
/* PostScript name of a given glyph index). */
/* */
/* <InOut> */
/* driver :: A handle to a driver object. */
/* */
/* <Input> */
/* interface :: A string designing the interface. Examples are */
/* `sfnt', `post_names', `charmaps', etc. */
/* */
/* <Return> */
/* A typeless pointer to the extension's interface (normally a table */
/* of function pointers). Returns NULL if the requested extension */
/* isn't available (i.e., wasn't compiled in the driver at build */
/* time). */
/* */
static
FT_Module_Interface Get_Interface( FT_Driver driver,
const FT_String* interface )
{
FT_UNUSED( driver );
FT_UNUSED( interface );
if ( strcmp( (const char*)interface, "glyph_name" ) == 0 )
return (FT_Module_Interface)get_z1_glyph_name;
#ifndef Z1_CONFIG_OPTION_NO_MM_SUPPORT
if ( strcmp( (const char*)interface, "get_mm" ) == 0 )
return (FT_Module_Interface)Z1_Get_Multi_Master;
if ( strcmp( (const char*)interface, "set_mm_design") == 0 )
return (FT_Module_Interface)Z1_Set_MM_Design;
if ( strcmp( (const char*)interface, "set_mm_blend") == 0 )
return (FT_Module_Interface)Z1_Set_MM_Blend;
#endif
return 0;
}
#ifndef Z1_CONFIG_OPTION_NO_AFM
/*************************************************************************/
/* */
/* <Function> */
/* Get_Kerning */
/* */
/* <Description> */
/* A driver method used to return the kerning vector between two */
/* glyphs of the same face. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* left_glyph :: The index of the left glyph in the kern pair. */
/* */
/* right_glyph :: The index of the right glyph in the kern pair. */
/* */
/* <Output> */
/* kerning :: The kerning vector. This is in font units for */
/* scalable formats, and in pixels for fixed-sizes */
/* formats. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only horizontal layouts (left-to-right & right-to-left) are */
/* supported by this function. Other layouts, or more sophisticated */
/* kernings are out of scope of this method (the basic driver */
/* interface is meant to be simple). */
/* */
/* They can be implemented by format-specific interfaces. */
/* */
static
FT_Error Get_Kerning( T1_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
{
Z1_AFM* afm;
kerning->x = 0;
kerning->y = 0;
afm = (Z1_AFM*)face->afm_data;
if ( afm )
Z1_Get_Kerning( afm, left_glyph, right_glyph, kerning );
return T1_Err_Ok;
}
#endif /* T1_CONFIG_OPTION_NO_AFM */
/*************************************************************************/
/* */
/* <Function> */
/* Get_Char_Index */
/* */
/* <Description> */
/* Uses a charmap to return a given character code's glyph index. */
/* */
/* <Input> */
/* charmap :: A handle to the source charmap object. */
/* charcode :: The character code. */
/* */
/* <Return> */
/* Glyph index. 0 means `undefined character code'. */
/* */
static
FT_UInt Get_Char_Index( FT_CharMap charmap,
FT_Long charcode )
{
T1_Face face;
FT_UInt result = 0;
PSNames_Interface* psnames;
face = (T1_Face)charmap->face;
psnames = (PSNames_Interface*)face->psnames;
if ( psnames )
switch ( charmap->encoding )
{
/*******************************************************************/
/* */
/* Unicode encoding support */
/* */
case ft_encoding_unicode:
/* use the `PSNames' module to synthetize the Unicode charmap */
result = psnames->lookup_unicode( &face->unicode_map,
(FT_ULong)charcode );
/* the function returns 0xFFFF if the Unicode charcode has */
/* no corresponding glyph */
if ( result == 0xFFFF )
result = 0;
goto Exit;
/*******************************************************************/
/* */
/* Custom Type 1 encoding */
/* */
case ft_encoding_adobe_custom:
{
T1_Encoding* encoding = &face->type1.encoding;
if ( charcode >= encoding->code_first &&
charcode <= encoding->code_last )
result = encoding->char_index[charcode];
goto Exit;
}
/*******************************************************************/
/* */
/* Adobe Standard & Expert encoding support */
/* */
default:
if ( charcode < 256 )
{
FT_UInt code;
FT_Int n;
const char* glyph_name;
code = psnames->adobe_std_encoding[charcode];
if ( charmap->encoding == ft_encoding_adobe_expert )
code = psnames->adobe_expert_encoding[charcode];
glyph_name = psnames->adobe_std_strings( code );
if ( !glyph_name )
break;
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
const char* gname = face->type1.glyph_names[n];
if ( gname && gname[0] == glyph_name[0] &&
strcmp( gname, glyph_name ) == 0 )
{
result = n;
break;
}
}
}
}
Exit:
return result;
}
const FT_Driver_Class t1_driver_class =
{
{
ft_module_font_driver | ft_module_driver_scalable,
sizeof( FT_DriverRec ),
"type1",
0x10000L,
0x20000L,
0, /* format interface */
(FT_Module_Constructor)Z1_Init_Driver,
(FT_Module_Destructor) Z1_Done_Driver,
(FT_Module_Requester) Get_Interface,
},
sizeof( T1_FaceRec ),
sizeof( Z1_SizeRec ),
sizeof( Z1_GlyphSlotRec ),
(FTDriver_initFace) Z1_Init_Face,
(FTDriver_doneFace) Z1_Done_Face,
(FTDriver_initSize) 0,
(FTDriver_doneSize) 0,
(FTDriver_initGlyphSlot)0,
(FTDriver_doneGlyphSlot)0,
(FTDriver_setCharSizes) 0,
(FTDriver_setPixelSizes)0,
(FTDriver_loadGlyph) Z1_Load_Glyph,
(FTDriver_getCharIndex) Get_Char_Index,
#ifdef Z1_CONFIG_OPTION_NO_AFM
(FTDriver_getKerning) 0,
(FTDriver_attachFile) 0,
#else
(FTDriver_getKerning) Get_Kerning,
(FTDriver_attachFile) Z1_Read_AFM,
#endif
(FTDriver_getAdvances) 0
};
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
EXPORT_FUNC( const FT_Driver_Class* ) getDriverClass( void )
{
return &t1z_driver_class;
}
#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */
/* END */

View File

@@ -1,29 +0,0 @@
/***************************************************************************/
/* */
/* z1driver.h */
/* */
/* High-level experimental Type 1 driver interface (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef Z1DRIVER_H
#define Z1DRIVER_H
#include <freetype/internal/ftdriver.h>
FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class;
#endif /* Z1DRIVER_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,187 +0,0 @@
/***************************************************************************/
/* */
/* z1gload.h */
/* */
/* Experimental Type 1 Glyph Loader (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef Z1GLOAD_H
#define Z1GLOAD_H
#ifdef FT_FLAT_COMPILE
#include "z1objs.h"
#else
#include <type1z/z1objs.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************/
/* */
/* <Structure> */
/* Z1_Builder */
/* */
/* <Description> */
/* A structure used during glyph loading to store its outline. */
/* */
/* <Fields> */
/* memory :: The current memory object. */
/* */
/* face :: The current face object. */
/* */
/* glyph :: The current glyph slot. */
/* */
/* loader :: The current glyph loader. */
/* */
/* current :: The current glyph outline. */
/* */
/* base :: The base glyph outline. */
/* */
/* last :: The last point position. */
/* */
/* scale_x :: The horizontal scale (FUnits to sub-pixels). */
/* */
/* scale_y :: The vertical scale (FUnits to sub-pixels). */
/* */
/* pos_x :: The horizontal translation (for composite glyphs). */
/* */
/* pos_y :: The vertical translation (for composite glyphs). */
/* */
/* left_bearing :: The left side bearing point. */
/* */
/* advance :: The horizontal advance vector. */
/* */
/* no_recurse :: */
/* */
/* bbox :: The glyph's bounding box. */
/* */
/* path_begun :: A flag which indicates that a new path has begun. */
/* */
/* load_points :: A flag which indicates, if not set, that no points */
/* are loaded. */
/* */
/* error :: The current error code. */
/* */
/* metrics_only :: A flag whether to compute metrics only. */
/* */
typedef struct Z1_Builder_
{
FT_Memory memory;
T1_Face face;
Z1_GlyphSlot glyph;
FT_GlyphLoader* loader;
FT_Outline* current; /* the current glyph outline */
FT_Outline* base; /* the composite glyph outline */
FT_Vector last;
FT_Fixed scale_x;
FT_Fixed scale_y;
FT_Pos pos_x;
FT_Pos pos_y;
FT_Vector left_bearing;
FT_Vector advance;
FT_BBox bbox; /* bounding box */
FT_Bool path_begun;
FT_Bool load_points;
FT_Bool no_recurse;
FT_Error error; /* only used for memory errors */
FT_Bool metrics_only;
} Z1_Builder;
/* execution context charstring zone */
typedef struct Z1_Decoder_Zone_
{
FT_Byte* base;
FT_Byte* limit;
FT_Byte* cursor;
} Z1_Decoder_Zone;
typedef struct Z1_Decoder_
{
Z1_Builder builder;
FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
FT_Int* top;
Z1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
Z1_Decoder_Zone* zone;
FT_Int flex_state;
FT_Int num_flex_vectors;
FT_Vector flex_vectors[7];
T1_Blend* blend; /* for multiple masters */
} Z1_Decoder;
LOCAL_DEF
void Z1_Init_Builder( Z1_Builder* builder,
T1_Face face,
Z1_Size size,
Z1_GlyphSlot glyph );
LOCAL_DEF
void Z1_Done_Builder( Z1_Builder* builder );
LOCAL_DEF
void Z1_Init_Decoder( Z1_Decoder* decoder );
LOCAL_DEF
FT_Error Z1_Compute_Max_Advance( T1_Face face,
FT_Int* max_advance );
LOCAL_DEF
FT_Error Z1_Parse_CharStrings( Z1_Decoder* decoder,
FT_Byte* charstring_base,
FT_Int charstring_len,
FT_Int num_subrs,
FT_Byte** subrs_base,
FT_Int* subrs_len );
LOCAL_DEF
FT_Error Z1_Load_Glyph( Z1_GlyphSlot glyph,
Z1_Size size,
FT_Int glyph_index,
FT_Int load_flags );
#ifdef __cplusplus
}
#endif
#endif /* Z1GLOAD_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,93 +0,0 @@
/***************************************************************************/
/* */
/* z1load.h */
/* */
/* Experimental Type 1 font loader (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef Z1LOAD_H
#define Z1LOAD_H
#include <freetype/internal/ftstream.h>
#include <freetype/internal/t1types.h>
#include <freetype/ftmm.h>
#ifdef FT_FLAT_COMPILE
#include "z1parse.h"
#else
#include <type1z/z1parse.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Z1_Loader_
{
Z1_Parser parser; /* parser used to read the stream */
FT_Int num_chars; /* number of characters in encoding */
Z1_Table encoding_table; /* Z1_Table used to store the */
/* encoding character names */
FT_Int num_glyphs;
Z1_Table glyph_names;
Z1_Table charstrings;
FT_Int num_subrs;
Z1_Table subrs;
FT_Bool fontdata;
} Z1_Loader;
LOCAL_DEF
FT_Error Z1_Open_Face( T1_Face face );
#ifndef Z1_CONFIG_OPTION_NO_MM_SUPPORT
LOCAL_DEF
FT_Error Z1_Get_Multi_Master( T1_Face face,
FT_Multi_Master* master );
LOCAL_DEF
FT_Error Z1_Set_MM_Blend( T1_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
LOCAL_DEF
FT_Error Z1_Set_MM_Design( T1_Face face,
FT_UInt num_coords,
FT_Long* coords );
LOCAL_DEF
void Z1_Done_Blend( T1_Face face );
#endif /* !Z1_CONFIG_OPTION_NO_MM_SUPPORT */
#ifdef __cplusplus
}
#endif
#endif /* Z1LOAD_H */
/* END */

View File

@@ -1,398 +0,0 @@
/***************************************************************************/
/* */
/* z1objs.c */
/* */
/* Experimental Type 1 objects manager (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#ifdef FT_FLAT_COMPILE
#include "z1gload.h"
#include "z1load.h"
#include "z1afm.h"
#else
#include <type1z/z1gload.h>
#include <type1z/z1load.h>
#include <type1z/z1afm.h>
#endif
#include <freetype/internal/psnames.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_z1objs
/*************************************************************************/
/* */
/* FACE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* Z1_Done_Face */
/* */
/* <Description> */
/* The face object destructor. */
/* */
/* <Input> */
/* face :: A typeless pointer to the face object to destroy. */
/* */
LOCAL_FUNC
void Z1_Done_Face( T1_Face face )
{
FT_Memory memory;
T1_Font* type1 = &face->type1;
if ( face )
{
memory = face->root.memory;
#ifndef Z1_CONFIG_OPTION_NO_MM_SUPPORT
/* release multiple masters information */
Z1_Done_Blend( face );
face->blend = 0;
#endif
/* release font info strings */
{
T1_FontInfo* info = &type1->font_info;
FREE( info->version );
FREE( info->notice );
FREE( info->full_name );
FREE( info->family_name );
FREE( info->weight );
}
/* release top dictionary */
FREE( type1->charstrings_len );
FREE( type1->charstrings );
FREE( type1->glyph_names );
FREE( type1->subrs );
FREE( type1->subrs_len );
FREE( type1->subrs_block );
FREE( type1->charstrings_block );
FREE( type1->glyph_names_block );
FREE( type1->encoding.char_index );
FREE( type1->font_name );
#ifndef Z1_CONFIG_OPTION_NO_AFM
/* release afm data if present */
if ( face->afm_data )
Z1_Done_AFM( memory, (Z1_AFM*)face->afm_data );
#endif
/* release unicode map, if any */
FREE( face->unicode_map.maps );
face->unicode_map.num_maps = 0;
face->root.family_name = 0;
face->root.style_name = 0;
}
}
/*************************************************************************/
/* */
/* <Function> */
/* Z1_Init_Face */
/* */
/* <Description> */
/* The face object constructor. */
/* */
/* <Input> */
/* stream :: input stream where to load font data. */
/* */
/* face_index :: The index of the font face in the resource. */
/* */
/* num_params :: Number of additional generic parameters. Ignored. */
/* */
/* params :: Additional generic parameters. Ignored. */
/* */
/* <InOut> */
/* face :: The face record to build. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error Z1_Init_Face( FT_Stream stream,
T1_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
PSNames_Interface* psnames;
FT_UNUSED( num_params );
FT_UNUSED( params );
FT_UNUSED( face_index );
FT_UNUSED( stream );
face->root.num_faces = 1;
psnames = (PSNames_Interface*)face->psnames;
if ( !psnames )
{
psnames = (PSNames_Interface*)
FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "psnames" );
face->psnames = psnames;
}
/* open the tokenizer, this will also check the font format */
error = Z1_Open_Face( face );
if ( error )
goto Exit;
/* if we just wanted to check the format, leave successfully now */
if ( face_index < 0 )
goto Exit;
/* check the face index */
if ( face_index != 0 )
{
FT_ERROR(( "Z1_Init_Face: invalid face index\n" ));
error = T1_Err_Invalid_Argument;
goto Exit;
}
/* Now, load the font program into the face object */
/* Init the face object fields */
/* Now set up root face fields */
{
FT_Face root = (FT_Face)&face->root;
root->num_glyphs = face->type1.num_glyphs;
root->num_charmaps = 1;
root->face_index = face_index;
root->face_flags = FT_FACE_FLAG_SCALABLE;
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
if ( face->type1.font_info.is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( face->blend )
root->face_flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
/* XXX: TODO -- add kerning with .afm support */
/* get style name -- be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
root->family_name = face->type1.font_info.family_name;
if ( root->family_name )
{
char* full = face->type1.font_info.full_name;
char* family = root->family_name;
while ( *family && *full == *family )
{
family++;
full++;
}
root->style_name = ( *full == ' ' ? full + 1
: (char *)"Regular" );
}
else
{
/* do we have a `/FontName'? */
if ( face->type1.font_name )
{
root->family_name = face->type1.font_name;
root->style_name = "Regular";
}
}
/* no embedded bitmap support */
root->num_fixed_sizes = 0;
root->available_sizes = 0;
root->bbox = face->type1.font_bbox;
root->units_per_EM = 1000;
root->ascender = (FT_Short)face->type1.font_bbox.yMax;
root->descender = -(FT_Short)face->type1.font_bbox.yMin;
root->height = ( ( root->ascender + root->descender ) * 12 ) / 10;
/* now compute the maximum advance width */
root->max_advance_width = face->type1.private_dict.standard_width[0];
/* compute max advance width for proportional fonts */
if ( !face->type1.font_info.is_fixed_pitch )
{
FT_Int max_advance;
error = Z1_Compute_Max_Advance( face, &max_advance );
/* in case of error, keep the standard width */
if ( !error )
root->max_advance_width = max_advance;
else
error = 0; /* clear error */
}
root->max_advance_height = root->height;
root->underline_position = face->type1.font_info.underline_position;
root->underline_thickness = face->type1.font_info.underline_thickness;
root->max_points = 0;
root->max_contours = 0;
}
/* charmap support -- synthetize unicode charmap if possible */
{
FT_Face root = &face->root;
FT_CharMap charmap = face->charmaprecs;
/* synthesize a Unicode charmap if there is support in the `PSNames' */
/* module */
if ( face->psnames )
{
PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
if ( psnames->unicode_value )
{
error = psnames->build_unicodes(
root->memory,
face->type1.num_glyphs,
(const char**)face->type1.glyph_names,
&face->unicode_map );
if ( !error )
{
root->charmap = charmap;
charmap->face = (FT_Face)face;
charmap->encoding = ft_encoding_unicode;
charmap->platform_id = 3;
charmap->encoding_id = 1;
charmap++;
}
/* simply clear the error in case of failure (which really) */
/* means that out of memory or no unicode glyph names */
error = FT_Err_Ok;
}
}
/* now, support either the standard, expert, or custom encoding */
charmap->face = (FT_Face)face;
charmap->platform_id = 7; /* a new platform id for Adobe fonts? */
switch ( face->type1.encoding_type )
{
case t1_encoding_standard:
charmap->encoding = ft_encoding_adobe_standard;
charmap->encoding_id = 0;
break;
case t1_encoding_expert:
charmap->encoding = ft_encoding_adobe_expert;
charmap->encoding_id = 1;
break;
default:
charmap->encoding = ft_encoding_adobe_custom;
charmap->encoding_id = 2;
break;
}
root->charmaps = face->charmaps;
root->num_charmaps = charmap - face->charmaprecs + 1;
face->charmaps[0] = &face->charmaprecs[0];
face->charmaps[1] = &face->charmaprecs[1];
}
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* Z1_Init_Driver */
/* */
/* <Description> */
/* Initializes a given Type 1 driver object. */
/* */
/* <Input> */
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error Z1_Init_Driver( Z1_Driver driver )
{
FT_UNUSED( driver );
return T1_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* Z1_Done_Driver */
/* */
/* <Description> */
/* Finalizes a given Type 1 driver. */
/* */
/* <Input> */
/* driver :: A handle to the target Type 1 driver. */
/* */
LOCAL_DEF
void Z1_Done_Driver( Z1_Driver driver )
{
FT_UNUSED( driver );
}
/* END */

View File

@@ -1,161 +0,0 @@
/***************************************************************************/
/* */
/* z1objs.h */
/* */
/* Experimental Type 1 objects manager (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef Z1OBJS_H
#define Z1OBJS_H
#include <freetype/internal/ftobjs.h>
#include <freetype/config/ftconfig.h>
#include <freetype/internal/t1errors.h>
#include <freetype/internal/t1types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The following structures must be defined by the hinter */
typedef struct Z1_Size_Hints_ Z1_Size_Hints;
typedef struct Z1_Glyph_Hints_ Z1_Glyph_Hints;
/*************************************************************************/
/* */
/* <Type> */
/* Z1_Driver */
/* */
/* <Description> */
/* A handle to a Type 1 driver object. */
/* */
typedef struct Z1_DriverRec_ *Z1_Driver;
/*************************************************************************/
/* */
/* <Type> */
/* Z1_Size */
/* */
/* <Description> */
/* A handle to a Type 1 size object. */
/* */
typedef struct Z1_SizeRec_* Z1_Size;
/*************************************************************************/
/* */
/* <Type> */
/* Z1_GlyphSlot */
/* */
/* <Description> */
/* A handle to a Type 1 glyph slot object. */
/* */
typedef struct Z1_GlyphSlotRec_* Z1_GlyphSlot;
/*************************************************************************/
/* */
/* <Type> */
/* Z1_CharMap */
/* */
/* <Description> */
/* A handle to a Type 1 character mapping object. */
/* */
/* <Note> */
/* The Type 1 format doesn't use a charmap but an encoding table. */
/* The driver is responsible for making up charmap objects */
/* corresponding to these tables. */
/* */
typedef struct Z1_CharMapRec_* Z1_CharMap;
/*************************************************************************/
/* */
/* HERE BEGINS THE TYPE1 SPECIFIC STUFF */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Type> */
/* Z1_SizeRec */
/* */
/* <Description> */
/* Type 1 size record. */
/* */
typedef struct Z1_SizeRec_
{
FT_SizeRec root;
FT_Bool valid;
Z1_Size_Hints* hints; /* defined in the hinter. This allows */
/* us to experiment with different */
/* hinting schemes without having to */
/* change `z1objs' each time. */
} Z1_SizeRec;
/*************************************************************************/
/* */
/* <Type> */
/* Z1_GlyphSlotRec */
/* */
/* <Description> */
/* Type 1 glyph slot record. */
/* */
typedef struct Z1_GlyphSlotRec_
{
FT_GlyphSlotRec root;
FT_Bool hint;
FT_Bool scaled;
FT_Int max_points;
FT_Int max_contours;
FT_Fixed x_scale;
FT_Fixed y_scale;
Z1_Glyph_Hints* hints; /* defined in the hinter */
} Z1_GlyphSlotRec;
LOCAL_DEF
FT_Error Z1_Init_Face( FT_Stream stream,
T1_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
LOCAL_DEF
void Z1_Done_Face( T1_Face face );
LOCAL_DEF
FT_Error Z1_Init_Driver( Z1_Driver driver );
LOCAL_DEF
void Z1_Done_Driver( Z1_Driver driver );
#ifdef __cplusplus
}
#endif
#endif /* Z1OBJS_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@@ -1,363 +0,0 @@
/***************************************************************************/
/* */
/* z1parse.h */
/* */
/* Experimental Type 1 parser (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef Z1PARSE_H
#define Z1PARSE_H
#include <freetype/internal/t1types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* simple enumeration type used to identify token types */
typedef enum Z1_Token_Type_
{
t1_token_none = 0,
t1_token_any,
t1_token_string,
t1_token_array,
/* do not remove */
t1_token_max
} Z1_Token_Type;
/* a simple structure used to identify tokens */
typedef struct Z1_Token_Rec_
{
FT_Byte* start; /* first character of token in input stream */
FT_Byte* limit; /* first character after the token */
Z1_Token_Type type; /* type of token.. */
} Z1_Token_Rec;
/* enumeration type used to identify object fields */
typedef enum Z1_Field_Type_
{
t1_field_none = 0,
t1_field_bool,
t1_field_integer,
t1_field_fixed,
t1_field_string,
t1_field_integer_array,
t1_field_fixed_array,
/* do not remove */
t1_field_max
} Z1_Field_Type;
/* structure type used to model object fields */
typedef struct Z1_Field_Rec_
{
Z1_Field_Type type; /* type of field */
FT_UInt offset; /* offset of field in object */
FT_UInt size; /* size of field in bytes */
FT_UInt array_max; /* maximum number of elements for array */
FT_UInt count_offset; /* offset of element count for arrays */
FT_Int flag_bit; /* bit number for field flag */
} Z1_Field_Rec;
#define Z1_FIELD_REF( s, f ) ( ((s*)0)->f )
#define Z1_FIELD_BOOL( _ftype, _fname ) \
{ \
t1_field_bool, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
0, 0, 0 \
}
#define Z1_FIELD_NUM( _ftype, _fname ) \
{ \
t1_field_integer, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
0, 0, 0 \
}
#define Z1_FIELD_FIXED( _ftype, _fname, _power ) \
{ \
t1_field_fixed, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
0, 0, 0 \
}
#define Z1_FIELD_STRING( _ftype, _fname ) \
{ \
t1_field_string, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
sizeof ( Z1_FIELD_REF( _ftype, _fname ) ), \
0, 0, 0 \
}
#define Z1_FIELD_NUM_ARRAY( _ftype, _fname, _fcount, _fmax ) \
{ \
t1_field_integer, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
_fmax, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fcount ), \
0 \
}
#define Z1_FIELD_FIXED_ARRAY( _ftype, _fname, _fcount, _fmax ) \
{ \
t1_field_fixed, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
_fmax, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fcount ), \
0 \
}
#define Z1_FIELD_NUM_ARRAY2( _ftype, _fname, _fmax ) \
{ \
t1_field_integer, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
_fmax, \
0, 0 \
}
#define Z1_FIELD_FIXED_ARRAY2( _ftype, _fname, _fmax ) \
{ \
t1_field_fixed, \
(FT_UInt)(char*)&Z1_FIELD_REF( _ftype, _fname ), \
sizeof ( Z1_FIELD_REF( _ftype, _fname )[0] ), \
_fmax, \
0, 0 \
}
/*************************************************************************/
/* */
/* <Struct> */
/* Z1_Table */
/* */
/* <Description> */
/* A Z1_Table is a simple object used to store an array of objects in */
/* a single memory block. */
/* */
/* <Fields> */
/* block :: The address in memory of the growheap's block. This */
/* can change between two object adds, due to the use of */
/* reallocation. */
/* */
/* cursor :: The current top of the grow heap within its block. */
/* */
/* capacity :: The current size of the heap block. Increments in */
/* 1kByte blocks. */
/* */
/* init :: A boolean. Set when the table has been initialized */
/* (the table user should set this field). */
/* */
/* max_elems :: The maximum number of elements in the table. */
/* */
/* num_elems :: The current number of elements in the table. */
/* */
/* elements :: A table of element addresses within the block. */
/* */
/* lengths :: A table of element sizes within the block. */
/* */
/* memory :: The memory object used for memory operations */
/* (allocation/reallocation). */
/* */
typedef struct Z1_Table_
{
FT_Byte* block; /* current memory block */
FT_Int cursor; /* current cursor in memory block */
FT_Int capacity; /* current size of memory block */
FT_Long init;
FT_Int max_elems;
FT_Int num_elems;
FT_Byte** elements; /* addresses of table elements */
FT_Int* lengths; /* lengths of table elements */
FT_Memory memory;
} Z1_Table;
/*************************************************************************/
/* */
/* <Struct> */
/* Z1_Parser */
/* */
/* <Description> */
/* A Z1_Parser is an object used to parse a Type 1 fonts very */
/* quickly. */
/* */
/* <Fields> */
/* stream :: The current input stream. */
/* */
/* memory :: The current memory object. */
/* */
/* base_dict :: A pointer to the top-level dictionary. */
/* */
/* base_len :: The length in bytes of the top dictionary. */
/* */
/* private_dict :: A pointer to the private dictionary. */
/* */
/* private_len :: The length in bytes of the private dictionary. */
/* */
/* in_pfb :: A boolean. Indicates that we are handling a PFB */
/* file. */
/* */
/* in_memory :: A boolean. Indicates a memory-based stream. */
/* */
/* single_block :: A boolean. Indicates that the private dictionary */
/* is stored in lieu of the base dictionary. */
/* */
/* cursor :: The current parser cursor. */
/* */
/* limit :: The current parser limit (first byte after the */
/* current dictionary). */
/* */
/* error :: The current parsing error. */
/* */
typedef struct Z1_Parser_
{
FT_Stream stream;
FT_Memory memory;
FT_Byte* base_dict;
FT_Int base_len;
FT_Byte* private_dict;
FT_Int private_len;
FT_Byte in_pfb;
FT_Byte in_memory;
FT_Byte single_block;
FT_Byte* cursor;
FT_Byte* limit;
FT_Error error;
} Z1_Parser;
LOCAL_DEF
FT_Error Z1_New_Table( Z1_Table* table,
FT_Int count,
FT_Memory memory );
LOCAL_DEF
FT_Error Z1_Add_Table( Z1_Table* table,
FT_Int index,
void* object,
FT_Int length );
#if 0
LOCAL_DEF
void Z1_Done_Table( Z1_Table* table );
#endif
LOCAL_DEF
void Z1_Release_Table( Z1_Table* table );
LOCAL_DEF
FT_Long Z1_ToInt( Z1_Parser* parser );
LOCAL_DEF
FT_Long Z1_ToFixed( Z1_Parser* parser,
FT_Int power_ten );
LOCAL_DEF
FT_Int Z1_ToCoordArray( Z1_Parser* parser,
FT_Int max_coords,
FT_Short* coords );
LOCAL_DEF
FT_Int Z1_ToFixedArray( Z1_Parser* parser,
FT_Int max_values,
FT_Fixed* values,
FT_Int power_ten );
#if 0
LOCAL_DEF
FT_String* Z1_ToString( Z1_Parser* parser );
LOCAL_DEF
FT_Bool Z1_ToBool( Z1_Parser* parser );
#endif
LOCAL_DEF
void Z1_Skip_Spaces( Z1_Parser* parser );
LOCAL_DEF
void Z1_ToToken( Z1_Parser* parser,
Z1_Token_Rec* token );
LOCAL_FUNC
void Z1_ToTokenArray( Z1_Parser* parser,
Z1_Token_Rec* tokens,
FT_UInt max_tokens,
FT_Int* pnum_tokens );
LOCAL_DEF
FT_Error Z1_Load_Field( Z1_Parser* parser,
const Z1_Field_Rec* field,
void** objects,
FT_UInt max_objects,
FT_ULong* pflags );
LOCAL_DEF
FT_Error Z1_Load_Field_Table( Z1_Parser* parser,
const Z1_Field_Rec* field,
void** objects,
FT_UInt max_objects,
FT_ULong* pflags );
LOCAL_DEF
FT_Error Z1_New_Parser( Z1_Parser* parser,
FT_Stream stream,
FT_Memory memory );
LOCAL_DEF
FT_Error Z1_Get_Private_Dict( Z1_Parser* parser );
LOCAL_DEF
void Z1_Decrypt( FT_Byte* buffer,
FT_Int length,
FT_UShort seed );
LOCAL_DEF
void Z1_Done_Parser( Z1_Parser* parser );
#ifdef __cplusplus
}
#endif
#endif /* Z1PARSE_H */
/* END */

View File

@@ -1,132 +0,0 @@
/***************************************************************************/
/* */
/* z1tokens.h */
/* */
/* Experimental Type 1 tokenizer (specification). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#undef T1TYPE
#define T1TYPE T1_FontInfo
Z1_FONTINFO_STRING( "version", version )
Z1_FONTINFO_STRING( "Notice", notice )
Z1_FONTINFO_STRING( "FullName", full_name )
Z1_FONTINFO_STRING( "FamilyName", family_name )
Z1_FONTINFO_STRING( "Weight", weight )
Z1_FONTINFO_NUM ( "ItalicAngle", italic_angle )
Z1_FONTINFO_BOOL ( "isFixedPitch", is_fixed_pitch )
Z1_FONTINFO_NUM ( "UnderlinePosition", underline_position )
Z1_FONTINFO_NUM ( "UnderlineThickness", underline_thickness )
#undef T1TYPE
#define T1TYPE T1_Private
Z1_PRIVATE_NUM ( "UniqueID", unique_id )
Z1_PRIVATE_NUM ( "lenIV", lenIV )
Z1_PRIVATE_NUM ( "LanguageGroup", language_group )
Z1_PRIVATE_NUM ( "password", password )
Z1_PRIVATE_FIXED ( "BlueScale", blue_scale )
Z1_PRIVATE_NUM ( "BlueShift", blue_shift )
Z1_PRIVATE_NUM ( "BlueFuzz", blue_fuzz )
Z1_PRIVATE_NUM_TABLE ( "BlueValues", blue_values, 14, num_blue_values )
Z1_PRIVATE_NUM_TABLE ( "OtherBlues", other_blues, 10, num_other_blues )
Z1_PRIVATE_NUM_TABLE ( "FamilyBlues", family_blues, 14, num_family_blues )
Z1_PRIVATE_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10, \
num_family_other_blues )
Z1_PRIVATE_NUM_TABLE2( "StdHW", standard_width, 1 )
Z1_PRIVATE_NUM_TABLE2( "StdVW", standard_height, 1 )
Z1_PRIVATE_NUM_TABLE2( "MinFeature", min_feature, 2 )
Z1_PRIVATE_NUM_TABLE ( "StemSnapH", snap_widths, 12, num_snap_widths )
Z1_PRIVATE_NUM_TABLE ( "StemSnapV", snap_heights, 12, num_snap_heights )
#undef T1TYPE
#define T1TYPE T1_Font
Z1_TOPDICT_NUM( "PaintType", paint_type )
Z1_TOPDICT_NUM( "FontType", font_type )
Z1_TOPDICT_NUM( "StrokeWidth", stroke_width )
#if 0
/* define the font info dictionary parsing callbacks */
#undef FACE
#define FACE (face->type1.font_info)
PARSE_STRING( "version", version )
PARSE_STRING( "Notice", notice )
PARSE_STRING( "FullName", full_name )
PARSE_STRING( "FamilyName", family_name )
PARSE_STRING( "Weight", weight )
PARSE_INT ( "ItalicAngle", italic_angle )
PARSE_BOOL ( "isFixedPitch", is_fixed_pitch )
PARSE_NUM ( "UnderlinePosition", underline_position, FT_Short )
PARSE_NUM ( "UnderlineThickness", underline_thickness, FT_UShort )
/* define the private dict parsing callbacks */
#undef FACE
#define FACE (face->type1.private_dict)
PARSE_INT ("UniqueID", unique_id )
PARSE_INT ("lenIV", lenIV )
PARSE_COORDS ( "BlueValues", num_blues, 14, blue_values)
PARSE_COORDS ( "OtherBlues", num_other_blues, 10, other_blues)
PARSE_COORDS ( "FamilyBlues", num_family_blues, 14, family_blues )
PARSE_COORDS ( "FamilyOtherBlues", num_family_other_blues, 10,
family_other_blues )
PARSE_FIXED ( "BlueScale", blue_scale )
PARSE_INT ( "BlueShift", blue_shift )
PARSE_INT ( "BlueFuzz", blue_fuzz )
PARSE_COORDS2( "StdHW", 1, standard_width )
PARSE_COORDS2( "StdVW", 1, standard_height )
PARSE_COORDS ( "StemSnapH", num_snap_widths, 12, stem_snap_widths )
PARSE_COORDS ( "StemSnapV", num_snap_heights, 12, stem_snap_heights )
PARSE_INT ( "LanguageGroup", language_group )
PARSE_INT ( "password", password )
PARSE_COORDS2( "MinFeature", 2, min_feature )
/* define the top-level dictionary parsing callbacks */
#undef FACE
#define FACE (face->type1)
/*PARSE_STRING ( "FontName", font_name ) -- handled by special routine */
PARSE_NUM ( "PaintType", paint_type, FT_Byte )
PARSE_NUM ( "FontType", font_type, FT_Byte )
PARSE_FIXEDS2( "FontMatrix", 4, font_matrix )
/*PARSE_COORDS2( "FontBBox", 4, font_bbox ) -- handled by special routine */
PARSE_INT ( "StrokeWidth", stroke_width )
#undef FACE
#endif /* 0 */
/* END */

View File

@@ -1,306 +0,0 @@
/***************************************************************************/
/* */
/* ftsystem.c */
/* */
/* Unix-specific FreeType low-level system interface (body). */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#include <ftconfig.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/ftsystem.h>
#include <freetype/fterrors.h>
#include <freetype/fttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* memory-mapping includes and definitions */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/mman.h>
#ifndef MAP_FILE
#define MAP_FILE 0x00
#endif
/*************************************************************************/
/* */
/* The prototype for munmap() is not provided on SunOS. This needs to */
/* have a check added later to see if the GNU C library is being used. */
/* If so, then this prototype is not needed. */
/* */
#if defined( __sun__ ) && !defined( SVR4 ) && !defined( __SVR4 )
extern int munmap( caddr_t addr,
int len );
#endif
#include <sys/stat.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*************************************************************************/
/* */
/* MEMORY MANAGEMENT INTERFACE */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* ft_alloc */
/* */
/* <Description> */
/* The memory allocation function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* size :: The requested size in bytes. */
/* */
/* <Return> */
/* block :: The address of newly allocated block. */
/* */
static
void* ft_alloc( FT_Memory memory,
long size )
{
FT_UNUSED( memory );
return malloc( size );
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_realloc */
/* */
/* <Description> */
/* The memory reallocation function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* */
/* cur_size :: The current size of the allocated memory block. */
/* */
/* new_size :: The newly requested size in bytes. */
/* */
/* block :: The current address of the block in memory. */
/* */
/* <Return> */
/* The address of the reallocated memory block. */
/* */
static
void* ft_realloc( FT_Memory memory,
long cur_size,
long new_size,
void* block )
{
FT_UNUSED( memory );
FT_UNUSED( cur_size );
return realloc( block, new_size );
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_free */
/* */
/* <Description> */
/* The memory release function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* */
/* block :: The address of block in memory to be freed. */
/* */
static
void ft_free( FT_Memory memory,
void* block )
{
FT_UNUSED( memory );
free( block );
}
/*************************************************************************/
/* */
/* RESOURCE MANAGEMENT INTERFACE */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_io
/* We use the macro STREAM_FILE for convenience to extract the */
/* system-specific stream handle from a given FreeType stream object */
#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
/*************************************************************************/
/* */
/* <Function> */
/* ft_close_stream */
/* */
/* <Description> */
/* The function to close a stream. */
/* */
/* <Input> */
/* stream :: A pointer to the stream object. */
/* */
static
void ft_close_stream( FT_Stream stream )
{
munmap ( stream->descriptor.pointer, stream->size );
stream->descriptor.pointer = NULL;
stream->size = 0;
stream->base = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* FT_New_Stream */
/* */
/* <Description> */
/* Creates a new stream object. */
/* */
/* <Input> */
/* filepathname :: The name of the stream (usually a file) to be */
/* opened. */
/* */
/* stream :: A pointer to the stream object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT_FUNC( FT_Error ) FT_New_Stream( const char* filepathname,
FT_Stream stream )
{
int file;
struct stat stat_buf;
if ( !stream )
return FT_Err_Invalid_Stream_Handle;
/* open the file */
file = open( filepathname, O_RDONLY );
if ( file < 0 )
{
FT_ERROR(( "FT_New_Stream:" ));
FT_ERROR(( " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Resource;
}
if ( fstat( file, &stat_buf ) < 0 )
{
FT_ERROR(( "FT_New_Stream:" ));
FT_ERROR(( " could not `fstat' file `%s'\n", filepathname ));
goto Fail_Map;
}
stream->size = stat_buf.st_size;
stream->pos = 0;
stream->base = mmap( NULL,
stream->size,
PROT_READ,
MAP_FILE | MAP_PRIVATE,
file,
0 );
if ( (long)stream->base == -1 )
{
FT_ERROR(( "FT_New_Stream:" ));
FT_ERROR(( " could not `mmap' file `%s'\n", filepathname ));
goto Fail_Map;
}
close( file );
stream->descriptor.pointer = stream->base;
stream->pathname.pointer = (char*)filepathname;
stream->close = ft_close_stream;
stream->read = 0;
FT_TRACE1(( "FT_New_Stream:" ));
FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
filepathname, stream->size ));
return FT_Err_Ok;
Fail_Map:
close( file );
stream->base = NULL;
stream->size = 0;
stream->pos = 0;
return FT_Err_Cannot_Open_Stream;
}
/*************************************************************************/
/* */
/* <Function> */
/* FT_New_Memory */
/* */
/* <Description> */
/* Creates a new memory object. */
/* */
/* <Return> */
/* A pointer to the new memory object. 0 in case of error. */
/* */
FT_EXPORT_FUNC( FT_Memory ) FT_New_Memory( void )
{
FT_Memory memory;
memory = (FT_Memory)malloc( sizeof ( *memory ) );
if ( memory )
{
memory->user = 0;
memory->alloc = ft_alloc;
memory->realloc = ft_realloc;
memory->free = ft_free;
}
return memory;
}
/* END */

View File

@@ -1,6 +0,0 @@
make_module_list: add_windows_driver
add_windows_driver:
$(OPEN_DRIVER)winfnt_driver_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)winfnt $(ECHO_DRIVER_DESC)Windows bitmap fonts with extension *.fnt or *.fon$(ECHO_DRIVER_DONE)

View File

@@ -1,64 +0,0 @@
#
# FreeType 2 Windows FNT/FON driver configuration rules
#
# Copyright 1996-2000 by
# 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.
# Windows driver directory
#
FNT_DIR := $(SRC_)winfonts
FNT_DIR_ := $(FNT_DIR)$(SEP)
FNT_COMPILE := $(FT_COMPILE)
# Windows driver sources (i.e., C files)
#
FNT_DRV_SRC := $(FNT_DIR_)winfnt.c
# Windows driver headers
#
FNT_DRV_H := $(FNT_DRV_SRC:%.c=%.h)
# Windows driver object(s)
#
# FNT_DRV_OBJ_M is used during `multi' builds
# FNT_DRV_OBJ_S is used during `single' builds
#
FNT_DRV_OBJ_M := $(FNT_DRV_SRC:$(FNT_DIR_)%.c=$(OBJ_)%.$O)
FNT_DRV_OBJ_S := $(OBJ_)winfnt.$O
# Windows driver source file for single build
#
FNT_DRV_SRC_S := $(FNT_DIR_)winfnt.c
# Windows driver - single object
#
$(FNT_DRV_OBJ_S): $(FNT_DRV_SRC_S) $(FNT_DRV_SRC) $(FREETYPE_H) $(FNT_DRV_H)
$(FNT_COMPILE) $T$@ $(FNT_DRV_SRC_S)
# Windows driver - multiple objects
#
$(OBJ_)%.$O: $(FNT_DIR_)%.c $(FREETYPE_H) $(FNT_DRV_H)
$(FNT_COMPILE) $T$@ $<
# update main driver object lists
#
DRV_OBJS_S += $(FNT_DRV_OBJ_S)
DRV_OBJS_M += $(FNT_DRV_OBJ_M)
# EOF

View File

@@ -1,623 +0,0 @@
/***************************************************************************/
/* */
/* winfnt.c */
/* */
/* FreeType font driver for Windows FNT/FON files */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifdef FT_FLAT_COMPILE
#include "winfnt.h"
#else
#include <winfonts/winfnt.h>
#endif
#include <freetype/fterrors.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_winfnt
static
const FT_Frame_Field winmz_header_fields[] =
{
FT_FRAME_START( 64 ),
FT_FRAME_USHORT_LE ( WinMZ_Header, magic ),
FT_FRAME_SKIP_BYTES( 29 * 2 ),
FT_FRAME_ULONG_LE ( WinMZ_Header, lfanew ),
FT_FRAME_END
};
static
const FT_Frame_Field winne_header_fields[] =
{
FT_FRAME_START( 40 ),
FT_FRAME_USHORT_LE ( WinNE_Header, magic ),
FT_FRAME_SKIP_BYTES( 34 ),
FT_FRAME_USHORT_LE ( WinNE_Header, resource_tab_offset ),
FT_FRAME_USHORT_LE ( WinNE_Header, rname_tab_offset ),
FT_FRAME_END
};
static
const FT_Frame_Field winfnt_header_fields[] =
{
FT_FRAME_START( 134 ),
FT_FRAME_USHORT_LE( WinFNT_Header, version ),
FT_FRAME_ULONG_LE ( WinFNT_Header, file_size ),
FT_FRAME_BYTES ( WinFNT_Header, copyright, 60 ),
FT_FRAME_USHORT_LE( WinFNT_Header, file_type ),
FT_FRAME_USHORT_LE( WinFNT_Header, nominal_point_size ),
FT_FRAME_USHORT_LE( WinFNT_Header, vertical_resolution ),
FT_FRAME_USHORT_LE( WinFNT_Header, horizontal_resolution ),
FT_FRAME_USHORT_LE( WinFNT_Header, ascent ),
FT_FRAME_USHORT_LE( WinFNT_Header, internal_leading ),
FT_FRAME_USHORT_LE( WinFNT_Header, external_leading ),
FT_FRAME_BYTE ( WinFNT_Header, italic ),
FT_FRAME_BYTE ( WinFNT_Header, underline ),
FT_FRAME_BYTE ( WinFNT_Header, strike_out ),
FT_FRAME_USHORT_LE( WinFNT_Header, weight ),
FT_FRAME_BYTE ( WinFNT_Header, charset ),
FT_FRAME_USHORT_LE( WinFNT_Header, pixel_width ),
FT_FRAME_USHORT_LE( WinFNT_Header, pixel_height ),
FT_FRAME_BYTE ( WinFNT_Header, pitch_and_family ),
FT_FRAME_USHORT_LE( WinFNT_Header, avg_width ),
FT_FRAME_USHORT_LE( WinFNT_Header, max_width ),
FT_FRAME_BYTE ( WinFNT_Header, first_char ),
FT_FRAME_BYTE ( WinFNT_Header, last_char ),
FT_FRAME_BYTE ( WinFNT_Header, default_char ),
FT_FRAME_BYTE ( WinFNT_Header, break_char ),
FT_FRAME_USHORT_LE( WinFNT_Header, bytes_per_row ),
FT_FRAME_ULONG_LE ( WinFNT_Header, device_offset ),
FT_FRAME_ULONG_LE ( WinFNT_Header, face_name_offset ),
FT_FRAME_ULONG_LE ( WinFNT_Header, bits_pointer ),
FT_FRAME_ULONG_LE ( WinFNT_Header, bits_offset ),
FT_FRAME_BYTE ( WinFNT_Header, reserved ),
FT_FRAME_ULONG_LE ( WinFNT_Header, flags ),
FT_FRAME_USHORT_LE( WinFNT_Header, A_space ),
FT_FRAME_USHORT_LE( WinFNT_Header, B_space ),
FT_FRAME_USHORT_LE( WinFNT_Header, C_space ),
FT_FRAME_USHORT_LE( WinFNT_Header, color_table_offset ),
FT_FRAME_BYTES ( WinFNT_Header, reserved, 4 ),
FT_FRAME_END
};
static
void fnt_done_font( FT_Stream stream,
FNT_Font* font )
{
if ( font->fnt_frame )
RELEASE_Frame( font->fnt_frame );
font->fnt_size = 0;
font->fnt_frame = 0;
}
static
FT_Error fnt_load_font( FT_Stream stream,
FNT_Font* font )
{
FT_Error error;
WinFNT_Header* header = &font->header;
/* first of all, read the FNT header */
if ( FILE_Seek( font->offset ) ||
READ_Fields( winfnt_header_fields, header ) )
goto Exit;
/* check header */
if ( header->version != 0x200 &&
header->version != 0x300 )
{
FT_TRACE2(( "[not a valid FNT file]\n" ));
error = FT_Err_Unknown_File_Format;
goto Exit;
}
if ( header->file_type & 1 )
{
FT_TRACE2(( "can't handle vector FNT fonts\n" ));
error = FT_Err_Unknown_File_Format;
goto Exit;
}
/* small fixup -- some fonts have the `pixel_width' field set to 0 */
if ( header->pixel_width == 0 )
header->pixel_width = header->pixel_height;
/* this is a FNT file/table, we now extract its frame */
if ( FILE_Seek( font->offset ) ||
EXTRACT_Frame( header->file_size, font->fnt_frame ) )
goto Exit;
Exit:
return error;
}
static
void fnt_done_fonts( FNT_Face face )
{
FT_Memory memory = FT_FACE(face)->memory;
FT_Stream stream = FT_FACE(face)->stream;
FNT_Font* cur = face->fonts;
FNT_Font* limit = cur + face->num_fonts;
for ( ; cur < limit; cur++ )
fnt_done_font( stream, cur );
FREE( face->fonts );
face->num_fonts = 0;
}
static
FT_Error fnt_get_dll_fonts( FNT_Face face )
{
FT_Error error;
FT_Stream stream = FT_FACE(face)->stream;
FT_Memory memory = FT_FACE(face)->memory;
WinMZ_Header mz_header;
face->fonts = 0;
face->num_fonts = 0;
/* does it begin with a MZ header? */
if ( FILE_Seek( 0 ) ||
READ_Fields( winmz_header_fields, &mz_header ) )
goto Exit;
error = FT_Err_Unknown_File_Format;
if ( mz_header.magic == WINFNT_MZ_MAGIC )
{
/* yes, now look for a NE header in the file */
WinNE_Header ne_header;
if ( FILE_Seek( mz_header.lfanew ) ||
READ_Fields( winne_header_fields, &ne_header ) )
goto Exit;
error = FT_Err_Unknown_File_Format;
if ( ne_header.magic == WINFNT_NE_MAGIC )
{
/* good, now look in the resource table for each FNT resource */
FT_ULong res_offset = mz_header.lfanew +
ne_header.resource_tab_offset;
FT_UShort size_shift;
FT_UShort font_count = 0;
FT_ULong font_offset = 0;
if ( FILE_Seek( res_offset ) ||
ACCESS_Frame( ne_header.rname_tab_offset -
ne_header.resource_tab_offset ) )
goto Exit;
size_shift = GET_UShortLE();
for (;;)
{
FT_UShort type_id, count;
type_id = GET_UShortLE();
if ( !type_id )
break;
count = GET_UShortLE();
if ( type_id == 0x8008 )
{
font_count = count;
font_offset = FILE_Pos() + 4 + ( stream->cursor - stream->limit );
break;
}
stream->cursor += 4 + count * 12;
}
FORGET_Frame();
if ( !font_count || !font_offset )
{
FT_TRACE2(( "this file doesn't contain any FNT resources!\n" ));
error = FT_Err_Unknown_File_Format;
goto Exit;
}
if ( FILE_Seek( font_offset ) ||
ALLOC_ARRAY( face->fonts, font_count, FNT_Font ) )
goto Exit;
face->num_fonts = font_count;
if ( ACCESS_Frame( (FT_Long)font_count * 12 ) )
goto Exit;
/* now read the offset and position of each FNT font */
{
FNT_Font* cur = face->fonts;
FNT_Font* limit = cur + font_count;
for ( ; cur < limit; cur++ )
{
cur->offset = (FT_ULong)GET_UShortLE() << size_shift;
cur->fnt_size = (FT_ULong)GET_UShortLE() << size_shift;
cur->size_shift = size_shift;
stream->cursor += 8;
}
}
FORGET_Frame();
/* finally, try to load each font there */
{
FNT_Font* cur = face->fonts;
FNT_Font* limit = cur + font_count;
for ( ; cur < limit; cur++ )
{
error = fnt_load_font( stream, cur );
if ( error )
goto Fail;
}
}
}
}
Fail:
if ( error )
fnt_done_fonts( face );
Exit:
return error;
}
static
void FNT_Done_Face( FNT_Face face )
{
FT_Memory memory = FT_FACE_MEMORY( face );
fnt_done_fonts( face );
FREE( face->root.available_sizes );
face->root.num_fixed_sizes = 0;
}
static
FT_Error FNT_Init_Face( FT_Stream stream,
FNT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
FT_Memory memory = FT_FACE_MEMORY( face );
FT_UNUSED( num_params );
FT_UNUSED( params );
FT_UNUSED( face_index );
/* try to load several fonts from a DLL */
error = fnt_get_dll_fonts( face );
if ( error )
{
/* this didn't work, now try to load a single FNT font */
FT_Memory memory = FT_FACE_MEMORY( face );
FNT_Font* font;
if ( ALLOC( face->fonts, sizeof ( *face->fonts ) ) )
goto Exit;
face->num_fonts = 1;
font = face->fonts;
font->offset = 0;
font->fnt_size = stream->size;
error = fnt_load_font( stream, font );
if ( error )
goto Fail;
}
/* all right, one or more fonts were loaded; we now need to */
/* fill the root FT_Face fields with relevant information */
{
FT_Face root = FT_FACE( face );
FNT_Font* fonts = face->fonts;
FNT_Font* limit = fonts + face->num_fonts;
FNT_Font* cur;
root->num_faces = 1;
root->face_flags = FT_FACE_FLAG_FIXED_SIZES |
FT_FACE_FLAG_HORIZONTAL;
if ( fonts->header.avg_width == fonts->header.max_width )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( fonts->header.italic )
root->style_flags |= FT_STYLE_FLAG_ITALIC;
if ( fonts->header.weight >= 800 )
root->style_flags |= FT_STYLE_FLAG_BOLD;
/* Setup the `fixed_sizes' array */
if ( ALLOC_ARRAY( root->available_sizes, face->num_fonts,
FT_Bitmap_Size ) )
goto Fail;
root->num_fixed_sizes = face->num_fonts;
{
FT_Bitmap_Size* size = root->available_sizes;
for ( cur = fonts; cur < limit; cur++, size++ )
{
size->width = cur->header.pixel_width;
size->height = cur->header.pixel_height;
}
}
/* Setup the `charmaps' array */
root->charmaps = &face->charmap_handle;
root->num_charmaps = 1;
face->charmap.encoding = ft_encoding_unicode;
face->charmap.platform_id = 3;
face->charmap.encoding_id = 1;
face->charmap.face = root;
face->charmap_handle = &face->charmap;
root->charmap = face->charmap_handle;
/* setup remaining flags */
root->num_glyphs = fonts->header.last_char -
fonts->header.first_char + 1;
root->family_name = (FT_String*)fonts->fnt_frame +
fonts->header.face_name_offset;
root->style_name = "Regular";
if ( root->style_flags & FT_STYLE_FLAG_BOLD )
{
if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
root->style_name = "Bold Italic";
else
root->style_name = "Bold";
}
else if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
root->style_name = "Italic";
}
Fail:
if ( error )
FNT_Done_Face( face );
Exit:
return error;
}
static
FT_Error FNT_Set_Pixel_Size( FNT_Size size )
{
/* look up a font corresponding to the current pixel size */
FNT_Face face = (FNT_Face)FT_SIZE_FACE( size );
FNT_Font* cur = face->fonts;
FNT_Font* limit = cur + face->num_fonts;
size->font = 0;
for ( ; cur < limit; cur++ )
{
/* we only compare the character height, as fonts used some strange */
/* values */
if ( cur->header.pixel_height == size->root.metrics.y_ppem )
{
size->font = cur;
size->root.metrics.ascender = cur->header.ascent * 64;
size->root.metrics.descender = ( cur->header.pixel_height -
cur->header.ascent ) * 64;
size->root.metrics.height = cur->header.pixel_height * 64;
break;
}
}
return ( size->font ? FT_Err_Ok : FT_Err_Invalid_Argument );
}
static
FT_UInt FNT_Get_Char_Index( FT_CharMap charmap,
FT_ULong char_code )
{
FT_UInt result = char_code;
if ( charmap )
{
FNT_Font* font = ((FNT_Face)charmap->face)->fonts;
FT_UInt first = font->header.first_char;
FT_UInt count = font->header.last_char - first + 1;
char_code -= first;
if ( char_code < count )
result = char_code + 1;
else
result = 0;
}
return result;
}
static
FT_Error FNT_Load_Glyph( FT_GlyphSlot slot,
FNT_Size size,
FT_UInt glyph_index,
FT_Int load_flags )
{
FNT_Font* font = size->font;
FT_Error error = 0;
FT_Byte* p;
FT_Int len;
FT_Bitmap* bitmap = &slot->bitmap;
FT_ULong offset;
FT_Bool new_format;
FT_UNUSED( slot );
FT_UNUSED( load_flags );
if ( !font )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
if ( glyph_index > 0 )
glyph_index--;
else
glyph_index = font->header.default_char - font->header.first_char;
new_format = font->header.version == 0x300;
len = new_format ? 6 : 4;
/* jump to glyph entry */
p = font->fnt_frame + 118 + len * glyph_index;
bitmap->width = NEXT_ShortLE(p);
if ( new_format )
offset = NEXT_ULongLE(p);
else
offset = NEXT_UShortLE(p);
/* jump to glyph data */
p = font->fnt_frame + /* font->header.bits_offset */ + offset;
/* allocate and build bitmap */
{
FT_Memory memory = FT_FACE_MEMORY( slot->face );
FT_Int pitch = ( bitmap->width + 7 ) >> 3;
FT_Byte* column;
FT_Byte* write;
bitmap->pitch = pitch;
bitmap->rows = font->header.pixel_height;
bitmap->pixel_mode = ft_pixel_mode_mono;
if ( ALLOC( bitmap->buffer, pitch * bitmap->rows ) )
goto Exit;
column = (FT_Byte*)bitmap->buffer;
for ( ; pitch > 0; pitch--, column++ )
{
FT_Byte* limit = p + bitmap->rows;
for ( write = column; p < limit; p++, write += bitmap->pitch )
write[0] = p[0];
}
}
slot->flags = ft_glyph_own_bitmap;
slot->bitmap_left = 0;
slot->bitmap_top = font->header.ascent;
slot->format = ft_glyph_format_bitmap;
/* now set up metrics */
slot->metrics.horiAdvance = bitmap->width << 6;
slot->metrics.horiBearingX = 0;
slot->metrics.horiBearingY = slot->bitmap_top << 6;
slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16;
Exit:
return error;
}
const FT_Driver_Class winfnt_driver_class =
{
{
ft_module_font_driver,
sizeof ( FT_DriverRec ),
"winfonts",
0x10000L,
0x20000L,
0,
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
},
sizeof( FNT_FaceRec ),
sizeof( FNT_SizeRec ),
sizeof( FT_GlyphSlotRec ),
(FTDriver_initFace) FNT_Init_Face,
(FTDriver_doneFace) FNT_Done_Face,
(FTDriver_initSize) 0,
(FTDriver_doneSize) 0,
(FTDriver_initGlyphSlot)0,
(FTDriver_doneGlyphSlot)0,
(FTDriver_setCharSizes) FNT_Set_Pixel_Size,
(FTDriver_setPixelSizes)FNT_Set_Pixel_Size,
(FTDriver_loadGlyph) FNT_Load_Glyph,
(FTDriver_getCharIndex) FNT_Get_Char_Index,
(FTDriver_getKerning) 0,
(FTDriver_attachFile) 0,
(FTDriver_getAdvances) 0
};
/* END */

View File

@@ -1,150 +0,0 @@
/***************************************************************************/
/* */
/* winfnt.h */
/* */
/* FreeType font driver for Windows FNT/FON files */
/* */
/* Copyright 1996-2000 by */
/* 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. */
/* */
/***************************************************************************/
#ifndef WINFNT_H
#define WINFNT_H
#include <freetype/internal/ftdriver.h>
typedef struct WinMZ_Header_
{
FT_UShort magic;
/* skipped content */
FT_UShort lfanew;
} WinMZ_Header;
typedef struct WinNE_Header_
{
FT_UShort magic;
/* skipped content */
FT_UShort resource_tab_offset;
FT_UShort rname_tab_offset;
} WinNE_Header;
typedef struct WinNameInfo_
{
FT_UShort offset;
FT_UShort length;
FT_UShort flags;
FT_UShort id;
FT_UShort handle;
FT_UShort usage;
} WinNameInfo;
typedef struct WinResourceInfo_
{
FT_UShort type_id;
FT_UShort count;
} WinResourceInfo;
#define WINFNT_MZ_MAGIC 0x5A4D
#define WINFNT_NE_MAGIC 0x454E
typedef struct WinFNT_Header_
{
FT_UShort version;
FT_ULong file_size;
FT_Byte copyright[60];
FT_UShort file_type;
FT_UShort nominal_point_size;
FT_UShort vertical_resolution;
FT_UShort horizontal_resolution;
FT_UShort ascent;
FT_UShort internal_leading;
FT_UShort external_leading;
FT_Byte italic;
FT_Byte underline;
FT_Byte strike_out;
FT_UShort weight;
FT_Byte charset;
FT_UShort pixel_width;
FT_UShort pixel_height;
FT_Byte pitch_and_family;
FT_UShort avg_width;
FT_UShort max_width;
FT_Byte first_char;
FT_Byte last_char;
FT_Byte default_char;
FT_Byte break_char;
FT_UShort bytes_per_row;
FT_ULong device_offset;
FT_ULong face_name_offset;
FT_ULong bits_pointer;
FT_ULong bits_offset;
FT_Byte reserved;
FT_ULong flags;
FT_UShort A_space;
FT_UShort B_space;
FT_UShort C_space;
FT_UShort color_table_offset;
FT_Byte reserved2[4];
} WinFNT_Header;
typedef struct FNT_Font_
{
FT_ULong offset;
FT_Int size_shift;
WinFNT_Header header;
FT_Byte* fnt_frame;
FT_ULong fnt_size;
} FNT_Font;
typedef struct FNT_SizeRec_
{
FT_SizeRec root;
FNT_Font* font;
} FNT_SizeRec, *FNT_Size;
typedef struct FNT_FaceRec_
{
FT_FaceRec root;
FT_UInt num_fonts;
FNT_Font* fonts;
FT_CharMap charmap_handle;
FT_CharMapRec charmap; /* a single charmap per face */
} FNT_FaceRec, *FNT_Face;
FT_EXPORT_VAR( const FT_Driver_Class ) winfnt_driver_class;
#endif /* WINFNT_H */
/* END */