Formatting, comment improvements.

This commit is contained in:
Werner Lemberg 2013-01-28 13:56:23 +01:00
parent ab02d9e8e7
commit 6b9034f0fd
8 changed files with 107 additions and 98 deletions

View File

@ -18,58 +18,61 @@
* src/truetype/ttsubpix.c: Updated.
(ALWAYS_SKIP_DELTAP_Rules): Remove rule for Trebuchet MS.
(sph_set_tweaks): Fix rasterizer_version logic.
(sph_set_tweaks): Fix `rasterizer_version' logic.
2013-01-26 Infinality <infinality@infinality.net>
[truetype] Align more to ClearType whitepaper for sph.
* include/freetype/internal/tttypes.h (TT_FaceRec): Add flags
for detected fdefs and compatibility mode.
for detected opcode patterns and compatibility mode.
* src/truetype/ttgload.c (tt_loader_init): Complete conditional.
* src/truetype/ttinterp.c: Updated. Remove SPH_DEBUG and replace
with FT_TRACE7.
* src/truetype/ttinterp.c: Updated.
Remove SPH_DEBUG and replace with FT_TRACE7.
(DO_RS): More conditions.
(Ins_FDEF): Add more opcode detection patterns. More specific
conditions when flagging a fdef. Make compatibility mode only turn
on when delta fdefs are found.
(Ins_CALL, Ins_LOOPCALL): Set flags for currently executing fdef.
(Ins_SHPIX): Remove logic to handle ttfautohinted fonts. Simplify
conditionals where possible. Use & instead of % operator for dumb
compilers.
(Ins_MIAP): Adjust twilight zone conditional. Ensure ingore_x_mode
is on when testing sph conditionals.
(Ins_MIRP): Ensure ingore_x_mode is on when testing sph conditionals.
Do cvt cutin always when in ignore_x_mode. Remove test for
ttfautohinted fonts.
(Ins_DELTAP): Ensure ingore_x_mode is on when testing sph conditionals.
Do cvt cutin always when in ignore_x_mode. Remove test for
ttfautohinted fonts. Use & instead of % operator for dumb
compilers.
(Ins_FDEF): Add more opcode detection patterns.
More specific conditions when flagging an fdef.
Make compatibility mode only turn on when delta fdefs are found.
(Ins_CALL, Ins_LOOPCALL): Set flags for currently executed fdef.
(Ins_SHPIX): Remove logic to handle ttfautohinted fonts.
Simplify conditionals where possible.
Use `&' instead of `%' operator for dumb compilers.
(Ins_MIAP): Adjust twilight zone conditional.
Ensure `ignore_x_mode' is on when testing sph conditionals.
(Ins_MIRP): Ensure `ignore_x_mode' is on when testing sph
conditionals.
Do cvt cutin always when `ignore_x_mode' is active.
Remove test for ttfautohinted fonts.
(Ins_DELTAP): Ensure `ignore_x_mode' is on when testing sph
conditionals.
Do cvt cutin always when `ignore_x_mode' is active.
Remove test for ttfautohinted fonts.
Use `&' instead of `%' operator for dumb compilers.
(Ins_GETINFO): Remove SPH_DEBUG and replace with FT_TRACE7.
* src/truetype/ttinterp.h: Updated.
(TT_ExecContextRec): Remove compatibility_mode variable. Add variable
to indicate when executing in special fdefs for sph.
(TT_ExecContextRec): Remove compatibility_mode variable.
Add variable to indicate when executing in special fdefs for sph.
* src/truetype/ttobjs.h: Updated.
(TT_DefRecord): Add flags to identify special fdefs for sph.
(TT_SizeRec): Remove unnecessary ttfautohinted variable.
* src/truetype/ttsubpix.c: Updated.
(COMPATIBILITY_MODE_Rules): Remove all. Auto-detected now.
(PIXEL_HINTING_Rules): Remove all. Unnecessary after fixes.
(COMPATIBILITY_MODE_Rules): Remove all. Auto-detected now.
(PIXEL_HINTING_Rules): Remove all. Unnecessary after fixes.
(SKIP_NONPIXEL_Y_MOVES_Rules): Remove Ubuntu.
(SKIP_NONPIXEL_Y_MOVES_Rules_Exceptions): Add Arial Bold `N'.
(SKIP_OFFPIXEL_Y_MOVES_Rules): Remove all. Happens automatically now.
(SKIP_OFFPIXEL_Y_MOVES_Rules): Remove all. Happens automatically
now.
(ROUND_NONPIXEL_Y_MOVES_Rules): Remove Ubuntu.
(ROUND_NONPIXEL_Y_MOVES_Rules_Exceptions): Remove all.
(NORMAL_ROUND_Rules): Remove Verdana.
(NO_DELTAP_AFTER_IUP_Rules): Remove all.
(sph_set_tweaks): Performance fix. Don't run prep always. Adjust
conditional for sph_compatibility_mode.
(sph_set_tweaks): Performance fix. Don't run prep always.
Adjust conditional for sph_compatibility_mode.
* src/truetype/ttsubpix.h: Add new fdef flags for sph.

View File

@ -5,7 +5,7 @@
/* Basic SFNT/TrueType type definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2002, 2004-2008, 2012 by */
/* Copyright 1996-2002, 2004-2008, 2012-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1429,8 +1429,9 @@ FT_BEGIN_HEADER
FT_ULong vert_metrics_offset;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
FT_ULong sph_found_func_flags; /* special funcs identified */
/* for this face */
/* since 2.4.12 */
FT_ULong sph_found_func_flags; /* special functions found */
/* for this face */
FT_Bool sph_compatibility_mode;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */

View File

@ -1943,7 +1943,6 @@
if ( subpixel_hinting )
grayscale = grayscale_hinting = FALSE;
else if ( SPH_OPTION_SET_GRAYSCALE )
{
grayscale = grayscale_hinting = TRUE;

View File

@ -3182,6 +3182,7 @@
args[0] = CUR.storage[I]; \
} \
}
#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#define DO_RS \
@ -4581,11 +4582,11 @@
return;
}
rec->range = CUR.curRange;
rec->opc = (FT_UInt16)n;
rec->start = CUR.IP + 1;
rec->active = TRUE;
rec->inline_delta = FALSE;
rec->range = CUR.curRange;
rec->opc = (FT_UInt16)n;
rec->start = CUR.IP + 1;
rec->active = TRUE;
rec->inline_delta = FALSE;
rec->sph_fdef_flags = 0x0000;
if ( n > CUR.maxFunc )
@ -4614,8 +4615,8 @@
if ( opcode_pointer[i] == opcode_size[i] )
{
FT_TRACE7(( "sph: Function %d, opcode ptrn: %d, %s %s\n", i, n,
FT_TRACE7(( "sph: Function %d, opcode ptrn: %d, %s %s\n",
i, n,
CUR.face->root.family_name,
CUR.face->root.style_name ));
@ -4683,7 +4684,6 @@
CUR.face->sph_found_func_flags |= SPH_FDEF_SPACING_2;
}
break;
}
opcode_pointer[i] = 0;
}
@ -4694,10 +4694,9 @@
}
/* Set sph_compatibility_mode only when deltas are detected */
CUR.face->sph_compatibility_mode = ( ( CUR.face->sph_found_func_flags &
SPH_FDEF_INLINE_DELTA_1 ) |
( CUR.face->sph_found_func_flags &
SPH_FDEF_INLINE_DELTA_2 ) );
CUR.face->sph_compatibility_mode =
( ( CUR.face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_1 ) |
( CUR.face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) );
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
@ -6035,7 +6034,8 @@
( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_INLINE_DELTAS ) )
goto Skip;
if ( !CUR.face->sph_compatibility_mode && CUR.GS.freeVector.y != 0 )
if ( !CUR.face->sph_compatibility_mode &&
CUR.GS.freeVector.y != 0 )
MOVE_Zp2_Point( point, dx, dy, TRUE );
else if ( CUR.face->sph_compatibility_mode )
@ -6069,7 +6069,7 @@
CUR.GS.freeVector.y != 0 &&
( B1 & 63 ) == 0 &&
( B2 & 63 ) != 0 &&
B1 != B2 ) )
B1 != B2 ) )
MOVE_Zp2_Point( point, -dx, -dy, TRUE );
}
else
@ -6260,8 +6260,8 @@
if ( CUR.GS.gep0 == 0 ) /* If in twilight zone */
{
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/* Only adjust when not in sph_compatibility_mode or ignore_x_mode */
/* Determined via experimentation and may be incorrect */
/* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */
/* Determined via experimentation and may be incorrect... */
if ( !CUR.ignore_x_mode || !CUR.face->sph_compatibility_mode )
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
CUR.zp0.org[point].x = TT_MulFix14( (FT_UInt32)distance,
@ -6643,7 +6643,7 @@
( B1 & 63 ) != 0 )
reverse_move = TRUE;
if ( ( CUR.sph_tweak_flags &
if ( ( CUR.sph_tweak_flags &
SPH_TWEAK_DELTAP_SKIP_EXAGGERATED_VALUES ) &&
!reverse_move &&
FT_ABS( B1 - B2 ) >= 64 )
@ -7371,15 +7371,15 @@
else
B1 = CUR.zp0.cur[A].x;
#if 0
/* Standard Subpixel Hinting: Allow y move */
/* This messes up dejavu and may not be needed */
/* Standard Subpixel Hinting: Allow y move. */
/* This messes up dejavu and may not be needed... */
if ( !CUR.face->sph_compatibility_mode &&
CUR.GS.freeVector.y != 0 )
CUR_Func_move( &CUR.zp0, A, B );
else
#endif
/* Compatibility Mode: Allow x or y move if point touched in
Y direction */
/* Compatibility Mode: Allow x or y move if point touched in */
/* Y direction. */
if ( CUR.face->sph_compatibility_mode &&
!( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
{
@ -7389,10 +7389,8 @@
if ( ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) )
B = FT_PIX_ROUND( B1 + B ) - B1;
/*
* Allow delta move if using sph_compatibility_mode, IUP has not
* been called, and point is touched on Y.
*/
/* Allow delta move if using sph_compatibility_mode, */
/* IUP has not been called, and point is touched on Y. */
if ( !CUR.iup_called &&
( CUR.zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
CUR_Func_move( &CUR.zp0, A, B );
@ -7401,14 +7399,14 @@
B2 = CUR.zp0.cur[A].y;
/* Reverse this move if it results in a disallowed move */
if ( CUR.GS.freeVector.y != 0 &&
( ( CUR.face->sph_compatibility_mode &&
( B1 & 63 ) == 0 &&
( B2 & 63 ) != 0 ) ||
( ( CUR.sph_tweak_flags &
SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
( B1 & 63 ) != 0 &&
( B2 & 63 ) != 0 ) ) )
if ( CUR.GS.freeVector.y != 0 &&
( ( CUR.face->sph_compatibility_mode &&
( B1 & 63 ) == 0 &&
( B2 & 63 ) != 0 ) ||
( ( CUR.sph_tweak_flags &
SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
( B1 & 63 ) != 0 &&
( B2 & 63 ) != 0 ) ) )
CUR_Func_move( &CUR.zp0, A, -B );
}
#else
@ -7552,7 +7550,8 @@
if ( ( args[0] & 1 ) != 0 && CUR.ignore_x_mode )
{
K = CUR.rasterizer_version;
FT_TRACE7(( "Setting rasterizer version %d\n", CUR.rasterizer_version ));
FT_TRACE7(( "Setting rasterizer version %d\n",
CUR.rasterizer_version ));
}
else
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
@ -8024,7 +8023,7 @@
#endif
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
CUR.iup_called = FALSE;
CUR.iup_called = FALSE;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* set CVT functions */

View File

@ -278,15 +278,15 @@ FT_BEGIN_HEADER
FT_Bool subpixel_positioned; /* subpixel positioned */
/* (DirectWrite ClearType)? */
FT_Int rasterizer_version; /* MS rasterizer version */
FT_Int rasterizer_version; /* MS rasterizer version */
FT_Bool iup_called; /* IUP called for glyph? */
FT_Bool iup_called; /* IUP called for glyph? */
FT_ULong sph_tweak_flags; /* flags to control */
/* hint tweaks */
FT_ULong sph_tweak_flags; /* flags to control */
/* hint tweaks */
FT_ULong sph_in_func_flags; /* flags to indicate if in */
/* special functions */
FT_ULong sph_in_func_flags; /* flags to indicate if in */
/* special functions */
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */

View File

@ -4,7 +4,7 @@
/* */
/* Objects manager (specification). */
/* */
/* Copyright 1996-2009, 2011-2012 by */
/* Copyright 1996-2009, 2011-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -173,13 +173,13 @@ FT_BEGIN_HEADER
/* */
typedef struct TT_DefRecord_
{
FT_Int range; /* in which code range is it located? */
FT_Long start; /* where does it start? */
FT_Long end; /* where does it end? */
FT_UInt opc; /* function #, or instruction code */
FT_Bool active; /* is it active? */
FT_Bool inline_delta; /* is function that defines inline delta? */
FT_ULong sph_fdef_flags; /* flags to identify special functions */
FT_Int range; /* in which code range is it located? */
FT_Long start; /* where does it start? */
FT_Long end; /* where does it end? */
FT_UInt opc; /* function #, or instruction code */
FT_Bool active; /* is it active? */
FT_Bool inline_delta; /* is function that defines inline delta? */
FT_ULong sph_fdef_flags; /* flags to identify special functions */
} TT_DefRecord, *TT_DefArray;

View File

@ -275,7 +275,7 @@
};
/* Force special legacy fixes for fonts; */
/* Force special legacy fixes for fonts. */
#define COMPATIBILITY_MODE_RULES_SIZE 1
const SPH_TweakRule COMPATIBILITY_MODE_Rules
@ -1030,22 +1030,29 @@
if ( loader->exec->rasterizer_version != 35 )
{
loader->exec->rasterizer_version = 35;
loader->exec->size->cvt_ready = FALSE;
tt_size_ready_bytecode( loader->exec->size,
FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
loader->exec->size->cvt_ready = FALSE;
tt_size_ready_bytecode(
loader->exec->size,
FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
}
else loader->exec->rasterizer_version = 35;
else
loader->exec->rasterizer_version = 35;
}
else
{
if ( loader->exec->rasterizer_version != SPH_OPTION_SET_RASTERIZER_VERSION )
if ( loader->exec->rasterizer_version !=
SPH_OPTION_SET_RASTERIZER_VERSION )
{
loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
loader->exec->size->cvt_ready = FALSE;
tt_size_ready_bytecode( loader->exec->size,
FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
loader->exec->size->cvt_ready = FALSE;
tt_size_ready_bytecode(
loader->exec->size,
FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
}
else loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
else
loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
}
if ( IS_HINTED( loader->load_flags ) )

View File

@ -34,14 +34,14 @@ FT_BEGIN_HEADER
/* ID flags to identify special functions at FDEF and runtime. */
/* */
/* */
#define SPH_FDEF_INLINE_DELTA_1 0x0000001
#define SPH_FDEF_INLINE_DELTA_2 0x0000002
#define SPH_FDEF_DIAGONAL_STROKE 0x0000004
#define SPH_FDEF_VACUFORM_ROUND_1 0x0000008
#define SPH_FDEF_TTFAUTOHINT_1 0x0000010
#define SPH_FDEF_SPACING_1 0x0000020
#define SPH_FDEF_SPACING_2 0x0000040
#define SPH_FDEF_TYPEMAN_STROKES 0x0000080
#define SPH_FDEF_INLINE_DELTA_1 0x0000001
#define SPH_FDEF_INLINE_DELTA_2 0x0000002
#define SPH_FDEF_DIAGONAL_STROKE 0x0000004
#define SPH_FDEF_VACUFORM_ROUND_1 0x0000008
#define SPH_FDEF_TTFAUTOHINT_1 0x0000010
#define SPH_FDEF_SPACING_1 0x0000020
#define SPH_FDEF_SPACING_2 0x0000040
#define SPH_FDEF_TYPEMAN_STROKES 0x0000080
/*************************************************************************/