Minor cleanups.

This commit is contained in:
Werner Lemberg 2003-04-29 13:23:47 +00:00
parent 3a317c69d6
commit a3f4da8e99
6 changed files with 150 additions and 106 deletions

View File

@ -17,30 +17,64 @@
2003-04-25: Graham Asher <graham.asher@btinternet.com>
Added the optional unpatented hinting system for TrueType. It
Added the optional unpatented hinting system for TrueType. It
allows typefaces which need hinting to produce correct glyph forms
(e.g., Chinese typefaces from Dynalab) to work acceptably without
infringing Apple patents. This system is compiled only if
infringing Apple patents. This system is compiled only if
TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING is defined in
ftoption.h.
* include/freetype/ttunpat.h: added header file ttunpat.h defining
* include/freetype/ttunpat.h: New file. Defines
FT_PARAM_TAG_UNPATENTED_HINTING.
* include/freetype/config/ftheader.h: Added macro FT_UNPATENTED_H
to use when including new header ttunpat.h.
* include/freetype/config/ftheader.h (FT_TRUETYPE_UNPATENTED_H): New
macro to use when including ttunpat.h.
* include/freetype/config/ftoption.h: Added configuration macros
* include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING,
TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING): New configuration macros
(not defined, but in comments) for the unpatented hinting system.
* include/freetype/internal/tttypes.h: If unpatented hinting is
compiled the TrueType face object acquires a new element,
"FT_Bool unpatented_hinting".
* include/freetype/internal/tttypes.h (TT_FaceRec)
[TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: New element "FT_Bool
unpatented_hinting".
* src/truetype/ttinterp.c, ttobjs.c, ttobjs.h: Added the unpatented
hinting system, which is compiled only if
TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING is defined in
ftoption.h.
* src/truetype/ttinterp.c (NO_APPLE_PATENT, APPLE_THRESHOLD):
Removed.
(GUESS_VECTOR): New macro.
(TT_Run_Context) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]:
Set `both_x_axis'.
(tt_default_graphics_state)
[TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Updated.
(Current_Ratio) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]:
Handle `unpatented_hinting'.
(Direct_Move) [NO_APPLE_PATENT]: Removed.
[TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Insert assertion.
(Project, FreeProject)
[TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Insert assertion.
(Compute_Funcs) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]:
Implement unpatented hinting.
(DO_SPVTCA, DO_SFVTCA, DO_SPVTL, DO_SFVTL, DO_SPVFS, DO_SFVFS,
Ins_SDPVTL): Call `GUESS_VECTOR'.
(DO_GPV, DO_GFV) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]:
Handle `unpatented_hinting'.
(Compute_Point_Displacement) [NO_APPLE_PATENT]: Removed.
[TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Implement unpatented
hinting.
(Move_Zp2_Point, Ins_SHPIX, Ins_DELTAP, Ins_DELTAC)
[TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Implement unpatented
hinting.
(TT_RunIns): Updated.
* src/truetype/ttobjs.c
[TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Include
FT_TRUETYPE_UNPATENTED_H.
(tt_face_init) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING,
TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING]: Check
FT_PARAM_TAG_UNPATENTED_HINTING.
* src/truetype/ttobjs.h (TT_GraphicsState)
[TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Add `both_x_axis'.
2003-04-25 Werner Lemberg <wl@gnu.org>

View File

@ -392,7 +392,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Define TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING to compile the */
/* unpatented work-around hinting system. You must define this if you */
/* unpatented work-around hinting system. You must define this if you */
/* want either to force the use of the unpatented hinting system by also */
/* defining TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING, or if you want to */
/* select it at run time using the FT_PARAM_TAG_UNPATENTED_HINTING tag. */
@ -405,7 +405,7 @@ FT_BEGIN_HEADER
/* Define TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING to restrict the */
/* TrueType bytecode interpreter to actions not protected by patents. */
/* This enables some fonts, for example mingliu.ttc from Dynalab, to */
/* work properly. They use hinting to make large changes to the glyph */
/* work properly. They use hinting to make large changes to the glyph */
/* shape, without which the glyph is unrecognisable. */
/* For this to work you must also define */
/* TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING. */

View File

@ -1564,7 +1564,7 @@ FT_BEGIN_HEADER
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
/* Use unpatented hinting only. */
FT_Bool unpatented_hinting;
FT_Bool unpatented_hinting;
#endif
/***********************************************************************/

View File

@ -4,9 +4,11 @@
/* */
/* Definitions for the unpatented TrueType hinting system */
/* */
/* Copyright 1996-2001 by */
/* Copyright 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* Written by Graham Asher <graham.asher@btinternet.com> */
/* */
/* 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 */

View File

@ -225,11 +225,11 @@
#define FAILURE 1
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
#define GUESS_VECTOR( V ) \
if ( CUR.face->unpatented_hinting ) \
{ \
CUR.GS.V.x = (FT_F2Dot14)(CUR.GS.both_x_axis ? 0x4000 : 0); \
CUR.GS.V.y = (FT_F2Dot14)(CUR.GS.both_x_axis ? 0 : 0x4000); \
#define GUESS_VECTOR( V ) \
if ( CUR.face->unpatented_hinting ) \
{ \
CUR.GS.V.x = (FT_F2Dot14)( CUR.GS.both_x_axis ? 0x4000 : 0 ); \
CUR.GS.V.y = (FT_F2Dot14)( CUR.GS.both_x_axis ? 0 : 0x4000 ); \
}
#else
#define GUESS_VECTOR( V )
@ -758,7 +758,7 @@
{ 0x4000, 0 },
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
TRUE,
TRUE,
#endif
1, 64, 1,
@ -1371,7 +1371,7 @@
}
else
#endif
{
{
if ( CUR.GS.projVector.y == 0 )
CUR.tt_metrics.ratio = CUR.tt_metrics.x_ratio;
@ -1382,12 +1382,15 @@
{
FT_Long x, y;
x = TT_MULDIV( CUR.GS.projVector.x, CUR.tt_metrics.x_ratio, 0x4000 );
y = TT_MULDIV( CUR.GS.projVector.y, CUR.tt_metrics.y_ratio, 0x4000 );
x = TT_MULDIV( CUR.GS.projVector.x,
CUR.tt_metrics.x_ratio, 0x4000 );
y = TT_MULDIV( CUR.GS.projVector.y,
CUR.tt_metrics.y_ratio, 0x4000 );
CUR.tt_metrics.ratio = TT_VecLen( x, y );
}
}
}
}
}
return CUR.tt_metrics.ratio;
}
@ -1555,11 +1558,11 @@
FT_UShort point,
FT_F26Dot6 distance )
{
FT_F26Dot6 v;
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
FT_ASSERT(!CUR.face->unpatented_hinting);
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
v = CUR.GS.freeVector.x;
@ -1585,7 +1588,6 @@
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
}
@ -2124,8 +2126,9 @@
FT_Vector* v2 )
{
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
FT_ASSERT(!CUR.face->unpatented_hinting);
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
return TT_DotFix14( v1->x - v2->x,
v1->y - v2->y,
CUR.GS.projVector.x,
@ -2180,7 +2183,7 @@
FT_Vector* v2 )
{
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
FT_ASSERT(!CUR.face->unpatented_hinting);
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
return TT_DotFix14( v1->x - v2->x,
v1->y - v2->y,
@ -2188,6 +2191,7 @@
CUR.GS.freeVector.y );
}
/*************************************************************************/
/* */
/* <Function> */
@ -2254,16 +2258,17 @@
{
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
{
{
/* If both vectors point rightwards along the x axis, set */
/* 'both-x-axis' true, otherwise set it false. The x values only */
/* need be tested because the vector has been normalised to a unit */
/* vector of length 0x4000 = unity. */
CUR.GS.both_x_axis = (FT_Bool)(CUR.GS.projVector.x == 0x4000 && CUR.GS.freeVector.x == 0x4000);
/* `both-x-axis' true, otherwise set it false. The x values only */
/* need be tested because the vector has been normalised to a unit */
/* vector of length 0x4000 = unity. */
CUR.GS.both_x_axis = (FT_Bool)( CUR.GS.projVector.x == 0x4000 &&
CUR.GS.freeVector.x == 0x4000 );
/* Throw away projection and freedom vector information */
/* because the patents don't allow them to be stored. */
/* The relevant US Patents are 5155805 and 5325479. */
/* Throw away projection and freedom vector information */
/* because the patents don't allow them to be stored. */
/* The relevant US Patents are 5155805 and 5325479. */
CUR.GS.projVector.x = 0;
CUR.GS.projVector.y = 0;
CUR.GS.freeVector.x = 0;
@ -2271,15 +2276,15 @@
if ( CUR.GS.both_x_axis )
{
CUR.func_project = Project_x;
CUR.func_freeProj = Project_x;
CUR.func_move = Direct_Move_X;
CUR.func_project = Project_x;
CUR.func_freeProj = Project_x;
CUR.func_move = Direct_Move_X;
}
else
else
{
CUR.func_project = Project_y;
CUR.func_freeProj = Project_y;
CUR.func_move = Direct_Move_Y;
CUR.func_project = Project_y;
CUR.func_freeProj = Project_y;
CUR.func_move = Direct_Move_Y;
}
if ( CUR.GS.dualVector.x == 0x4000 )
@ -2287,7 +2292,7 @@
else
{
if ( CUR.GS.dualVector.y == 0x4000 )
CUR.func_dualproj = Project_y;
CUR.func_dualproj = Project_y;
else
CUR.func_dualproj = Dual_Project;
}
@ -2295,9 +2300,9 @@
/* Force recalculation of cached aspect ratio */
CUR.tt_metrics.ratio = 0;
return;
}
#endif
return;
}
#endif /* TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING */
if ( CUR.GS.freeVector.x == 0x4000 )
{
@ -2656,39 +2661,39 @@
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
#define DO_GPV \
if ( CUR.face->unpatented_hinting ) \
{ \
args[0] = CUR.GS.both_x_axis ? 0x4000 : 0;\
args[1] = CUR.GS.both_x_axis ? 0 : 0x4000;\
} \
else \
{ \
args[0] = CUR.GS.projVector.x; \
args[1] = CUR.GS.projVector.y; \
#define DO_GPV \
if ( CUR.face->unpatented_hinting ) \
{ \
args[0] = CUR.GS.both_x_axis ? 0x4000 : 0; \
args[1] = CUR.GS.both_x_axis ? 0 : 0x4000; \
} \
else \
{ \
args[0] = CUR.GS.projVector.x; \
args[1] = CUR.GS.projVector.y; \
}
#else
#define DO_GPV \
args[0] = CUR.GS.projVector.x; \
#define DO_GPV \
args[0] = CUR.GS.projVector.x; \
args[1] = CUR.GS.projVector.y;
#endif
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
#define DO_GFV \
if ( CUR.face->unpatented_hinting ) \
{ \
args[0] = CUR.GS.both_x_axis ? 0x4000 : 0;\
args[1] = CUR.GS.both_x_axis ? 0 : 0x4000;\
} \
else \
{ \
args[0] = CUR.GS.freeVector.x; \
args[1] = CUR.GS.freeVector.y; \
#define DO_GFV \
if ( CUR.face->unpatented_hinting ) \
{ \
args[0] = CUR.GS.both_x_axis ? 0x4000 : 0; \
args[1] = CUR.GS.both_x_axis ? 0 : 0x4000; \
} \
else \
{ \
args[0] = CUR.GS.freeVector.x; \
args[1] = CUR.GS.freeVector.y; \
}
#else
#define DO_GFV \
args[0] = CUR.GS.freeVector.x; \
#define DO_GFV \
args[0] = CUR.GS.freeVector.x; \
args[1] = CUR.GS.freeVector.y;
#endif
@ -5262,7 +5267,7 @@
FT_Bool touch )
{
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
if (CUR.face->unpatented_hinting)
if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
{
@ -5466,16 +5471,16 @@
}
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting)
if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
{
dx = TT_MulFix14( args[0], 0x4000 );
dy = 0;
dy = 0;
}
else
{
dx = 0;
dx = 0;
dy = TT_MulFix14( args[0], 0x4000 );
}
}
@ -6383,7 +6388,7 @@
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
/* Delta hinting is covered by US Patent 5159668. */
if ( CUR.face->unpatented_hinting )
{
{
FT_Long n = args[0] * 2;
if ( CUR.args < n )
{
@ -6391,7 +6396,7 @@
return;
}
CUR.args -= n;
CUR.args -= n;
CUR.new_top = CUR.args;
return;
}
@ -6471,18 +6476,21 @@
FT_ULong A, C;
FT_Long B;
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
/* Delta hinting is covered by US Patent 5159668. */
if ( CUR.face->unpatented_hinting )
{
FT_Long n = args[0] * 2;
{
FT_Long n = args[0] * 2;
if ( CUR.args < n )
{
CUR.error = TT_Err_Too_Few_Arguments;
return;
}
CUR.args -= n;
CUR.args -= n;
CUR.new_top = CUR.args;
return;
}

View File

@ -204,46 +204,46 @@
goto Exit;
if ( face->root.face_flags & FT_FACE_FLAG_SCALABLE )
{
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( !face->root.internal->incremental_interface )
error = tt_face_load_loca( face, stream );
if ( !error )
error = tt_face_load_cvt ( face, stream ) ||
tt_face_load_fpgm ( face, stream );
if ( !face->root.internal->incremental_interface )
error = tt_face_load_loca( face, stream );
if ( !error )
error = tt_face_load_cvt( face, stream ) ||
tt_face_load_fpgm( face, stream );
#else
if ( !error )
error = tt_face_load_loca( face, stream ) ||
tt_face_load_cvt ( face, stream ) ||
tt_face_load_fpgm ( face, stream );
if ( !error )
error = tt_face_load_loca( face, stream ) ||
tt_face_load_cvt( face, stream ) ||
tt_face_load_fpgm( face, stream );
#endif
}
}
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
/* Determine whether unpatented hinting is to be used for this face. */
/* Determine whether unpatented hinting is to be used for this face. */
#ifdef TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING
face->unpatented_hinting = TRUE;
face->unpatented_hinting = TRUE;
#else
face->unpatented_hinting = FALSE;
face->unpatented_hinting = FALSE;
{
int i;
int i;
for ( i = 0; i < num_params && !face->unpatented_hinting;
i++ )
if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
face->unpatented_hinting = TRUE;
for ( i = 0; i < num_params && !face->unpatented_hinting; i++ )
if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
face->unpatented_hinting = TRUE;
}
#endif
#endif /* TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING */
#endif
#endif /* TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING */
/* initialize standard glyph loading routines */
TT_Init_Glyph_Loading( face );