ref: 78575dc0d188d18f806e802e36752ea85318e543
parent: e35cac66c652480b0d682647e92c2e7ef5cf7081
author: Werner Lemberg <[email protected]>
date: Mon Jun 12 15:36:41 EDT 2000
A lot of formatting. Added more tracing levels. More Makefile fixes. Minor other changes.
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -43,7 +43,7 @@
FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64 l );
-#endif /* OLD_CALCS */
+#endif /* FT_CONFIG_OPTION_OLD_CALCS */
#else /* LONG64 */
--- a/include/freetype/internal/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -48,36 +48,48 @@
/* the first level must always be `trace_any' */
trace_any = 0,
- /* we start with an enum for each base component */
- trace_aaraster, /* anti-aliasing raster (ftgrays.c) */
- trace_calc, /* calculations (ftcalc.c) */
- trace_extend, /* extension manager (ftextend.c) */
- trace_glyph, /* glyph manager (ftglyph.c) */
- trace_io, /* i/o monitoring (ftsystem.c) */
- trace_init, /* initialization (ftinit.c) */
- trace_list, /* list manager (ftlist.c) */
- trace_memory, /* memory manager (ftobjs.c) */
- trace_mm, /* MM interface (ftmm.c) */
- trace_objs, /* base objects (ftobjs.c) */
- trace_outline, /* outline management (ftoutln.c) */
- trace_raster, /* raster (ftraster.c) */
- trace_stream, /* stream manager (ftstream.c) */
+ /* base components */
+ trace_aaraster, /* anti-aliasing raster (ftgrays.c) */
+ trace_calc, /* calculations (ftcalc.c) */
+ trace_extend, /* extension manager (ftextend.c) */
+ trace_glyph, /* glyph manager (ftglyph.c) */
+ trace_io, /* i/o monitoring (ftsystem.c) */
+ trace_init, /* initialization (ftinit.c) */
+ trace_list, /* list manager (ftlist.c) */
+ trace_memory, /* memory manager (ftobjs.c) */
+ trace_mm, /* MM interface (ftmm.c) */
+ trace_objs, /* base objects (ftobjs.c) */
+ trace_outline, /* outline management (ftoutln.c) */
+ trace_raster, /* rasterizer (ftraster.c) */
+ trace_stream, /* stream manager (ftstream.c) */
- /* then define an enum for each TrueType driver component */
- trace_ttobjs,
- trace_ttload,
- trace_ttgload,
- trace_ttinterp,
- trace_ttcmap,
- trace_ttextend,
- trace_ttdriver,
+ /* SFNT driver components */
+ trace_sfobjs, /* SFNT object handler (sfobjs.c) */
+ trace_ttcmap, /* charmap handler (ttcmap.c) */
+ trace_ttload, /* basic TrueType tables (ttload.c) */
+ trace_ttpost, /* PS table processing (ttpost.c) */
+ trace_ttsbit, /* TrueType sbit handling (ttsbit.c) */
- /* define an enum for each Type 1 driver component */
+ /* TrueType driver components */
+ trace_ttdriver, /* TT font driver (ttdriver.c) */
+ trace_ttgload, /* TT glyph loader (ttgload.c) */
+ trace_ttinterp, /* bytecode interpreter (ttinterp.c) */
+ trace_ttobjs, /* TT objects manager (ttobjs.c) */
+ trace_ttpload, /* TT data/program loader (ttpload.c) */
+
+ /* Type 1 driver components */
trace_t1objs,
trace_t1load,
trace_t1gload,
trace_t1hint,
trace_t1driver,
+
+ /* Type 2 driver components */
+ trace_t2driver,
+ trace_t2gload,
+ trace_t2load,
+ trace_t2objs,
+ trace_t2parse,
/* other trace levels */
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -108,7 +108,7 @@
return root;
}
-#endif /* OLD_CALCS */
+#endif /* FT_CONFIG_OPTION_OLD_CALCS */
#ifdef LONG64
--- a/src/cff/cff.c
+++ b/src/cff/cff.c
@@ -4,11 +4,11 @@
/* */
/* FreeType OpenType driver component (body only). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -16,29 +16,6 @@
/***************************************************************************/
- /*************************************************************************/
- /* */
- /* This file is used to compile the FreeType TrueType font driver. It */
- /* relies on all components included in the `base' layer (see the file */
- /* `ftbase.c'). The source code is located in `freetype/ttlib' and */
- /* contains: */
- /* */
- /* - a driver interface */
- /* - an object manager */
- /* - a table loader */
- /* - a glyph loader */
- /* - a glyph hinter/bytecode interpreter */
- /* - a charmap processor */
- /* - an extension manager (only used for some tools) */
- /* */
- /* Note that the engine extensions found in `freetype/ttlib/extend' are */
- /* reserved to specific tools and/or font servers; they're not part of */
- /* the `core' TrueType driver, even though they are separately linkable */
- /* to it. */
- /* */
- /*************************************************************************/
-
-
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <t2driver.c> /* driver interface */
@@ -46,5 +23,6 @@
#include <t2load.c> /* tables loader */
#include <t2objs.c> /* object management */
#include <t2gload.c> /* glyph loader */
+
/* END */
--- a/src/cff/t2driver.c
+++ b/src/cff/t2driver.c
@@ -4,7 +4,7 @@
/* */
/* OpenType font driver implementation (body). */
/* */
-/* Copyright 1996-1999 by */
+/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,11 +25,16 @@
#include <t2gload.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_ttdriver
+#define FT_COMPONENT trace_t2driver
-
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -43,7 +48,9 @@
/*************************************************************************/
#undef PAIR_TAG
-#define PAIR_TAG( left, right ) ( ((TT_ULong)left << 16) | (TT_ULong)right )
+#define PAIR_TAG( left, right ) ( ( (TT_ULong)left << 16 ) | \
+ (TT_ULong)right )
+
/*************************************************************************/
/* */
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -4,11 +4,11 @@
/* */
/* OpenType Glyph Loader (body). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -22,13 +22,21 @@
#include <freetype/internal/sfnt.h>
#include <freetype/tttags.h>
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1gload
-
#include <t2load.h>
#include <t2gload.h>
- typedef enum T2_Operator_
+
+ /*************************************************************************/
+ /* */
+ /* 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_t2gload
+
+
+ typedef enum T2_Operator_
{
t2_op_unknown = 0,
t2_op_rmoveto,
--- a/src/cff/t2load.c
+++ b/src/cff/t2load.c
@@ -4,11 +4,11 @@
/* */
/* TrueType glyph data/program tables loader (body). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -26,8 +26,16 @@
#include <t2load.h>
#include <t2parse.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_ttload
+#define FT_COMPONENT trace_t2load
+
/* read a CFF offset from memory */
static
--- a/src/cff/t2objs.c
+++ b/src/cff/t2objs.c
@@ -1,14 +1,14 @@
/***************************************************************************/
/* */
-/* ttobjs.c */
+/* t2objs.c */
/* */
-/* Objects manager (body). */
+/* OpenType objects manager (body). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -29,9 +29,15 @@
#include <t2load.h>
#include <freetype/internal/t2errors.h>
-/* required by tracing mode */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_ttobjs
+
+ /*************************************************************************/
+ /* */
+ /* 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_t2objs
/*************************************************************************/
--- a/src/cff/t2parse.c
+++ b/src/cff/t2parse.c
@@ -1,5 +1,34 @@
+/***************************************************************************/
+/* */
+/* t2parse.c */
+/* */
+/* OpenType 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 <t2parse.h>
#include <freetype/fterrors.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_t2parse
+
#define T2_Err_Stack_Underflow FT_Err_Invalid_Argument
#define T2_Err_Syntax_Error FT_Err_Invalid_Argument
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -24,6 +24,16 @@
/*************************************************************************/
/* */
+ /* 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 */
/* */
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -32,6 +32,17 @@
#include <ttpost.h>
#include <ttload.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_ttpost
+
+
/* If this configuration macro is defined, we rely on the `psnames' */
/* module to grab the glyph names. */
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -25,6 +25,16 @@
/*************************************************************************/
/* */
+ /* 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_ttsbit
+
+
+ /*************************************************************************/
+ /* */
/* <Function> */
/* blit_sbit */
/* */
--- a/src/truetype/truetype.c
+++ b/src/truetype/truetype.c
@@ -4,11 +4,11 @@
/* */
/* FreeType TrueType driver component (body only). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -16,29 +16,6 @@
/***************************************************************************/
- /*************************************************************************/
- /* */
- /* This file is used to compile the FreeType TrueType font driver. It */
- /* relies on all components included in the `base' layer (see the file */
- /* `ftbase.c'). The source code is located in `freetype/ttlib' and */
- /* contains: */
- /* */
- /* - a driver interface */
- /* - an object manager */
- /* - a table loader */
- /* - a glyph loader */
- /* - a glyph hinter/bytecode interpreter */
- /* - a charmap processor */
- /* - an extension manager (only used for some tools) */
- /* */
- /* Note that the engine extensions found in `freetype/ttlib/extend' are */
- /* reserved to specific tools and/or font servers; they're not part of */
- /* the `core' TrueType driver, even though they are separately linkable */
- /* to it. */
- /* */
- /*************************************************************************/
-
-
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ttdriver.c> /* driver interface */
@@ -49,4 +26,6 @@
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#include <ttinterp.c> /* bytecode interpreter */
#endif
+
+
/* END */
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -4,7 +4,7 @@
/* */
/* TrueType font driver implementation (body). */
/* */
-/* Copyright 1996-1999 by */
+/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,11 +25,16 @@
#include <ttgload.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_ttdriver
-
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -45,7 +50,8 @@
#undef PAIR_TAG
-#define PAIR_TAG( left, right ) ( ((TT_ULong)left << 16) | (TT_ULong)right )
+#define PAIR_TAG( left, right ) ( ( (TT_ULong)left << 16 ) | \
+ (TT_ULong)right )
/*************************************************************************/
@@ -70,12 +76,12 @@
/* formats. */
/* */
/* <Return> */
- /* FreeType error code. 0 means success. */
+ /* TrueType 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 */
+ /* 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. */
@@ -107,7 +113,7 @@
while ( left <= right )
{
- TT_Int middle = left + ((right-left) >> 1);
+ TT_Int middle = left + ( ( right - left ) >> 1 );
TT_ULong cur_pair;
@@ -118,9 +124,9 @@
goto Found;
if ( cur_pair < search_tag )
- left = middle+1;
+ left = middle + 1;
else
- right = middle-1;
+ right = middle - 1;
}
}
@@ -159,16 +165,21 @@
/* 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. */
+ /* 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. */
+ /* TrueType error code. 0 means success. */
/* */
static
TT_Error Set_Char_Sizes( TT_Size size,
@@ -181,25 +192,27 @@
TT_Face face = (TT_Face)size->root.face;
TT_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 */
+ /* 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 if this is useful, but hey, that's the spec :-) */
+ /* 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 )
+ 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;
+ 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 = (TT_UShort)(dim_x >> 6);
- metrics->y_ppem = (TT_UShort)(dim_y >> 6);
+ metrics->x_ppem = (TT_UShort)( dim_x >> 6 );
+ metrics->y_ppem = (TT_UShort)( dim_y >> 6 );
}
size->ttmetrics.valid = FALSE;
@@ -226,7 +239,7 @@
/* size :: A handle to the target size object. */
/* */
/* <Return> */
- /* FreeType error code. 0 means success */
+ /* TrueType error code. 0 means success. */
/* */
static
TT_Error Set_Pixel_Sizes( TT_Size size,
@@ -233,10 +246,10 @@
TT_UInt pixel_width,
TT_UInt pixel_height )
{
- UNUSED(pixel_width);
- UNUSED(pixel_height);
+ UNUSED( pixel_width );
+ UNUSED( pixel_height );
- /* many things were pre-computed by the base layer */
+ /* many things have been pre-computed by the base layer */
size->ttmetrics.valid = FALSE;
@@ -257,7 +270,7 @@
/* will be loaded. */
/* */
/* size :: A handle to the source face size at which the glyph */
- /* must be scaled/loaded/etc. */
+ /* must be scaled, loaded, etc. */
/* */
/* glyph_index :: The index of the glyph in the font file. */
/* */
@@ -266,13 +279,9 @@
/* glyph loading process (e.g., whether the outline */
/* should be scaled, whether to load bitmaps or not, */
/* whether to hint the outline, etc). */
- /* <Output> */
- /* result :: A set of bit flags indicating the type of data that */
- /* was loaded in the glyph slot (outline, bitmap, */
- /* pixmap, etc). */
/* */
/* <Return> */
- /* FreeType error code. 0 means success. */
+ /* TrueType error code. 0 means success. */
/* */
static
TT_Error Load_Glyph( TT_GlyphSlot slot,
@@ -286,7 +295,7 @@
if ( !slot )
return TT_Err_Invalid_Glyph_Handle;
- /* check that we want a scaled outline or bitmap */
+ /* check whether we want a scaled outline or bitmap */
if ( !size )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
@@ -345,7 +354,7 @@
/* Glyph index. 0 means `undefined character code'. */
/* */
static
- FT_UInt Get_Char_Index( TT_CharMap charmap,
+ TT_UInt Get_Char_Index( TT_CharMap charmap,
TT_Long charcode )
{
TT_Error error;
@@ -352,6 +361,7 @@
TT_Face face;
TT_CMapTable* cmap;
+
cmap = &charmap->cmap;
face = (TT_Face)charmap->root.face;
@@ -360,9 +370,10 @@
{
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
+
error = sfnt->load_charmap( face, cmap, face->root.stream );
- if (error)
- return error;
+ if ( error )
+ return 0;
cmap->loaded = TRUE;
}
@@ -374,19 +385,34 @@
}
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** ****/
+ /**** D R I V E R I N T E R F A C E ****/
+ /**** ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
static
- FTDriver_Interface tt_get_interface( TT_Driver driver, const char* interface )
+ FTDriver_Interface tt_get_interface( TT_Driver driver,
+ const char* interface )
{
FT_Driver sfntd = FT_Get_Driver( driver->root.library, "sfnt" );
SFNT_Interface* sfnt;
+
/* only return the default interface from the SFNT module */
- if (sfntd)
+ if ( sfntd )
{
sfnt = (SFNT_Interface*)(sfntd->interface.format_interface);
- if (sfnt)
+ if ( sfnt )
return sfnt->get_interface( (FT_Driver)driver, interface );
}
+
return 0;
}
@@ -406,28 +432,30 @@
(void*)0,
- (FTDriver_initDriver) TT_Init_Driver,
- (FTDriver_doneDriver) TT_Done_Driver,
- (FTDriver_getInterface) tt_get_interface,
+ (FTDriver_initDriver) TT_Init_Driver,
+ (FTDriver_doneDriver) TT_Done_Driver,
+ (FTDriver_getInterface) tt_get_interface,
- (FTDriver_initFace) TT_Init_Face,
- (FTDriver_doneFace) TT_Done_Face,
- (FTDriver_getKerning) Get_Kerning,
+ (FTDriver_initFace) TT_Init_Face,
+ (FTDriver_doneFace) TT_Done_Face,
+ (FTDriver_getKerning) Get_Kerning,
- (FTDriver_initSize) TT_Init_Size,
- (FTDriver_doneSize) TT_Done_Size,
- (FTDriver_setCharSizes) Set_Char_Sizes,
- (FTDriver_setPixelSizes) Set_Pixel_Sizes,
+ (FTDriver_initSize) TT_Init_Size,
+ (FTDriver_doneSize) TT_Done_Size,
+ (FTDriver_setCharSizes) Set_Char_Sizes,
+ (FTDriver_setPixelSizes) Set_Pixel_Sizes,
- (FTDriver_initGlyphSlot) TT_Init_GlyphSlot,
- (FTDriver_doneGlyphSlot) TT_Done_GlyphSlot,
- (FTDriver_loadGlyph) Load_Glyph,
+ (FTDriver_initGlyphSlot) TT_Init_GlyphSlot,
+ (FTDriver_doneGlyphSlot) TT_Done_GlyphSlot,
+ (FTDriver_loadGlyph) Load_Glyph,
- (FTDriver_getCharIndex) Get_Char_Index,
+ (FTDriver_getCharIndex) Get_Char_Index,
};
+#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
+
/*************************************************************************/
/* */
/* <Function> */
@@ -447,12 +475,11 @@
/* format-specific interface can then be retrieved through the method */
/* interface->get_format_interface. */
/* */
-#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
-
- EXPORT_FUNC(FT_DriverInterface*) getDriverInterface( void )
+ EXPORT_FUNC( FT_DriverInterface* ) getDriverInterface( void )
{
return &tt_driver_interface;
}
+
#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
--- a/src/truetype/ttdriver.h
+++ b/src/truetype/ttdriver.h
@@ -4,7 +4,7 @@
/* */
/* High-level TrueType driver interface (specification). */
/* */
-/* Copyright 1996-1999 by */
+/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,7 +25,7 @@
#include <freetype/internal/tterrors.h>
- FT_EXPORT_VAR(const FT_DriverInterface) tt_driver_interface;
+ FT_EXPORT_VAR( const FT_DriverInterface ) tt_driver_interface;
#endif /* TTDRIVER_H */
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -4,11 +4,11 @@
/* */
/* TrueType Glyph Loader (body). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -29,7 +29,13 @@
#include <ttinterp.h>
#endif
- /* required for the tracing mode */
+
+ /*************************************************************************/
+ /* */
+ /* 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_ttgload
@@ -50,15 +56,34 @@
#define USE_MY_METRICS 0x200
-
/*************************************************************************/
+ /* */
+ /* <Function> */
+ /* TT_Get_Metrics */
+ /* */
+ /* <Description> */
/* Returns the horizontal or vertical metrics in font units for a */
/* given glyph. The metrics are the left side bearing (resp. top */
/* side bearing) and advance width (resp. advance height). */
/* */
+ /* <Input> */
+ /* header :: A pointer to either the horizontal or vertical metrics */
+ /* structure. */
+ /* */
+ /* index :: The glyph index. */
+ /* */
+ /* <Output> */
+ /* bearing :: The bearing, either left side or top side. */
+ /* */
+ /* advance :: The advance width resp. advance height. */
+ /* */
+ /* <Note> */
+ /* This function will much probably move to another component in the */
+ /* near future, but I haven't decided which yet. */
+ /* */
LOCAL_FUNC
void TT_Get_Metrics( TT_HoriHeader* header,
- TT_UInt index,
+ TT_UInt index,
TT_Short* bearing,
TT_UShort* advance )
{
@@ -81,6 +106,7 @@
/*************************************************************************/
+ /* */
/* Returns the horizontal metrics in font units for a given glyph. */
/* If `check' is true, take care of monospaced fonts by returning the */
/* advance width maximum. */
@@ -100,6 +126,7 @@
/*************************************************************************/
+ /* */
/* Returns the advance width table for a given pixel size if it is */
/* found in the font's `hdmx' table (if any). */
/* */
@@ -126,6 +153,7 @@
/*************************************************************************/
+ /* */
/* Translates an array of coordinates. */
/* */
static
@@ -136,6 +164,7 @@
{
TT_UInt k;
+
if ( delta_x )
for ( k = 0; k < n; k++ )
coords[k].x += delta_x;
@@ -146,8 +175,8 @@
}
-
/*************************************************************************/
+ /* */
/* Mounts one glyph zone on top of another. This is needed to */
/* assemble composite glyphs. */
/* */
@@ -158,11 +187,12 @@
TT_UInt np;
TT_Int nc;
+
np = source->n_points;
nc = source->n_contours;
- target->org = source->org + np;
- target->cur = source->cur + np;
+ target->org = source->org + np;
+ target->cur = source->cur + np;
target->tags = source->tags + np;
target->contours = source->contours + nc;
@@ -173,8 +203,9 @@
#undef IS_HINTED
-#define IS_HINTED(flags) ((flags & FT_LOAD_NO_HINTING) == 0)
+#define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
+
/*************************************************************************/
/* */
/* <Function> */
@@ -183,13 +214,13 @@
/* <Description> */
/* Loads a simple (i.e, non-composite) glyph. This function is used */
/* for the `Load_Simple' state of TT_Load_Glyph(). All composite */
- /* glyphs elements will be loaded with routine. */
+ /* glyphs elements will be loaded with this routine. */
/* */
static
- TT_Error Load_Simple( TT_Loader* load,
- TT_UInt byte_count,
- TT_Int n_contours,
- TT_Bool debug )
+ TT_Error Load_Simple( TT_Loader* load,
+ TT_UInt byte_count,
+ TT_Int n_contours,
+ TT_Bool debug )
{
TT_Error error;
FT_Stream stream = load->stream;
@@ -199,9 +230,9 @@
TT_UShort n_ins;
TT_Int n, n_points;
- /*********************************************************************/
- /* simple check */
+ /* simple check */
+
if ( n_contours > load->left_contours )
{
FT_TRACE0(( "ERROR: Glyph index %ld has %d contours > left %d\n",
@@ -214,8 +245,7 @@
/* preparing the execution context */
mount_zone( &load->base, zone );
- /*********************************************************************/
- /* reading the contours endpoints */
+ /* reading the contours endpoints */
if ( ACCESS_Frame( byte_count ) )
return error;
@@ -227,9 +257,7 @@
if ( n_contours > 0 )
n_points = zone->contours[n_contours - 1] + 1;
-
- /*********************************************************************/
- /* reading the bytecode instructions */
+ /* reading the bytecode instructions */
n_ins = GET_UShort();
load->face->root.glyph->control_len = n_ins;
@@ -236,7 +264,8 @@
if ( n_points > load->left_points )
{
- FT_TRACE0(( "ERROR: Too many points in glyph %ld\n", load->glyph_index ));
+ FT_TRACE0(( "ERROR: Too many points in glyph %ld\n",
+ load->glyph_index ));
error = TT_Err_Too_Many_Points;
goto Fail;
}
@@ -250,7 +279,7 @@
goto Fail;
}
- if (stream->cursor + n_ins > stream->limit)
+ if ( stream->cursor + n_ins > stream->limit )
{
FT_TRACE0(( "ERROR: Instruction count mismatch!\n" ));
error = TT_Err_Too_Many_Ins;
@@ -258,20 +287,21 @@
}
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- if ( (load->load_flags & (FT_LOAD_NO_SCALE|FT_LOAD_NO_HINTING))==0 )
+ if ( ( load->load_flags &
+ ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) == 0 )
{
MEM_Copy( load->exec->glyphIns, stream->cursor, n_ins );
error = TT_Set_CodeRange( load->exec, tt_coderange_glyph,
load->exec->glyphIns, n_ins );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
}
-#endif
+#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
stream->cursor += n_ins;
- /*********************************************************************/
- /* reading the point tags */
+ /* reading the point tags */
{
TT_Byte* flag = load->zone.tags;
@@ -278,7 +308,8 @@
TT_Byte* limit = flag + n_points;
TT_Byte c, count;
- for (; flag < limit; flag++)
+
+ for ( ; flag < limit; flag++ )
{
*flag = c = GET_Byte();
if ( c & 8 )
@@ -289,8 +320,7 @@
}
}
- /*********************************************************************/
- /* reading the X coordinates */
+ /* reading the X coordinates */
{
TT_Vector* vec = zone->org;
@@ -298,16 +328,19 @@
TT_Byte* flag = zone->tags;
TT_Pos x = 0;
+
for ( ; vec < limit; vec++, flag++ )
{
TT_Pos y = 0;
+
if ( *flag & 2 )
{
y = GET_Byte();
- if ((*flag & 16) == 0) y = -y;
+ if ( ( *flag & 16 ) == 0 )
+ y = -y;
}
- else if ((*flag & 16) == 0)
+ else if ( ( *flag & 16 ) == 0 )
y = GET_Short();
x += y;
@@ -315,8 +348,7 @@
}
}
- /*********************************************************************/
- /* reading the Y coordinates */
+ /* reading the Y coordinates */
{
TT_Vector* vec = zone->org;
@@ -324,16 +356,19 @@
TT_Byte* flag = zone->tags;
TT_Pos x = 0;
+
for ( ; vec < limit; vec++, flag++ )
{
TT_Pos y = 0;
+
if ( *flag & 4 )
{
y = GET_Byte();
- if ((*flag & 32) == 0) y = -y;
+ if ( ( *flag & 32 ) == 0 )
+ y = -y;
}
- else if ((*flag & 32) == 0)
+ else if ( ( *flag & 32 ) == 0 )
y = GET_Short();
x += y;
@@ -343,8 +378,7 @@
FORGET_Frame();
- /*********************************************************************/
- /* Add shadow points */
+ /* add shadow points */
/* Now add the two shadow points at n and n + 1. */
/* We need the left side bearing and advance width. */
@@ -353,6 +387,7 @@
TT_Vector* pp1;
TT_Vector* pp2;
+
/* pp1 = xMin - lsb */
pp1 = zone->org + n_points;
pp1->x = load->bbox.xMin - load->left_bearing;
@@ -370,6 +405,7 @@
zone->tags[n_points ] = 0;
zone->tags[n_points + 1] = 0;
}
+
/* Note that we return two more points that are not */
/* part of the glyph outline. */
@@ -377,10 +413,9 @@
zone->n_contours = n_contours;
n_points += 2;
- /*******************************************/
/* now eventually scale and hint the glyph */
- if (load->load_flags & FT_LOAD_NO_SCALE)
+ if ( load->load_flags & FT_LOAD_NO_SCALE )
{
/* no scaling, just copy the orig arrays into the cur ones */
org_to_cur( n_points, zone );
@@ -392,8 +427,9 @@
TT_Fixed x_scale = load->size->root.metrics.x_scale;
TT_Fixed y_scale = load->size->root.metrics.y_scale;
+
/* first scale the glyph points */
- for (; vec < limit; vec++)
+ for ( ; vec < limit; vec++ )
{
vec->x = FT_MulFix( vec->x, x_scale );
vec->y = FT_MulFix( vec->y, y_scale );
@@ -400,7 +436,7 @@
}
/* if hinting, round pp1, and shift the glyph accordingly */
- if ( !IS_HINTED(load->load_flags) )
+ if ( !IS_HINTED( load->load_flags ) )
{
org_to_cur( n_points, zone );
}
@@ -407,12 +443,14 @@
else
{
TT_Pos x = zone->org[n_points-2].x;
- x = ((x + 32) & -64) - x;
+
+
+ x = ( ( x + 32 ) & -64 ) - x;
translate_array( n_points, zone->org, x, 0 );
org_to_cur( n_points, zone );
- zone->cur[n_points-1].x = (zone->cur[n_points-1].x + 32) & -64;
+ zone->cur[n_points - 1].x = ( zone->cur[n_points - 1].x + 32 ) & -64;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
/* now consider hinting */
@@ -419,7 +457,8 @@
if ( n_ins > 0 )
{
load->exec->is_composite = FALSE;
- load->exec->pedantic_hinting = (TT_Bool)(load->load_flags & FT_LOAD_PEDANTIC);
+ load->exec->pedantic_hinting = (TT_Bool)(load->load_flags &
+ FT_LOAD_PEDANTIC);
load->exec->pts = *zone;
load->exec->pts.n_points += 2;
@@ -427,7 +466,7 @@
if ( error && load->exec->pedantic_hinting )
return error;
}
-#endif
+#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
}
}
@@ -446,10 +485,6 @@
}
-
-
-
-
/*************************************************************************/
/* */
/* <Function> */
@@ -456,8 +491,8 @@
/* load_truetype_glyph */
/* */
/* <Description> */
- /* Loads a given truetype glyph. Handles composites and uses a */
- /* TT_Loader object.. */
+ /* Loads a given truetype glyph. Handles composites and uses a */
+ /* TT_Loader object. */
/* */
static
TT_Error load_truetype_glyph( TT_Loader* loader,
@@ -472,6 +507,7 @@
TT_Fixed x_scale, y_scale;
TT_ULong ins_offset;
+
/* check glyph index */
index = glyph_index;
if ( index >= (TT_UInt)face->root.num_glyphs )
@@ -485,9 +521,9 @@
num_points = 0;
ins_offset = 0;
- x_scale = 0x10000;
- y_scale = 0x10000;
- if ( (loader->load_flags & FT_LOAD_NO_SCALE)==0 )
+ x_scale = 0x10000L;
+ y_scale = 0x10000L;
+ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
x_scale = loader->size->root.metrics.x_scale;
y_scale = loader->size->root.metrics.y_scale;
@@ -498,6 +534,7 @@
TT_Short left_bearing;
TT_UShort advance_width;
+
Get_HMetrics( face, index,
(TT_Bool)!(loader->load_flags &
FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH),
@@ -511,11 +548,11 @@
/* load glyph header */
offset = face->glyph_locations[index];
count = 0;
- if (index < (TT_UInt)face->num_locations-1)
- count = face->glyph_locations[index+1] - offset;
+ if ( index < (TT_UInt)face->num_locations - 1 )
+ count = face->glyph_locations[index + 1] - offset;
- if (count == 0)
+ if ( count == 0 )
{
/* as described by Frederic Loyer, these are spaces, and */
/* not the unknown glyph. */
@@ -527,11 +564,11 @@
loader->pp1.x = 0;
loader->pp2.x = loader->advance;
- if ( (loader->load_flags & FT_LOAD_NO_SCALE)==0 )
+ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- if (loader->exec)
+ if ( loader->exec )
loader->exec->glyphSize = 0;
#endif
goto Load_End;
@@ -573,22 +610,23 @@
loader->pp2.x = loader->pp1.x + loader->advance;
loader->pp2.y = 0;
- if ((loader->load_flags & FT_LOAD_NO_SCALE)==0)
+ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
}
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
- /**********************************************************************/
- /* if it is a simple glyph, load it */
- if (contours_count >= 0)
+ /* if it is a simple glyph, load it */
+
+ if ( contours_count >= 0 )
{
TT_UInt num_base_points;
+
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
error = Load_Simple( loader,
count,
@@ -609,6 +647,8 @@
num_base_points = loader->base.n_points;
{
TT_UInt k;
+
+
for ( k = 0; k < num_contours; k++ )
loader->zone.contours[k] += num_base_points;
}
@@ -622,43 +662,48 @@
loader->left_points -= num_points;
loader->left_contours -= num_contours;
}
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /************************************************************************/
- else /* otherwise, load a composite !! */
+ /***********************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
+
+ /* otherwise, load a composite! */
+ else
{
/* for each subglyph, read composite header */
- TT_GlyphSlot glyph = loader->glyph;
+ TT_GlyphSlot glyph = loader->glyph;
FT_SubGlyph* subglyph = glyph->subglyphs + glyph->num_subglyphs;
- if (ACCESS_Frame(count)) goto Fail;
+ if ( ACCESS_Frame( count ) )
+ goto Fail;
num_subglyphs = 0;
do
{
TT_Fixed xx, xy, yy, yx;
- FT_UInt total_subglyphs;
+ FT_UInt total_subglyphs;
- /* grow the 'glyph->subglyphs' table if necessary */
- total_subglyphs = glyph->num_subglyphs + num_subglyphs;
- if ( total_subglyphs >= glyph->max_subglyphs )
- {
- FT_UInt new_max = glyph->max_subglyphs;
- FT_Memory memory = loader->face->root.memory;
- while (new_max <= total_subglyphs)
- new_max += 4;
-
- if ( REALLOC_ARRAY( glyph->subglyphs, glyph->max_subglyphs,
- new_max, FT_SubGlyph ) )
- goto Fail;
-
- glyph->max_subglyphs = new_max;
- subglyph = glyph->subglyphs + glyph->num_subglyphs + num_subglyphs;
- }
+ /* grow the `glyph->subglyphs' table if necessary */
+ total_subglyphs = glyph->num_subglyphs + num_subglyphs;
+ if ( total_subglyphs >= glyph->max_subglyphs )
+ {
+ FT_UInt new_max = glyph->max_subglyphs;
+ FT_Memory memory = loader->face->root.memory;
+
+
+ while ( new_max <= total_subglyphs )
+ new_max += 4;
+
+ if ( REALLOC_ARRAY( glyph->subglyphs, glyph->max_subglyphs,
+ new_max, FT_SubGlyph ) )
+ goto Fail;
+
+ glyph->max_subglyphs = new_max;
+ subglyph = glyph->subglyphs + glyph->num_subglyphs + num_subglyphs;
+ }
+
subglyph->arg1 = subglyph->arg2 = 0;
subglyph->flags = GET_UShort();
@@ -665,7 +710,7 @@
subglyph->index = GET_UShort();
/* read arguments */
- if (subglyph->flags & ARGS_ARE_WORDS)
+ if ( subglyph->flags & ARGS_ARE_WORDS )
{
subglyph->arg1 = GET_Short();
subglyph->arg2 = GET_Short();
@@ -677,20 +722,20 @@
}
/* read transform */
- xx = yy = 0x10000;
+ xx = yy = 0x10000L;
xy = yx = 0;
- if (subglyph->flags & WE_HAVE_A_SCALE)
+ if ( subglyph->flags & WE_HAVE_A_SCALE )
{
xx = (TT_Fixed)GET_Short() << 2;
yy = xx;
}
- else if (subglyph->flags & WE_HAVE_AN_XY_SCALE)
+ else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
{
xx = (TT_Fixed)GET_Short() << 2;
yy = (TT_Fixed)GET_Short() << 2;
}
- else if (subglyph->flags & WE_HAVE_A_2X2)
+ else if ( subglyph->flags & WE_HAVE_A_2X2 )
{
xx = (TT_Fixed)GET_Short() << 2;
xy = (TT_Fixed)GET_Short() << 2;
@@ -711,8 +756,9 @@
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
{
/* we must undo the ACCESS_Frame in order to point to the */
- /* composite instructions, if we find some .. */
- /* we will process them later.. */
+ /* composite instructions, if we find some. */
+ /* we will process them later... */
+ /* */
ins_offset = FILE_Pos() + stream->cursor - stream->limit;
}
#endif
@@ -719,8 +765,9 @@
FORGET_Frame();
/* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
- /* "as is" in the glyph slot (the client application will be */
- /* responsible for interpreting this data..) */
+ /* `as is' in the glyph slot (the client application will be */
+ /* responsible for interpreting this data)... */
+ /* */
if ( loader->load_flags & FT_LOAD_NO_RECURSE )
{
/* set up remaining glyph fields */
@@ -730,9 +777,9 @@
}
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
/*********************************************************************/
/* Now, read each subglyph independently.. */
@@ -740,13 +787,15 @@
TT_Int n, num_base_points, num_new_points;
subglyph = glyph->subglyphs + glyph->num_subglyphs;
- glyph->num_subglyphs += num_subglyphs;
-
+ glyph->num_subglyphs += num_subglyphs;
+
+
for ( n = 0; n < num_subglyphs; n++, subglyph++ )
{
TT_Vector pp1, pp2;
TT_Pos x, y;
+
pp1 = loader->pp1;
pp2 = loader->pp2;
@@ -753,7 +802,8 @@
num_base_points = loader->base.n_points;
error = load_truetype_glyph( loader, subglyph->index );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
if ( subglyph->flags & USE_MY_METRICS )
{
@@ -771,7 +821,6 @@
num_new_points = num_points - num_base_points;
- /********************************************************/
/* now perform the transform required for this subglyph */
if ( subglyph->flags & ( WE_HAVE_A_SCALE |
@@ -782,10 +831,12 @@
TT_Vector* org = loader->zone.org;
TT_Vector* limit = cur + num_new_points;
+
for ( ; cur < limit; cur++, org++ )
{
TT_Pos nx, ny;
+
nx = FT_MulFix( cur->x, subglyph->transform.xx ) +
FT_MulFix( cur->y, subglyph->transform.yx );
@@ -808,11 +859,12 @@
/* apply offset */
- if ( !(subglyph->flags & ARGS_ARE_XY_VALUES) )
+ if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
{
TT_Int k = subglyph->arg1;
TT_UInt l = subglyph->arg2;
+
if ( k >= num_base_points ||
l >= (TT_UInt)num_new_points )
{
@@ -830,16 +882,16 @@
x = subglyph->arg1;
y = subglyph->arg2;
- if (!(loader->load_flags & FT_LOAD_NO_SCALE))
+ if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
{
x = FT_MulFix( x, x_scale );
y = FT_MulFix( y, y_scale );
if ( subglyph->flags & ROUND_XY_TO_GRID )
- {
- x = (x + 32) & -64;
- y = (y + 32) & -64;
- }
+ {
+ x = ( x + 32 ) & -64;
+ y = ( y + 32 ) & -64;
+ }
}
}
@@ -847,16 +899,19 @@
cur_to_org( num_new_points, &loader->zone );
}
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
/* we have finished loading all sub-glyphs, now, look for */
- /* instructions for this composite !! */
+ /* instructions for this composite! */
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
subglyph--;
- if (num_subglyphs > 0 && loader->exec && subglyph->flags & WE_HAVE_INSTR)
+ if ( num_subglyphs > 0 &&
+ loader->exec &&
+ subglyph->flags & WE_HAVE_INSTR )
{
TT_UShort n_ins;
TT_ExecContext exec = loader->exec;
@@ -864,9 +919,11 @@
FT_GlyphZone* pts;
TT_Vector* pp1;
+
/* read size of instructions */
if ( FILE_Seek( ins_offset ) ||
- READ_UShort(n_ins) ) goto Fail;
+ READ_UShort(n_ins) )
+ goto Fail;
FT_TRACE5(( " Instructions size = %d\n", n_ins ));
/* check it */
@@ -877,9 +934,11 @@
return TT_Err_Too_Many_Ins;
}
- if (exec)
+ if ( exec )
{
+ /* XXX */
}
+
/* read the instructions */
if ( FILE_Read( exec->glyphIns, n_ins ) )
goto Fail;
@@ -888,11 +947,12 @@
tt_coderange_glyph,
exec->glyphIns,
n_ins );
- if ( error ) goto Fail;
+ if ( error )
+ goto Fail;
/* prepare the execution context */
- exec->pts = loader->base;
- pts = &exec->pts;
+ exec->pts = loader->base;
+ pts = &exec->pts;
pts->n_points = num_points + 2;
pts->n_contours = num_contours;
@@ -906,14 +966,16 @@
pts->tags[num_points + 2] = 0;
/* if hinting, round the phantom points */
- if ( IS_HINTED(loader->load_flags) )
+ if ( IS_HINTED( loader->load_flags ) )
{
- pp1[0].x = ((loader->pp1.x + 32) & -64);
- pp1[1].x = ((loader->pp2.x + 32) & -64);
+ pp1[0].x = ( ( loader->pp1.x + 32 ) & -64 );
+ pp1[1].x = ( ( loader->pp2.x + 32 ) & -64 );
}
{
TT_UInt k;
+
+
for ( k = 0; k < n_points; k++ )
pts->tags[k] &= FT_Curve_Tag_On;
}
@@ -936,15 +998,15 @@
loader->pp1 = pp1[0];
loader->pp2 = pp1[1];
}
-#endif
+#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
}
- /* end of composite loading */
+ /* end of composite loading */
}
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
Load_End:
error = TT_Err_Ok;
@@ -954,12 +1016,9 @@
}
-
-
-
static
- void compute_glyph_metrics( TT_Loader* loader,
- TT_UInt glyph_index )
+ void compute_glyph_metrics( TT_Loader* loader,
+ TT_UInt glyph_index )
{
TT_UInt num_points = loader->base.n_points;
TT_UInt num_contours = loader->base.n_contours;
@@ -969,9 +1028,10 @@
TT_GlyphSlot glyph = loader->glyph;
TT_Size size = loader->size;
+
/* when a simple glyph was loaded, the value of */
- /* "base.n_points" and "base.n_contours" is 0, we must */
- /* take those in the "zone" instead.. */
+ /* `base.n_points' and `base.n_contours' is 0, we will */
+ /* take those in the `zone' instead. */
if ( num_points == 0 && num_contours == 0 )
{
num_points = loader->zone.n_points;
@@ -978,9 +1038,9 @@
num_contours = loader->zone.n_contours;
}
- x_scale = 0x10000;
- y_scale = 0x10000;
- if ( (loader->load_flags & FT_LOAD_NO_SCALE) == 0)
+ x_scale = 0x10000L;
+ y_scale = 0x10000L;
+ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
x_scale = size->root.metrics.x_scale;
y_scale = size->root.metrics.y_scale;
@@ -989,6 +1049,8 @@
if ( glyph->format != ft_glyph_format_composite )
{
TT_UInt u;
+
+
for ( u = 0; u < num_points + 2; u++ )
{
glyph->outline.points[u] = loader->base.cur[u];
@@ -1003,7 +1065,7 @@
glyph->outline.n_contours = num_contours;
/* translate array so that (0,0) is the glyph's origin */
- translate_array( (TT_UShort)(num_points + 2),
+ translate_array( (TT_UShort)( num_points + 2 ),
glyph->outline.points,
-loader->pp1.x,
0 );
@@ -1010,49 +1072,50 @@
FT_Outline_Get_CBox( &glyph->outline, &bbox );
- if ( IS_HINTED(loader->load_flags) )
+ if ( IS_HINTED( loader->load_flags ) )
{
/* grid-fit the bounding box */
bbox.xMin &= -64;
bbox.yMin &= -64;
- bbox.xMax = (bbox.xMax + 63) & -64;
- bbox.yMax = (bbox.yMax + 63) & -64;
+ bbox.xMax = ( bbox.xMax + 63 ) & -64;
+ bbox.yMax = ( bbox.yMax + 63 ) & -64;
}
}
else
bbox = loader->bbox;
- /* get the device-independent scaled horizontal metrics */
- /* take care of fixed-pitch fonts... */
+ /* get the device-independent scaled horizontal metrics; */
+ /* take care of fixed-pitch fonts... */
{
TT_Pos left_bearing;
TT_Pos advance;
-
+
TT_Pos lsb2, adv2;
+
left_bearing = loader->left_bearing;
advance = loader->advance;
- /* the flag FT_LOAD_NO_ADVANCE_CHECK was introduced to */
- /* correctly support DynaLab fonts, who have an incorrect */
- /* "advance_Width_Max" field !! It is used, to my knowledge */
- /* exclusively in the X-TrueType font server.. */
- /* */
- if ( face->postscript.isFixedPitch &&
- (loader->load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH) == 0 )
+ /* the flag FT_LOAD_NO_ADVANCE_CHECK was introduced to */
+ /* correctly support DynaLab fonts, which have an incorrect */
+ /* `advance_Width_Max' field! It is used, to my knowledge, */
+ /* exclusively in the X-TrueType font server. */
+ /* */
+ if ( face->postscript.isFixedPitch &&
+ ( loader->load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) == 0 )
advance = face->horizontal.advance_Width_Max;
lsb2 = left_bearing;
adv2 = advance;
-
+
/* if necessary, scale the horizontal left bearing and advance */
/* to get their values in 16.16 format.. */
- if ( !(loader->load_flags & FT_LOAD_NO_SCALE) &&
- loader->load_flags & FT_LOAD_LINEAR )
+ if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
+ loader->load_flags & FT_LOAD_LINEAR )
{
FT_Pos em_size = face->root.units_per_EM;
FT_Pos pixel_size = (FT_Pos)face->root.size->metrics.x_ppem << 16;
-
+
lsb2 = FT_MulDiv( lsb2, pixel_size, em_size );
adv2 = FT_MulDiv( adv2, pixel_size, em_size );
}
@@ -1092,40 +1155,40 @@
}
else
{
- /* Make up the distances from the horizontal header.. */
+ /* Make up the distances from the horizontal header. */
- /* NOTE: The OS/2 values are the only `portable' ones, */
- /* which is why we use them, when there is an */
- /* OS/2 table in the font. Otherwise, we use the */
- /* values defined in the horizontal header.. */
- /* */
- /* NOTE2: The sTypoDescender is negative, which is why */
- /* we compute the baseline-to-baseline distance */
- /* here with: */
- /* ascender - descender + linegap */
- /* */
+ /* NOTE: The OS/2 values are the only `portable' ones, */
+ /* which is why we use them, if there is an OS/2 */
+ /* table in the font. Otherwise, we use the */
+ /* values defined in the horizontal header. */
+ /* */
+ /* NOTE2: The sTypoDescender is negative, which is why */
+ /* we compute the baseline-to-baseline distance */
+ /* here with: */
+ /* ascender - descender + linegap */
+ /* */
if ( face->os2.version != 0xFFFF )
{
top_bearing = face->os2.sTypoLineGap / 2;
- advance_height = (TT_UShort)(face->os2.sTypoAscender -
- face->os2.sTypoDescender +
- face->os2.sTypoLineGap);
+ advance_height = (TT_UShort)( face->os2.sTypoAscender -
+ face->os2.sTypoDescender +
+ face->os2.sTypoLineGap );
}
else
{
top_bearing = face->horizontal.Line_Gap / 2;
- advance_height = (TT_UShort)(face->horizontal.Ascender +
- face->horizontal.Descender +
- face->horizontal.Line_Gap);
+ advance_height = (TT_UShort)( face->horizontal.Ascender +
+ face->horizontal.Descender +
+ face->horizontal.Line_Gap );
}
}
- /* We must adjust the top_bearing value from the bounding box given
- in the glyph header to te bounding box calculated with
- TT_Get_Outline_BBox() */
+ /* We must adjust the top_bearing value from the bounding box given */
+ /* in the glyph header to te bounding box calculated with */
+ /* TT_Get_Outline_BBox(). */
/* scale the metrics */
- if ( !(loader->load_flags & FT_LOAD_NO_SCALE) )
+ if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
{
Top = FT_MulFix( top_bearing, y_scale );
top = FT_MulFix( top_bearing + loader->bbox.yMax, y_scale )
@@ -1141,20 +1204,22 @@
/* compute metrics2 fields */
{
- FT_Pos vtb2 = top_bearing;
- FT_Pos adv2 = advance_height;
-
+ TT_Pos vtb2 = top_bearing;
+ TT_Pos adv2 = advance_height;
+
+
/* scale to 16.16 format if required */
- if ( !(loader->load_flags & FT_LOAD_NO_SCALE) &&
- loader->load_flags & FT_LOAD_LINEAR )
- {
- FT_Pos em_size = face->root.units_per_EM;
- FT_Pos pixel_size = face->root.size->metrics.y_ppem;
-
+ if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
+ loader->load_flags & FT_LOAD_LINEAR )
+ {
+ TT_Pos em_size = face->root.units_per_EM;
+ TT_Pos pixel_size = face->root.size->metrics.y_ppem;
+
+
vtb2 = FT_MulDiv( vtb2, pixel_size, em_size );
adv2 = FT_MulDiv( adv2, pixel_size, em_size );
}
-
+
glyph->metrics2.vertBearingY = vtb2;
glyph->metrics2.vertAdvance = adv2;
}
@@ -1165,11 +1230,11 @@
left = ( bbox.xMin - bbox.xMax ) / 2;
/* grid-fit them if necessary */
- if ( IS_HINTED(loader->load_flags) )
+ if ( IS_HINTED( loader->load_flags ) )
{
left &= -64;
- top = (top + 63) & -64;
- advance = (advance + 32) & -64;
+ top = ( top + 63 ) & -64;
+ advance = ( advance + 32 ) & -64;
}
glyph->metrics.vertBearingX = left;
@@ -1179,10 +1244,10 @@
/* Adjust advance width to the value contained in the hdmx table. */
if ( !face->postscript.isFixedPitch && size &&
- IS_HINTED(loader->load_flags) )
+ IS_HINTED( loader->load_flags ) )
{
TT_Byte* widths = Get_Advance_Widths( face,
- size->root.metrics.x_ppem );
+ size->root.metrics.x_ppem );
if ( widths )
glyph->metrics.horiAdvance = widths[glyph_index] << 6;
}
@@ -1190,7 +1255,7 @@
/* drop-out mode is irrelevant, we always use mode 2 */
#if 0
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- if (loader->exec)
+ if ( loader->exec )
glyph->outline.dropout_mode = (TT_Char)loader->exec->GS.scan_type;
#else
glyph->outline.dropout_mode = 2;
@@ -1204,16 +1269,33 @@
}
-
-
-
-
-
-
-
-
-
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* TT_Load_Glyph */
+ /* */
+ /* <Description> */
+ /* A function used to load a single glyph within a given glyph slot, */
+ /* for a given size. */
+ /* */
+ /* <Input> */
+ /* glyph :: A handle to a 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. */
+ /* */
+ /* glyph_index :: The index of the glyph in the font file. */
+ /* */
+ /* load_flags :: A flag indicating what to load for this glyph. The */
+ /* FT_LOAD_XXX 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> */
+ /* TrueType error code. 0 means success. */
+ /* */
LOCAL_FUNC
TT_Error TT_Load_Glyph( TT_Size size,
TT_GlyphSlot glyph,
@@ -1228,6 +1310,7 @@
TT_Loader loader;
FT_GlyphZone* zone;
+
face = (TT_Face)glyph->face;
sfnt = (SFNT_Interface*)face->sfnt;
stream = face->root.stream;
@@ -1234,8 +1317,8 @@
memory = face->root.memory;
error = 0;
- if ( !size || (load_flags & FT_LOAD_NO_SCALE) ||
- (load_flags & FT_LOAD_NO_RECURSE ))
+ if ( !size || ( load_flags & FT_LOAD_NO_SCALE ) ||
+ ( load_flags & FT_LOAD_NO_RECURSE ) )
{
size = NULL;
load_flags |= FT_LOAD_NO_SCALE |
@@ -1246,12 +1329,15 @@
glyph->num_subglyphs = 0;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
- /*********************************************************************/
- /* Try to load embedded bitmap if any */
- if ( size && (load_flags & FT_LOAD_NO_BITMAP) == 0 && sfnt->load_sbits )
+
+ /* try to load embedded bitmap if any */
+ if ( size &&
+ ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
+ sfnt->load_sbits )
{
TT_SBit_Metrics metrics;
+
error = sfnt->load_sbit_image( face,
size->root.metrics.x_ppem,
size->root.metrics.y_ppem,
@@ -1280,31 +1366,33 @@
return error;
}
}
+
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
if ( load_flags & FT_LOAD_NO_OUTLINE )
return ( error ? error : TT_Err_Unavailable_Bitmap );
- /* seek to the beginning of the glyph table. For Type 43 fonts */
- /* the table might be accessed from a Postscript stream or something */
- /* else... */
+ /* seek to the beginning of the glyph table. For Type 43 fonts */
+ /* the table might be accessed from a Postscript stream or something */
+ /* else... */
+
error = face->goto_table( face, TTAG_glyf, stream, 0 );
- if (error)
+ if ( error )
{
- FT_ERROR(( "TT.GLoad: could not access glyph table\n" ));
+ FT_ERROR(( "TT_Load_Glyph: Could not access glyph table\n" ));
goto Exit;
}
- MEM_Set( &loader, 0, sizeof(loader) );
+ MEM_Set( &loader, 0, sizeof ( loader ) );
/* update the glyph zone bounds */
- zone = &((TT_Driver)face->root.driver)->zone;
- error = FT_Update_GlyphZone( zone,
- face->root.max_points,
- face->root.max_contours );
- if (error)
+ zone = &((TT_Driver)face->root.driver)->zone;
+ error = FT_Update_GlyphZone( zone,
+ face->root.max_points,
+ face->root.max_contours );
+ if ( error )
{
- FT_ERROR(( "TT.GLoad: could not update loader glyph zone\n" ));
+ FT_ERROR(( "TT_Load_Glyph: Could not update loader glyph zone\n" ));
goto Exit;
}
loader.base = *zone;
@@ -1313,10 +1401,11 @@
loader.zone.n_contours = 0;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
if ( size )
{
/* query new execution context */
- loader.exec = size->debug ? size->context : TT_New_Context(face);
+ loader.exec = size->debug ? size->context : TT_New_Context( face );
if ( !loader.exec )
return TT_Err_Could_Not_Find_Context;
@@ -1326,16 +1415,17 @@
if ( size->GS.instruct_control & 2 )
loader.exec->GS = tt_default_graphics_state;
}
+
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
- /* clear all outline flags, except the "owner" one */
+ /* clear all outline flags, except the `owner' one */
glyph->outline.flags &= ft_outline_owner;
if ( size && size->root.metrics.y_ppem < 24 )
glyph->outline.flags |= ft_outline_high_precision;
- /************************************************************************/
- /* let's initialise the rest of our loader now */
+ /* let's initialize the rest of our loader now */
+
loader.left_points = face->root.max_points;
loader.left_contours = face->root.max_contours;
loader.load_flags = load_flags;
@@ -1348,17 +1438,19 @@
loader.glyf_offset = FILE_Pos();
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- /* when the cvt program has disabled hinting, the argument */
- /* is ignored. */
- if ( size && (size->GS.instruct_control & 1) )
+
+ /* if the cvt program has disabled hinting, the argument */
+ /* is ignored. */
+ if ( size && ( size->GS.instruct_control & 1 ) )
loader.load_flags |= FT_LOAD_NO_HINTING;
-#endif
+#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+
/* Main loading loop */
glyph->format = ft_glyph_format_outline;
- glyph->num_subglyphs = 0;
+ glyph->num_subglyphs = 0;
error = load_truetype_glyph( &loader, glyph_index );
- if (!error)
+ if ( !error )
compute_glyph_metrics( &loader, glyph_index );
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
@@ -1369,7 +1461,6 @@
Exit:
return error;
}
-
/* END */
--- a/src/truetype/ttgload.h
+++ b/src/truetype/ttgload.h
@@ -4,11 +4,11 @@
/* */
/* TrueType Glyph Loader (specification). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -29,7 +29,7 @@
extern "C" {
#endif
- typedef struct TT_Loader_
+ typedef struct TT_Loader_
{
TT_Face face;
TT_Size size;
@@ -64,31 +64,6 @@
} TT_Loader;
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Get_Metrics */
- /* */
- /* <Description> */
- /* Returns the horizontal or vertical metrics in font units for a */
- /* given glyph. The metrics are the left side bearing (resp. top */
- /* side bearing) and advance width (resp. advance height). */
- /* */
- /* <Input> */
- /* header :: A pointer to either the horizontal or vertical metrics */
- /* structure. */
- /* */
- /* index :: The glyph index. */
- /* */
- /* <Output> */
- /* bearing :: The bearing, either left side or top side. */
- /* */
- /* advance :: The advance width resp. advance height. */
- /* */
- /* <Note> */
- /* This function will much probably move to another component in the */
- /* near future, but I haven't decided which yet. */
- /* */
LOCAL_DEF
void TT_Get_Metrics( TT_HoriHeader* header,
TT_UInt index,
@@ -95,41 +70,6 @@
TT_Short* bearing,
TT_UShort* advance );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Load_Glyph */
- /* */
- /* <Description> */
- /* A function used to load a single glyph within a given glyph slot, */
- /* for a given size. */
- /* */
- /* <Input> */
- /* glyph :: A handle to a 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. */
- /* */
- /* glyph_index :: The index of the glyph in the font file. */
- /* */
- /* load_flags :: A flag indicating what to load for this glyph. The */
- /* FT_LOAD_XXX 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). */
- /* <Output> */
- /* result :: A set of bit flags indicating the type of data that */
- /* was loaded in the glyph slot (outline or bitmap, */
- /* etc). */
- /* */
- /* You can set this field to 0 if you don't want this */
- /* information. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
LOCAL_DEF
TT_Error TT_Load_Glyph( TT_Size size,
TT_GlyphSlot glyph,
@@ -139,7 +79,6 @@
#ifdef __cplusplus
}
#endif
-
#endif /* TTGLOAD_H */
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -2,13 +2,13 @@
/* */
/* ttinterp.c */
/* */
-/* TrueType bytecode intepreter (body). */
+/* TrueType bytecode interpreter (body). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -24,6 +24,7 @@
#include <freetype/internal/tterrors.h>
#include <ttinterp.h>
+
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
@@ -32,20 +33,26 @@
#define TT_INT64 FT_Int64
-/* required by the tracing mode */
+
+ /*************************************************************************/
+ /* */
+ /* 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_ttinterp
+#define FT_COMPONENT trace_ttinterp
#undef NO_APPLE_PATENT
-#define APPLE_THRESHOLD 0x4000000
+#define APPLE_THRESHOLD 0x4000000L
/*************************************************************************/
/* */
- /* In order to detect infinite loops in the code, we set-up a counter */
- /* within the run loop. a single stroke of interpretation is now limited */
- /* to a maximum number of opcodes defined below. */
+ /* In order to detect infinite loops in the code, we set up a counter */
+ /* within the run loop. A single stroke of interpretation is now */
+ /* limitet to a maximal number of opcodes defined below. */
/* */
-#define MAX_RUNNABLE_OPCODES 1000000
+#define MAX_RUNNABLE_OPCODES 1000000L
/*************************************************************************/
@@ -52,7 +59,7 @@
/* */
/* There are two kinds of implementations: */
/* */
- /* a. static implementation: */
+ /* a. static implementation */
/* */
/* The current execution context is a static variable, which fields */
/* are accessed directly by the interpreter during execution. The */
@@ -60,7 +67,7 @@
/* */
/* This version is non-reentrant, of course. */
/* */
- /* b. indirect implementation: */
+ /* b. indirect implementation */
/* */
/* The current execution context is passed to _each_ function as its */
/* first argument, and each field is thus accessed indirectly. */
@@ -85,13 +92,13 @@
/*************************************************************************/
-#ifndef TT_CONFIG_OPTION_STATIC_INTERPRETER /* indirect implementation */
+#ifndef TT_CONFIG_OPTION_STATIC_INTERPRETER /* indirect implementation */
-#define CUR (*exc) /* see ttobjs.h */
+#define CUR (*exc) /* see ttobjs.h */
-#else /* static implementation */
+#else /* static implementation */
-#define CUR cur
+#define CUR cur
static
TT_ExecContextRec cur; /* static exec. context variable */
@@ -105,11 +112,9 @@
/*************************************************************************/
/* */
- /* Most of FreeType builds don't use engine compensations. We thus */
- /* introduce a macro, FT_CONFIG_OPTION_INTERPRETER_QUICK, which controls */
- /* the use of these values. */
+ /* The instruction argument stack. */
/* */
-#define INS_ARG EXEC_OP_ TT_Long* args /* see ttobjs.h for EXEC_OP_ */
+#define INS_ARG EXEC_OP_ TT_Long* args /* see ttobjs.h for EXEC_OP_ */
/*************************************************************************/
@@ -117,7 +122,7 @@
/* This macro is used whenever `exec' is unused in a function, to avoid */
/* stupid warnings from pedantic compilers. */
/* */
-#define UNUSED_EXEC UNUSED(CUR)
+#define UNUSED_EXEC UNUSED( CUR )
/*************************************************************************/
@@ -125,13 +130,13 @@
/* This macro is used whenever `args' is unused in a function, to avoid */
/* stupid warnings from pedantic compilers. */
/* */
-#define UNUSED_ARG UNUSED_EXEC; UNUSED(args);
+#define UNUSED_ARG UNUSED_EXEC; UNUSED( args )
/*************************************************************************/
/* */
/* The following macros hide the use of EXEC_ARG and EXEC_ARG_ to */
- /* increase readabiltyof the code. */
+ /* increase readabilty of the code. */
/* */
/*************************************************************************/
@@ -206,7 +211,6 @@
Move_Zp2_Point( EXEC_ARG_ a, b, c, t )
-
/*************************************************************************/
/* */
/* Instruction dispatch function, as used by the interpreter. */
@@ -218,14 +222,14 @@
/* */
/* A simple bounds-checking macro. */
/* */
-#define BOUNDS( x, n ) ((TT_UInt)(x) >= (TT_UInt)(n))
+#define BOUNDS( x, n ) ( (TT_UInt)(x) >= (TT_UInt)(n) )
-#undef SUCCESS
-#define SUCCESS 0
+#undef SUCCESS
+#define SUCCESS 0
-#undef FAILURE
-#define FAILURE 1
+#undef FAILURE
+#define FAILURE 1
/*************************************************************************/
@@ -246,8 +250,9 @@
/* */
/* <Input> */
/* range :: The new execution code range. */
- /* IP :: The new IP in the new code range. */
/* */
+ /* IP :: The new IP in the new code range. */
+ /* */
/* <InOut> */
/* exec :: The target execution context. */
/* */
@@ -270,7 +275,7 @@
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
- /* range, we test for IP <= Size, instead of IP < Size. */
+ /* range, we test for IP <= Size instead of IP < Size. */
/* */
FT_Assert( (TT_ULong)IP <= coderange->size );
@@ -293,7 +298,9 @@
/* */
/* <Input> */
/* range :: The code range index. */
+ /* */
/* base :: The new code base. */
+ /* */
/* length :: The range size in bytes. */
/* */
/* <InOut> */
@@ -367,8 +374,9 @@
/* */
/* <Input> */
/* exec :: A handle to the target execution context. */
- /* system :: A handle to the parent system object. */
/* */
+ /* memory :: A handle to the parent memory object. */
+ /* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
@@ -467,7 +475,7 @@
Fail_Memory:
FT_ERROR(( "TT.Context_Create: not enough memory for 0x%08lx\n",
- (long)exec ));
+ (long)exec ));
TT_Destroy_Context( exec, memory );
return error;
@@ -483,6 +491,8 @@
/* Checks the size of a buffer and reallocates it if necessary. */
/* */
/* <Input> */
+ /* memory :: A handle to the parent memory object. */
+ /* */
/* multiplier :: The size in bytes of each element in the buffer. */
/* */
/* new_max :: The new capacity (size) of the buffer. */
@@ -529,6 +539,7 @@
/* */
/* <Input> */
/* face :: A handle to the source face object. */
+ /* */
/* size :: A handle to the source size object. */
/* */
/* <InOut> */
@@ -550,6 +561,7 @@
TT_MaxProfile* maxp;
TT_Error error;
+
exec->face = face;
maxp = &face->max_profile;
exec->size = size;
@@ -633,8 +645,8 @@
/* <Input> */
/* exec :: A handle to the source execution context. */
/* */
- /* <Output> */
- /* ins :: A handle to the target size object. */
+ /* <InOut> */
+ /* size :: A handle to the target size object. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
@@ -648,6 +660,7 @@
{
TT_Int i;
+
/* XXXX: Will probably disappear soon with all the code range */
/* management, which is now rather obsolete. */
/* */
@@ -677,6 +690,8 @@
/* variables and returns immediately, otherwise TT_RunIns() */
/* is called. */
/* */
+ /* This is commented out currently. */
+ /* */
/* <Input> */
/* exec :: A handle to the target execution context. */
/* */
@@ -692,7 +707,8 @@
{
TT_Error error;
- if ( (error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ))
+
+ if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) )
!= TT_Err_Ok )
return error;
@@ -719,7 +735,8 @@
exec->callTop = 0;
#if 1
- UNUSED(debug);
+ UNUSED( debug );
+
return exec->face->interpreter( exec );
#else
if ( !debug )
@@ -762,15 +779,21 @@
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
/* */
- FT_EXPORT_FUNC(TT_ExecContext) TT_New_Context( TT_Face face )
+ FT_EXPORT_FUNC( TT_ExecContext ) TT_New_Context( TT_Face face )
{
- TT_Driver driver = (TT_Driver)face->root.driver;
+ TT_Driver driver;
TT_ExecContext exec;
- FT_Memory memory = driver->root.memory;
+ FT_Memory memory;
- exec = driver->context;
+ if ( !face )
+ return 0;
+ driver = (TT_Driver)face->root.driver;
+
+ memory = driver->root.memory;
+ exec = driver->context;
+
if ( !driver->context )
{
TT_Error error;
@@ -828,10 +851,12 @@
#ifdef FT_CONFIG_OPTION_OLD_CALCS
- static TT_F26Dot6 Norm( TT_F26Dot6 X, TT_F26Dot6 Y )
+ static TT_F26Dot6 Norm( TT_F26Dot6 X,
+ TT_F26Dot6 Y )
{
- FT_Int64 T1, T2;
+ FT_Int64 T1, T2;
+
MUL_64( X, X, T1 );
MUL_64( Y, Y, T2 );
@@ -839,9 +864,10 @@
return (TT_F26Dot6)SQRT_64( T1 );
}
-#endif
+#endif /* FT_CONFIG_OPTION_OLD_CALCS */
+
/*************************************************************************/
/* */
/* Before an opcode is executed, the interpreter verifies that there are */
@@ -866,7 +892,7 @@
#undef PACK
-#define PACK( x, y ) ((x << 4) | y)
+#define PACK( x, y ) ( ( x << 4 ) | y )
static
@@ -1181,7 +1207,7 @@
#undef NULL_Vector
-#define NULL_Vector (TT_Vector*)&Null_Vector
+#define NULL_Vector (TT_Vector*)&Null_Vector
/*************************************************************************/
@@ -1218,8 +1244,8 @@
#else
x = TT_MULDIV( CUR.GS.projVector.x, CUR.tt_metrics.x_ratio, 0x8000 );
y = TT_MULDIV( CUR.GS.projVector.y, CUR.tt_metrics.y_ratio, 0x8000 );
- CUR.tt_metrics.ratio = FT_Sqrt32( x*x+y*y ) << 1;
-#endif
+ CUR.tt_metrics.ratio = FT_Sqrt32( x * x + y * y ) << 1;
+#endif /* FT_CONFIG_OPTION_OLD_CALCS */
}
return CUR.tt_metrics.ratio;
@@ -1304,7 +1330,8 @@
{
/* Reading a byte stream so there is no endianess (DaveP) */
CUR.IP += 2;
- return (TT_Short)((CUR.code[CUR.IP - 2] << 8) + CUR.code[CUR.IP - 1]);
+ return (TT_Short)( ( CUR.code[CUR.IP - 2] << 8 ) +
+ CUR.code[CUR.IP - 1] );
}
@@ -1375,6 +1402,7 @@
/* */
/* <Input> */
/* point :: The index of the point to move. */
+ /* */
/* distance :: The distance to apply. */
/* */
/* <InOut> */
@@ -1393,7 +1421,7 @@
if ( v != 0 )
{
#ifdef NO_APPLE_PATENT
- if ( ABS(CUR.F_dot_P) > APPLE_THRESHOLD )
+ if ( ABS( CUR.F_dot_P ) > APPLE_THRESHOLD )
zone->cur[point].x += distance;
#else
zone->cur[point].x += TT_MULDIV( distance,
@@ -1408,7 +1436,7 @@
if ( v != 0 )
{
#ifdef NO_APPLE_PATENT
- if ( ABS(CUR.F_dot_P) > APPLE_THRESHOLD )
+ if ( ABS( CUR.F_dot_P ) > APPLE_THRESHOLD )
zone->cur[point].y += distance;
#else
zone->cur[point].y += TT_MULDIV( distance,
@@ -1425,7 +1453,7 @@
/* Special versions of Direct_Move() */
/* */
/* The following versions are used whenever both vectors are both */
- /* along one of the coordinate unit vectors, i.e. in 90% cases. */
+ /* along one of the coordinate unit vectors, i.e. in 90% of the cases. */
/* */
/*************************************************************************/
@@ -1463,6 +1491,7 @@
/* */
/* <Input> */
/* distance :: The distance (not) to round. */
+ /* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
@@ -1480,9 +1509,9 @@
{
TT_F26Dot6 val;
-
UNUSED_EXEC;
+
if ( distance >= 0 )
{
val = distance + compensation;
@@ -1508,6 +1537,7 @@
/* */
/* <Input> */
/* distance :: The distance to round. */
+ /* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
@@ -1519,9 +1549,9 @@
{
TT_F26Dot6 val;
-
UNUSED_EXEC;
+
if ( distance >= 0 )
{
val = distance + compensation + 32;
@@ -1532,10 +1562,11 @@
}
else
{
- val = -( (compensation - distance + 32) & (-64) );
+ val = -( ( compensation - distance + 32 ) & -64 );
if ( val > 0 )
val = 0;
}
+
return val;
}
@@ -1550,6 +1581,7 @@
/* */
/* <Input> */
/* distance :: The distance to round. */
+ /* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
@@ -1561,21 +1593,22 @@
{
TT_F26Dot6 val;
+ UNUSED_EXEC;
- UNUSED_EXEC;
if ( distance >= 0 )
{
- val = ((distance + compensation) & (-64)) + 32;
+ val = ( ( distance + compensation ) & -64 ) + 32;
if ( val < 0 )
val = 0;
}
else
{
- val = -( ((compensation - distance) & (-64)) + 32 );
+ val = -( ( (compensation - distance) & -64 ) + 32 );
if ( val > 0 )
val = 0;
}
+
return val;
}
@@ -1590,6 +1623,7 @@
/* */
/* <Input> */
/* distance :: The distance to round. */
+ /* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
@@ -1601,9 +1635,9 @@
{
TT_F26Dot6 val;
-
UNUSED_EXEC;
+
if ( distance >= 0 )
{
val = distance + compensation;
@@ -1614,10 +1648,11 @@
}
else
{
- val = -( (compensation - distance) & (-64) );
+ val = -( ( compensation - distance ) & -64 );
if ( val > 0 )
val = 0;
}
+
return val;
}
@@ -1632,6 +1667,7 @@
/* */
/* <Input> */
/* distance :: The distance to round. */
+ /* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
@@ -1656,10 +1692,11 @@
}
else
{
- val = -( (compensation - distance + 63) & (-64) );
+ val = -( ( compensation - distance + 63 ) & -64 );
if ( val > 0 )
val = 0;
}
+
return val;
}
@@ -1674,6 +1711,7 @@
/* */
/* <Input> */
/* distance :: The distance to round. */
+ /* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
@@ -1687,6 +1725,7 @@
UNUSED_EXEC;
+
if ( distance >= 0 )
{
val = distance + compensation + 16;
@@ -1697,10 +1736,11 @@
}
else
{
- val = -( (compensation - distance + 16) & (-32) );
+ val = -( ( compensation - distance + 16 ) & -32 );
if ( val > 0 )
val = 0;
}
+
return val;
}
@@ -1715,6 +1755,7 @@
/* */
/* <Input> */
/* distance :: The distance to round. */
+ /* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
@@ -1735,8 +1776,8 @@
if ( distance >= 0 )
{
- val = (distance - CUR.phase + CUR.threshold + compensation) &
- (-CUR.period);
+ val = ( distance - CUR.phase + CUR.threshold + compensation ) &
+ -CUR.period;
if ( val < 0 )
val = 0;
val += CUR.phase;
@@ -1743,12 +1784,13 @@
}
else
{
- val = -( (CUR.threshold - CUR.phase - distance + compensation) &
- (-CUR.period) );
+ val = -( ( CUR.threshold - CUR.phase - distance + compensation ) &
+ -CUR.period );
if ( val > 0 )
val = 0;
val -= CUR.phase;
}
+
return val;
}
@@ -1763,6 +1805,7 @@
/* */
/* <Input> */
/* distance :: The distance to round. */
+ /* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
@@ -1781,7 +1824,7 @@
if ( distance >= 0 )
{
- val = ( (distance - CUR.phase + CUR.threshold + compensation) /
+ val = ( ( distance - CUR.phase + CUR.threshold + compensation ) /
CUR.period ) * CUR.period;
if ( val < 0 )
val = 0;
@@ -1789,7 +1832,7 @@
}
else
{
- val = -( ( (CUR.threshold - CUR.phase - distance + compensation) /
+ val = -( ( ( CUR.threshold - CUR.phase - distance + compensation ) /
CUR.period ) * CUR.period );
if ( val > 0 )
val = 0;
@@ -1867,7 +1910,7 @@
void SetSuperRound( EXEC_OP_ TT_F26Dot6 GridPeriod,
TT_Long selector )
{
- switch ( (TT_Int)(selector & 0xC0) )
+ switch ( (TT_Int)( selector & 0xC0 ) )
{
case 0:
CUR.period = GridPeriod / 2;
@@ -1888,7 +1931,7 @@
break;
}
- switch ( (TT_Int)(selector & 0x30) )
+ switch ( (TT_Int)( selector & 0x30 ) )
{
case 0:
CUR.phase = 0;
@@ -1910,7 +1953,7 @@
if ( (selector & 0x0F) == 0 )
CUR.threshold = CUR.period - 1;
else
- CUR.threshold = ( (TT_Int)(selector & 0x0F) - 4 ) * CUR.period / 8;
+ CUR.threshold = ( (TT_Int)( selector & 0x0F ) - 4 ) * CUR.period / 8;
CUR.period /= 256;
CUR.phase /= 256;
@@ -2015,7 +2058,7 @@
{
UNUSED_EXEC;
- return (v1->x - v2->x);
+ return ( v1->x - v2->x );
}
@@ -2041,7 +2084,7 @@
{
UNUSED_EXEC;
- return (v1->y - v2->y);
+ return ( v1->y - v2->y );
}
@@ -2145,9 +2188,11 @@
/* */
#ifdef FT_CONFIG_OPTION_OLD_CALCS
- static TT_Bool Normalize( EXEC_OP_ TT_F26Dot6 Vx,
- TT_F26Dot6 Vy,
- TT_UnitVector* R )
+
+ static
+ TT_Bool Normalize( EXEC_OP_ TT_F26Dot6 Vx,
+ TT_F26Dot6 Vy,
+ TT_UnitVector* R )
{
TT_F26Dot6 W;
TT_Bool S1, S2;
@@ -2154,6 +2199,7 @@
UNUSED_EXEC;
+
if ( ABS( Vx ) < 0x10000L && ABS( Vy ) < 0x10000L )
{
Vx *= 0x100;
@@ -2163,8 +2209,8 @@
if ( W == 0 )
{
- /* XXX : UNDOCUMENTED! It seems that it's possible to try */
- /* to normalize the vector (0,0). Return immediately */
+ /* XXX: UNDOCUMENTED! It seems that it's possible to try */
+ /* to normalize the vector (0,0). Return immediately. */
return SUCCESS;
}
@@ -2202,7 +2248,7 @@
while ( W < 0x1000000L )
{
- /* We need to increase W, by a minimal amount */
+ /* We need to increase W by a minimal amount */
if ( Vx < Vy )
Vx++;
else
@@ -2213,7 +2259,7 @@
while ( W >= 0x1004000L )
{
- /* We need to decrease W, by a minimal amount */
+ /* We need to decrease W by a minimal amount */
if ( Vx < Vy )
Vx--;
else
@@ -2236,7 +2282,9 @@
return SUCCESS;
}
+
#else
+
static
TT_Bool Normalize( EXEC_OP_ TT_F26Dot6 Vx,
TT_F26Dot6 Vy,
@@ -2246,10 +2294,11 @@
TT_Int shift;
TT_ULong H, L, L2, hi, lo, med;
- u = ABS(Vx);
- v = ABS(Vy);
- if (u < v)
+ u = ABS( Vx );
+ v = ABS( Vy );
+
+ if ( u < v )
{
d = u;
u = v;
@@ -2259,42 +2308,46 @@
R->x = 0;
R->y = 0;
- /* check that we're not trying to normalise zero !! */
- if (u==0) return SUCCESS;
+ /* check that we are not trying to normalise zero! */
+ if ( u == 0 )
+ return SUCCESS;
- /* compute (u*u+v*v) on 64 bits with two 32-bit registers [H:L] */
+ /* compute (u*u + v*v) on 64 bits with two 32-bit registers [H:L] */
hi = (TT_ULong)u >> 16;
lo = (TT_ULong)u & 0xFFFF;
- med = hi*lo;
+ med = hi * lo;
- H = hi*hi + (med >> 15);
+ H = hi * hi + ( med >> 15 );
med <<= 17;
- L = lo*lo + med;
- if (L < med) H++;
+ L = lo * lo + med;
+ if ( L < med )
+ H++;
hi = (TT_ULong)v >> 16;
lo = (TT_ULong)v & 0xFFFF;
- med = hi*lo;
+ med = hi * lo;
- H += hi*hi + (med >> 15);
+ H += hi * hi + ( med >> 15 );
med <<= 17;
- L2 = lo*lo + med;
- if (L2 < med) H++;
+ L2 = lo * lo + med;
+ if ( L2 < med )
+ H++;
L += L2;
- if (L < L2) H++;
+ if ( L < L2 )
+ H++;
/* if the value is smaller than 32-bits */
- if (H == 0)
+ if ( H == 0 )
{
shift = 0;
- while ((L & 0xC0000000) == 0)
+ while ( ( L & 0xC0000000L ) == 0 )
{
L <<= 2;
shift++;
}
- d = FT_Sqrt32(L);
+ d = FT_Sqrt32( L );
R->x = (TT_F2Dot14)TT_MULDIV( Vx << shift, 0x4000, d );
R->y = (TT_F2Dot14)TT_MULDIV( Vy << shift, 0x4000, d );
}
@@ -2302,14 +2355,14 @@
else
{
shift = 0;
- while (H)
+ while ( H )
{
- L = (L >> 2) | (H << 30);
+ L = ( L >> 2 ) | ( H << 30 );
H >>= 2;
shift++;
}
- d = FT_Sqrt32(L);
+ d = FT_Sqrt32( L );
R->x = (TT_F2Dot14)TT_MULDIV( Vx >> shift, 0x4000, d );
R->y = (TT_F2Dot14)TT_MULDIV( Vy >> shift, 0x4000, d );
}
@@ -2318,39 +2371,48 @@
TT_ULong x, y, w;
TT_Int sx, sy;
- sx = ( R->x >= 0 ? 1 : -1 );
- sy = ( R->y >= 0 ? 1 : -1 );
- x = (TT_ULong)sx*R->x;
- y = (TT_ULong)sy*R->y;
- w = x*x+y*y;
+ sx = R->x >= 0 ? 1 : -1;
+ sy = R->y >= 0 ? 1 : -1;
+ x = (TT_ULong)sx * R->x;
+ y = (TT_ULong)sy * R->y;
+ w = x * x + y * y;
+
/* we now want to adjust (x,y) in order to have sqrt(w) == 0x4000 */
/* which means 0x1000000 <= w < 0x1004000 */
while ( w <= 0x10000000L )
{
/* increment the smallest coordinate */
- if ( x < y ) x++;
- else y++;
+ if ( x < y )
+ x++;
+ else
+ y++;
- w = x*x+y*y;
+ w = x * x + y * y;
}
while ( w >= 0x10040000L )
{
/* decrement the smallest coordinate */
- if ( x < y ) x--;
- else y--;
- w = x*x+y*y;
+ if ( x < y )
+ x--;
+ else
+ y--;
+
+ w = x * x + y * y;
}
- R->x = sx*x;
- R->y = sy*y;
+ R->x = sx * x;
+ R->y = sy * y;
}
+
return SUCCESS;
}
-#endif
+#endif /* FT_CONFIG_OPTION_OLD_CALCS */
+
+
/*************************************************************************/
/* */
/* Here we start with the implementation of the various opcodes. */
@@ -2383,9 +2445,9 @@
A = p1->x - p2->x;
B = p1->y - p2->y;
- if ( (aOpc & 1) != 0 )
+ if ( ( aOpc & 1 ) != 0 )
{
- C = B; /* CounterClockwise rotation */
+ C = B; /* counter clockwise rotation */
B = A;
A = -C;
}
@@ -2400,77 +2462,77 @@
/* call table defined later below in this source. Each opcode must */
/* thus have a corresponding function, even trivial ones. */
/* */
- /* They're all defined there. */
+ /* They are all defined there. */
-#define DO_SVTCA \
- { \
- TT_Short A, B; \
- \
- \
- A = (TT_Short)(CUR.opcode & 1) << 14; \
- B = A ^ (TT_Short)0x4000; \
- \
- CUR.GS.freeVector.x = A; \
- CUR.GS.projVector.x = A; \
- CUR.GS.dualVector.x = A; \
- \
- CUR.GS.freeVector.y = B; \
- CUR.GS.projVector.y = B; \
- CUR.GS.dualVector.y = B; \
- \
- COMPUTE_Funcs(); \
+#define DO_SVTCA \
+ { \
+ TT_Short A, B; \
+ \
+ \
+ A = (TT_Short)( CUR.opcode & 1 ) << 14; \
+ B = A ^ (TT_Short)0x4000; \
+ \
+ CUR.GS.freeVector.x = A; \
+ CUR.GS.projVector.x = A; \
+ CUR.GS.dualVector.x = A; \
+ \
+ CUR.GS.freeVector.y = B; \
+ CUR.GS.projVector.y = B; \
+ CUR.GS.dualVector.y = B; \
+ \
+ COMPUTE_Funcs(); \
}
-#define DO_SPVTCA \
- { \
- TT_Short A, B; \
- \
- \
- A = (TT_Short)(CUR.opcode & 1) << 14; \
- B = A ^ (TT_Short)0x4000; \
- \
- CUR.GS.projVector.x = A; \
- CUR.GS.dualVector.x = A; \
- \
- CUR.GS.projVector.y = B; \
- CUR.GS.dualVector.y = B; \
- \
- COMPUTE_Funcs(); \
+#define DO_SPVTCA \
+ { \
+ TT_Short A, B; \
+ \
+ \
+ A = (TT_Short)( CUR.opcode & 1 ) << 14; \
+ B = A ^ (TT_Short)0x4000; \
+ \
+ CUR.GS.projVector.x = A; \
+ CUR.GS.dualVector.x = A; \
+ \
+ CUR.GS.projVector.y = B; \
+ CUR.GS.dualVector.y = B; \
+ \
+ COMPUTE_Funcs(); \
}
-#define DO_SFVTCA \
- { \
- TT_Short A, B; \
- \
- \
- A = (TT_Short)(CUR.opcode & 1) << 14; \
- B = A ^ (TT_Short)0x4000; \
- \
- CUR.GS.freeVector.x = A; \
- CUR.GS.freeVector.y = B; \
- \
- COMPUTE_Funcs(); \
+#define DO_SFVTCA \
+ { \
+ TT_Short A, B; \
+ \
+ \
+ A = (TT_Short)( CUR.opcode & 1 ) << 14; \
+ B = A ^ (TT_Short)0x4000; \
+ \
+ CUR.GS.freeVector.x = A; \
+ CUR.GS.freeVector.y = B; \
+ \
+ COMPUTE_Funcs(); \
}
-#define DO_SPVTL \
- if ( INS_SxVTL( (TT_UShort)args[1], \
- (TT_UShort)args[0], \
- CUR.opcode, \
- &CUR.GS.projVector) == SUCCESS ) \
- { \
- CUR.GS.dualVector = CUR.GS.projVector; \
- COMPUTE_Funcs(); \
+#define DO_SPVTL \
+ if ( INS_SxVTL( (TT_UShort)args[1], \
+ (TT_UShort)args[0], \
+ CUR.opcode, \
+ &CUR.GS.projVector ) == SUCCESS ) \
+ { \
+ CUR.GS.dualVector = CUR.GS.projVector; \
+ COMPUTE_Funcs(); \
}
-#define DO_SFVTL \
- if ( INS_SxVTL( (TT_UShort)(args[1]), \
- (TT_UShort)(args[0]), \
- CUR.opcode, \
- &CUR.GS.freeVector) == SUCCESS ) \
+#define DO_SFVTL \
+ if ( INS_SxVTL( (TT_UShort)args[1], \
+ (TT_UShort)args[0], \
+ CUR.opcode, \
+ &CUR.GS.freeVector ) == SUCCESS ) \
COMPUTE_Funcs();
@@ -2525,16 +2587,16 @@
args[1] = CUR.GS.freeVector.y;
-#define DO_SRP0 \
- CUR.GS.rp0 = (TT_UShort)(args[0]);
+#define DO_SRP0 \
+ CUR.GS.rp0 = (TT_UShort)args[0];
-#define DO_SRP1 \
- CUR.GS.rp1 = (TT_UShort)(args[0]);
+#define DO_SRP1 \
+ CUR.GS.rp1 = (TT_UShort)args[0];
-#define DO_SRP2 \
- CUR.GS.rp2 = (TT_UShort)(args[0]);
+#define DO_SRP2 \
+ CUR.GS.rp2 = (TT_UShort)args[0];
#define DO_RTHG \
@@ -2602,10 +2664,10 @@
/* */
/* It seems that the value that is read here is */
/* expressed in 16.16 format rather than in font */
- /* units.. . */
+ /* units.. */
/* */
-#define DO_SSW \
- CUR.GS.single_width_value = (TT_F26Dot6)(args[0] >> 10);
+#define DO_SSW \
+ CUR.GS.single_width_value = (TT_F26Dot6)( args[0] >> 10 );
#define DO_FLIPON \
@@ -2631,16 +2693,21 @@
args[0] = CURRENT_Ppem();
-/* Note: the pointSize should be irrelevant in a given font program */
-/* we thus decide to return only the ppem */
+ /* Note: The pointSize should be irrelevant in a given font program; */
+ /* we thus decide to return only the ppem. */
#if 0
+
#define DO_MPS \
args[0] = CUR.metrics.pointSize;
+
#else
-#define DO_MPS \
+
+#define DO_MPS \
args[0] = CURRENT_Ppem();
-#endif
+#endif /* 0 */
+
+
#define DO_DUP \
args[1] = args[0];
@@ -2653,6 +2720,7 @@
{ \
TT_Long L; \
\
+ \
L = args[0]; \
args[0] = args[1]; \
args[1] = L; \
@@ -2698,36 +2766,36 @@
}
-#define DO_LT \
- args[0] = (args[0] < args[1]);
+#define DO_LT \
+ args[0] = ( args[0] < args[1] );
-#define DO_LTEQ \
- args[0] = (args[0] <= args[1]);
+#define DO_LTEQ \
+ args[0] = ( args[0] <= args[1] );
-#define DO_GT \
- args[0] = (args[0] > args[1]);
+#define DO_GT \
+ args[0] = ( args[0] > args[1] );
-#define DO_GTEQ \
- args[0] = (args[0] >= args[1]);
+#define DO_GTEQ \
+ args[0] = ( args[0] >= args[1] );
-#define DO_EQ \
- args[0] = (args[0] == args[1]);
+#define DO_EQ \
+ args[0] = ( args[0] == args[1] );
-#define DO_NEQ \
- args[0] = (args[0] != args[1]);
+#define DO_NEQ \
+ args[0] = ( args[0] != args[1] );
-#define DO_ODD \
- args[0] = ( (CUR_Func_round( args[0], 0 ) & 127) == 64 );
+#define DO_ODD \
+ args[0] = ( ( CUR_Func_round( args[0], 0 ) & 127 ) == 64 );
-#define DO_EVEN \
- args[0] = ( (CUR_Func_round( args[0], 0 ) & 127) == 0 );
+#define DO_EVEN \
+ args[0] = ( ( CUR_Func_round( args[0], 0 ) & 127 ) == 0 );
#define DO_AND \
@@ -2774,7 +2842,7 @@
#define DO_CEILING \
- args[0] = (args[0] + 63) & (-64);
+ args[0] = ( args[0] + 63 ) & -64;
#define DO_RS \
@@ -2813,22 +2881,22 @@
}
-#define DO_RCVT \
- { \
- TT_ULong I = (TT_ULong)args[0]; \
- \
- \
- if ( BOUNDS( I, CUR.cvtSize ) ) \
- { \
- if ( CUR.pedantic_hinting ) \
- { \
- ARRAY_BOUND_ERROR; \
- } \
- else \
- args[0] = 0; \
- } \
- else \
- args[0] = CUR_Func_read_cvt(I); \
+#define DO_RCVT \
+ { \
+ TT_ULong I = (TT_ULong)args[0]; \
+ \
+ \
+ if ( BOUNDS( I, CUR.cvtSize ) ) \
+ { \
+ if ( CUR.pedantic_hinting ) \
+ { \
+ ARRAY_BOUND_ERROR; \
+ } \
+ else \
+ args[0] = 0; \
+ } \
+ else \
+ args[0] = CUR_Func_read_cvt( I ); \
}
@@ -2895,11 +2963,11 @@
#undef ARRAY_BOUND_ERROR
-#define ARRAY_BOUND_ERROR \
- { \
- CUR.error = TT_Err_Invalid_Reference; \
- return; \
- }
+#define ARRAY_BOUND_ERROR \
+ { \
+ CUR.error = TT_Err_Invalid_Reference; \
+ return; \
+ }
/*************************************************************************/
@@ -3330,7 +3398,7 @@
/*************************************************************************/
/* */
- /* DUP[]: DUPlicate top stack element */
+ /* DUP[]: DUPlicate the top stack's element */
/* Opcode range: 0x20 */
/* Stack: StkElt --> StkElt StkElt */
/* */
@@ -3343,7 +3411,7 @@
/*************************************************************************/
/* */
- /* POP[]: POP the stack's top elt */
+ /* POP[]: POP the stack's top element */
/* Opcode range: 0x21 */
/* Stack: StkElt --> */
/* */
@@ -3369,7 +3437,7 @@
/*************************************************************************/
/* */
- /* SWAP[]: SWAP the top two elements */
+ /* SWAP[]: SWAP the stack's top two elements */
/* Opcode range: 0x23 */
/* Stack: 2 * StkElt --> 2 * StkElt */
/* */
@@ -3785,11 +3853,11 @@
/*************************************************************************/
/* */
- /* DEBUG[]: DEBUG. Unsupported */
+ /* DEBUG[]: DEBUG. Unsupported. */
/* Opcode range: 0x4F */
/* Stack: uint32 --> */
/* */
- /* Note: The original instruction pops a value from the stack */
+ /* Note: The original instruction pops a value from the stack. */
/* */
static
void Ins_DEBUG( INS_ARG )
@@ -3882,9 +3950,9 @@
K = CUR.stack[CUR.args - L];
- MEM_Move( (&CUR.stack[CUR.args - L ]),
- (&CUR.stack[CUR.args - L + 1]),
- (L - 1) * sizeof ( TT_Long ) );
+ MEM_Move( &CUR.stack[CUR.args - L ],
+ &CUR.stack[CUR.args - L + 1],
+ ( L - 1 ) * sizeof ( TT_Long ) );
CUR.stack[CUR.args - 1] = K;
}
@@ -3901,9 +3969,9 @@
{
TT_Long A, B, C;
-
UNUSED_EXEC;
+
A = args[2];
B = args[1];
C = args[0];
@@ -3918,7 +3986,7 @@
/* */
/* MANAGING THE FLOW OF CONTROL */
/* */
- /* Instructions appear in the specs' order. */
+ /* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
@@ -3981,12 +4049,12 @@
break;
case 0x1B: /* ELSE */
- Out = (nIfs == 1);
+ Out = ( nIfs == 1 );
break;
case 0x59: /* EIF */
nIfs--;
- Out = (nIfs == 0);
+ Out = ( nIfs == 0 );
break;
}
} while ( Out == 0 );
@@ -4004,9 +4072,9 @@
{
TT_Int nIfs;
-
UNUSED_ARG;
+
nIfs = 1;
do
@@ -4032,7 +4100,7 @@
/* */
/* DEFINING AND USING FUNCTIONS AND INSTRUCTIONS */
/* */
- /* Instructions appear in the specs' order. */
+ /* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
@@ -4050,8 +4118,10 @@
TT_DefRecord* rec;
TT_DefRecord* limit;
+
/* some font programs are broken enough to redefine functions! */
- /* We will then parse the current table.. */
+ /* We will then parse the current table. */
+
rec = CUR.FDefs;
limit = rec + CUR.numFDefs;
n = args[0];
@@ -4058,7 +4128,7 @@
for ( ; rec < limit; rec++ )
{
- if (rec->opc == n)
+ if ( rec->opc == n )
break;
}
@@ -4075,7 +4145,7 @@
rec->range = CUR.curRange;
rec->opc = n;
- rec->start = CUR.IP+1;
+ rec->start = CUR.IP + 1;
rec->active = TRUE;
if ( n > CUR.maxFunc )
@@ -4111,9 +4181,9 @@
{
TT_CallRec* pRec;
-
UNUSED_ARG;
+
if ( CUR.callTop <= 0 ) /* We encountered an ENDF without a call */
{
CUR.error = TT_Err_ENDF_In_Exec_Stream;
@@ -4138,13 +4208,13 @@
INS_Goto_CodeRange( pRec->Caller_Range,
pRec->Caller_IP );
- /* Exit the current call frame. */
+ /* Exit the current call frame. */
- /* NOTE: When the last intruction of a program */
- /* is a CALL or LOOPCALL, the return address */
- /* is always out of the code range. This is */
- /* a valid address, and it's why we do not test */
- /* the result of Ins_Goto_CodeRange() here! */
+ /* NOTE: If the last intruction of a program is a */
+ /* CALL or LOOPCALL, the return address is */
+ /* always out of the code range. This is a */
+ /* valid address, and it is why we do not test */
+ /* the result of Ins_Goto_CodeRange() here! */
}
@@ -4161,12 +4231,15 @@
TT_CallRec* pCrec;
TT_DefRecord* def;
+
/* first of all, check the index */
+
F = args[0];
- if ( BOUNDS( F, CUR.maxFunc+1 ) ) goto Fail;
+ if ( BOUNDS( F, CUR.maxFunc + 1 ) )
+ goto Fail;
/* Except for some old Apple fonts, all functions in a TrueType */
- /* font are defined in increasing order, starting from 0. This */
+ /* font are defined in increasing order, starting from 0. This */
/* means that we normally have */
/* */
/* CUR.maxFunc+1 == CUR.numFDefs */
@@ -4175,22 +4248,24 @@
/* If this isn't true, we need to look up the function table. */
def = CUR.FDefs + F;
- if ( CUR.maxFunc+1 != CUR.numFDefs || def->opc != F )
+ if ( CUR.maxFunc + 1 != CUR.numFDefs || def->opc != F )
{
/* look up the FDefs table */
TT_DefRecord* limit;
+
def = CUR.FDefs;
limit = def + CUR.numFDefs;
- while (def < limit && def->opc != F)
+ while ( def < limit && def->opc != F )
def++;
- if (def == limit) goto Fail;
+ if ( def == limit )
+ goto Fail;
}
/* check that the function is active */
- if (!def->active)
+ if ( !def->active )
goto Fail;
/* check the call stack */
@@ -4233,12 +4308,14 @@
TT_CallRec* pCrec;
TT_DefRecord* def;
+
/* first of all, check the index */
F = args[1];
- if ( BOUNDS( F, CUR.maxFunc+1 ) ) goto Fail;
+ if ( BOUNDS( F, CUR.maxFunc + 1 ) )
+ goto Fail;
/* Except for some old Apple fonts, all functions in a TrueType */
- /* font are defined in increasing order, starting from 0. This */
+ /* font are defined in increasing order, starting from 0. This */
/* means that we normally have */
/* */
/* CUR.maxFunc+1 == CUR.numFDefs */
@@ -4247,22 +4324,24 @@
/* If this isn't true, we need to look up the function table. */
def = CUR.FDefs + F;
- if ( CUR.maxFunc+1 != CUR.numFDefs || def->opc != F )
+ if ( CUR.maxFunc + 1 != CUR.numFDefs || def->opc != F )
{
/* look up the FDefs table */
TT_DefRecord* limit;
+
def = CUR.FDefs;
limit = def + CUR.numFDefs;
- while (def < limit && def->opc != F)
+ while ( def < limit && def->opc != F )
def++;
- if (def == limit) goto Fail;
+ if ( def == limit )
+ goto Fail;
}
/* check that the function is active */
- if (!def->active)
+ if ( !def->active )
goto Fail;
/* check stack */
@@ -4278,7 +4357,7 @@
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
- pCrec->Cur_Count = (TT_Int)(args[0]);
+ pCrec->Cur_Count = (TT_Int)args[0];
pCrec->Cur_Restart = def->start;
CUR.callTop++;
@@ -4306,11 +4385,14 @@
TT_DefRecord* def;
TT_DefRecord* limit;
+
/* First of all, look for the same function in our table */
+
def = CUR.IDefs;
limit = def + CUR.numIDefs;
+
for ( ; def < limit; def++ )
- if (def->opc == (TT_ULong)args[0] )
+ if ( def->opc == (TT_ULong)args[0] )
break;
if ( def == limit )
@@ -4354,7 +4436,7 @@
/* */
/* PUSHING DATA ONTO THE INTERPRETER STACK */
/* */
- /* Instructions appear in the specs' order. */
+ /* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
@@ -4635,9 +4717,9 @@
B = v1->y - v2->y;
}
- if ( (CUR.opcode & 1) != 0 )
+ if ( ( CUR.opcode & 1 ) != 0 )
{
- C = B; /* CounterClockwise rotation */
+ C = B; /* counter clockwise rotation */
B = A;
A = -C;
}
@@ -4653,9 +4735,9 @@
B = v1->y - v2->y;
}
- if ( (CUR.opcode & 1) != 0 )
+ if ( ( CUR.opcode & 1 ) != 0 )
{
- C = B; /* CounterClockwise rotation */
+ C = B; /* counter clockwise rotation */
B = A;
A = -C;
}
@@ -4691,7 +4773,7 @@
return;
}
- CUR.GS.gep0 = (TT_UShort)(args[0]);
+ CUR.GS.gep0 = (TT_UShort)args[0];
}
@@ -4720,7 +4802,7 @@
return;
}
- CUR.GS.gep1 = (TT_UShort)(args[0]);
+ CUR.GS.gep1 = (TT_UShort)args[0];
}
@@ -4749,7 +4831,7 @@
return;
}
- CUR.GS.gep2 = (TT_UShort)(args[0]);
+ CUR.GS.gep2 = (TT_UShort)args[0];
}
@@ -4781,9 +4863,9 @@
CUR.zp1 = CUR.zp0;
CUR.zp2 = CUR.zp0;
- CUR.GS.gep0 = (TT_UShort)(args[0]);
- CUR.GS.gep1 = (TT_UShort)(args[0]);
- CUR.GS.gep2 = (TT_UShort)(args[0]);
+ CUR.GS.gep0 = (TT_UShort)args[0];
+ CUR.GS.gep1 = (TT_UShort)args[0];
+ CUR.GS.gep2 = (TT_UShort)args[0];
}
@@ -4830,7 +4912,7 @@
/* Get Threshold */
- A = (TT_Int)(args[0] & 0xFF);
+ A = (TT_Int)( args[0] & 0xFF );
if ( A == 0xFF )
{
@@ -4845,10 +4927,10 @@
A *= 64;
- /*
+#if 0
if ( (args[0] & 0x100) != 0 && CUR.metrics.pointSize <= A )
CUR.GS.scan_control = TRUE;
- */
+#endif
if ( (args[0] & 0x200) != 0 && CUR.tt_metrics.rotated )
CUR.GS.scan_control = TRUE;
@@ -4856,10 +4938,10 @@
if ( (args[0] & 0x400) != 0 && CUR.tt_metrics.stretched )
CUR.GS.scan_control = TRUE;
- /*
+#if 0
if ( (args[0] & 0x800) != 0 && CUR.metrics.pointSize > A )
CUR.GS.scan_control = FALSE;
- */
+#endif
if ( (args[0] & 0x1000) != 0 && CUR.tt_metrics.rotated )
CUR.GS.scan_control = FALSE;
@@ -4895,7 +4977,7 @@
/* */
/* MANAGING OUTLINES */
/* */
- /* Instructions appear in the specs' order. */
+ /* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
@@ -5036,9 +5118,12 @@
d = CUR_Func_project( zp.cur + p, zp.org + p );
#ifdef NO_APPLE_PATENT
+
*x = TT_MULDIV( d, CUR.GS.freeVector.x, 0x4000 );
*y = TT_MULDIV( d, CUR.GS.freeVector.y, 0x4000 );
+
#else
+
*x = TT_MULDIV( d,
(TT_Long)CUR.GS.freeVector.x * 0x10000L,
CUR.F_dot_P );
@@ -5045,7 +5130,9 @@
*y = TT_MULDIV( d,
(TT_Long)CUR.GS.freeVector.y * 0x10000L,
CUR.F_dot_P );
-#endif
+
+#endif /* NO_APPLE_PATENT */
+
return SUCCESS;
}
@@ -5088,9 +5175,9 @@
dy;
TT_UShort point;
-
UNUSED_ARG;
+
if ( CUR.top < CUR.GS.loop )
{
CUR.error = TT_Err_Invalid_Reference;
@@ -5282,7 +5369,7 @@
static
void Ins_MSIRP( INS_ARG )
{
- TT_UShort point;
+ TT_UShort point;
TT_F26Dot6 distance;
@@ -5341,7 +5428,7 @@
/* XXX: Is there some undocumented feature while in the */
/* twilight zone? ? */
- if ( (CUR.opcode & 1) != 0 )
+ if ( ( CUR.opcode & 1 ) != 0 )
{
cur_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector );
distance = CUR_Func_round( cur_dist,
@@ -5399,7 +5486,7 @@
/* some key font heights. It allows the use of the */
/* IP instruction in the twilight zone, which */
/* otherwise would be `illegal' according to the */
- /* specs :) */
+ /* specification. */
/* */
/* We implement it with a special sequence for the */
/* twilight zone. This is a bad hack, but it seems */
@@ -5418,7 +5505,7 @@
org_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector );
- if ( (CUR.opcode & 1) != 0 ) /* rounding and control cutin flag */
+ if ( ( CUR.opcode & 1 ) != 0 ) /* rounding and control cutin flag */
{
if ( ABS( distance - org_dist ) > CUR.GS.control_value_cutin )
distance = org_dist;
@@ -5474,16 +5561,18 @@
/* round flag */
- if ( (CUR.opcode & 4) != 0 )
- distance = CUR_Func_round( org_dist,
- CUR.tt_metrics.compensations[CUR.opcode & 3] );
+ if ( ( CUR.opcode & 4 ) != 0 )
+ distance = CUR_Func_round(
+ org_dist,
+ CUR.tt_metrics.compensations[CUR.opcode & 3] );
else
- distance = ROUND_None( org_dist,
- CUR.tt_metrics.compensations[CUR.opcode & 3] );
+ distance = ROUND_None(
+ org_dist,
+ CUR.tt_metrics.compensations[CUR.opcode & 3] );
/* minimum distance flag */
- if ( (CUR.opcode & 8) != 0 )
+ if ( ( CUR.opcode & 8 ) != 0 )
{
if ( org_dist >= 0 )
{
@@ -5507,7 +5596,7 @@
CUR.GS.rp1 = CUR.GS.rp0;
CUR.GS.rp2 = point;
- if ( (CUR.opcode & 16) != 0 )
+ if ( ( CUR.opcode & 16 ) != 0 )
CUR.GS.rp0 = point;
}
@@ -5531,7 +5620,7 @@
point = (TT_UShort)args[0];
- cvtEntry = (TT_ULong)(args[1] + 1);
+ cvtEntry = (TT_ULong)( args[1] + 1 );
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
@@ -5586,13 +5675,13 @@
if ( CUR.GS.auto_flip )
{
- if ( (org_dist ^ cvt_dist) < 0 )
+ if ( ( org_dist ^ cvt_dist ) < 0 )
cvt_dist = -cvt_dist;
}
/* control value cutin and round */
- if ( (CUR.opcode & 4) != 0 )
+ if ( ( CUR.opcode & 4 ) != 0 )
{
/* XXX: UNDOCUMENTED! Only perform cut-in test when both points */
/* refer to the same zone. */
@@ -5601,16 +5690,18 @@
if ( ABS( cvt_dist - org_dist ) >= CUR.GS.control_value_cutin )
cvt_dist = org_dist;
- distance = CUR_Func_round( cvt_dist,
- CUR.tt_metrics.compensations[CUR.opcode & 3] );
+ distance = CUR_Func_round(
+ cvt_dist,
+ CUR.tt_metrics.compensations[CUR.opcode & 3] );
}
else
- distance = ROUND_None( cvt_dist,
- CUR.tt_metrics.compensations[CUR.opcode & 3] );
+ distance = ROUND_None(
+ cvt_dist,
+ CUR.tt_metrics.compensations[CUR.opcode & 3] );
/* minimum distance test */
- if ( (CUR.opcode & 8) != 0 )
+ if ( ( CUR.opcode & 8 ) != 0 )
{
if ( org_dist >= 0 )
{
@@ -5628,7 +5719,7 @@
CUR.GS.rp1 = CUR.GS.rp0;
- if ( (CUR.opcode & 16) != 0 )
+ if ( ( CUR.opcode & 16 ) != 0 )
CUR.GS.rp0 = point;
/* XXX: UNDOCUMENTED! */
@@ -5649,9 +5740,9 @@
TT_UShort point;
TT_F26Dot6 distance;
-
UNUSED_ARG;
+
if ( CUR.top < CUR.GS.loop ||
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
@@ -5818,9 +5909,9 @@
distance;
TT_UShort point;
-
UNUSED_ARG;
+
if ( CUR.top < CUR.GS.loop )
{
CUR.error = TT_Err_Invalid_Reference;
@@ -5936,14 +6027,16 @@
};
- static void Shift( TT_UInt p1,
- TT_UInt p2,
- TT_UInt p,
- struct LOC_Ins_IUP* LINK )
+ static
+ void Shift( TT_UInt p1,
+ TT_UInt p2,
+ TT_UInt p,
+ struct LOC_Ins_IUP* LINK )
{
TT_UInt i;
TT_F26Dot6 x;
+
x = LINK->curs[p].x - LINK->orgs[p].x;
for ( i = p1; i < p; i++ )
@@ -5954,15 +6047,17 @@
}
- static void Interp( TT_UInt p1,
- TT_UInt p2,
- TT_UInt ref1,
- TT_UInt ref2,
- struct LOC_Ins_IUP* LINK )
+ static
+ void Interp( TT_UInt p1,
+ TT_UInt p2,
+ TT_UInt ref1,
+ TT_UInt ref2,
+ struct LOC_Ins_IUP* LINK )
{
TT_UInt i;
TT_F26Dot6 x, x1, x2, d1, d2;
+
if ( p1 > p2 )
return;
@@ -6053,9 +6148,9 @@
TT_UInt point; /* current point */
TT_Short contour; /* current contour */
-
UNUSED_ARG;
+
if ( CUR.opcode & 1 )
{
mask = FT_Curve_Tag_Touch_X;
@@ -6065,8 +6160,8 @@
else
{
mask = FT_Curve_Tag_Touch_Y;
- V.orgs = (TT_Vector*)( ((TT_F26Dot6*)CUR.pts.org) + 1 );
- V.curs = (TT_Vector*)( ((TT_F26Dot6*)CUR.pts.cur) + 1 );
+ V.orgs = (TT_Vector*)( (TT_F26Dot6*)CUR.pts.org + 1 );
+ V.curs = (TT_Vector*)( (TT_F26Dot6*)CUR.pts.cur + 1 );
}
contour = 0;
@@ -6089,7 +6184,7 @@
while ( point <= end_point )
{
- if ( (CUR.pts.tags[point] & mask) != 0 )
+ if ( ( CUR.pts.tags[point] & mask ) != 0 )
{
if ( point > 0 )
Interp( cur_touched + 1,
@@ -6107,7 +6202,7 @@
Shift( first_point, end_point, cur_touched, &V );
else
{
- Interp( (TT_UShort)(cur_touched + 1),
+ Interp( (TT_UShort)( cur_touched + 1 ),
end_point,
cur_touched,
first_touched,
@@ -6157,15 +6252,15 @@
A = (TT_UShort)CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
- /* XXX : because some popular fonts contain some invalid DeltaP */
- /* instructions, we simply ignore them when the stacked */
- /* point reference is off limit, rather than returning an */
- /* error. As a delta instruction doesn't change a glyph */
- /* in great ways, this shouldn't be a problem.. */
+ /* XXX: Because some popular fonts contain some invalid DeltaP */
+ /* instructions, we simply ignore them when the stacked */
+ /* point reference is off limit, rather than returning an */
+ /* error. As a delta instruction doesn't change a glyph */
+ /* in great ways, this shouldn't be a problem. */
if ( !BOUNDS( A, CUR.zp0.n_points ) )
{
- C = ((TT_ULong)B & 0xF0) >> 4;
+ C = ( (TT_ULong)B & 0xF0 ) >> 4;
switch ( CUR.opcode )
{
@@ -6185,10 +6280,10 @@
if ( CURRENT_Ppem() == (TT_Long)C )
{
- B = ((TT_ULong)B & 0xF) - 8;
+ B = ( (TT_ULong)B & 0xF ) - 8;
if ( B >= 0 )
B++;
- B = B * 64 / (1L << CUR.GS.delta_shift);
+ B = B * 64 / ( 1L << CUR.GS.delta_shift );
CUR_Func_move( &CUR.zp0, A, B );
}
@@ -6233,7 +6328,7 @@
if ( BOUNDS( A, CUR.cvtSize ) )
{
- if (CUR.pedantic_hinting)
+ if ( CUR.pedantic_hinting )
{
CUR.error = TT_Err_Invalid_Reference;
return;
@@ -6241,7 +6336,7 @@
}
else
{
- C = ((TT_ULong)B & 0xF0) >> 4;
+ C = ( (TT_ULong)B & 0xF0 ) >> 4;
switch ( CUR.opcode )
{
@@ -6261,10 +6356,10 @@
if ( CURRENT_Ppem() == (TT_Long)C )
{
- B = ((TT_ULong)B & 0xF) - 8;
+ B = ( (TT_ULong)B & 0xF ) - 8;
if ( B >= 0 )
B++;
- B = B * 64 / (1L << CUR.GS.delta_shift);
+ B = B * 64 / ( 1L << CUR.GS.delta_shift );
CUR_Func_move_cvt( A, B );
}
@@ -6300,7 +6395,7 @@
/* We return then Windows 3.1 version number */
/* for the font scaler */
- if ( (args[0] & 1) != 0 )
+ if ( ( args[0] & 1 ) != 0 )
K = 3;
/* Has the glyph been rotated ? */
@@ -6323,12 +6418,14 @@
UNUSED_ARG;
+
for ( ; def < limit; def++ )
{
- if (def->opc == CUR.opcode && def->active )
+ if ( def->opc == CUR.opcode && def->active )
{
TT_CallRec* call;
+
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = TT_Err_Stack_Overflow;
@@ -6354,6 +6451,8 @@
#ifndef TT_CONFIG_OPTION_INTERPRETER_SWITCH
+
+
static
TInstruction_Function Instruct_Dispatch[256] =
{
@@ -6632,6 +6731,8 @@
/* MIRP[30] */ Ins_MIRP,
/* MIRP[31] */ Ins_MIRP
};
+
+
#endif /* !TT_CONFIG_OPTION_INTERPRETER_SWITCH */
@@ -6656,24 +6757,46 @@
/* */
/* */
/* Note: The documented DEBUG opcode pops a value from the stack. This */
- /* behaviour is unsupported, here a DEBUG opcode is always an */
+ /* behaviour is unsupported; here a DEBUG opcode is always an */
/* error. */
/* */
/* */
/* THIS IS THE INTERPRETER'S MAIN LOOP. */
/* */
- /* Instructions appear in the specs' order. */
+ /* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
- FT_EXPORT_FUNC(TT_Error) TT_RunIns( TT_ExecContext exc )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* TT_RunIns */
+ /* */
+ /* <Description> */
+ /* Executes one or more instruction in the execution context. This */
+ /* is the main function of the TrueType opcode interpreter. */
+ /* */
+ /* <Input> */
+ /* exec :: A handle to the target execution context. */
+ /* */
+ /* <Return> */
+ /* TrueType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* Only the object manager and debugger should call this function. */
+ /* */
+ /* This function is publicly exported because it is directly */
+ /* invoked by the TrueType debugger. */
+ /* */
+ FT_EXPORT_FUNC( TT_Error ) TT_RunIns( TT_ExecContext exc )
{
- TT_Long ins_counter = 0; /* executed instructions counter */
+ TT_Long ins_counter = 0; /* executed instructions counter */
- #ifdef TT_CONFIG_OPTION_STATIC_RASTER
+
+#ifdef TT_CONFIG_OPTION_STATIC_RASTER
cur = *exc;
- #endif
+#endif
/* set CVT functions */
CUR.tt_metrics.ratio = 0;
@@ -6711,7 +6834,7 @@
goto LErrorCodeOverflow_;
/* First, let's check for empty stack and overflow */
- CUR.args = CUR.top - (Pop_Push_Count[CUR.opcode] >> 4);
+ CUR.args = CUR.top - ( Pop_Push_Count[CUR.opcode] >> 4 );
/* `args' is the top of the stack once arguments have been popped. */
/* One can also interpret it as the index of the last argument. */
@@ -6721,7 +6844,7 @@
goto LErrorLabel_;
}
- CUR.new_top = CUR.args + (Pop_Push_Count[CUR.opcode] & 15);
+ CUR.new_top = CUR.args + ( Pop_Push_Count[CUR.opcode] & 15 );
/* `new_top' is the new top of the stack, after the instruction's */
/* execution. `top' will be set to `new_top' after the `switch' */
@@ -6736,6 +6859,7 @@
CUR.error = TT_Err_Ok;
#ifdef TT_CONFIG_OPTION_INTERPRETER_SWITCH
+
{
TT_Long* args = CUR.stack + CUR.args;
TT_Byte opcode = CUR.opcode;
@@ -6742,7 +6866,7 @@
#undef ARRAY_BOUND_ERROR
-#define ARRAY_BOUND_ERROR goto Set_Invalid_Ref
+#define ARRAY_BOUND_ERROR goto Set_Invalid_Ref
switch ( opcode )
@@ -6757,7 +6881,7 @@
TT_Short AA, BB;
- AA = (TT_Short)(opcode & 1) << 14;
+ AA = (TT_Short)( opcode & 1 ) << 14;
BB = AA ^ (TT_Short)0x4000;
if ( opcode < 4 )
@@ -6769,7 +6893,7 @@
CUR.GS.dualVector.y = BB;
}
- if ( (opcode & 2) == 0 )
+ if ( ( opcode & 2 ) == 0 )
{
CUR.GS.freeVector.x = AA;
CUR.GS.freeVector.y = BB;
@@ -6810,7 +6934,7 @@
break;
case 0x0F: /* ISECT */
- Ins_ISECT( EXEC_ARG_ args );
+ Ins_ISECT( EXEC_ARG_ args );
break;
case 0x10: /* SRP0 */
@@ -6826,19 +6950,19 @@
break;
case 0x13: /* SZP0 */
- Ins_SZP0( EXEC_ARG_ args );
+ Ins_SZP0( EXEC_ARG_ args );
break;
case 0x14: /* SZP1 */
- Ins_SZP1( EXEC_ARG_ args );
+ Ins_SZP1( EXEC_ARG_ args );
break;
case 0x15: /* SZP2 */
- Ins_SZP2( EXEC_ARG_ args );
+ Ins_SZP2( EXEC_ARG_ args );
break;
case 0x16: /* SZPS */
- Ins_SZPS( EXEC_ARG_ args );
+ Ins_SZPS( EXEC_ARG_ args );
break;
case 0x17: /* SLOOP */
@@ -6858,7 +6982,7 @@
break;
case 0x1B: /* ELSE */
- Ins_ELSE( EXEC_ARG_ args );
+ Ins_ELSE( EXEC_ARG_ args );
break;
case 0x1C: /* JMPR */
@@ -6882,7 +7006,7 @@
break;
case 0x21: /* POP */
- /* nothing :-) ! */
+ /* nothing :-) */
break;
case 0x22: /* CLEAR */
@@ -6902,78 +7026,78 @@
break;
case 0x26: /* MINDEX */
- Ins_MINDEX( EXEC_ARG_ args );
+ Ins_MINDEX( EXEC_ARG_ args );
break;
case 0x27: /* ALIGNPTS */
- Ins_ALIGNPTS( EXEC_ARG_ args );
+ Ins_ALIGNPTS( EXEC_ARG_ args );
break;
case 0x28: /* ???? */
- Ins_UNKNOWN( EXEC_ARG_ args );
+ Ins_UNKNOWN( EXEC_ARG_ args );
break;
case 0x29: /* UTP */
- Ins_UTP( EXEC_ARG_ args );
+ Ins_UTP( EXEC_ARG_ args );
break;
case 0x2A: /* LOOPCALL */
- Ins_LOOPCALL( EXEC_ARG_ args );
+ Ins_LOOPCALL( EXEC_ARG_ args );
break;
case 0x2B: /* CALL */
- Ins_CALL( EXEC_ARG_ args );
+ Ins_CALL( EXEC_ARG_ args );
break;
case 0x2C: /* FDEF */
- Ins_FDEF( EXEC_ARG_ args );
+ Ins_FDEF( EXEC_ARG_ args );
break;
case 0x2D: /* ENDF */
- Ins_ENDF( EXEC_ARG_ args );
+ Ins_ENDF( EXEC_ARG_ args );
break;
case 0x2E: /* MDAP */
case 0x2F: /* MDAP */
- Ins_MDAP( EXEC_ARG_ args );
+ Ins_MDAP( EXEC_ARG_ args );
break;
case 0x30: /* IUP */
case 0x31: /* IUP */
- Ins_IUP( EXEC_ARG_ args );
+ Ins_IUP( EXEC_ARG_ args );
break;
case 0x32: /* SHP */
case 0x33: /* SHP */
- Ins_SHP( EXEC_ARG_ args );
+ Ins_SHP( EXEC_ARG_ args );
break;
case 0x34: /* SHC */
case 0x35: /* SHC */
- Ins_SHC( EXEC_ARG_ args );
+ Ins_SHC( EXEC_ARG_ args );
break;
case 0x36: /* SHZ */
case 0x37: /* SHZ */
- Ins_SHZ( EXEC_ARG_ args );
+ Ins_SHZ( EXEC_ARG_ args );
break;
case 0x38: /* SHPIX */
- Ins_SHPIX( EXEC_ARG_ args );
+ Ins_SHPIX( EXEC_ARG_ args );
break;
case 0x39: /* IP */
- Ins_IP( EXEC_ARG_ args );
+ Ins_IP( EXEC_ARG_ args );
break;
case 0x3A: /* MSIRP */
case 0x3B: /* MSIRP */
- Ins_MSIRP( EXEC_ARG_ args );
+ Ins_MSIRP( EXEC_ARG_ args );
break;
case 0x3C: /* AlignRP */
- Ins_ALIGNRP( EXEC_ARG_ args );
+ Ins_ALIGNRP( EXEC_ARG_ args );
break;
case 0x3D: /* RTDG */
@@ -6982,15 +7106,15 @@
case 0x3E: /* MIAP */
case 0x3F: /* MIAP */
- Ins_MIAP( EXEC_ARG_ args );
+ Ins_MIAP( EXEC_ARG_ args );
break;
case 0x40: /* NPUSHB */
- Ins_NPUSHB( EXEC_ARG_ args );
+ Ins_NPUSHB( EXEC_ARG_ args );
break;
case 0x41: /* NPUSHW */
- Ins_NPUSHW( EXEC_ARG_ args );
+ Ins_NPUSHW( EXEC_ARG_ args );
break;
case 0x42: /* WS */
@@ -6997,7 +7121,7 @@
DO_WS
break;
- Set_Invalid_Ref:
+ Set_Invalid_Ref:
CUR.error = TT_Err_Invalid_Reference;
break;
@@ -7015,16 +7139,16 @@
case 0x46: /* GC */
case 0x47: /* GC */
- Ins_GC( EXEC_ARG_ args );
+ Ins_GC( EXEC_ARG_ args );
break;
case 0x48: /* SCFS */
- Ins_SCFS( EXEC_ARG_ args );
+ Ins_SCFS( EXEC_ARG_ args );
break;
case 0x49: /* MD */
case 0x4A: /* MD */
- Ins_MD( EXEC_ARG_ args );
+ Ins_MD( EXEC_ARG_ args );
break;
case 0x4B: /* MPPEM */
@@ -7080,7 +7204,7 @@
break;
case 0x58: /* IF */
- Ins_IF( EXEC_ARG_ args );
+ Ins_IF( EXEC_ARG_ args );
break;
case 0x59: /* EIF */
@@ -7100,7 +7224,7 @@
break;
case 0x5D: /* DELTAP1 */
- Ins_DELTAP( EXEC_ARG_ args );
+ Ins_DELTAP( EXEC_ARG_ args );
break;
case 0x5E: /* SDB */
@@ -7163,13 +7287,13 @@
case 0x71: /* DELTAP2 */
case 0x72: /* DELTAP3 */
- Ins_DELTAP( EXEC_ARG_ args );
+ Ins_DELTAP( EXEC_ARG_ args );
break;
case 0x73: /* DELTAC0 */
case 0x74: /* DELTAC1 */
case 0x75: /* DELTAC2 */
- Ins_DELTAC( EXEC_ARG_ args );
+ Ins_DELTAC( EXEC_ARG_ args );
break;
case 0x76: /* SROUND */
@@ -7193,7 +7317,7 @@
break;
case 0x7B: /* ???? */
- Ins_UNKNOWN( EXEC_ARG_ args );
+ Ins_UNKNOWN( EXEC_ARG_ args );
break;
case 0x7C: /* RUTG */
@@ -7210,41 +7334,41 @@
break;
case 0x80: /* FLIPPT */
- Ins_FLIPPT( EXEC_ARG_ args );
+ Ins_FLIPPT( EXEC_ARG_ args );
break;
case 0x81: /* FLIPRGON */
- Ins_FLIPRGON( EXEC_ARG_ args );
+ Ins_FLIPRGON( EXEC_ARG_ args );
break;
case 0x82: /* FLIPRGOFF */
- Ins_FLIPRGOFF( EXEC_ARG_ args );
+ Ins_FLIPRGOFF( EXEC_ARG_ args );
break;
case 0x83: /* UNKNOWN */
case 0x84: /* UNKNOWN */
- Ins_UNKNOWN( EXEC_ARG_ args );
+ Ins_UNKNOWN( EXEC_ARG_ args );
break;
case 0x85: /* SCANCTRL */
- Ins_SCANCTRL( EXEC_ARG_ args );
+ Ins_SCANCTRL( EXEC_ARG_ args );
break;
case 0x86: /* SDPVTL */
case 0x87: /* SDPVTL */
- Ins_SDPVTL( EXEC_ARG_ args );
+ Ins_SDPVTL( EXEC_ARG_ args );
break;
case 0x88: /* GETINFO */
- Ins_GETINFO( EXEC_ARG_ args );
+ Ins_GETINFO( EXEC_ARG_ args );
break;
case 0x89: /* IDEF */
- Ins_IDEF( EXEC_ARG_ args );
+ Ins_IDEF( EXEC_ARG_ args );
break;
case 0x8A: /* ROLL */
- Ins_ROLL( EXEC_ARG_ args );
+ Ins_ROLL( EXEC_ARG_ args );
break;
case 0x8B: /* MAX */
@@ -7256,34 +7380,38 @@
break;
case 0x8D: /* SCANTYPE */
- Ins_SCANTYPE( EXEC_ARG_ args );
+ Ins_SCANTYPE( EXEC_ARG_ args );
break;
case 0x8E: /* INSTCTRL */
- Ins_INSTCTRL( EXEC_ARG_ args );
+ Ins_INSTCTRL( EXEC_ARG_ args );
break;
case 0x8F:
- Ins_UNKNOWN( EXEC_ARG_ args );
+ Ins_UNKNOWN( EXEC_ARG_ args );
break;
default:
if ( opcode >= 0xE0 )
- Ins_MIRP( EXEC_ARG_ args );
+ Ins_MIRP( EXEC_ARG_ args );
else if ( opcode >= 0xC0 )
- Ins_MDRP( EXEC_ARG_ args );
+ Ins_MDRP( EXEC_ARG_ args );
else if ( opcode >= 0xB8 )
- Ins_PUSHW( EXEC_ARG_ args );
+ Ins_PUSHW( EXEC_ARG_ args );
else if ( opcode >= 0xB0 )
- Ins_PUSHB( EXEC_ARG_ args );
+ Ins_PUSHB( EXEC_ARG_ args );
else
- Ins_UNKNOWN( EXEC_ARG_ args );
+ Ins_UNKNOWN( EXEC_ARG_ args );
}
}
+
#else
+
Instruct_Dispatch[CUR.opcode]( EXEC_ARG_ &CUR.stack[CUR.args] );
-#endif
+
+#endif /* TT_CONFIG_OPTION_INTERPRETER_SWITCH */
+
if ( CUR.error != TT_Err_Ok )
{
switch ( CUR.error )
@@ -7293,6 +7421,7 @@
TT_DefRecord* def = CUR.IDefs;
TT_DefRecord* limit = def + CUR.numIDefs;
+
for ( ; def < limit; def++ )
{
if ( def->active && CUR.opcode == def->opc )
@@ -7299,6 +7428,7 @@
{
TT_CallRec* callrec;
+
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = TT_Err_Invalid_Reference;
@@ -7322,12 +7452,19 @@
CUR.error = TT_Err_Invalid_Opcode;
goto LErrorLabel_;
-/* break; Unreachable code warning suppress. Leave in case a later
- change to remind the editor to consider break; */
+#if 0
+ break; /* Unreachable code warning suppression. */
+ /* Leave to remind in case a later change the editor */
+ /* to consider break; */
+#endif
+
default:
goto LErrorLabel_;
-/* break; */
+
+#if 0
+ break;
+#endif
}
}
@@ -7336,12 +7473,12 @@
if ( CUR.step_ins )
CUR.IP += CUR.length;
- /* increment instruction counter and check if we didn't */
- /* run this program for too long ?? (e.g. infinite loops) */
+ /* increment instruction counter and check if we didn't */
+ /* run this program for too long (e.g. infinite loops). */
if ( ++ins_counter > MAX_RUNNABLE_OPCODES )
return TT_Err_Execution_Too_Long;
- LSuiteLabel_:
+ LSuiteLabel_:
if ( CUR.IP >= CUR.codeSize )
{
if ( CUR.callTop > 0 )
@@ -7355,9 +7492,11 @@
} while ( !CUR.instruction_trap );
LNo_Error_:
- #ifdef TT_CONFIG_OPTION_STATIC_RASTER
+
+#ifdef TT_CONFIG_OPTION_STATIC_RASTER
*exc = cur;
- #endif
+#endif
+
return TT_Err_Ok;
LErrorCodeOverflow_:
@@ -7364,13 +7503,16 @@
CUR.error = TT_Err_Code_Overflow;
LErrorLabel_:
- #ifdef TT_CONFIG_OPTION_STATIC_RASTER
+
+#ifdef TT_CONFIG_OPTION_STATIC_RASTER
*exc = cur;
- #endif
+#endif
+
return CUR.error;
}
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+
/* END */
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -2,13 +2,13 @@
/* */
/* ttinterp.h */
/* */
-/* TrueType bytecode intepreter (specification). */
+/* TrueType bytecode interpreter (specification). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -27,7 +27,7 @@
#endif
-#ifndef TT_STATIC_INTEPRETER /* indirect implementation */
+#ifndef TT_CONFIG_OPTION_STATIC_INTEPRETER /* indirect implementation */
#define EXEC_OP_ TT_ExecContext exc,
#define EXEC_OP TT_ExecContext exc
@@ -34,7 +34,7 @@
#define EXEC_ARG_ exc,
#define EXEC_ARG exc
-#else /* static implementation */
+#else /* static implementation */
#define EXEC_OP_ /* void */
#define EXEC_OP /* void */
@@ -41,7 +41,7 @@
#define EXEC_ARG_ /* void */
#define EXEC_ARG /* void */
-#endif /* TT_STATIC_INTERPRETER */
+#endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */
/*************************************************************************/
@@ -215,54 +215,15 @@
} TT_ExecContextRec;
-
LOCAL_DEF
const TT_GraphicsState tt_default_graphics_state;
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Goto_CodeRange */
- /* */
- /* <Description> */
- /* Switches to a new code range (updates the code related elements in */
- /* `exec', and `IP'). */
- /* */
- /* <Input> */
- /* range :: The new execution code range. */
- /* IP :: The new IP in the new code range. */
- /* */
- /* <InOut> */
- /* exec :: The target execution context. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
LOCAL_DEF
TT_Error TT_Goto_CodeRange( TT_ExecContext exec,
TT_Int range,
TT_Long IP );
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Set_CodeRange */
- /* */
- /* <Description> */
- /* Sets a code range. */
- /* */
- /* <Input> */
- /* range :: The code range index. */
- /* base :: The new code base. */
- /* length :: The range size in bytes. */
- /* */
- /* <InOut> */
- /* exec :: The target execution context. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
LOCAL_DEF
TT_Error TT_Set_CodeRange( TT_ExecContext exec,
TT_Int range,
@@ -269,199 +230,33 @@
void* base,
TT_Long length );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Clear_CodeRange */
- /* */
- /* <Description> */
- /* Clears a code range. */
- /* */
- /* <Input> */
- /* range :: The code range index. */
- /* */
- /* <InOut> */
- /* exec :: The target execution context. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Does not set the Error variable. */
- /* */
LOCAL_DEF
TT_Error TT_Clear_CodeRange( TT_ExecContext exec,
TT_Int range );
+ FT_EXPORT_DEF( TT_ExecContext ) TT_New_Context( TT_Face face );
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_New_Context */
- /* */
- /* <Description> */
- /* Queries the face context for a given font. Note that there is */
- /* now a _single_ execution context in the TrueType driver which is */
- /* shared among faces. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* <Return> */
- /* A handle to the execution context. Initialized for `face'. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
- /* This function is publicly exported because it is directly */
- /* invoked by the TrueType debugger.. */
- /* */
- FT_EXPORT_DEF(TT_ExecContext) TT_New_Context( TT_Face face );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Done_Context */
- /* */
- /* <Description> */
- /* Discards an execution context. */
- /* */
- /* <Input> */
- /* exec :: A handle to the target execution context. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
LOCAL_DEF
TT_Error TT_Done_Context( TT_ExecContext exec );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Destroy_Context */
- /* */
- /* <Description> */
- /* Destroys a given context. */
- /* */
- /* <Input> */
- /* exec :: A handle to the target execution context. */
- /* memory :: A handle to the parent memory object. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
LOCAL_DEF
TT_Error TT_Destroy_Context( TT_ExecContext exec,
FT_Memory memory );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Load_Context */
- /* */
- /* <Description> */
- /* Prepare an execution context for glyph hinting. */
- /* */
- /* <Input> */
- /* exec :: A handle to the target execution context. */
- /* face :: A handle to the source face object. */
- /* size :: A handle to the source size object. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
LOCAL_DEF
TT_Error TT_Load_Context( TT_ExecContext exec,
TT_Face face,
TT_Size size );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Save_Context */
- /* */
- /* <Description> */
- /* Saves the code ranges in a `size' object. */
- /* */
- /* <Input> */
- /* exec :: A handle to the source execution context. */
- /* */
- /* <Output> */
- /* ins :: A handle to the target size object. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
LOCAL_DEF
TT_Error TT_Save_Context( TT_ExecContext exec,
TT_Size ins );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Run_Context */
- /* */
- /* <Description> */
- /* Executes one or more instructions in the execution context. */
- /* */
- /* <Input> */
- /* exec :: A handle to the target execution context. */
- /* */
- /* debug :: A Boolean flag. If set, the function sets some internal */
- /* variables and returns immediately, otherwise TT_RunIns() */
- /* is called. */
- /* */
- /* <Return> */
- /* TrueTyoe error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
LOCAL_DEF
TT_Error TT_Run_Context( TT_ExecContext exec,
TT_Bool debug );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_RunIns */
- /* */
- /* <Description> */
- /* Executes one or more instruction in the execution context. This */
- /* is the main function of the TrueType opcode interpreter. */
- /* */
- /* <Input> */
- /* exec :: A handle to the target execution context. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only object manager and debugger should call this function. */
- /* */
- /* This function is publicly exported because it is directly */
- /* invoked by the TrueType debugger.. */
- /* */
- FT_EXPORT_DEF(TT_Error) TT_RunIns( TT_ExecContext exec );
+ FT_EXPORT_DEF( TT_Error ) TT_RunIns( TT_ExecContext exec );
#ifdef __cplusplus
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -4,11 +4,11 @@
/* */
/* Objects manager (body). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -33,7 +33,13 @@
#include <ttinterp.h>
#endif
-/* required by tracing mode */
+
+ /*************************************************************************/
+ /* */
+ /* 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
@@ -45,8 +51,6 @@
/*************************************************************************/
-
-
/*************************************************************************/
/* */
/* <Function> */
@@ -56,8 +60,15 @@
/* Initializes a given TrueType face object. */
/* */
/* <Input> */
- /* resource :: The source font resource. */
+ /* 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> */
@@ -70,43 +81,49 @@
TT_Int num_params,
FT_Parameter* params )
{
- TT_Error error;
- FT_Driver sfnt_driver;
- SFNT_Interface* sfnt;
+ TT_Error error;
+ FT_Driver sfnt_driver;
+ SFNT_Interface* sfnt;
+
sfnt_driver = FT_Get_Driver( face->root.driver->library, "sfnt" );
- if (!sfnt_driver) goto Bad_Format;
+ if ( !sfnt_driver )
+ goto Bad_Format;
sfnt = (SFNT_Interface*)(sfnt_driver->interface.format_interface);
- if (!sfnt) goto Bad_Format;
+ if ( !sfnt )
+ goto Bad_Format;
/* create input stream from resource */
- if ( FILE_Seek(0) )
+ 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;
+ if ( error )
+ goto Exit;
/* We must also be able to accept Mac/GX fonts, as well as OT ones */
- if ( face->format_tag != 0x00010000 && /* MS fonts */
- face->format_tag != TTAG_true ) /* Mac fonts */
+ if ( face->format_tag != 0x00010000L && /* MS fonts */
+ face->format_tag != TTAG_true ) /* Mac fonts */
{
- FT_TRACE2(( "[not a valid TTF font]" ));
+ FT_TRACE2(( "[not a valid TTF font]\n" ));
goto Bad_Format;
}
- /* If we're performing a simple font format check, exit immediately */
+ /* 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;
+ if ( error )
+ goto Exit;
error = TT_Load_Locations( face, stream ) ||
TT_Load_CVT ( face, stream ) ||
TT_Load_Programs ( face, stream );
+
Exit:
return error;
@@ -136,9 +153,10 @@
SFNT_Interface* sfnt = face->sfnt;
- if (sfnt)
- sfnt->done_face(face);
+ if ( sfnt )
+ sfnt->done_face( face );
+
/* freeing the locations table */
FREE( face->glyph_locations );
face->num_locations = 0;
@@ -182,6 +200,7 @@
TT_Error error = 0;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
TT_Face face = (TT_Face)size->root.face;
FT_Memory memory = face->root.memory;
TT_Int i;
@@ -190,6 +209,7 @@
TT_UShort n_twilight;
TT_MaxProfile* maxp = &face->max_profile;
+
size->ttmetrics.valid = FALSE;
size->max_function_defs = maxp->maxFunctionDefs;
@@ -209,6 +229,7 @@
FT_Size_Metrics* metrics = &size->root.metrics;
TT_Size_Metrics* metrics2 = &size->ttmetrics;
+
metrics->x_ppem = 0;
metrics->y_ppem = 0;
@@ -220,7 +241,7 @@
metrics2->compensations[i] = 0;
}
- /* allocate function defs, instruction defs, cvt and storage area */
+ /* allocate function defs, instruction defs, cvt, and storage area */
if ( ALLOC_ARRAY( size->function_defs,
size->max_function_defs,
TT_DefRecord ) ||
@@ -249,17 +270,18 @@
{
FT_Library library = face->root.driver->library;
+
face->interpreter = (TT_Interpreter)
- library->debug_hooks[ FT_DEBUG_HOOK_TRUETYPE ];
- if (!face->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;
- if (!size->debug)
- exec = TT_New_Context( face );
/* size objects used during debugging have their own context */
+ if ( !size->debug )
+ exec = TT_New_Context( face );
if ( !exec )
{
@@ -282,14 +304,14 @@
TT_Size_Metrics* tt_metrics = &exec->tt_metrics;
- metrics->x_ppem = 0;
- metrics->y_ppem = 0;
- metrics->x_scale = 0;
- metrics->y_scale = 0;
+ 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 = 0x10000;
+ tt_metrics->ppem = 0;
+ tt_metrics->scale = 0;
+ tt_metrics->ratio = 0x10000L;
}
exec->instruction_trap = FALSE;
@@ -332,11 +354,13 @@
return error;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
Fail_Exec:
if ( !size->debug )
TT_Done_Context( exec );
Fail_Memory:
+
#endif
TT_Done_Size( size );
@@ -358,9 +382,12 @@
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 */
@@ -380,6 +407,7 @@
FREE( size->function_defs );
FREE( size->instruction_defs );
+
size->num_function_defs = 0;
size->max_function_defs = 0;
size->num_instruction_defs = 0;
@@ -387,6 +415,7 @@
size->max_func = 0;
size->max_ins = 0;
+
#endif
size->ttmetrics.valid = FALSE;
@@ -413,6 +442,7 @@
FT_Size_Metrics* metrics;
+
if ( size->ttmetrics.valid )
return TT_Err_Ok;
@@ -428,7 +458,7 @@
{
size->ttmetrics.scale = metrics->x_scale;
size->ttmetrics.ppem = metrics->x_ppem;
- size->ttmetrics.x_ratio = 0x10000;
+ size->ttmetrics.x_ratio = 0x10000L;
size->ttmetrics.y_ratio = FT_MulDiv( metrics->y_ppem,
0x10000L,
metrics->x_ppem );
@@ -440,7 +470,7 @@
size->ttmetrics.x_ratio = FT_MulDiv( metrics->x_ppem,
0x10000L,
metrics->y_ppem );
- size->ttmetrics.y_ratio = 0x10000;
+ size->ttmetrics.y_ratio = 0x10000L;
}
/* Compute root ascender, descender, test height, and max_advance */
@@ -457,13 +487,14 @@
metrics->x_scale ) + 32 ) & -64;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
{
TT_ExecContext exec;
TT_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 );
@@ -528,6 +559,7 @@
TT_Done_Context( exec );
/* debugging instances keep their context */
}
+
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
if ( !error )
@@ -559,7 +591,7 @@
FT_Library library = face->driver->library;
- FT_TRACE4(( "TT.Init_GlyphSlot: Creating outline maxp = %d, maxc = %d\n",
+ FT_TRACE4(( "TT_Init_GlyphSlot: Creating outline maxp = %d, maxc = %d\n",
face->max_points, face->max_contours ));
return FT_Outline_New( library,
@@ -586,7 +618,8 @@
FT_Library library = slot->face->driver->library;
FT_Memory memory = library->memory;
- if (slot->flags & ft_glyph_own_bitmap)
+
+ if ( slot->flags & ft_glyph_own_bitmap )
FREE( slot->bitmap.buffer );
FT_Outline_Done( library, &slot->outline );
@@ -614,10 +647,13 @@
FT_Memory memory = driver->root.memory;
FT_Error error;
+
error = FT_New_GlyphZone( memory, 0, 0, &driver->zone );
- if (error) return error;
+ if ( error )
+ return error;
/* init extension registry if needed */
+
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
return TT_Init_Extensions( driver );
#else
@@ -641,6 +677,7 @@
void TT_Done_Driver( TT_Driver driver )
{
/* destroy extensions registry if needed */
+
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
TT_Done_Extensions( driver );
#endif
@@ -649,6 +686,7 @@
FT_Done_GlyphZone( &driver->zone );
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
/* destroy the execution context */
if ( driver->context )
{
@@ -655,6 +693,7 @@
TT_Destroy_Context( driver->context, driver->root.memory );
driver->context = NULL;
}
+
#endif
}
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -4,11 +4,11 @@
/* */
/* Objects manager (specification). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -209,7 +209,7 @@
/* */
/* A note regarding non-squared pixels: */
/* */
- /* (This text will probably go into some docs at some time, for now, it */
+ /* (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). */
/* */
@@ -312,6 +312,7 @@
TT_Size_Metrics ttmetrics;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
TT_UInt num_function_defs; /* number of function definitions */
TT_UInt max_function_defs;
TT_DefArray function_defs; /* table of function definitions */
@@ -364,44 +365,59 @@
} TT_DriverRec;
- /*************************************************************************/
- /* Face Funcs */
+ /*************************************************************************/
+ /* */
+ /* Face functions */
+ /* */
+ LOCAL_DEF
+ TT_Error TT_Init_Face( FT_Stream stream,
+ TT_Face face,
+ TT_Int face_index,
+ TT_Int num_params,
+ FT_Parameter* params );
- LOCAL_DEF TT_Error TT_Init_Face( FT_Stream stream,
- TT_Face face,
- TT_Int face_index,
- TT_Int num_params,
- FT_Parameter* params );
+ LOCAL_DEF
+ void TT_Done_Face( TT_Face face );
- LOCAL_DEF void TT_Done_Face( TT_Face face );
+ /*************************************************************************/
+ /* */
+ /* Size functions */
+ /* */
+ LOCAL_DEF
+ TT_Error TT_Init_Size( TT_Size size );
- /*************************************************************************/
- /* Size funcs */
+ LOCAL_DEF
+ void TT_Done_Size( TT_Size size );
- LOCAL_DEF TT_Error TT_Init_Size ( TT_Size size );
- LOCAL_DEF void TT_Done_Size ( TT_Size size );
- LOCAL_DEF TT_Error TT_Reset_Size( TT_Size size );
+ LOCAL_DEF
+ TT_Error TT_Reset_Size( TT_Size size );
- /*************************************************************************/
- /* GlyphSlot funcs */
+ /*************************************************************************/
+ /* */
+ /* GlyphSlot functions */
+ /* */
+ LOCAL_DEF
+ TT_Error TT_Init_GlyphSlot( TT_GlyphSlot slot );
- LOCAL_DEF TT_Error TT_Init_GlyphSlot( TT_GlyphSlot slot );
- LOCAL_DEF void TT_Done_GlyphSlot( TT_GlyphSlot slot );
+ LOCAL_DEF
+ void TT_Done_GlyphSlot( TT_GlyphSlot slot );
- /*************************************************************************/
- /* Driver funcs */
+ /*************************************************************************/
+ /* */
+ /* Driver functions */
+ /* */
+ LOCAL_DEF
+ TT_Error TT_Init_Driver( TT_Driver driver );
- LOCAL_DEF TT_Error TT_Init_Driver( TT_Driver driver );
- LOCAL_DEF void TT_Done_Driver( TT_Driver driver );
+ LOCAL_DEF
+ void TT_Done_Driver( TT_Driver driver );
-
#ifdef __cplusplus
}
#endif
-
#endif /* TTOBJS_H */
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -4,11 +4,11 @@
/* */
/* TrueType glyph data/program tables loader (body). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -24,9 +24,17 @@
#include <ttpload.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_ttload
+#define FT_COMPONENT trace_ttpload
+
/*************************************************************************/
/* */
/* <Function> */
@@ -35,8 +43,10 @@
/* <Description> */
/* Loads the locations table. */
/* */
- /* <Input> */
+ /* <InOut> */
/* face :: A handle to the target face object. */
+ /* */
+ /* <Input> */
/* stream :: The input stream. */
/* */
/* <Return> */
@@ -51,11 +61,12 @@
TT_Short LongOffsets;
TT_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)
+ if ( error )
{
error = TT_Err_Locations_Missing;
goto Exit;
@@ -63,9 +74,9 @@
if ( LongOffsets != 0 )
{
- face->num_locations = (TT_UShort)(table_len >> 2);
+ face->num_locations = (TT_UShort)( table_len >> 2 );
- FT_TRACE2(( "(32 bits offsets): %12d ", face->num_locations ));
+ FT_TRACE2(( "(32bit offsets): %12d ", face->num_locations ));
if ( ALLOC_ARRAY( face->glyph_locations,
face->num_locations,
@@ -79,6 +90,7 @@
TT_Long* loc = face->glyph_locations;
TT_Long* limit = loc + face->num_locations;
+
for ( ; loc < limit; loc++ )
*loc = GET_Long();
}
@@ -87,10 +99,9 @@
}
else
{
- face->num_locations = (TT_UShort)(table_len >> 1);
+ face->num_locations = (TT_UShort)( table_len >> 1 );
- FT_TRACE2(( "(16 bits offsets): %12d ",
- face->num_locations ));
+ FT_TRACE2(( "(16bit offsets): %12d ", face->num_locations ));
if ( ALLOC_ARRAY( face->glyph_locations,
face->num_locations,
@@ -103,8 +114,9 @@
TT_Long* loc = face->glyph_locations;
TT_Long* limit = loc + face->num_locations;
+
for ( ; loc < limit; loc++ )
- *loc = (TT_Long)((TT_ULong)GET_UShort() * 2);
+ *loc = (TT_Long)( (TT_ULong)GET_UShort() * 2 );
}
FORGET_Frame();
}
@@ -124,8 +136,10 @@
/* <Description> */
/* Loads the control value table into a face object. */
/* */
- /* <Input> */
+ /* <InOut> */
/* face :: A handle to the target face object. */
+ /* */
+ /* <Input> */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
@@ -139,10 +153,11 @@
FT_Memory memory = stream->memory;
TT_ULong table_len;
+
FT_TRACE2(( "CVT " ));
error = face->goto_table( face, TTAG_cvt, stream, &table_len );
- if (error)
+ if ( error )
{
FT_TRACE2(( "is missing!\n" ));
@@ -167,6 +182,7 @@
TT_Short* cur = face->cvt;
TT_Short* limit = cur + face->cvt_size;
+
for ( ; cur < limit; cur++ )
*cur = GET_Short();
}
@@ -187,8 +203,10 @@
/* <Description> */
/* Loads the font program and the cvt program. */
/* */
- /* <Input> */
+ /* <InOut> */
/* face :: A handle to the target face object. */
+ /* */
+ /* <Input> */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
@@ -201,6 +219,7 @@
TT_Error error;
TT_ULong table_len;
+
FT_TRACE2(( "Font program " ));
/* The font program is optional */
@@ -209,6 +228,7 @@
{
face->font_program = NULL;
face->font_program_size = 0;
+
FT_TRACE2(( "is missing!\n" ));
}
else
@@ -236,6 +256,7 @@
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 ));
}
--- a/src/truetype/ttpload.h
+++ b/src/truetype/ttpload.h
@@ -4,11 +4,11 @@
/* */
/* TrueType glyph data/program tables loader (specification). */
/* */
-/* Copyright 1996-1999 by */
+/* 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 */
+/* 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. */
@@ -27,61 +27,14 @@
#endif
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Load_Locations */
- /* */
- /* <Description> */
- /* Loads the locations table. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
LOCAL_DEF
TT_Error TT_Load_Locations( TT_Face face,
FT_Stream stream );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Load_CVT */
- /* */
- /* <Description> */
- /* Loads the control value table into a face object. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
LOCAL_DEF
TT_Error TT_Load_CVT( TT_Face face,
FT_Stream stream );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Load_Progams */
- /* */
- /* <Description> */
- /* Loads the font program and the cvt program. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
LOCAL_DEF
TT_Error TT_Load_Programs( TT_Face face,
FT_Stream stream );
--- a/src/type1/rules.mk
+++ b/src/type1/rules.mk
@@ -1,85 +1,16 @@
-#****************************************************************************
-#* *
-#* Type1 driver Makefile *
-#* *
-#* Copyright 1996-1999 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. *
-#* *
-#****************************************************************************
+#
+# FreeType 2 Type 1 driver configuration rules
+#
-#****************************************************************************
-#* *
-#* IMPORTANT NOTE: This Makefile is intended for GNU Make! *
-#* If you provide Makefiles for other make utilities, *
-#* please place them in `freetype/lib/arch/<system>'. *
-#* *
-#* *
-#* This file is to be included by the FreeType Makefile.lib, located in *
-#* the `freetype/lib' directory. Here is the list of the variables that *
-#* must be defined to use it: *
-#* *
-#* *
-#* BASE_DIR: The location of the base layer's directory. This is *
-#* usually `freetype/lib/base'. *
-#* *
-#* ARCH_DIR: The location of the architecture-dependent directory. *
-#* This is usually `freetype/lib/arch/<system>'. *
-#* *
-#* DRIVERS_DIR: The location of the font driver sub-dirs, usually *
-#* `freetype/lib/drivers'. *
-#* *
-#* OBJ_DIR: The location where the compiled object(s) file will be *
-#* placed. *
-#* *
-#* BASE_H: A list of pathnames to the base layer's header files on *
-#* which the driver depends. *
-#* *
-#* FT_CFLAGS: A set of flags used for compilation of object files. *
-#* This contains at least the include paths of the arch *
-#* and base directories + optimization + warnings + ANSI *
-#* compliance. *
-#* *
-#* FT_IFLAG: The flag used to specify an include path on the *
-#* compiler command line. For example, with GCC, this is *
-#* `-I', while some other compilers use `/i=' or `-J', *
-#* etc. *
-#* *
-#* FT_OBJ: The suffix of an object file for the platform; can be *
-#* `o', `obj', `coff', `tco', etc. depending on the *
-#* platform. *
-#* *
-#* *
-#* It also updates the following variables defined and used in the main *
-#* Makefile: *
-#* *
-#* DRV_OBJ_S: The list of driver object files in *
-#* single-object mode. *
-#* *
-#* DRV_OBJ_M: The list of driver object files in *
-#* multiple-objects mode. *
-#* *
-#* FTINIT_DRIVER_PATHS: The list of include paths used to compile the *
-#* `ftinit' component which registers all font *
-#* drivers in the FT_Init_FreeType() function. *
-#* *
-#* FTINIT_DRIVER_H: The list of header dependencies used to *
-#* compile the `ftinit' component. *
-#* *
-#* FTINIT_DRIVER_MACROS: The list of macros to be defined when *
-#* compiling the `ftinit' component. *
-#* *
-#* `Single-object compilation' means that each font driver is compiled *
-#* into a single object file. This is useful to get rid of all *
-#* driver-specific entries. *
-#* *
-#****************************************************************************
+# 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
@@ -90,68 +21,58 @@
# additional include flags used when compiling the driver
#
-T1_INCLUDE := $(SHARED) $(T1_DIR)
-T1_COMPILE := $(FT_COMPILE) $(T1_INCLUDE:%=$I%)
+T1_INCLUDE := $(T1_DIR)
+# compilation flags for the driver
+#
+T1_CFLAGS := $(T1_INCLUDE:%=$I%)
+T1_COMPILE := $(FT_COMPILE) $(T1_CFLAGS)
+
# 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_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 := $(T1SHARED_H) \
- $(T1_DRV_SRC:%.c=%.h)
+T1_DRV_H := $(T1_DRV_SRC:%.c=%.h)
-# driver object(s)
+# Type1 driver object(s)
#
-# T1_DRV_OBJ_M is used during `debug' builds
-# T1_DRV_OBJ_S is used during `release' builds
+# 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) \
- $(T1SHARED:$(T1SHARED_DIR_)%.c=$(OBJ_)%.$O)
+T1_DRV_OBJ_M := $(T1_DRV_SRC:$(T1_DIR_)%.c=$(OBJ_)%.$O)
T1_DRV_OBJ_S := $(OBJ_)type1.$O
-
-
-# driver root source file(s)
+# Type1 driver source file for single build
#
-T1_DRV_SRC_M := $(T1_DRV_SRC) $(T1SHARED_SRC)
T1_DRV_SRC_S := $(T1_DIR_)type1.c
-# driver - single object
+# Type1 driver - single object
#
-# the driver is recompiled if any of the header or source files is changed
-#
-$(T1_DRV_OBJ_S): $(BASE_H) $(T1_DRV_H) $(T1_DRV_SRC) $(T1_DRV_SRC_S)
+$(T1_DRV_OBJ_S): $(T1_DRV_SRC_S) $(T1_DRV_SRC) $(FREETYPE_H) $(T1_DRV_H)
$(T1_COMPILE) $T$@ $(T1_DRV_SRC_S)
-
-# driver - multiple objects
+# Type1 driver - multiple objects
#
-# All objects are recompiled if any of the header files is changed
-#
-$(OBJ_)t1%.$O: $(T1_DIR_)t1%.c $(BASE_H) $(T1_DRV_H)
+$(OBJ_)%.$O: $(T1_DIR_)%.c $(FREETYPE_H) $(T1_DRV_H)
$(T1_COMPILE) $T$@ $<
-$(OBJ_)t1%.$O: $(T1SHARED_DIR_)t1%.c $(BASE_H) $(T1SHARED_H)
- $(T1_COMPILE) $T$@ $<
-
# update main driver object lists
#
DRV_OBJS_S += $(T1_DRV_OBJ_S)
DRV_OBJS_M += $(T1_DRV_OBJ_M)
-# END
+# EOF
--- a/src/type1z/rules.mk
+++ b/src/type1z/rules.mk
@@ -1,5 +1,5 @@
#
-# FreeType 2 driver configuration rules
+# FreeType 2 Type1z driver configuration rules
#
@@ -6,7 +6,7 @@
# 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
+# 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
@@ -13,19 +13,6 @@
# fully.
-#****************************************************************************
-#* *
-#* The "Type1z" driver is an experimental replacement for the current *
-#* Type 1 driver. It features a very different loading mechanism that *
-#* is much faster than the one used by the `normal' driver, and also *
-#* deals nicely with nearly broken Type 1 font files. It is also *
-#* much smaller... *
-#* *
-#* Note that it may become a permanent replacement of the current *
-#* "src/type1" driver in the future.. *
-#* *
-#****************************************************************************
-
# Type1z driver directory
#
T1Z_DIR := $(SRC_)type1z
@@ -35,9 +22,13 @@
# additional include flags used when compiling the driver
#
T1Z_INCLUDE := $(SHARED) $(T1Z_DIR)
-T1Z_COMPILE := $(FT_COMPILE) $(T1Z_INCLUDE:%=$I%)
+# compilation flags for the driver
+#
+T1Z_CFLAGS := $(T1Z_INCLUDE:%=$I%)
+T1Z_COMPILE := $(FT_COMPILE) $(T1Z_CFLAGS)
+
# Type1 driver sources (i.e., C files)
#
T1Z_DRV_SRC := $(T1Z_DIR_)t1parse.c \
@@ -44,46 +35,37 @@
$(T1Z_DIR_)t1load.c \
$(T1Z_DIR_)t1driver.c \
$(T1Z_DIR_)t1afm.c \
- $(T1Z_DIR_)t1gload.c
+ $(T1Z_DIR_)t1gload.c \
+ $(T1Z_DIR_)t1objs.c
# Type1 driver headers
#
-T1Z_DRV_H := $(T1SHARED_H) \
- $(T1Z_DRV_SRC:%.c=%.h)
+T1Z_DRV_H := $(T1Z_DRV_SRC:%.c=%.h) \
+ $(T1Z_DIR_)t1tokens.h
-# driver object(s)
+# Type1z driver object(s)
#
-# T1Z_DRV_OBJ_M is used during `debug' builds
-# T1Z_DRV_OBJ_S is used during `release' builds
+# 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) \
- $(T1SHARED:$(T1SHARED_DIR_)%.c=$(OBJ_)%.$O)
+T1Z_DRV_OBJ_M := $(T1Z_DRV_SRC:$(T1Z_DIR_)%.c=$(OBJ_)%.$O)
T1Z_DRV_OBJ_S := $(OBJ_)type1z.$O
-
-# driver source file(s)
+# Type1z driver source file for single build
#
-T1Z_DRV_SRC_M := $(T1Z_DRV_SRC) $(T1SHARED_SRC)
T1Z_DRV_SRC_S := $(T1Z_DIR_)type1z.c
-# driver - single object
+# Type1z driver - single object
#
-# the driver is recompiled if any of the header or source files is changed
-#
-$(T1Z_DRV_OBJ_S): $(BASE_H) $(T1Z_DRV_H) $(T1Z_DRV_SRC) $(T1Z_DRV_SRC_S)
+$(T1Z_DRV_OBJ_S): $(T1Z_DRV_SRC_S) $(T1Z_DRV_SRC) $(FREETYPE_H) $(T1Z_DRV_H)
$(T1Z_COMPILE) $T$@ $(T1Z_DRV_SRC_S)
-# driver - multiple objects
+# Type1z driver - multiple objects
#
-# All objects are recompiled if any of the header files is changed
-#
-$(OBJ_)t1%.$O: $(T1Z_DIR_)t1%.c $(BASE_H) $(T1Z_DRV_H)
- $(T1Z_COMPILE) $T$@ $<
-
-$(OBJ_)t1%.$O: $(T1SHARED_DIR_)t1%.c $(BASE_H) $(T1SHARED_H)
+$(OBJ_)%.$O: $(T1Z_DIR_)%.c $(FREETYPE_H) $(T1Z_DRV_H)
$(T1Z_COMPILE) $T$@ $<