1999-12-17 00:11:37 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ttinterp.c */
|
|
|
|
/* */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* TrueType bytecode interpreter (body). */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2018-01-02 09:33:57 +01:00
|
|
|
/* Copyright 1996-2018 by */
|
2015-01-17 20:11:10 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2011-08-05 09:07:21 +02:00
|
|
|
/* Greg Hitchcock from Microsoft has helped a lot in resolving unclear */
|
|
|
|
/* issues; many thanks! */
|
|
|
|
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_CALC_H
|
2001-06-14 14:34:00 +02:00
|
|
|
#include FT_TRIGONOMETRY_H
|
2000-12-08 03:42:29 +01:00
|
|
|
#include FT_SYSTEM_H
|
New `ftdriver.h' file, covering all driver modules.
This reduces redundancy and increases synergy; it also reduces the
number of header files.
* include/freetype/config/ftheader.h (FT_DRIVER_H): New macro.
(FT_AUTOHINTER_H, FT_CFF_DRIVER_H, FT_TRUETYPE_DRIVER_H,
FT_PCF_DRIVER_H, FT_TYPE1_DRIVER_H): Make them aliases to
FT_DRIVER_H.
* include/freetype/ftautoh.h, include/freetype/ftcffdrv.h,
include/freetype/ftpcfdrv.h, include/freetype/ftt1drv.h,
include/freetype/ftttdrv.h: Replaced with...
* include/freetype/ftdriver.h: ...this new file.
(FT_CFF_HINTING_ADOBE, FT_T1_HINTING_ADOBE): Renamed to...
(FT_HINTING_ADOBE): ... this new macro.
(FT_CFF_HINTING_FREETYPE, FT_T1_HINTING_FREETYPE): Renamed to...
(FT_HINTING_FREETYPE): ... this new macro.
* src/*/*: Updated accordingly.
2017-12-08 18:38:41 +01:00
|
|
|
#include FT_DRIVER_H
|
2016-07-16 18:46:28 +02:00
|
|
|
#include FT_MULTIPLE_MASTERS_H
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "ttinterp.h"
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "tterrors.h"
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
#include "ttsubpix.h"
|
2016-09-08 08:56:34 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
#include "ttgxvar.h"
|
|
|
|
#endif
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2006-08-26 00:45:13 +02:00
|
|
|
#ifdef TT_USE_BYTECODE_INTERPRETER
|
2000-02-10 19:08:17 +01:00
|
|
|
|
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
#undef FT_COMPONENT
|
2000-06-12 21:36:41 +02:00
|
|
|
#define FT_COMPONENT trace_ttinterp
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#define NO_SUBPIXEL_HINTING \
|
|
|
|
( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
|
|
|
|
TT_INTERPRETER_VERSION_35 )
|
|
|
|
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
#define SUBPIXEL_HINTING_INFINALITY \
|
2015-01-10 19:56:28 +01:00
|
|
|
( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
|
2013-05-17 13:51:07 +02:00
|
|
|
TT_INTERPRETER_VERSION_38 )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
|
|
|
#define SUBPIXEL_HINTING_MINIMAL \
|
|
|
|
( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
|
|
|
|
TT_INTERPRETER_VERSION_40 )
|
|
|
|
#endif
|
2013-05-17 13:51:07 +02:00
|
|
|
|
2017-06-09 11:21:58 +02:00
|
|
|
#define PROJECT( v1, v2 ) \
|
|
|
|
exc->func_project( exc, \
|
|
|
|
SUB_LONG( (v1)->x, (v2)->x ), \
|
|
|
|
SUB_LONG( (v1)->y, (v2)->y ) )
|
2017-06-07 17:08:01 +02:00
|
|
|
|
2017-06-09 11:21:58 +02:00
|
|
|
#define DUALPROJ( v1, v2 ) \
|
|
|
|
exc->func_dualproj( exc, \
|
|
|
|
SUB_LONG( (v1)->x, (v2)->x ), \
|
|
|
|
SUB_LONG( (v1)->y, (v2)->y ) )
|
2014-09-03 04:38:59 +02:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
#define FAST_PROJECT( v ) \
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_project( exc, (v)->x, (v)->y )
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
#define FAST_DUALPROJ( v ) \
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_dualproj( exc, (v)->x, (v)->y )
|
2007-02-12 16:24:51 +01:00
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2010-08-06 00:47:57 +02:00
|
|
|
/* Two simple bounds-checking macros. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2010-08-06 00:47:57 +02:00
|
|
|
#define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) )
|
|
|
|
#define BOUNDSL( x, n ) ( (FT_ULong)(x) >= (FT_ULong)(n) )
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
#undef SUCCESS
|
|
|
|
#define SUCCESS 0
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
#undef FAILURE
|
|
|
|
#define FAILURE 1
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* CODERANGE FUNCTIONS */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <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. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
|
|
|
/* IP :: The new IP in the new code range. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* exec :: The target execution context. */
|
|
|
|
/* */
|
[Savannah bug #43682] Change some signatures to `void' return type.
* include/internal/pshints.h (PSH_Globals_SetScaleFunc),
include/internal/sfnt.h (TT_Get_Metrics_Func),
src/pshinter/pshglob.c (psh_globals_set_scale),
src/pshinter/pshrec.c (ps_hints_init), src/sfnt/ttmtx.c
(tt_face_get_metrics), src/truetype/ttinterp.c (TT_Goto_CodeRange,
TT_Set_CodeRange, TT_Clear_CodeRange, TT_Done_Context,
TT_Save_Context): Do it.
* src/pshinter/pshglob.h, src/pshinter/pshrec.h, src/sfnt/ttmtx.h,
src/truetype/ttgload.c (TT_Hint_Glyph), src/truetype/ttinterp.c
(TT_Run_Context), src/truetype/ttinterp.h, src/truetype/ttobjs.c
(tt_size_run_fpgm, tt_size_run_prep): Updated.
2014-11-25 08:14:15 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
2001-06-28 09:17:51 +02:00
|
|
|
TT_Goto_CodeRange( TT_ExecContext exec,
|
|
|
|
FT_Int range,
|
|
|
|
FT_Long IP )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
TT_CodeRange* coderange;
|
|
|
|
|
|
|
|
|
2002-03-29 08:43:04 +01:00
|
|
|
FT_ASSERT( range >= 1 && range <= 3 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
coderange = &exec->codeRangeTable[range - 1];
|
|
|
|
|
2016-12-26 17:08:17 +01:00
|
|
|
FT_ASSERT( coderange->base );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* NOTE: Because the last instruction of a program may be a CALL */
|
|
|
|
/* which will return to the first byte *after* the code */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* range, we test for IP <= Size instead of IP < Size. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2015-02-17 09:21:26 +01:00
|
|
|
FT_ASSERT( IP <= coderange->size );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
exec->code = coderange->base;
|
|
|
|
exec->codeSize = coderange->size;
|
|
|
|
exec->IP = IP;
|
|
|
|
exec->curRange = range;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Set_CodeRange */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Sets a code range. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* range :: The code range index. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* base :: The new code base. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* length :: The range size in bytes. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* exec :: The target execution context. */
|
|
|
|
/* */
|
[Savannah bug #43682] Change some signatures to `void' return type.
* include/internal/pshints.h (PSH_Globals_SetScaleFunc),
include/internal/sfnt.h (TT_Get_Metrics_Func),
src/pshinter/pshglob.c (psh_globals_set_scale),
src/pshinter/pshrec.c (ps_hints_init), src/sfnt/ttmtx.c
(tt_face_get_metrics), src/truetype/ttinterp.c (TT_Goto_CodeRange,
TT_Set_CodeRange, TT_Clear_CodeRange, TT_Done_Context,
TT_Save_Context): Do it.
* src/pshinter/pshglob.h, src/pshinter/pshrec.h, src/sfnt/ttmtx.h,
src/truetype/ttgload.c (TT_Hint_Glyph), src/truetype/ttinterp.c
(TT_Run_Context), src/truetype/ttinterp.h, src/truetype/ttobjs.c
(tt_size_run_fpgm, tt_size_run_prep): Updated.
2014-11-25 08:14:15 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
2001-06-28 09:17:51 +02:00
|
|
|
TT_Set_CodeRange( TT_ExecContext exec,
|
|
|
|
FT_Int range,
|
|
|
|
void* base,
|
|
|
|
FT_Long length )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-29 08:43:04 +01:00
|
|
|
FT_ASSERT( range >= 1 && range <= 3 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
exec->codeRangeTable[range - 1].base = (FT_Byte*)base;
|
1999-12-17 00:11:37 +01:00
|
|
|
exec->codeRangeTable[range - 1].size = length;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Clear_CodeRange */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Clears a code range. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* range :: The code range index. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* exec :: The target execution context. */
|
|
|
|
/* */
|
[Savannah bug #43682] Change some signatures to `void' return type.
* include/internal/pshints.h (PSH_Globals_SetScaleFunc),
include/internal/sfnt.h (TT_Get_Metrics_Func),
src/pshinter/pshglob.c (psh_globals_set_scale),
src/pshinter/pshrec.c (ps_hints_init), src/sfnt/ttmtx.c
(tt_face_get_metrics), src/truetype/ttinterp.c (TT_Goto_CodeRange,
TT_Set_CodeRange, TT_Clear_CodeRange, TT_Done_Context,
TT_Save_Context): Do it.
* src/pshinter/pshglob.h, src/pshinter/pshrec.h, src/sfnt/ttmtx.h,
src/truetype/ttgload.c (TT_Hint_Glyph), src/truetype/ttinterp.c
(TT_Run_Context), src/truetype/ttinterp.h, src/truetype/ttobjs.c
(tt_size_run_fpgm, tt_size_run_prep): Updated.
2014-11-25 08:14:15 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
2001-06-28 09:17:51 +02:00
|
|
|
TT_Clear_CodeRange( TT_ExecContext exec,
|
|
|
|
FT_Int range )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-29 08:43:04 +01:00
|
|
|
FT_ASSERT( range >= 1 && range <= 3 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
exec->codeRangeTable[range - 1].base = NULL;
|
|
|
|
exec->codeRangeTable[range - 1].size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* EXECUTION CONTEXT ROUTINES */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2005-08-16 03:54:59 +02:00
|
|
|
/* TT_Done_Context */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Destroys a given context. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* exec :: A handle to the target execution context. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
|
|
|
/* memory :: A handle to the parent memory object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* Only the glyph loader and debugger should call this function. */
|
|
|
|
/* */
|
[Savannah bug #43682] Change some signatures to `void' return type.
* include/internal/pshints.h (PSH_Globals_SetScaleFunc),
include/internal/sfnt.h (TT_Get_Metrics_Func),
src/pshinter/pshglob.c (psh_globals_set_scale),
src/pshinter/pshrec.c (ps_hints_init), src/sfnt/ttmtx.c
(tt_face_get_metrics), src/truetype/ttinterp.c (TT_Goto_CodeRange,
TT_Set_CodeRange, TT_Clear_CodeRange, TT_Done_Context,
TT_Save_Context): Do it.
* src/pshinter/pshglob.h, src/pshinter/pshrec.h, src/sfnt/ttmtx.h,
src/truetype/ttgload.c (TT_Hint_Glyph), src/truetype/ttinterp.c
(TT_Run_Context), src/truetype/ttinterp.h, src/truetype/ttobjs.c
(tt_size_run_fpgm, tt_size_run_prep): Updated.
2014-11-25 08:14:15 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
2005-08-16 03:54:59 +02:00
|
|
|
TT_Done_Context( TT_ExecContext exec )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2005-08-16 03:54:59 +02:00
|
|
|
FT_Memory memory = exec->memory;
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* points zone */
|
|
|
|
exec->maxPoints = 0;
|
|
|
|
exec->maxContours = 0;
|
|
|
|
|
|
|
|
/* free stack */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( exec->stack );
|
1999-12-17 00:11:37 +01:00
|
|
|
exec->stackSize = 0;
|
|
|
|
|
|
|
|
/* free call stack */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( exec->callStack );
|
1999-12-17 00:11:37 +01:00
|
|
|
exec->callSize = 0;
|
|
|
|
exec->callTop = 0;
|
|
|
|
|
|
|
|
/* free glyph code range */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( exec->glyphIns );
|
1999-12-17 00:11:37 +01:00
|
|
|
exec->glyphSize = 0;
|
|
|
|
|
|
|
|
exec->size = NULL;
|
|
|
|
exec->face = NULL;
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( exec );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Init_Context */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Initializes a context object. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* memory :: A handle to the parent memory object. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* exec :: A handle to the target execution context. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_Error
|
|
|
|
Init_Context( TT_ExecContext exec,
|
|
|
|
FT_Memory memory )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2005-08-16 03:54:59 +02:00
|
|
|
FT_TRACE1(( "Init_Context: new object at 0x%08p\n", exec ));
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
exec->memory = memory;
|
|
|
|
exec->callSize = 32;
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Fail_Memory;
|
|
|
|
|
|
|
|
/* all values in the context are set to 0 already, but this is */
|
|
|
|
/* here as a remainder */
|
|
|
|
exec->maxPoints = 0;
|
|
|
|
exec->maxContours = 0;
|
|
|
|
|
|
|
|
exec->stackSize = 0;
|
|
|
|
exec->glyphSize = 0;
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
exec->stack = NULL;
|
|
|
|
exec->glyphIns = NULL;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2005-08-16 03:54:59 +02:00
|
|
|
exec->face = NULL;
|
1999-12-17 00:11:37 +01:00
|
|
|
exec->size = NULL;
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
Fail_Memory:
|
2010-10-24 17:14:13 +02:00
|
|
|
FT_ERROR(( "Init_Context: not enough memory for %p\n", exec ));
|
2005-08-16 03:54:59 +02:00
|
|
|
TT_Done_Context( exec );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Update_Max */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Checks the size of a buffer and reallocates it if necessary. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* memory :: A handle to the parent memory object. */
|
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* multiplier :: The size in bytes of each element in the buffer. */
|
|
|
|
/* */
|
|
|
|
/* new_max :: The new capacity (size) of the buffer. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* size :: The address of the buffer's current size expressed */
|
|
|
|
/* in elements. */
|
|
|
|
/* */
|
|
|
|
/* buff :: The address of the buffer base pointer. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2010-05-20 15:38:00 +02:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2001-06-28 09:17:51 +02:00
|
|
|
Update_Max( FT_Memory memory,
|
|
|
|
FT_ULong* size,
|
2015-02-17 09:21:26 +01:00
|
|
|
FT_ULong multiplier,
|
2007-01-13 01:19:18 +01:00
|
|
|
void* _pbuff,
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_ULong new_max )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
2007-01-13 01:19:18 +01:00
|
|
|
void** pbuff = (void**)_pbuff;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( *size < new_max )
|
|
|
|
{
|
2007-01-13 01:19:18 +01:00
|
|
|
if ( FT_REALLOC( *pbuff, *size * multiplier, new_max * multiplier ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
return error;
|
|
|
|
*size = new_max;
|
|
|
|
}
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Load_Context */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Prepare an execution context for glyph hinting. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to the source face object. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* size :: A handle to the source size object. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* exec :: A handle to the target execution context. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* Only the glyph loader and debugger should call this function. */
|
|
|
|
/* */
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2001-06-28 09:17:51 +02:00
|
|
|
TT_Load_Context( TT_ExecContext exec,
|
|
|
|
TT_Face face,
|
|
|
|
TT_Size size )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int i;
|
|
|
|
FT_ULong tmp;
|
1999-12-17 00:11:37 +01:00
|
|
|
TT_MaxProfile* maxp;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
exec->face = face;
|
|
|
|
maxp = &face->max_profile;
|
|
|
|
exec->size = size;
|
|
|
|
|
|
|
|
if ( size )
|
|
|
|
{
|
|
|
|
exec->numFDefs = size->num_function_defs;
|
|
|
|
exec->maxFDefs = size->max_function_defs;
|
|
|
|
exec->numIDefs = size->num_instruction_defs;
|
|
|
|
exec->maxIDefs = size->max_instruction_defs;
|
|
|
|
exec->FDefs = size->function_defs;
|
|
|
|
exec->IDefs = size->instruction_defs;
|
2016-08-22 19:32:34 +02:00
|
|
|
exec->pointSize = size->point_size;
|
1999-12-17 00:11:37 +01:00
|
|
|
exec->tt_metrics = size->ttmetrics;
|
2017-04-22 23:02:21 +02:00
|
|
|
exec->metrics = *size->metrics;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
exec->maxFunc = size->max_func;
|
|
|
|
exec->maxIns = size->max_ins;
|
|
|
|
|
|
|
|
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
|
|
|
|
exec->codeRangeTable[i] = size->codeRangeTable[i];
|
|
|
|
|
|
|
|
/* set graphics state */
|
|
|
|
exec->GS = size->GS;
|
|
|
|
|
|
|
|
exec->cvtSize = size->cvt_size;
|
|
|
|
exec->cvt = size->cvt;
|
|
|
|
|
|
|
|
exec->storeSize = size->storage_size;
|
|
|
|
exec->storage = size->storage;
|
|
|
|
|
|
|
|
exec->twilight = size->twilight;
|
2010-11-26 11:58:08 +01:00
|
|
|
|
|
|
|
/* In case of multi-threading it can happen that the old size object */
|
|
|
|
/* no longer exists, thus we must clear all glyph zone references. */
|
2016-09-28 19:06:21 +02:00
|
|
|
FT_ZERO( &exec->zp0 );
|
2010-11-26 11:58:08 +01:00
|
|
|
exec->zp1 = exec->zp0;
|
|
|
|
exec->zp2 = exec->zp0;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: We reserve a little more elements on the stack to deal safely */
|
|
|
|
/* with broken fonts like arialbs, courbs, timesbs, etc. */
|
2015-02-17 09:21:26 +01:00
|
|
|
tmp = (FT_ULong)exec->stackSize;
|
1999-12-17 00:11:37 +01:00
|
|
|
error = Update_Max( exec->memory,
|
|
|
|
&tmp,
|
2000-06-16 21:34:52 +02:00
|
|
|
sizeof ( FT_F26Dot6 ),
|
2007-01-13 01:19:18 +01:00
|
|
|
(void*)&exec->stack,
|
1999-12-17 00:11:37 +01:00
|
|
|
maxp->maxStackElements + 32 );
|
2015-02-17 09:21:26 +01:00
|
|
|
exec->stackSize = (FT_Long)tmp;
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( error )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
tmp = exec->glyphSize;
|
|
|
|
error = Update_Max( exec->memory,
|
|
|
|
&tmp,
|
2000-06-16 21:34:52 +02:00
|
|
|
sizeof ( FT_Byte ),
|
2007-01-13 01:19:18 +01:00
|
|
|
(void*)&exec->glyphIns,
|
1999-12-17 00:11:37 +01:00
|
|
|
maxp->maxSizeOfInstructions );
|
2000-06-16 21:34:52 +02:00
|
|
|
exec->glyphSize = (FT_UShort)tmp;
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( error )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
exec->pts.n_points = 0;
|
|
|
|
exec->pts.n_contours = 0;
|
2007-06-17 07:31:23 +02:00
|
|
|
|
2007-06-16 19:07:20 +02:00
|
|
|
exec->zp1 = exec->pts;
|
|
|
|
exec->zp2 = exec->pts;
|
|
|
|
exec->zp0 = exec->pts;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
exec->instruction_trap = FALSE;
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Save_Context */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Saves the code ranges in a `size' object. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* exec :: A handle to the source execution context. */
|
|
|
|
/* */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* <InOut> */
|
|
|
|
/* size :: A handle to the target size object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* Only the glyph loader and debugger should call this function. */
|
|
|
|
/* */
|
[Savannah bug #43682] Change some signatures to `void' return type.
* include/internal/pshints.h (PSH_Globals_SetScaleFunc),
include/internal/sfnt.h (TT_Get_Metrics_Func),
src/pshinter/pshglob.c (psh_globals_set_scale),
src/pshinter/pshrec.c (ps_hints_init), src/sfnt/ttmtx.c
(tt_face_get_metrics), src/truetype/ttinterp.c (TT_Goto_CodeRange,
TT_Set_CodeRange, TT_Clear_CodeRange, TT_Done_Context,
TT_Save_Context): Do it.
* src/pshinter/pshglob.h, src/pshinter/pshrec.h, src/sfnt/ttmtx.h,
src/truetype/ttgload.c (TT_Hint_Glyph), src/truetype/ttinterp.c
(TT_Run_Context), src/truetype/ttinterp.h, src/truetype/ttobjs.c
(tt_size_run_fpgm, tt_size_run_prep): Updated.
2014-11-25 08:14:15 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
2001-06-28 09:17:51 +02:00
|
|
|
TT_Save_Context( TT_ExecContext exec,
|
|
|
|
TT_Size size )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int i;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2011-08-05 09:07:21 +02:00
|
|
|
/* XXX: Will probably disappear soon with all the code range */
|
|
|
|
/* management, which is now rather obsolete. */
|
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
size->num_function_defs = exec->numFDefs;
|
|
|
|
size->num_instruction_defs = exec->numIDefs;
|
|
|
|
|
|
|
|
size->max_func = exec->maxFunc;
|
|
|
|
size->max_ins = exec->maxIns;
|
|
|
|
|
|
|
|
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
|
|
|
|
size->codeRangeTable[i] = exec->codeRangeTable[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Run_Context */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Executes one or more instructions in the execution context. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* debug :: A Boolean flag. If set, the function sets some internal */
|
|
|
|
/* variables and returns immediately, otherwise TT_RunIns() */
|
|
|
|
/* is called. */
|
|
|
|
/* */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* This is commented out currently. */
|
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* <Input> */
|
|
|
|
/* exec :: A handle to the target execution context. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2008-06-22 15:40:08 +02:00
|
|
|
/* TrueType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2015-01-14 17:46:55 +01:00
|
|
|
TT_Run_Context( TT_ExecContext exec )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[Savannah bug #43682] Change some signatures to `void' return type.
* include/internal/pshints.h (PSH_Globals_SetScaleFunc),
include/internal/sfnt.h (TT_Get_Metrics_Func),
src/pshinter/pshglob.c (psh_globals_set_scale),
src/pshinter/pshrec.c (ps_hints_init), src/sfnt/ttmtx.c
(tt_face_get_metrics), src/truetype/ttinterp.c (TT_Goto_CodeRange,
TT_Set_CodeRange, TT_Clear_CodeRange, TT_Done_Context,
TT_Save_Context): Do it.
* src/pshinter/pshglob.h, src/pshinter/pshrec.h, src/sfnt/ttmtx.h,
src/truetype/ttgload.c (TT_Hint_Glyph), src/truetype/ttinterp.c
(TT_Run_Context), src/truetype/ttinterp.h, src/truetype/ttobjs.c
(tt_size_run_fpgm, tt_size_run_prep): Updated.
2014-11-25 08:14:15 +01:00
|
|
|
TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
exec->zp0 = exec->pts;
|
|
|
|
exec->zp1 = exec->pts;
|
|
|
|
exec->zp2 = exec->pts;
|
|
|
|
|
|
|
|
exec->GS.gep0 = 1;
|
|
|
|
exec->GS.gep1 = 1;
|
|
|
|
exec->GS.gep2 = 1;
|
|
|
|
|
|
|
|
exec->GS.projVector.x = 0x4000;
|
|
|
|
exec->GS.projVector.y = 0x0000;
|
|
|
|
|
|
|
|
exec->GS.freeVector = exec->GS.projVector;
|
|
|
|
exec->GS.dualVector = exec->GS.projVector;
|
|
|
|
|
|
|
|
exec->GS.round_state = 1;
|
|
|
|
exec->GS.loop = 1;
|
|
|
|
|
|
|
|
/* some glyphs leave something on the stack. so we clean it */
|
|
|
|
/* before a new execution. */
|
|
|
|
exec->top = 0;
|
|
|
|
exec->callTop = 0;
|
|
|
|
|
|
|
|
return exec->face->interpreter( exec );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-15 11:35:51 +01:00
|
|
|
/* The default value for `scan_control' is documented as FALSE in the */
|
|
|
|
/* TrueType specification. This is confusing since it implies a */
|
|
|
|
/* Boolean value. However, this is not the case, thus both the */
|
|
|
|
/* default values of our `scan_type' and `scan_control' fields (which */
|
|
|
|
/* the documentation's `scan_control' variable is split into) are */
|
|
|
|
/* zero. */
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
const TT_GraphicsState tt_default_graphics_state =
|
|
|
|
{
|
|
|
|
0, 0, 0,
|
|
|
|
{ 0x4000, 0 },
|
|
|
|
{ 0x4000, 0 },
|
|
|
|
{ 0x4000, 0 },
|
2003-04-25 13:40:46 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
1, 64, 1,
|
|
|
|
TRUE, 68, 0, 0, 9, 3,
|
2008-11-15 11:35:51 +01:00
|
|
|
0, FALSE, 0, 1, 1, 1
|
1999-12-17 00:11:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ttinterp.h */
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_EXPORT_DEF( TT_ExecContext )
|
2005-08-16 03:54:59 +02:00
|
|
|
TT_New_Context( TT_Driver driver )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2014-11-26 21:59:21 +01:00
|
|
|
FT_Memory memory;
|
2015-01-14 17:46:55 +01:00
|
|
|
FT_Error error;
|
|
|
|
|
* Version 2.6 released.
=======================
Tag sources with `VER-2-6'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.6.
* README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
builds/windows/vc2005/index.html,
builds/windows/vc2008/freetype.vcproj,
builds/windows/vc2008/index.html,
builds/windows/vc2010/freetype.vcxproj,
builds/windows/vc2010/index.html,
builds/windows/visualc/freetype.dsp,
builds/windows/visualc/freetype.vcproj,
builds/windows/visualc/index.html,
builds/windows/visualce/freetype.dsp,
builds/windows/visualce/freetype.vcproj,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.5.5/2.6/, s/255/26/.
* include/freetype/freetype.h (FREETYPE_MINOR): Set to 6.
(FREETYPE_PATCH): Set to 0.
* builds/unix/configure.raw (version_info): Set to 18:0:12.
* CMakeLists.txt (VERSION_MINOR): Set to 0.
(VERSION_PATCH): Set to 6.
* src/autofit/afmodule.c [!FT_MAKE_OPTION_SINGLE_OBJECT]: Add
declarations for dumping functions.
* src/truetype/ttinterp.c (TT_New_Context): Pacify compiler.
* builds/toplevel.mk: Use `freetype.mk's code to compute the version
string.
Don't include a zero patch level in version string.
* builds/freetype.mk: Remove code for computing the version string.
2015-06-07 16:11:18 +02:00
|
|
|
TT_ExecContext exec = NULL;
|
2000-06-12 21:36:41 +02:00
|
|
|
|
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
if ( !driver )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
memory = driver->root.root.memory;
|
|
|
|
|
2015-01-14 17:46:55 +01:00
|
|
|
/* allocate object */
|
|
|
|
if ( FT_NEW( exec ) )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-14 17:46:55 +01:00
|
|
|
/* initialize it; in case of error this deallocates `exec' too */
|
|
|
|
error = Init_Context( exec, memory );
|
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-14 17:46:55 +01:00
|
|
|
return exec;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
Fail:
|
2009-06-07 13:09:21 +02:00
|
|
|
return NULL;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Before an opcode is executed, the interpreter verifies that there are */
|
2004-10-09 09:07:43 +02:00
|
|
|
/* enough arguments on the stack, with the help of the `Pop_Push_Count' */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* table. */
|
|
|
|
/* */
|
|
|
|
/* For each opcode, the first column gives the number of arguments that */
|
|
|
|
/* are popped from the stack; the second one gives the number of those */
|
|
|
|
/* that are pushed in result. */
|
|
|
|
/* */
|
2004-10-09 09:07:43 +02:00
|
|
|
/* Opcodes which have a varying number of parameters in the data stream */
|
|
|
|
/* (NPUSHB, NPUSHW) are handled specially; they have a negative value in */
|
|
|
|
/* the `opcode_length' table, and the value in `Pop_Push_Count' is set */
|
|
|
|
/* to zero. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#undef PACK
|
2000-06-12 21:36:41 +02:00
|
|
|
#define PACK( x, y ) ( ( x << 4 ) | y )
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
static
|
2000-06-16 21:34:52 +02:00
|
|
|
const FT_Byte Pop_Push_Count[256] =
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
/* opcodes are gathered in groups of 16 */
|
|
|
|
/* please keep the spaces as they are */
|
|
|
|
|
|
|
|
/* SVTCA y */ PACK( 0, 0 ),
|
|
|
|
/* SVTCA x */ PACK( 0, 0 ),
|
|
|
|
/* SPvTCA y */ PACK( 0, 0 ),
|
|
|
|
/* SPvTCA x */ PACK( 0, 0 ),
|
|
|
|
/* SFvTCA y */ PACK( 0, 0 ),
|
|
|
|
/* SFvTCA x */ PACK( 0, 0 ),
|
|
|
|
/* SPvTL // */ PACK( 2, 0 ),
|
|
|
|
/* SPvTL + */ PACK( 2, 0 ),
|
|
|
|
/* SFvTL // */ PACK( 2, 0 ),
|
|
|
|
/* SFvTL + */ PACK( 2, 0 ),
|
|
|
|
/* SPvFS */ PACK( 2, 0 ),
|
|
|
|
/* SFvFS */ PACK( 2, 0 ),
|
2015-01-11 00:56:55 +01:00
|
|
|
/* GPv */ PACK( 0, 2 ),
|
|
|
|
/* GFv */ PACK( 0, 2 ),
|
1999-12-17 00:11:37 +01:00
|
|
|
/* SFvTPv */ PACK( 0, 0 ),
|
|
|
|
/* ISECT */ PACK( 5, 0 ),
|
|
|
|
|
|
|
|
/* SRP0 */ PACK( 1, 0 ),
|
|
|
|
/* SRP1 */ PACK( 1, 0 ),
|
|
|
|
/* SRP2 */ PACK( 1, 0 ),
|
|
|
|
/* SZP0 */ PACK( 1, 0 ),
|
|
|
|
/* SZP1 */ PACK( 1, 0 ),
|
|
|
|
/* SZP2 */ PACK( 1, 0 ),
|
|
|
|
/* SZPS */ PACK( 1, 0 ),
|
|
|
|
/* SLOOP */ PACK( 1, 0 ),
|
|
|
|
/* RTG */ PACK( 0, 0 ),
|
|
|
|
/* RTHG */ PACK( 0, 0 ),
|
|
|
|
/* SMD */ PACK( 1, 0 ),
|
|
|
|
/* ELSE */ PACK( 0, 0 ),
|
|
|
|
/* JMPR */ PACK( 1, 0 ),
|
|
|
|
/* SCvTCi */ PACK( 1, 0 ),
|
|
|
|
/* SSwCi */ PACK( 1, 0 ),
|
|
|
|
/* SSW */ PACK( 1, 0 ),
|
|
|
|
|
|
|
|
/* DUP */ PACK( 1, 2 ),
|
|
|
|
/* POP */ PACK( 1, 0 ),
|
|
|
|
/* CLEAR */ PACK( 0, 0 ),
|
|
|
|
/* SWAP */ PACK( 2, 2 ),
|
|
|
|
/* DEPTH */ PACK( 0, 1 ),
|
|
|
|
/* CINDEX */ PACK( 1, 1 ),
|
|
|
|
/* MINDEX */ PACK( 1, 0 ),
|
|
|
|
/* AlignPTS */ PACK( 2, 0 ),
|
|
|
|
/* INS_$28 */ PACK( 0, 0 ),
|
|
|
|
/* UTP */ PACK( 1, 0 ),
|
|
|
|
/* LOOPCALL */ PACK( 2, 0 ),
|
|
|
|
/* CALL */ PACK( 1, 0 ),
|
|
|
|
/* FDEF */ PACK( 1, 0 ),
|
|
|
|
/* ENDF */ PACK( 0, 0 ),
|
|
|
|
/* MDAP[0] */ PACK( 1, 0 ),
|
|
|
|
/* MDAP[1] */ PACK( 1, 0 ),
|
|
|
|
|
|
|
|
/* IUP[0] */ PACK( 0, 0 ),
|
|
|
|
/* IUP[1] */ PACK( 0, 0 ),
|
2016-08-12 05:40:05 +02:00
|
|
|
/* SHP[0] */ PACK( 0, 0 ), /* loops */
|
|
|
|
/* SHP[1] */ PACK( 0, 0 ), /* loops */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* SHC[0] */ PACK( 1, 0 ),
|
|
|
|
/* SHC[1] */ PACK( 1, 0 ),
|
|
|
|
/* SHZ[0] */ PACK( 1, 0 ),
|
|
|
|
/* SHZ[1] */ PACK( 1, 0 ),
|
2016-08-12 05:40:05 +02:00
|
|
|
/* SHPIX */ PACK( 1, 0 ), /* loops */
|
|
|
|
/* IP */ PACK( 0, 0 ), /* loops */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* MSIRP[0] */ PACK( 2, 0 ),
|
|
|
|
/* MSIRP[1] */ PACK( 2, 0 ),
|
2016-08-12 05:40:05 +02:00
|
|
|
/* AlignRP */ PACK( 0, 0 ), /* loops */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* RTDG */ PACK( 0, 0 ),
|
|
|
|
/* MIAP[0] */ PACK( 2, 0 ),
|
|
|
|
/* MIAP[1] */ PACK( 2, 0 ),
|
|
|
|
|
|
|
|
/* NPushB */ PACK( 0, 0 ),
|
|
|
|
/* NPushW */ PACK( 0, 0 ),
|
|
|
|
/* WS */ PACK( 2, 0 ),
|
|
|
|
/* RS */ PACK( 1, 1 ),
|
|
|
|
/* WCvtP */ PACK( 2, 0 ),
|
|
|
|
/* RCvt */ PACK( 1, 1 ),
|
|
|
|
/* GC[0] */ PACK( 1, 1 ),
|
|
|
|
/* GC[1] */ PACK( 1, 1 ),
|
|
|
|
/* SCFS */ PACK( 2, 0 ),
|
|
|
|
/* MD[0] */ PACK( 2, 1 ),
|
|
|
|
/* MD[1] */ PACK( 2, 1 ),
|
|
|
|
/* MPPEM */ PACK( 0, 1 ),
|
|
|
|
/* MPS */ PACK( 0, 1 ),
|
|
|
|
/* FlipON */ PACK( 0, 0 ),
|
|
|
|
/* FlipOFF */ PACK( 0, 0 ),
|
|
|
|
/* DEBUG */ PACK( 1, 0 ),
|
|
|
|
|
|
|
|
/* LT */ PACK( 2, 1 ),
|
|
|
|
/* LTEQ */ PACK( 2, 1 ),
|
|
|
|
/* GT */ PACK( 2, 1 ),
|
|
|
|
/* GTEQ */ PACK( 2, 1 ),
|
|
|
|
/* EQ */ PACK( 2, 1 ),
|
|
|
|
/* NEQ */ PACK( 2, 1 ),
|
|
|
|
/* ODD */ PACK( 1, 1 ),
|
|
|
|
/* EVEN */ PACK( 1, 1 ),
|
|
|
|
/* IF */ PACK( 1, 0 ),
|
|
|
|
/* EIF */ PACK( 0, 0 ),
|
|
|
|
/* AND */ PACK( 2, 1 ),
|
|
|
|
/* OR */ PACK( 2, 1 ),
|
|
|
|
/* NOT */ PACK( 1, 1 ),
|
|
|
|
/* DeltaP1 */ PACK( 1, 0 ),
|
|
|
|
/* SDB */ PACK( 1, 0 ),
|
|
|
|
/* SDS */ PACK( 1, 0 ),
|
|
|
|
|
|
|
|
/* ADD */ PACK( 2, 1 ),
|
|
|
|
/* SUB */ PACK( 2, 1 ),
|
|
|
|
/* DIV */ PACK( 2, 1 ),
|
|
|
|
/* MUL */ PACK( 2, 1 ),
|
|
|
|
/* ABS */ PACK( 1, 1 ),
|
|
|
|
/* NEG */ PACK( 1, 1 ),
|
|
|
|
/* FLOOR */ PACK( 1, 1 ),
|
|
|
|
/* CEILING */ PACK( 1, 1 ),
|
|
|
|
/* ROUND[0] */ PACK( 1, 1 ),
|
|
|
|
/* ROUND[1] */ PACK( 1, 1 ),
|
|
|
|
/* ROUND[2] */ PACK( 1, 1 ),
|
|
|
|
/* ROUND[3] */ PACK( 1, 1 ),
|
|
|
|
/* NROUND[0] */ PACK( 1, 1 ),
|
|
|
|
/* NROUND[1] */ PACK( 1, 1 ),
|
|
|
|
/* NROUND[2] */ PACK( 1, 1 ),
|
|
|
|
/* NROUND[3] */ PACK( 1, 1 ),
|
|
|
|
|
|
|
|
/* WCvtF */ PACK( 2, 0 ),
|
|
|
|
/* DeltaP2 */ PACK( 1, 0 ),
|
|
|
|
/* DeltaP3 */ PACK( 1, 0 ),
|
|
|
|
/* DeltaCn[0] */ PACK( 1, 0 ),
|
|
|
|
/* DeltaCn[1] */ PACK( 1, 0 ),
|
|
|
|
/* DeltaCn[2] */ PACK( 1, 0 ),
|
|
|
|
/* SROUND */ PACK( 1, 0 ),
|
|
|
|
/* S45Round */ PACK( 1, 0 ),
|
|
|
|
/* JROT */ PACK( 2, 0 ),
|
|
|
|
/* JROF */ PACK( 2, 0 ),
|
|
|
|
/* ROFF */ PACK( 0, 0 ),
|
|
|
|
/* INS_$7B */ PACK( 0, 0 ),
|
|
|
|
/* RUTG */ PACK( 0, 0 ),
|
|
|
|
/* RDTG */ PACK( 0, 0 ),
|
|
|
|
/* SANGW */ PACK( 1, 0 ),
|
|
|
|
/* AA */ PACK( 1, 0 ),
|
|
|
|
|
2016-08-12 05:40:05 +02:00
|
|
|
/* FlipPT */ PACK( 0, 0 ), /* loops */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* FlipRgON */ PACK( 2, 0 ),
|
|
|
|
/* FlipRgOFF */ PACK( 2, 0 ),
|
|
|
|
/* INS_$83 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$84 */ PACK( 0, 0 ),
|
|
|
|
/* ScanCTRL */ PACK( 1, 0 ),
|
2015-01-11 00:56:55 +01:00
|
|
|
/* SDPvTL[0] */ PACK( 2, 0 ),
|
|
|
|
/* SDPvTL[1] */ PACK( 2, 0 ),
|
1999-12-17 00:11:37 +01:00
|
|
|
/* GetINFO */ PACK( 1, 1 ),
|
|
|
|
/* IDEF */ PACK( 1, 0 ),
|
|
|
|
/* ROLL */ PACK( 3, 3 ),
|
|
|
|
/* MAX */ PACK( 2, 1 ),
|
|
|
|
/* MIN */ PACK( 2, 1 ),
|
|
|
|
/* ScanTYPE */ PACK( 1, 0 ),
|
|
|
|
/* InstCTRL */ PACK( 2, 0 ),
|
|
|
|
/* INS_$8F */ PACK( 0, 0 ),
|
|
|
|
|
|
|
|
/* INS_$90 */ PACK( 0, 0 ),
|
2016-07-16 18:46:28 +02:00
|
|
|
/* GETVAR */ PACK( 0, 0 ), /* will be handled specially */
|
2016-07-17 22:40:31 +02:00
|
|
|
/* GETDATA */ PACK( 0, 1 ),
|
1999-12-17 00:11:37 +01:00
|
|
|
/* INS_$93 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$94 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$95 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$96 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$97 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$98 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$99 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$9A */ PACK( 0, 0 ),
|
|
|
|
/* INS_$9B */ PACK( 0, 0 ),
|
|
|
|
/* INS_$9C */ PACK( 0, 0 ),
|
|
|
|
/* INS_$9D */ PACK( 0, 0 ),
|
|
|
|
/* INS_$9E */ PACK( 0, 0 ),
|
|
|
|
/* INS_$9F */ PACK( 0, 0 ),
|
|
|
|
|
|
|
|
/* INS_$A0 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A1 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A2 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A3 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A4 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A5 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A6 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A7 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A8 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$A9 */ PACK( 0, 0 ),
|
|
|
|
/* INS_$AA */ PACK( 0, 0 ),
|
|
|
|
/* INS_$AB */ PACK( 0, 0 ),
|
|
|
|
/* INS_$AC */ PACK( 0, 0 ),
|
|
|
|
/* INS_$AD */ PACK( 0, 0 ),
|
|
|
|
/* INS_$AE */ PACK( 0, 0 ),
|
|
|
|
/* INS_$AF */ PACK( 0, 0 ),
|
|
|
|
|
|
|
|
/* PushB[0] */ PACK( 0, 1 ),
|
|
|
|
/* PushB[1] */ PACK( 0, 2 ),
|
|
|
|
/* PushB[2] */ PACK( 0, 3 ),
|
|
|
|
/* PushB[3] */ PACK( 0, 4 ),
|
|
|
|
/* PushB[4] */ PACK( 0, 5 ),
|
|
|
|
/* PushB[5] */ PACK( 0, 6 ),
|
|
|
|
/* PushB[6] */ PACK( 0, 7 ),
|
|
|
|
/* PushB[7] */ PACK( 0, 8 ),
|
|
|
|
/* PushW[0] */ PACK( 0, 1 ),
|
|
|
|
/* PushW[1] */ PACK( 0, 2 ),
|
|
|
|
/* PushW[2] */ PACK( 0, 3 ),
|
|
|
|
/* PushW[3] */ PACK( 0, 4 ),
|
|
|
|
/* PushW[4] */ PACK( 0, 5 ),
|
|
|
|
/* PushW[5] */ PACK( 0, 6 ),
|
|
|
|
/* PushW[6] */ PACK( 0, 7 ),
|
|
|
|
/* PushW[7] */ PACK( 0, 8 ),
|
|
|
|
|
|
|
|
/* MDRP[00] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[01] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[02] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[03] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[04] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[05] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[06] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[07] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[08] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[09] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[10] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[11] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[12] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[13] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[14] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[15] */ PACK( 1, 0 ),
|
|
|
|
|
|
|
|
/* MDRP[16] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[17] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[18] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[19] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[20] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[21] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[22] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[23] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[24] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[25] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[26] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[27] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[28] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[29] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[30] */ PACK( 1, 0 ),
|
|
|
|
/* MDRP[31] */ PACK( 1, 0 ),
|
|
|
|
|
|
|
|
/* MIRP[00] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[01] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[02] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[03] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[04] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[05] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[06] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[07] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[08] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[09] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[10] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[11] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[12] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[13] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[14] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[15] */ PACK( 2, 0 ),
|
|
|
|
|
|
|
|
/* MIRP[16] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[17] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[18] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[19] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[20] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[21] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[22] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[23] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[24] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[25] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[26] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[27] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[28] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[29] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[30] */ PACK( 2, 0 ),
|
|
|
|
/* MIRP[31] */ PACK( 2, 0 )
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-07-01 11:28:43 +02:00
|
|
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
|
|
|
2015-06-01 12:12:06 +02:00
|
|
|
/* the first hex digit gives the length of the opcode name; the space */
|
|
|
|
/* after the digit is here just to increase readability of the source */
|
|
|
|
/* code */
|
|
|
|
|
2010-07-01 11:28:43 +02:00
|
|
|
static
|
|
|
|
const char* const opcode_name[256] =
|
|
|
|
{
|
2015-06-01 12:12:06 +02:00
|
|
|
"7 SVTCA y",
|
|
|
|
"7 SVTCA x",
|
|
|
|
"8 SPvTCA y",
|
|
|
|
"8 SPvTCA x",
|
|
|
|
"8 SFvTCA y",
|
|
|
|
"8 SFvTCA x",
|
|
|
|
"8 SPvTL ||",
|
|
|
|
"7 SPvTL +",
|
|
|
|
"8 SFvTL ||",
|
|
|
|
"7 SFvTL +",
|
|
|
|
"5 SPvFS",
|
|
|
|
"5 SFvFS",
|
|
|
|
"3 GPv",
|
|
|
|
"3 GFv",
|
|
|
|
"6 SFvTPv",
|
|
|
|
"5 ISECT",
|
|
|
|
|
|
|
|
"4 SRP0",
|
|
|
|
"4 SRP1",
|
|
|
|
"4 SRP2",
|
|
|
|
"4 SZP0",
|
|
|
|
"4 SZP1",
|
|
|
|
"4 SZP2",
|
|
|
|
"4 SZPS",
|
|
|
|
"5 SLOOP",
|
|
|
|
"3 RTG",
|
|
|
|
"4 RTHG",
|
|
|
|
"3 SMD",
|
|
|
|
"4 ELSE",
|
|
|
|
"4 JMPR",
|
|
|
|
"6 SCvTCi",
|
|
|
|
"5 SSwCi",
|
|
|
|
"3 SSW",
|
|
|
|
|
|
|
|
"3 DUP",
|
|
|
|
"3 POP",
|
|
|
|
"5 CLEAR",
|
|
|
|
"4 SWAP",
|
|
|
|
"5 DEPTH",
|
|
|
|
"6 CINDEX",
|
|
|
|
"6 MINDEX",
|
|
|
|
"8 AlignPTS",
|
|
|
|
"7 INS_$28",
|
|
|
|
"3 UTP",
|
|
|
|
"8 LOOPCALL",
|
|
|
|
"4 CALL",
|
|
|
|
"4 FDEF",
|
|
|
|
"4 ENDF",
|
|
|
|
"7 MDAP[0]",
|
|
|
|
"7 MDAP[1]",
|
|
|
|
|
|
|
|
"6 IUP[0]",
|
|
|
|
"6 IUP[1]",
|
|
|
|
"6 SHP[0]",
|
|
|
|
"6 SHP[1]",
|
|
|
|
"6 SHC[0]",
|
|
|
|
"6 SHC[1]",
|
|
|
|
"6 SHZ[0]",
|
|
|
|
"6 SHZ[1]",
|
|
|
|
"5 SHPIX",
|
|
|
|
"2 IP",
|
|
|
|
"8 MSIRP[0]",
|
|
|
|
"8 MSIRP[1]",
|
|
|
|
"7 AlignRP",
|
|
|
|
"4 RTDG",
|
|
|
|
"7 MIAP[0]",
|
|
|
|
"7 MIAP[1]",
|
|
|
|
|
|
|
|
"6 NPushB",
|
|
|
|
"6 NPushW",
|
|
|
|
"2 WS",
|
|
|
|
"2 RS",
|
|
|
|
"5 WCvtP",
|
|
|
|
"4 RCvt",
|
|
|
|
"5 GC[0]",
|
|
|
|
"5 GC[1]",
|
|
|
|
"4 SCFS",
|
|
|
|
"5 MD[0]",
|
|
|
|
"5 MD[1]",
|
|
|
|
"5 MPPEM",
|
|
|
|
"3 MPS",
|
|
|
|
"6 FlipON",
|
|
|
|
"7 FlipOFF",
|
|
|
|
"5 DEBUG",
|
|
|
|
|
|
|
|
"2 LT",
|
|
|
|
"4 LTEQ",
|
|
|
|
"2 GT",
|
|
|
|
"4 GTEQ",
|
|
|
|
"2 EQ",
|
|
|
|
"3 NEQ",
|
|
|
|
"3 ODD",
|
|
|
|
"4 EVEN",
|
|
|
|
"2 IF",
|
|
|
|
"3 EIF",
|
|
|
|
"3 AND",
|
|
|
|
"2 OR",
|
|
|
|
"3 NOT",
|
|
|
|
"7 DeltaP1",
|
|
|
|
"3 SDB",
|
|
|
|
"3 SDS",
|
|
|
|
|
|
|
|
"3 ADD",
|
|
|
|
"3 SUB",
|
|
|
|
"3 DIV",
|
|
|
|
"3 MUL",
|
|
|
|
"3 ABS",
|
|
|
|
"3 NEG",
|
|
|
|
"5 FLOOR",
|
|
|
|
"7 CEILING",
|
|
|
|
"8 ROUND[0]",
|
|
|
|
"8 ROUND[1]",
|
|
|
|
"8 ROUND[2]",
|
|
|
|
"8 ROUND[3]",
|
|
|
|
"9 NROUND[0]",
|
|
|
|
"9 NROUND[1]",
|
|
|
|
"9 NROUND[2]",
|
|
|
|
"9 NROUND[3]",
|
|
|
|
|
|
|
|
"5 WCvtF",
|
|
|
|
"7 DeltaP2",
|
|
|
|
"7 DeltaP3",
|
|
|
|
"A DeltaCn[0]",
|
|
|
|
"A DeltaCn[1]",
|
|
|
|
"A DeltaCn[2]",
|
|
|
|
"6 SROUND",
|
|
|
|
"8 S45Round",
|
|
|
|
"4 JROT",
|
|
|
|
"4 JROF",
|
|
|
|
"4 ROFF",
|
|
|
|
"7 INS_$7B",
|
|
|
|
"4 RUTG",
|
|
|
|
"4 RDTG",
|
|
|
|
"5 SANGW",
|
|
|
|
"2 AA",
|
|
|
|
|
|
|
|
"6 FlipPT",
|
|
|
|
"8 FlipRgON",
|
|
|
|
"9 FlipRgOFF",
|
|
|
|
"7 INS_$83",
|
|
|
|
"7 INS_$84",
|
|
|
|
"8 ScanCTRL",
|
|
|
|
"9 SDPvTL[0]",
|
|
|
|
"9 SDPvTL[1]",
|
|
|
|
"7 GetINFO",
|
|
|
|
"4 IDEF",
|
|
|
|
"4 ROLL",
|
|
|
|
"3 MAX",
|
|
|
|
"3 MIN",
|
|
|
|
"8 ScanTYPE",
|
|
|
|
"8 InstCTRL",
|
|
|
|
"7 INS_$8F",
|
|
|
|
|
|
|
|
"7 INS_$90",
|
2016-07-16 18:46:28 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
"6 GETVAR",
|
2016-07-18 06:23:36 +02:00
|
|
|
"7 GETDATA",
|
2016-07-16 18:46:28 +02:00
|
|
|
#else
|
2015-06-01 12:12:06 +02:00
|
|
|
"7 INS_$91",
|
2016-07-18 06:23:36 +02:00
|
|
|
"7 INS_$92",
|
2016-07-16 18:46:28 +02:00
|
|
|
#endif
|
2015-06-01 12:12:06 +02:00
|
|
|
"7 INS_$93",
|
|
|
|
"7 INS_$94",
|
|
|
|
"7 INS_$95",
|
|
|
|
"7 INS_$96",
|
|
|
|
"7 INS_$97",
|
|
|
|
"7 INS_$98",
|
|
|
|
"7 INS_$99",
|
|
|
|
"7 INS_$9A",
|
|
|
|
"7 INS_$9B",
|
|
|
|
"7 INS_$9C",
|
|
|
|
"7 INS_$9D",
|
|
|
|
"7 INS_$9E",
|
|
|
|
"7 INS_$9F",
|
|
|
|
|
|
|
|
"7 INS_$A0",
|
|
|
|
"7 INS_$A1",
|
|
|
|
"7 INS_$A2",
|
|
|
|
"7 INS_$A3",
|
|
|
|
"7 INS_$A4",
|
|
|
|
"7 INS_$A5",
|
|
|
|
"7 INS_$A6",
|
|
|
|
"7 INS_$A7",
|
|
|
|
"7 INS_$A8",
|
|
|
|
"7 INS_$A9",
|
|
|
|
"7 INS_$AA",
|
|
|
|
"7 INS_$AB",
|
|
|
|
"7 INS_$AC",
|
|
|
|
"7 INS_$AD",
|
|
|
|
"7 INS_$AE",
|
|
|
|
"7 INS_$AF",
|
|
|
|
|
|
|
|
"8 PushB[0]",
|
|
|
|
"8 PushB[1]",
|
|
|
|
"8 PushB[2]",
|
|
|
|
"8 PushB[3]",
|
|
|
|
"8 PushB[4]",
|
|
|
|
"8 PushB[5]",
|
|
|
|
"8 PushB[6]",
|
|
|
|
"8 PushB[7]",
|
|
|
|
"8 PushW[0]",
|
|
|
|
"8 PushW[1]",
|
|
|
|
"8 PushW[2]",
|
|
|
|
"8 PushW[3]",
|
|
|
|
"8 PushW[4]",
|
|
|
|
"8 PushW[5]",
|
|
|
|
"8 PushW[6]",
|
|
|
|
"8 PushW[7]",
|
|
|
|
|
|
|
|
"8 MDRP[00]",
|
|
|
|
"8 MDRP[01]",
|
|
|
|
"8 MDRP[02]",
|
|
|
|
"8 MDRP[03]",
|
|
|
|
"8 MDRP[04]",
|
|
|
|
"8 MDRP[05]",
|
|
|
|
"8 MDRP[06]",
|
|
|
|
"8 MDRP[07]",
|
|
|
|
"8 MDRP[08]",
|
|
|
|
"8 MDRP[09]",
|
|
|
|
"8 MDRP[10]",
|
|
|
|
"8 MDRP[11]",
|
|
|
|
"8 MDRP[12]",
|
|
|
|
"8 MDRP[13]",
|
|
|
|
"8 MDRP[14]",
|
|
|
|
"8 MDRP[15]",
|
|
|
|
|
|
|
|
"8 MDRP[16]",
|
|
|
|
"8 MDRP[17]",
|
|
|
|
"8 MDRP[18]",
|
|
|
|
"8 MDRP[19]",
|
|
|
|
"8 MDRP[20]",
|
|
|
|
"8 MDRP[21]",
|
|
|
|
"8 MDRP[22]",
|
|
|
|
"8 MDRP[23]",
|
|
|
|
"8 MDRP[24]",
|
|
|
|
"8 MDRP[25]",
|
|
|
|
"8 MDRP[26]",
|
|
|
|
"8 MDRP[27]",
|
|
|
|
"8 MDRP[28]",
|
|
|
|
"8 MDRP[29]",
|
|
|
|
"8 MDRP[30]",
|
|
|
|
"8 MDRP[31]",
|
|
|
|
|
|
|
|
"8 MIRP[00]",
|
|
|
|
"8 MIRP[01]",
|
|
|
|
"8 MIRP[02]",
|
|
|
|
"8 MIRP[03]",
|
|
|
|
"8 MIRP[04]",
|
|
|
|
"8 MIRP[05]",
|
|
|
|
"8 MIRP[06]",
|
|
|
|
"8 MIRP[07]",
|
|
|
|
"8 MIRP[08]",
|
|
|
|
"8 MIRP[09]",
|
|
|
|
"8 MIRP[10]",
|
|
|
|
"8 MIRP[11]",
|
|
|
|
"8 MIRP[12]",
|
|
|
|
"8 MIRP[13]",
|
|
|
|
"8 MIRP[14]",
|
|
|
|
"8 MIRP[15]",
|
|
|
|
|
|
|
|
"8 MIRP[16]",
|
|
|
|
"8 MIRP[17]",
|
|
|
|
"8 MIRP[18]",
|
|
|
|
"8 MIRP[19]",
|
|
|
|
"8 MIRP[20]",
|
|
|
|
"8 MIRP[21]",
|
|
|
|
"8 MIRP[22]",
|
|
|
|
"8 MIRP[23]",
|
|
|
|
"8 MIRP[24]",
|
|
|
|
"8 MIRP[25]",
|
|
|
|
"8 MIRP[26]",
|
|
|
|
"8 MIRP[27]",
|
|
|
|
"8 MIRP[28]",
|
|
|
|
"8 MIRP[29]",
|
|
|
|
"8 MIRP[30]",
|
|
|
|
"8 MIRP[31]"
|
2010-07-01 11:28:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* FT_DEBUG_LEVEL_TRACE */
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
static
|
2000-06-16 21:34:52 +02:00
|
|
|
const FT_Char opcode_length[256] =
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
|
2004-10-09 09:07:43 +02:00
|
|
|
-1,-2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1999-12-17 00:11:37 +01:00
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
2, 3, 4, 5, 6, 7, 8, 9, 3, 5, 7, 9, 11,13,15,17,
|
|
|
|
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
|
|
|
};
|
|
|
|
|
2000-07-02 15:53:16 +02:00
|
|
|
#undef PACK
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
|
|
|
|
#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
|
|
|
|
|
|
|
|
#if defined( __arm__ ) && \
|
|
|
|
( defined( __thumb2__ ) || !defined( __thumb__ ) )
|
|
|
|
|
|
|
|
#define TT_MulFix14 TT_MulFix14_arm
|
2007-02-16 09:10:17 +01:00
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
static FT_Int32
|
|
|
|
TT_MulFix14_arm( FT_Int32 a,
|
|
|
|
FT_Int b )
|
|
|
|
{
|
2014-08-31 08:47:11 +02:00
|
|
|
FT_Int32 t, t2;
|
2013-07-16 13:18:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
#if defined( __CC_ARM ) || defined( __ARMCC__ )
|
|
|
|
|
|
|
|
__asm
|
|
|
|
{
|
|
|
|
smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
|
|
|
|
mov a, t, asr #31 /* a = (hi >> 31) */
|
|
|
|
add a, a, #0x2000 /* a += 0x2000 */
|
|
|
|
adds t2, t2, a /* t2 += a */
|
|
|
|
adc t, t, #0 /* t += carry */
|
|
|
|
mov a, t2, lsr #14 /* a = t2 >> 14 */
|
|
|
|
orr a, a, t, lsl #18 /* a |= t << 18 */
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined( __GNUC__ )
|
|
|
|
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
|
|
|
|
"mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
|
2014-01-08 08:52:59 +01:00
|
|
|
#if defined( __clang__ ) && defined( __thumb2__ )
|
2013-10-15 11:40:34 +02:00
|
|
|
"add.w %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
|
|
|
|
#else
|
2013-07-16 13:18:00 +02:00
|
|
|
"add %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
|
2013-10-15 11:40:34 +02:00
|
|
|
#endif
|
2013-07-16 13:18:00 +02:00
|
|
|
"adds %1, %1, %0\n\t" /* %1 += %0 */
|
|
|
|
"adc %2, %2, #0\n\t" /* %2 += carry */
|
|
|
|
"mov %0, %1, lsr #14\n\t" /* %0 = %1 >> 16 */
|
|
|
|
"orr %0, %0, %2, lsl #18\n\t" /* %0 |= %2 << 16 */
|
|
|
|
: "=r"(a), "=&r"(t2), "=&r"(t)
|
|
|
|
: "r"(a), "r"(b)
|
|
|
|
: "cc" );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __arm__ && ( __thumb2__ || !__thumb__ ) */
|
|
|
|
|
|
|
|
#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
|
|
|
|
|
|
|
|
|
|
|
|
#if defined( __GNUC__ ) && \
|
|
|
|
( defined( __i386__ ) || defined( __x86_64__ ) )
|
|
|
|
|
|
|
|
#define TT_MulFix14 TT_MulFix14_long_long
|
|
|
|
|
2013-08-05 23:38:32 +02:00
|
|
|
/* Temporarily disable the warning that C90 doesn't support `long long'. */
|
2013-08-06 00:21:46 +02:00
|
|
|
#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
|
2013-08-05 23:38:32 +02:00
|
|
|
#pragma GCC diagnostic push
|
2013-08-06 00:21:46 +02:00
|
|
|
#endif
|
2013-08-05 23:38:32 +02:00
|
|
|
#pragma GCC diagnostic ignored "-Wlong-long"
|
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
/* This is declared `noinline' because inlining the function results */
|
|
|
|
/* in slower code. The `pure' attribute indicates that the result */
|
|
|
|
/* only depends on the parameters. */
|
|
|
|
static __attribute__(( noinline ))
|
|
|
|
__attribute__(( pure )) FT_Int32
|
|
|
|
TT_MulFix14_long_long( FT_Int32 a,
|
|
|
|
FT_Int b )
|
|
|
|
{
|
|
|
|
|
|
|
|
long long ret = (long long)a * b;
|
|
|
|
|
|
|
|
/* The following line assumes that right shifting of signed values */
|
|
|
|
/* will actually preserve the sign bit. The exact behaviour is */
|
|
|
|
/* undefined, but this is true on x86 and x86_64. */
|
|
|
|
long long tmp = ret >> 63;
|
|
|
|
|
|
|
|
|
|
|
|
ret += 0x2000 + tmp;
|
|
|
|
|
|
|
|
return (FT_Int32)( ret >> 14 );
|
2013-08-05 23:38:32 +02:00
|
|
|
}
|
2013-07-16 13:18:00 +02:00
|
|
|
|
2013-08-06 00:21:46 +02:00
|
|
|
#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
|
2013-07-16 13:18:00 +02:00
|
|
|
#pragma GCC diagnostic pop
|
2013-08-06 00:21:46 +02:00
|
|
|
#endif
|
2013-07-16 13:18:00 +02:00
|
|
|
|
|
|
|
#endif /* __GNUC__ && ( __i386__ || __x86_64__ ) */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef TT_MulFix14
|
|
|
|
|
|
|
|
/* Compute (a*b)/2^14 with maximum accuracy and rounding. */
|
|
|
|
/* This is optimized to be faster than calling FT_MulFix() */
|
|
|
|
/* for platforms where sizeof(int) == 2. */
|
2007-02-14 16:08:47 +01:00
|
|
|
static FT_Int32
|
|
|
|
TT_MulFix14( FT_Int32 a,
|
|
|
|
FT_Int b )
|
2007-02-16 09:10:17 +01:00
|
|
|
{
|
|
|
|
FT_Int32 sign;
|
|
|
|
FT_UInt32 ah, al, mid, lo, hi;
|
|
|
|
|
2007-02-14 16:08:47 +01:00
|
|
|
|
2007-02-16 09:10:17 +01:00
|
|
|
sign = a ^ b;
|
2007-02-14 16:08:47 +01:00
|
|
|
|
2007-02-16 09:10:17 +01:00
|
|
|
if ( a < 0 )
|
|
|
|
a = -a;
|
|
|
|
if ( b < 0 )
|
|
|
|
b = -b;
|
2007-02-14 16:08:47 +01:00
|
|
|
|
2007-02-16 09:10:17 +01:00
|
|
|
ah = (FT_UInt32)( ( a >> 16 ) & 0xFFFFU );
|
|
|
|
al = (FT_UInt32)( a & 0xFFFFU );
|
2007-02-14 16:08:47 +01:00
|
|
|
|
2007-02-16 09:10:17 +01:00
|
|
|
lo = al * b;
|
|
|
|
mid = ah * b;
|
|
|
|
hi = mid >> 16;
|
|
|
|
mid = ( mid << 16 ) + ( 1 << 13 ); /* rounding */
|
|
|
|
lo += mid;
|
|
|
|
if ( lo < mid )
|
|
|
|
hi += 1;
|
2007-02-14 16:08:47 +01:00
|
|
|
|
2007-02-16 09:10:17 +01:00
|
|
|
mid = ( lo >> 14 ) | ( hi << 18 );
|
|
|
|
|
|
|
|
return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
|
|
|
|
}
|
2007-02-14 16:08:47 +01:00
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
#endif /* !TT_MulFix14 */
|
2007-02-16 09:10:17 +01:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
#if defined( __GNUC__ ) && \
|
|
|
|
( defined( __i386__ ) || \
|
|
|
|
defined( __x86_64__ ) || \
|
|
|
|
defined( __arm__ ) )
|
2002-04-01 16:25:28 +02:00
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
#define TT_DotFix14 TT_DotFix14_long_long
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2013-08-06 00:21:46 +02:00
|
|
|
#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
|
2013-08-05 23:38:32 +02:00
|
|
|
#pragma GCC diagnostic push
|
2013-08-06 00:21:46 +02:00
|
|
|
#endif
|
2013-08-05 23:38:32 +02:00
|
|
|
#pragma GCC diagnostic ignored "-Wlong-long"
|
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
static __attribute__(( pure )) FT_Int32
|
|
|
|
TT_DotFix14_long_long( FT_Int32 ax,
|
|
|
|
FT_Int32 ay,
|
|
|
|
FT_Int bx,
|
|
|
|
FT_Int by )
|
|
|
|
{
|
|
|
|
/* Temporarily disable the warning that C90 doesn't support */
|
|
|
|
/* `long long'. */
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
long long temp1 = (long long)ax * bx;
|
|
|
|
long long temp2 = (long long)ay * by;
|
2002-03-25 18:02:26 +01:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
temp1 += temp2;
|
|
|
|
temp2 = temp1 >> 63;
|
|
|
|
temp1 += 0x2000 + temp2;
|
|
|
|
|
|
|
|
return (FT_Int32)( temp1 >> 14 );
|
|
|
|
|
2002-03-25 18:02:26 +01:00
|
|
|
}
|
|
|
|
|
2013-08-06 00:21:46 +02:00
|
|
|
#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
|
2013-08-05 23:38:32 +02:00
|
|
|
#pragma GCC diagnostic pop
|
2013-08-06 00:21:46 +02:00
|
|
|
#endif
|
2013-08-05 23:38:32 +02:00
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
#endif /* __GNUC__ && (__arm__ || __i386__ || __x86_64__) */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef TT_DotFix14
|
2002-03-25 18:02:26 +01:00
|
|
|
|
2012-03-11 13:48:25 +01:00
|
|
|
/* compute (ax*bx+ay*by)/2^14 with maximum accuracy and rounding */
|
2002-03-25 18:02:26 +01:00
|
|
|
static FT_Int32
|
2002-04-01 16:25:28 +02:00
|
|
|
TT_DotFix14( FT_Int32 ax,
|
|
|
|
FT_Int32 ay,
|
|
|
|
FT_Int bx,
|
|
|
|
FT_Int by )
|
2002-03-25 18:02:26 +01:00
|
|
|
{
|
|
|
|
FT_Int32 m, s, hi1, hi2, hi;
|
|
|
|
FT_UInt32 l, lo1, lo2, lo;
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2002-04-01 16:25:28 +02:00
|
|
|
|
2002-03-25 18:02:26 +01:00
|
|
|
/* compute ax*bx as 64-bit value */
|
2002-04-01 16:25:28 +02:00
|
|
|
l = (FT_UInt32)( ( ax & 0xFFFFU ) * bx );
|
|
|
|
m = ( ax >> 16 ) * bx;
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2013-05-04 16:40:12 +02:00
|
|
|
lo1 = l + ( (FT_UInt32)m << 16 );
|
2002-04-01 16:25:28 +02:00
|
|
|
hi1 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo1 < l );
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2002-03-25 18:02:26 +01:00
|
|
|
/* compute ay*by as 64-bit value */
|
2002-04-01 16:25:28 +02:00
|
|
|
l = (FT_UInt32)( ( ay & 0xFFFFU ) * by );
|
|
|
|
m = ( ay >> 16 ) * by;
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2013-05-04 16:40:12 +02:00
|
|
|
lo2 = l + ( (FT_UInt32)m << 16 );
|
2002-04-01 16:25:28 +02:00
|
|
|
hi2 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo2 < l );
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2002-03-25 18:02:26 +01:00
|
|
|
/* add them */
|
|
|
|
lo = lo1 + lo2;
|
2002-04-01 16:25:28 +02:00
|
|
|
hi = hi1 + hi2 + ( lo < lo1 );
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2002-03-25 18:02:26 +01:00
|
|
|
/* divide the result by 2^14 with rounding */
|
2002-04-01 16:25:28 +02:00
|
|
|
s = hi >> 31;
|
2002-03-25 18:02:26 +01:00
|
|
|
l = lo + (FT_UInt32)s;
|
2002-04-01 16:25:28 +02:00
|
|
|
hi += s + ( l < lo );
|
2002-03-25 18:02:26 +01:00
|
|
|
lo = l;
|
|
|
|
|
|
|
|
l = lo + 0x2000U;
|
2002-04-01 16:25:28 +02:00
|
|
|
hi += ( l < lo );
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
|
2013-05-04 16:40:12 +02:00
|
|
|
return (FT_Int32)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
|
2002-03-25 18:02:26 +01:00
|
|
|
}
|
|
|
|
|
2013-07-16 13:18:00 +02:00
|
|
|
#endif /* TT_DotFix14 */
|
|
|
|
|
2002-04-01 16:25:28 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Current_Ratio */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Returns the current aspect ratio scaling factor depending on the */
|
|
|
|
/* projection vector's state and device resolutions. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The aspect ratio in 16.16 format, always <= 1.0 . */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_Long
|
2015-01-10 20:23:10 +01:00
|
|
|
Current_Ratio( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( !exc->tt_metrics.ratio )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2016-01-28 12:24:36 +01:00
|
|
|
if ( exc->GS.projVector.y == 0 )
|
|
|
|
exc->tt_metrics.ratio = exc->tt_metrics.x_ratio;
|
2000-07-02 15:53:16 +02:00
|
|
|
|
2016-01-28 12:24:36 +01:00
|
|
|
else if ( exc->GS.projVector.x == 0 )
|
|
|
|
exc->tt_metrics.ratio = exc->tt_metrics.y_ratio;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2016-01-28 12:24:36 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_F26Dot6 x, y;
|
2003-04-25 13:40:46 +02:00
|
|
|
|
2003-04-29 15:23:47 +02:00
|
|
|
|
2016-01-28 12:24:36 +01:00
|
|
|
x = TT_MulFix14( exc->tt_metrics.x_ratio,
|
|
|
|
exc->GS.projVector.x );
|
|
|
|
y = TT_MulFix14( exc->tt_metrics.y_ratio,
|
|
|
|
exc->GS.projVector.y );
|
|
|
|
exc->tt_metrics.ratio = FT_Hypot( x, y );
|
2003-04-29 15:23:47 +02:00
|
|
|
}
|
|
|
|
}
|
2015-01-10 19:56:28 +01:00
|
|
|
return exc->tt_metrics.ratio;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-03 04:38:59 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Long )
|
2015-01-10 20:23:10 +01:00
|
|
|
Current_Ppem( TT_ExecContext exc )
|
2014-09-03 04:38:59 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
return exc->tt_metrics.ppem;
|
2014-09-03 04:38:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_Long )
|
2015-01-10 20:23:10 +01:00
|
|
|
Current_Ppem_Stretched( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
return FT_MulFix( exc->tt_metrics.ppem, Current_Ratio( exc ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Functions related to the control value table (CVT). */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_CALLBACK_DEF( FT_F26Dot6 )
|
2015-01-10 20:23:10 +01:00
|
|
|
Read_CVT( TT_ExecContext exc,
|
|
|
|
FT_ULong idx )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
return exc->cvt[idx];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_CALLBACK_DEF( FT_F26Dot6 )
|
2015-01-10 20:23:10 +01:00
|
|
|
Read_CVT_Stretched( TT_ExecContext exc,
|
|
|
|
FT_ULong idx )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
return FT_MulFix( exc->cvt[idx], Current_Ratio( exc ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_CALLBACK_DEF( void )
|
2015-01-10 20:23:10 +01:00
|
|
|
Write_CVT( TT_ExecContext exc,
|
|
|
|
FT_ULong idx,
|
|
|
|
FT_F26Dot6 value )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->cvt[idx] = value;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2000-07-02 15:53:16 +02:00
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_CALLBACK_DEF( void )
|
2015-01-10 20:23:10 +01:00
|
|
|
Write_CVT_Stretched( TT_ExecContext exc,
|
|
|
|
FT_ULong idx,
|
|
|
|
FT_F26Dot6 value )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->cvt[idx] = FT_DivFix( value, Current_Ratio( exc ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_CALLBACK_DEF( void )
|
2015-01-10 20:23:10 +01:00
|
|
|
Move_CVT( TT_ExecContext exc,
|
|
|
|
FT_ULong idx,
|
|
|
|
FT_F26Dot6 value )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->cvt[idx] += value;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_CALLBACK_DEF( void )
|
2015-01-10 20:23:10 +01:00
|
|
|
Move_CVT_Stretched( TT_ExecContext exc,
|
|
|
|
FT_ULong idx,
|
|
|
|
FT_F26Dot6 value )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->cvt[idx] += FT_DivFix( value, Current_Ratio( exc ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* GetShortIns */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Returns a short integer taken from the instruction stream at */
|
|
|
|
/* address IP. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Short read at code[IP]. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* This one could become a macro. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_Short
|
2015-01-10 20:23:10 +01:00
|
|
|
GetShortIns( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2016-04-09 05:21:34 +02:00
|
|
|
/* Reading a byte stream so there is no endianness (DaveP) */
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->IP += 2;
|
|
|
|
return (FT_Short)( ( exc->code[exc->IP - 2] << 8 ) +
|
|
|
|
exc->code[exc->IP - 1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Ins_Goto_CodeRange */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Goes to a certain code range in the instruction stream. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* aRange :: The index of the code range. */
|
|
|
|
/* */
|
|
|
|
/* aIP :: The new IP address in the code range. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* SUCCESS or FAILURE. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_Bool
|
2015-01-10 20:23:10 +01:00
|
|
|
Ins_Goto_CodeRange( TT_ExecContext exc,
|
|
|
|
FT_Int aRange,
|
2015-02-17 09:21:26 +01:00
|
|
|
FT_Long aIP )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
TT_CodeRange* range;
|
|
|
|
|
|
|
|
|
|
|
|
if ( aRange < 1 || aRange > 3 )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Bad_Argument );
|
1999-12-17 00:11:37 +01:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
range = &exc->codeRangeTable[aRange - 1];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2016-12-26 17:08:17 +01:00
|
|
|
if ( !range->base ) /* invalid coderange */
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_CodeRange );
|
1999-12-17 00:11:37 +01:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: Because the last instruction of a program may be a CALL */
|
|
|
|
/* which will return to the first byte *after* the code */
|
2012-02-11 20:56:10 +01:00
|
|
|
/* range, we test for aIP <= Size, instead of aIP < Size. */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( aIP > range->size )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Code_Overflow );
|
1999-12-17 00:11:37 +01:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->code = range->base;
|
|
|
|
exc->codeSize = range->size;
|
|
|
|
exc->IP = aIP;
|
|
|
|
exc->curRange = aRange;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Direct_Move */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Moves a point by a given distance along the freedom vector. The */
|
|
|
|
/* point will be `touched'. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* point :: The index of the point to move. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* distance :: The distance to apply. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* zone :: The affected glyph zone. */
|
|
|
|
/* */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
/* <Note> */
|
2017-05-03 23:54:29 +02:00
|
|
|
/* See `ttinterp.h' for details on backward compatibility mode. */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
/* `Touches' the point. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Direct_Move( TT_ExecContext exc,
|
|
|
|
TT_GlyphZone zone,
|
|
|
|
FT_UShort point,
|
|
|
|
FT_F26Dot6 distance )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-04-01 16:25:28 +02:00
|
|
|
FT_F26Dot6 v;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2003-04-29 15:23:47 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
v = exc->GS.freeVector.x;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( v != 0 )
|
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
( !exc->ignore_x_mode ||
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_ALLOW_X_DMOVE ) ) )
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->cur[point].x = ADD_LONG( zone->cur[point].x,
|
|
|
|
FT_MulDiv( distance,
|
|
|
|
v,
|
|
|
|
exc->F_dot_P ) );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
else
|
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
|
|
|
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
|
|
|
/* Exception to the post-IUP curfew: Allow the x component of */
|
|
|
|
/* diagonal moves, but only post-IUP. DejaVu tries to adjust */
|
|
|
|
/* diagonal stems like on `Z' and `z' post-IUP. */
|
2017-05-03 23:54:29 +02:00
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->cur[point].x = ADD_LONG( zone->cur[point].x,
|
|
|
|
FT_MulDiv( distance,
|
|
|
|
v,
|
|
|
|
exc->F_dot_P ) );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ( NO_SUBPIXEL_HINTING )
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->cur[point].x = ADD_LONG( zone->cur[point].x,
|
|
|
|
FT_MulDiv( distance,
|
|
|
|
v,
|
|
|
|
exc->F_dot_P ) );
|
2000-07-02 15:53:16 +02:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
v = exc->GS.freeVector.y;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( v != 0 )
|
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
if ( !( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility &&
|
|
|
|
exc->iupx_called &&
|
|
|
|
exc->iupy_called ) )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->cur[point].y = ADD_LONG( zone->cur[point].y,
|
|
|
|
FT_MulDiv( distance,
|
|
|
|
v,
|
|
|
|
exc->F_dot_P ) );
|
2000-07-02 15:53:16 +02:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Direct_Move_Orig */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2003-11-28 23:47:26 +01:00
|
|
|
/* Moves the *original* position of a point by a given distance along */
|
|
|
|
/* the freedom vector. Obviously, the point will not be `touched'. */
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* point :: The index of the point to move. */
|
|
|
|
/* */
|
|
|
|
/* distance :: The distance to apply. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* zone :: The affected glyph zone. */
|
|
|
|
/* */
|
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Direct_Move_Orig( TT_ExecContext exc,
|
|
|
|
TT_GlyphZone zone,
|
|
|
|
FT_UShort point,
|
|
|
|
FT_F26Dot6 distance )
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
{
|
|
|
|
FT_F26Dot6 v;
|
|
|
|
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
v = exc->GS.freeVector.x;
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
|
|
|
|
if ( v != 0 )
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->org[point].x = ADD_LONG( zone->org[point].x,
|
|
|
|
FT_MulDiv( distance,
|
|
|
|
v,
|
|
|
|
exc->F_dot_P ) );
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
v = exc->GS.freeVector.y;
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
|
|
|
|
if ( v != 0 )
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->org[point].y = ADD_LONG( zone->org[point].y,
|
|
|
|
FT_MulDiv( distance,
|
|
|
|
v,
|
|
|
|
exc->F_dot_P ) );
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Special versions of Direct_Move() */
|
|
|
|
/* */
|
|
|
|
/* The following versions are used whenever both vectors are both */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* along one of the coordinate unit vectors, i.e. in 90% of the cases. */
|
2017-05-03 23:54:29 +02:00
|
|
|
/* See `ttinterp.h' for details on backward compatibility mode. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-07-02 15:53:16 +02:00
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Direct_Move_X( TT_ExecContext exc,
|
|
|
|
TT_GlyphZone zone,
|
|
|
|
FT_UShort point,
|
|
|
|
FT_F26Dot6 distance )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY && !exc->ignore_x_mode )
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
else
|
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
|
|
|
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
else
|
|
|
|
#endif
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( NO_SUBPIXEL_HINTING )
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
|
2013-05-17 13:51:07 +02:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Direct_Move_Y( TT_ExecContext exc,
|
|
|
|
TT_GlyphZone zone,
|
|
|
|
FT_UShort point,
|
|
|
|
FT_F26Dot6 distance )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
|
|
|
if ( !( SUBPIXEL_HINTING_MINIMAL &&
|
2017-05-03 23:54:29 +02:00
|
|
|
exc->backward_compatibility &&
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
exc->iupx_called && exc->iupy_called ) )
|
|
|
|
#endif
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->cur[point].y = ADD_LONG( zone->cur[point].y, distance );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
|
|
|
|
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Special versions of Direct_Move_Orig() */
|
|
|
|
/* */
|
|
|
|
/* The following versions are used whenever both vectors are both */
|
|
|
|
/* along one of the coordinate unit vectors, i.e. in 90% of the cases. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Direct_Move_Orig_X( TT_ExecContext exc,
|
|
|
|
TT_GlyphZone zone,
|
|
|
|
FT_UShort point,
|
|
|
|
FT_F26Dot6 distance )
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
{
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->org[point].x = ADD_LONG( zone->org[point].x, distance );
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Direct_Move_Orig_Y( TT_ExecContext exc,
|
|
|
|
TT_GlyphZone zone,
|
|
|
|
FT_UShort point,
|
|
|
|
FT_F26Dot6 distance )
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
{
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
|
2017-06-09 11:21:58 +02:00
|
|
|
zone->org[point].y = ADD_LONG( zone->org[point].y, distance );
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Round_None */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Does not round, but adds engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* distance :: The distance (not) to round. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compensation :: The engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The compensated distance. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* The TrueType specification says very few about the relationship */
|
|
|
|
/* between rounding and engine compensation. However, it seems from */
|
|
|
|
/* the description of super round that we should add the compensation */
|
|
|
|
/* before rounding. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Round_None( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6 distance,
|
|
|
|
FT_F26Dot6 compensation )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( distance >= 0 )
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = ADD_LONG( distance, compensation );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
val = 0;
|
|
|
|
}
|
2010-06-08 08:37:11 +02:00
|
|
|
else
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = SUB_LONG( distance, compensation );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( val > 0 )
|
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Round_To_Grid */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Rounds value to grid after adding engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* distance :: The distance to round. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compensation :: The engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Rounded distance. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Round_To_Grid( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6 distance,
|
|
|
|
FT_F26Dot6 compensation )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( distance >= 0 )
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = FT_PIX_ROUND_LONG( ADD_LONG( distance, compensation ) );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = NEG_LONG( FT_PIX_ROUND_LONG( SUB_LONG( compensation,
|
|
|
|
distance ) ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( val > 0 )
|
|
|
|
val = 0;
|
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-05-20 12:33:40 +02:00
|
|
|
return val;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Round_To_Half_Grid */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Rounds value to half grid after adding engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* distance :: The distance to round. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compensation :: The engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Rounded distance. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Round_To_Half_Grid( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6 distance,
|
|
|
|
FT_F26Dot6 compensation )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( distance >= 0 )
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = ADD_LONG( FT_PIX_FLOOR( ADD_LONG( distance, compensation ) ),
|
|
|
|
32 );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val < 0 )
|
|
|
|
val = 32;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = NEG_LONG( ADD_LONG( FT_PIX_FLOOR( SUB_LONG( compensation,
|
|
|
|
distance ) ),
|
|
|
|
32 ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( val > 0 )
|
2014-10-20 05:31:08 +02:00
|
|
|
val = -32;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Round_Down_To_Grid */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Rounds value down to grid after adding engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* distance :: The distance to round. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compensation :: The engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Rounded distance. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Round_Down_To_Grid( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6 distance,
|
|
|
|
FT_F26Dot6 compensation )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( distance >= 0 )
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = FT_PIX_FLOOR( ADD_LONG( distance, compensation ) );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = NEG_LONG( FT_PIX_FLOOR( SUB_LONG( compensation, distance ) ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( val > 0 )
|
|
|
|
val = 0;
|
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Round_Up_To_Grid */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Rounds value up to grid after adding engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* distance :: The distance to round. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compensation :: The engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Rounded distance. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Round_Up_To_Grid( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6 distance,
|
|
|
|
FT_F26Dot6 compensation )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2007-02-12 23:08:15 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( distance >= 0 )
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = FT_PIX_CEIL_LONG( ADD_LONG( distance, compensation ) );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = NEG_LONG( FT_PIX_CEIL_LONG( SUB_LONG( compensation,
|
|
|
|
distance ) ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( val > 0 )
|
|
|
|
val = 0;
|
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Round_To_Double_Grid */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Rounds value to double grid after adding engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* distance :: The distance to round. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compensation :: The engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Rounded distance. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Round_To_Double_Grid( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6 distance,
|
|
|
|
FT_F26Dot6 compensation )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( distance >= 0 )
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = FT_PAD_ROUND_LONG( ADD_LONG( distance, compensation ), 32 );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = NEG_LONG( FT_PAD_ROUND_LONG( SUB_LONG( compensation, distance ),
|
|
|
|
32 ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( val > 0 )
|
|
|
|
val = 0;
|
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Round_Super */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Super-rounds value to grid after adding engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* distance :: The distance to round. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compensation :: The engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Rounded distance. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
/* The TrueType specification says very little about the relationship */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* between rounding and engine compensation. However, it seems from */
|
|
|
|
/* the description of super round that we should add the compensation */
|
|
|
|
/* before rounding. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Round_Super( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6 distance,
|
|
|
|
FT_F26Dot6 compensation )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( distance >= 0 )
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = ADD_LONG( distance,
|
|
|
|
exc->threshold - exc->phase + compensation ) &
|
2015-01-10 19:56:28 +01:00
|
|
|
-exc->period;
|
2018-04-09 21:28:37 +02:00
|
|
|
val = ADD_LONG( val, exc->phase );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val < 0 )
|
2015-01-10 19:56:28 +01:00
|
|
|
val = exc->phase;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = NEG_LONG( SUB_LONG( exc->threshold - exc->phase + compensation,
|
|
|
|
distance ) &
|
|
|
|
-exc->period );
|
2018-04-09 21:28:37 +02:00
|
|
|
val = SUB_LONG( val, exc->phase );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val > 0 )
|
2015-01-10 19:56:28 +01:00
|
|
|
val = -exc->phase;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Round_Super_45 */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Super-rounds value to grid after adding engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* distance :: The distance to round. */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compensation :: The engine compensation. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Rounded distance. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* There is a separate function for Round_Super_45() as we may need */
|
|
|
|
/* greater precision. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Round_Super_45( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6 distance,
|
|
|
|
FT_F26Dot6 compensation )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( distance >= 0 )
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = ( ADD_LONG( distance,
|
|
|
|
exc->threshold - exc->phase + compensation ) /
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->period ) * exc->period;
|
2018-04-09 21:28:37 +02:00
|
|
|
val = ADD_LONG( val, exc->phase );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val < 0 )
|
2015-01-10 19:56:28 +01:00
|
|
|
val = exc->phase;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
val = NEG_LONG( ( SUB_LONG( exc->threshold - exc->phase + compensation,
|
|
|
|
distance ) /
|
|
|
|
exc->period ) * exc->period );
|
2018-04-09 21:28:37 +02:00
|
|
|
val = SUB_LONG( val, exc->phase );
|
2014-10-20 05:31:08 +02:00
|
|
|
if ( val > 0 )
|
2015-01-10 19:56:28 +01:00
|
|
|
val = -exc->phase;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Compute_Round */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Sets the rounding mode. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* round_mode :: The rounding mode to be used. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Compute_Round( TT_ExecContext exc,
|
|
|
|
FT_Byte round_mode )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
switch ( round_mode )
|
|
|
|
{
|
|
|
|
case TT_Round_Off:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_round = (TT_Round_Func)Round_None;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_Round_To_Grid:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_round = (TT_Round_Func)Round_To_Grid;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_Round_Up_To_Grid:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_round = (TT_Round_Func)Round_Up_To_Grid;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_Round_Down_To_Grid:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_round = (TT_Round_Func)Round_Down_To_Grid;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_Round_To_Half_Grid:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_round = (TT_Round_Func)Round_To_Half_Grid;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_Round_To_Double_Grid:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_round = (TT_Round_Func)Round_To_Double_Grid;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_Round_Super:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_round = (TT_Round_Func)Round_Super;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_Round_Super_45:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_round = (TT_Round_Func)Round_Super_45;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* SetSuperRound */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Sets Super Round parameters. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2012-06-27 08:16:06 +02:00
|
|
|
/* GridPeriod :: The grid period. */
|
|
|
|
/* */
|
|
|
|
/* selector :: The SROUND opcode. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
SetSuperRound( TT_ExecContext exc,
|
2015-05-20 12:33:40 +02:00
|
|
|
FT_F2Dot14 GridPeriod,
|
2015-01-10 20:23:10 +01:00
|
|
|
FT_Long selector )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
switch ( (FT_Int)( selector & 0xC0 ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->period = GridPeriod / 2;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x40:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->period = GridPeriod;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x80:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->period = GridPeriod * 2;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* This opcode is reserved, but... */
|
|
|
|
case 0xC0:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->period = GridPeriod;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
switch ( (FT_Int)( selector & 0x30 ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->phase = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x10:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->phase = exc->period / 4;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x20:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->phase = exc->period / 2;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x30:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->phase = exc->period * 3 / 4;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-03-21 14:30:14 +01:00
|
|
|
if ( ( selector & 0x0F ) == 0 )
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->threshold = exc->period - 1;
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->threshold = ( (FT_Int)( selector & 0x0F ) - 4 ) * exc->period / 8;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-05-20 12:33:40 +02:00
|
|
|
/* convert to F26Dot6 format */
|
|
|
|
exc->period >>= 8;
|
|
|
|
exc->phase >>= 8;
|
|
|
|
exc->threshold >>= 8;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Project */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Computes the projection of vector given by (v2-v1) along the */
|
|
|
|
/* current projection vector. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* v1 :: First input vector. */
|
|
|
|
/* v2 :: Second input vector. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The distance in F26dot6 format. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Project( TT_ExecContext exc,
|
|
|
|
FT_Pos dx,
|
|
|
|
FT_Pos dy )
|
2007-02-12 23:01:18 +01:00
|
|
|
{
|
2015-02-17 09:21:26 +01:00
|
|
|
return TT_DotFix14( dx, dy,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.projVector.x,
|
|
|
|
exc->GS.projVector.y );
|
2007-02-12 23:01:18 +01:00
|
|
|
}
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Dual_Project */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Computes the projection of the vector given by (v2-v1) along the */
|
|
|
|
/* current dual vector. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* v1 :: First input vector. */
|
|
|
|
/* v2 :: Second input vector. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The distance in F26dot6 format. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Dual_Project( TT_ExecContext exc,
|
|
|
|
FT_Pos dx,
|
|
|
|
FT_Pos dy )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-02-17 09:21:26 +01:00
|
|
|
return TT_DotFix14( dx, dy,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.dualVector.x,
|
|
|
|
exc->GS.dualVector.y );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2007-02-12 23:01:18 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Project_x */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Computes the projection of the vector given by (v2-v1) along the */
|
|
|
|
/* horizontal axis. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* v1 :: First input vector. */
|
|
|
|
/* v2 :: Second input vector. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The distance in F26dot6 format. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Project_x( TT_ExecContext exc,
|
|
|
|
FT_Pos dx,
|
|
|
|
FT_Pos dy )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
2007-02-12 23:08:15 +01:00
|
|
|
FT_UNUSED( dy );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2007-02-12 16:24:51 +01:00
|
|
|
return dx;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2007-02-12 23:01:18 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Project_y */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Computes the projection of the vector given by (v2-v1) along the */
|
|
|
|
/* vertical axis. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* v1 :: First input vector. */
|
|
|
|
/* v2 :: Second input vector. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The distance in F26dot6 format. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_F26Dot6
|
2015-01-10 20:23:10 +01:00
|
|
|
Project_y( TT_ExecContext exc,
|
|
|
|
FT_Pos dx,
|
|
|
|
FT_Pos dy )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 08:42:28 +01:00
|
|
|
FT_UNUSED( exc );
|
2007-02-12 23:08:15 +01:00
|
|
|
FT_UNUSED( dx );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2007-02-12 16:24:51 +01:00
|
|
|
return dy;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2007-02-12 23:01:18 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Compute_Funcs */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Computes the projection and movement function pointers according */
|
|
|
|
/* to the current graphics state. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Compute_Funcs( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.x == 0x4000 )
|
|
|
|
exc->F_dot_P = exc->GS.projVector.x;
|
|
|
|
else if ( exc->GS.freeVector.y == 0x4000 )
|
|
|
|
exc->F_dot_P = exc->GS.projVector.y;
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-11 00:56:55 +01:00
|
|
|
exc->F_dot_P =
|
|
|
|
( (FT_Long)exc->GS.projVector.x * exc->GS.freeVector.x +
|
|
|
|
(FT_Long)exc->GS.projVector.y * exc->GS.freeVector.y ) >> 14;
|
2015-01-10 19:56:28 +01:00
|
|
|
|
|
|
|
if ( exc->GS.projVector.x == 0x4000 )
|
|
|
|
exc->func_project = (TT_Project_Func)Project_x;
|
|
|
|
else if ( exc->GS.projVector.y == 0x4000 )
|
|
|
|
exc->func_project = (TT_Project_Func)Project_y;
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_project = (TT_Project_Func)Project;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.dualVector.x == 0x4000 )
|
|
|
|
exc->func_dualproj = (TT_Project_Func)Project_x;
|
|
|
|
else if ( exc->GS.dualVector.y == 0x4000 )
|
|
|
|
exc->func_dualproj = (TT_Project_Func)Project_y;
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_dualproj = (TT_Project_Func)Dual_Project;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_move = (TT_Move_Func)Direct_Move;
|
|
|
|
exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->F_dot_P == 0x4000L )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.x == 0x4000 )
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_move = (TT_Move_Func)Direct_Move_X;
|
|
|
|
exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_X;
|
* src/truetype/ttinterp.c (CUR_Func_move_orig): New macro.
(Direct_Move_Orig, Direct_Move_Orig_X, Direct_Move_Orig_Y): New
functions. Similar to Direct_Move, Direct_Move_X, and
Direct_Move_Y but without touching.
(Compute_Funcs): Use new functions.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super,
Round_Super_45): Fix rounding of value zero.
(DO_DIV): Don't use TT_MULDIV.
(Ins_SHC): This instruction actually touches the points.
(Ins_MSIRP): Fix undocumented behaviour.
* src/truetype/ttinterp.h (TT_ExecContextRec): Updated.
* docs/VERSION.DLL: Updated.
* src/base/ftobjs.c (FT_Set_Char_Size): Make metrics->x_scale and
metrics->y_scale really precise.
(FT_Load_Glyph): Update computation of linearHoriAdvance and
linearVertAdvance.
* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
2003-11-24 23:54:58 +01:00
|
|
|
}
|
2015-01-10 19:56:28 +01:00
|
|
|
else if ( exc->GS.freeVector.y == 0x4000 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_move = (TT_Move_Func)Direct_Move_Y;
|
|
|
|
exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* at small sizes, F_dot_P can become too small, resulting */
|
|
|
|
/* in overflows and `spikes' in a number of glyphs like `w'. */
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( FT_ABS( exc->F_dot_P ) < 0x400L )
|
|
|
|
exc->F_dot_P = 0x4000L;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* Disable cached aspect ratio */
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->tt_metrics.ratio = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Normalize */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Norms a vector. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* Vx :: The horizontal input vector coordinate. */
|
|
|
|
/* Vy :: The vertical input vector coordinate. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* R :: The normed unit vector. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* Returns FAILURE if a vector parameter is zero. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
2015-01-11 08:45:50 +01:00
|
|
|
/* In case Vx and Vy are both zero, `Normalize' returns SUCCESS, and */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* R is undefined. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_Bool
|
2015-01-11 08:45:50 +01:00
|
|
|
Normalize( FT_F26Dot6 Vx,
|
2015-01-10 20:23:10 +01:00
|
|
|
FT_F26Dot6 Vy,
|
|
|
|
FT_UnitVector* R )
|
2000-05-02 13:01:12 +02:00
|
|
|
{
|
2015-06-30 04:46:54 +02:00
|
|
|
FT_Vector V;
|
2000-05-02 13:01:12 +02:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-06-30 04:46:54 +02:00
|
|
|
if ( Vx == 0 && Vy == 0 )
|
2000-05-02 13:01:12 +02:00
|
|
|
{
|
2015-06-30 04:46:54 +02:00
|
|
|
/* XXX: UNDOCUMENTED! It seems that it is possible to try */
|
|
|
|
/* to normalize the vector (0,0). Return immediately. */
|
|
|
|
return SUCCESS;
|
2000-05-02 13:01:12 +02:00
|
|
|
}
|
|
|
|
|
2015-06-30 04:46:54 +02:00
|
|
|
V.x = Vx;
|
|
|
|
V.y = Vy;
|
|
|
|
|
|
|
|
FT_Vector_NormLen( &V );
|
2000-05-02 13:01:12 +02:00
|
|
|
|
2015-06-30 04:46:54 +02:00
|
|
|
R->x = (FT_F2Dot14)( V.x / 4 );
|
|
|
|
R->y = (FT_F2Dot14)( V.y / 4 );
|
2000-05-02 13:01:12 +02:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Here we start with the implementation of the various opcodes. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
#define ARRAY_BOUND_ERROR \
|
2015-01-10 23:05:37 +01:00
|
|
|
do \
|
2015-01-10 19:56:28 +01:00
|
|
|
{ \
|
|
|
|
exc->error = FT_THROW( Invalid_Reference ); \
|
|
|
|
return; \
|
2015-01-10 23:05:37 +01:00
|
|
|
} while (0)
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* MPPEM[]: Measure Pixel Per EM */
|
|
|
|
/* Opcode range: 0x4B */
|
|
|
|
/* Stack: --> Euint16 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_MPPEM( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = exc->func_cur_ppem( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* MPS[]: Measure Point Size */
|
|
|
|
/* Opcode range: 0x4C */
|
|
|
|
/* Stack: --> Euint16 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_MPS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2016-08-22 19:32:34 +02:00
|
|
|
if ( NO_SUBPIXEL_HINTING )
|
|
|
|
{
|
|
|
|
/* Microsoft's GDI bytecode interpreter always returns value 12; */
|
|
|
|
/* we return the current PPEM value instead. */
|
|
|
|
args[0] = exc->func_cur_ppem( exc );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* A possible practical application of the MPS instruction is to */
|
|
|
|
/* implement optical scaling and similar features, which should be */
|
|
|
|
/* based on perceptual attributes, thus independent of the */
|
|
|
|
/* resolution. */
|
|
|
|
args[0] = exc->pointSize;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* DUP[]: DUPlicate the stack's top element */
|
|
|
|
/* Opcode range: 0x20 */
|
|
|
|
/* Stack: StkElt --> StkElt StkElt */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_DUP( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[1] = args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* POP[]: POP the stack's top element */
|
|
|
|
/* Opcode range: 0x21 */
|
|
|
|
/* Stack: StkElt --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_POP( void )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
/* nothing to do */
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* CLEAR[]: CLEAR the entire stack */
|
|
|
|
/* Opcode range: 0x22 */
|
|
|
|
/* Stack: StkElt... --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_CLEAR( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->new_top = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SWAP[]: SWAP the stack's top two elements */
|
|
|
|
/* Opcode range: 0x23 */
|
|
|
|
/* Stack: 2 * StkElt --> 2 * StkElt */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_SWAP( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_Long L;
|
2015-01-11 00:23:27 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
L = args[0];
|
|
|
|
args[0] = args[1];
|
|
|
|
args[1] = L;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* DEPTH[]: return the stack DEPTH */
|
|
|
|
/* Opcode range: 0x24 */
|
|
|
|
/* Stack: --> uint32 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_DEPTH( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = exc->top;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2015-01-11 00:56:55 +01:00
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* LT[]: Less Than */
|
|
|
|
/* Opcode range: 0x50 */
|
|
|
|
/* Stack: int32? int32? --> bool */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_LT( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( args[0] < args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* LTEQ[]: Less Than or EQual */
|
|
|
|
/* Opcode range: 0x51 */
|
|
|
|
/* Stack: int32? int32? --> bool */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_LTEQ( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( args[0] <= args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* GT[]: Greater Than */
|
|
|
|
/* Opcode range: 0x52 */
|
|
|
|
/* Stack: int32? int32? --> bool */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_GT( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( args[0] > args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* GTEQ[]: Greater Than or EQual */
|
|
|
|
/* Opcode range: 0x53 */
|
|
|
|
/* Stack: int32? int32? --> bool */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_GTEQ( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( args[0] >= args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* EQ[]: EQual */
|
|
|
|
/* Opcode range: 0x54 */
|
|
|
|
/* Stack: StkElt StkElt --> bool */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_EQ( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( args[0] == args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* NEQ[]: Not EQual */
|
|
|
|
/* Opcode range: 0x55 */
|
|
|
|
/* Stack: StkElt StkElt --> bool */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_NEQ( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( args[0] != args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* ODD[]: Is ODD */
|
|
|
|
/* Opcode range: 0x56 */
|
|
|
|
/* Stack: f26.6 --> bool */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_ODD( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 64 );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* EVEN[]: Is EVEN */
|
|
|
|
/* Opcode range: 0x57 */
|
|
|
|
/* Stack: f26.6 --> bool */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_EVEN( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* AND[]: logical AND */
|
|
|
|
/* Opcode range: 0x5A */
|
|
|
|
/* Stack: uint32 uint32 --> uint32 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_AND( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( args[0] && args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* OR[]: logical OR */
|
|
|
|
/* Opcode range: 0x5B */
|
|
|
|
/* Stack: uint32 uint32 --> uint32 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_OR( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = ( args[0] || args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* NOT[]: logical NOT */
|
|
|
|
/* Opcode range: 0x5C */
|
|
|
|
/* Stack: StkElt --> uint32 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_NOT( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = !args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* ADD[]: ADD */
|
|
|
|
/* Opcode range: 0x60 */
|
|
|
|
/* Stack: f26.6 f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_ADD( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2017-06-09 11:21:58 +02:00
|
|
|
args[0] = ADD_LONG( args[0], args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SUB[]: SUBtract */
|
|
|
|
/* Opcode range: 0x61 */
|
|
|
|
/* Stack: f26.6 f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_SUB( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2017-06-09 11:21:58 +02:00
|
|
|
args[0] = SUB_LONG( args[0], args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* DIV[]: DIVide */
|
|
|
|
/* Opcode range: 0x62 */
|
|
|
|
/* Stack: f26.6 f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_DIV( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( args[1] == 0 )
|
|
|
|
exc->error = FT_THROW( Divide_By_Zero );
|
|
|
|
else
|
|
|
|
args[0] = FT_MulDiv_No_Round( args[0], 64L, args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* MUL[]: MULtiply */
|
|
|
|
/* Opcode range: 0x63 */
|
|
|
|
/* Stack: f26.6 f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_MUL( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = FT_MulDiv( args[0], args[1], 64L );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* ABS[]: ABSolute value */
|
|
|
|
/* Opcode range: 0x64 */
|
|
|
|
/* Stack: f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_ABS( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2017-06-20 07:49:52 +02:00
|
|
|
if ( args[0] < 0 )
|
|
|
|
args[0] = NEG_LONG( args[0] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* NEG[]: NEGate */
|
|
|
|
/* Opcode range: 0x65 */
|
2016-08-12 05:03:09 +02:00
|
|
|
/* Stack: f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_NEG( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2017-06-03 06:52:13 +02:00
|
|
|
args[0] = NEG_LONG( args[0] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* FLOOR[]: FLOOR */
|
|
|
|
/* Opcode range: 0x66 */
|
|
|
|
/* Stack: f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_FLOOR( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = FT_PIX_FLOOR( args[0] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* CEILING[]: CEILING */
|
|
|
|
/* Opcode range: 0x67 */
|
|
|
|
/* Stack: f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_CEILING( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = FT_PIX_CEIL( args[0] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* RS[]: Read Store */
|
|
|
|
/* Opcode range: 0x43 */
|
|
|
|
/* Stack: uint32 --> uint32 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_RS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_ULong I = (FT_ULong)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDSL( I, exc->storeSize ) )
|
|
|
|
{
|
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
ARRAY_BOUND_ERROR;
|
|
|
|
else
|
|
|
|
args[0] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2015-01-11 10:08:09 +01:00
|
|
|
/* subpixel hinting - avoid Typeman Dstroke and */
|
|
|
|
/* IStroke and Vacuform rounds */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
( ( I == 24 &&
|
|
|
|
( exc->face->sph_found_func_flags &
|
|
|
|
( SPH_FDEF_SPACING_1 |
|
|
|
|
SPH_FDEF_SPACING_2 ) ) ) ||
|
|
|
|
( I == 22 &&
|
|
|
|
( exc->sph_in_func_flags &
|
|
|
|
SPH_FDEF_TYPEMAN_STROKES ) ) ||
|
|
|
|
( I == 8 &&
|
|
|
|
( exc->face->sph_found_func_flags &
|
|
|
|
SPH_FDEF_VACUFORM_ROUND_1 ) &&
|
|
|
|
exc->iup_called ) ) )
|
|
|
|
args[0] = 0;
|
|
|
|
else
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = exc->storage[I];
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* WS[]: Write Store */
|
|
|
|
/* Opcode range: 0x42 */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_WS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_ULong I = (FT_ULong)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDSL( I, exc->storeSize ) )
|
|
|
|
{
|
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
ARRAY_BOUND_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
exc->storage[I] = args[1];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* WCVTP[]: Write CVT in Pixel units */
|
|
|
|
/* Opcode range: 0x44 */
|
|
|
|
/* Stack: f26.6 uint32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_WCVTP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_ULong I = (FT_ULong)args[0];
|
2015-01-11 00:23:27 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDSL( I, exc->cvtSize ) )
|
|
|
|
{
|
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
ARRAY_BOUND_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
exc->func_write_cvt( exc, I, args[1] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* WCVTF[]: Write CVT in Funits */
|
|
|
|
/* Opcode range: 0x70 */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_WCVTF( TT_ExecContext exc,
|
2015-01-11 08:39:14 +01:00
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_ULong I = (FT_ULong)args[0];
|
|
|
|
|
|
|
|
|
|
|
|
if ( BOUNDSL( I, exc->cvtSize ) )
|
|
|
|
{
|
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
ARRAY_BOUND_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
exc->cvt[I] = FT_MulFix( args[1], exc->tt_metrics.scale );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* RCVT[]: Read CVT */
|
|
|
|
/* Opcode range: 0x45 */
|
|
|
|
/* Stack: uint32 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_RCVT( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_ULong I = (FT_ULong)args[0];
|
2015-01-11 00:23:27 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDSL( I, exc->cvtSize ) )
|
2015-01-11 00:23:27 +01:00
|
|
|
{
|
|
|
|
if ( exc->pedantic_hinting )
|
2015-01-11 10:08:09 +01:00
|
|
|
ARRAY_BOUND_ERROR;
|
|
|
|
else
|
|
|
|
args[0] = 0;
|
2015-01-11 00:23:27 +01:00
|
|
|
}
|
|
|
|
else
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = exc->func_read_cvt( exc, I );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* AA[]: Adjust Angle */
|
|
|
|
/* Opcode range: 0x7F */
|
|
|
|
/* Stack: uint32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_AA( void )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
/* intentionally no longer supported */
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* DEBUG[]: DEBUG. Unsupported. */
|
|
|
|
/* Opcode range: 0x4F */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
|
|
|
/* Note: The original instruction pops a value from the stack. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_DEBUG( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Debug_OpCode );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-11 08:58:54 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* ROUND[ab]: ROUND value */
|
|
|
|
/* Opcode range: 0x68-0x6B */
|
|
|
|
/* Stack: f26.6 --> f26.6 */
|
2015-01-11 08:58:54 +01:00
|
|
|
/* */
|
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_ROUND( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
2015-01-11 08:58:54 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = exc->func_round(
|
|
|
|
exc,
|
|
|
|
args[0],
|
|
|
|
exc->tt_metrics.compensations[exc->opcode - 0x68] );
|
2015-01-11 08:58:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* NROUND[ab]: No ROUNDing of value */
|
|
|
|
/* Opcode range: 0x6C-0x6F */
|
|
|
|
/* Stack: f26.6 --> f26.6 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_NROUND( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = Round_None(
|
|
|
|
exc,
|
|
|
|
args[0],
|
|
|
|
exc->tt_metrics.compensations[exc->opcode - 0x6C] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* MAX[]: MAXimum */
|
2016-08-12 05:03:09 +02:00
|
|
|
/* Opcode range: 0x8B */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Stack: int32? int32? --> int32 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_MAX( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( args[1] > args[0] )
|
|
|
|
args[0] = args[1];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* MIN[]: MINimum */
|
2016-08-12 05:03:09 +02:00
|
|
|
/* Opcode range: 0x8C */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Stack: int32? int32? --> int32 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_MIN( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( args[1] < args[0] )
|
|
|
|
args[0] = args[1];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* MINDEX[]: Move INDEXed element */
|
|
|
|
/* Opcode range: 0x26 */
|
|
|
|
/* Stack: int32? --> StkElt */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_MINDEX( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_Long L, K;
|
|
|
|
|
|
|
|
|
|
|
|
L = args[0];
|
|
|
|
|
|
|
|
if ( L <= 0 || L > exc->args )
|
|
|
|
{
|
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
K = exc->stack[exc->args - L];
|
|
|
|
|
|
|
|
FT_ARRAY_MOVE( &exc->stack[exc->args - L ],
|
|
|
|
&exc->stack[exc->args - L + 1],
|
|
|
|
( L - 1 ) );
|
|
|
|
|
|
|
|
exc->stack[exc->args - 1] = K;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* CINDEX[]: Copy INDEXed element */
|
|
|
|
/* Opcode range: 0x25 */
|
|
|
|
/* Stack: int32 --> StkElt */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_CINDEX( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_Long L;
|
|
|
|
|
|
|
|
|
|
|
|
L = args[0];
|
|
|
|
|
|
|
|
if ( L <= 0 || L > exc->args )
|
|
|
|
{
|
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
|
|
|
args[0] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
args[0] = exc->stack[exc->args - L];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* ROLL[]: ROLL top three elements */
|
|
|
|
/* Opcode range: 0x8A */
|
|
|
|
/* Stack: 3 * StkElt --> 3 * StkElt */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_ROLL( FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_Long A, B, C;
|
|
|
|
|
|
|
|
|
|
|
|
A = args[2];
|
|
|
|
B = args[1];
|
|
|
|
C = args[0];
|
|
|
|
|
|
|
|
args[2] = C;
|
|
|
|
args[1] = A;
|
|
|
|
args[0] = B;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* MANAGING THE FLOW OF CONTROL */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SLOOP[]: Set LOOP variable */
|
|
|
|
/* Opcode range: 0x17 */
|
|
|
|
/* Stack: int32? --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_SLOOP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( args[0] < 0 )
|
|
|
|
exc->error = FT_THROW( Bad_Argument );
|
|
|
|
else
|
2018-04-15 21:55:04 +02:00
|
|
|
{
|
|
|
|
/* we heuristically limit the number of loops to 16 bits */
|
|
|
|
exc->GS.loop = args[0] > 0xFFFFL ? 0xFFFFL : args[0];
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
static FT_Bool
|
|
|
|
SkipCode( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->IP += exc->length;
|
|
|
|
|
|
|
|
if ( exc->IP < exc->codeSize )
|
|
|
|
{
|
|
|
|
exc->opcode = exc->code[exc->IP];
|
|
|
|
|
|
|
|
exc->length = opcode_length[exc->opcode];
|
|
|
|
if ( exc->length < 0 )
|
|
|
|
{
|
|
|
|
if ( exc->IP + 1 >= exc->codeSize )
|
|
|
|
goto Fail_Overflow;
|
|
|
|
exc->length = 2 - exc->length * exc->code[exc->IP + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( exc->IP + exc->length <= exc->codeSize )
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fail_Overflow:
|
|
|
|
exc->error = FT_THROW( Code_Overflow );
|
|
|
|
return FAILURE;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* IF[]: IF test */
|
|
|
|
/* Opcode range: 0x58 */
|
|
|
|
/* Stack: StkElt --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_IF( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_Int nIfs;
|
|
|
|
FT_Bool Out;
|
|
|
|
|
|
|
|
|
|
|
|
if ( args[0] != 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
nIfs = 1;
|
|
|
|
Out = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( SkipCode( exc ) == FAILURE )
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch ( exc->opcode )
|
|
|
|
{
|
|
|
|
case 0x58: /* IF */
|
|
|
|
nIfs++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x1B: /* ELSE */
|
|
|
|
Out = FT_BOOL( nIfs == 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x59: /* EIF */
|
|
|
|
nIfs--;
|
|
|
|
Out = FT_BOOL( nIfs == 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while ( Out == 0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* ELSE[]: ELSE */
|
|
|
|
/* Opcode range: 0x1B */
|
|
|
|
/* Stack: --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_ELSE( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_Int nIfs;
|
|
|
|
|
|
|
|
|
|
|
|
nIfs = 1;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( SkipCode( exc ) == FAILURE )
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch ( exc->opcode )
|
|
|
|
{
|
|
|
|
case 0x58: /* IF */
|
|
|
|
nIfs++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x59: /* EIF */
|
|
|
|
nIfs--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while ( nIfs != 0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* EIF[]: End IF */
|
|
|
|
/* Opcode range: 0x59 */
|
|
|
|
/* Stack: --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_EIF( void )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
/* nothing to do */
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* JMPR[]: JuMP Relative */
|
|
|
|
/* Opcode range: 0x1C */
|
|
|
|
/* Stack: int32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_JMPR( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( args[0] == 0 && exc->args == 0 )
|
2016-09-27 08:44:31 +02:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Bad_Argument );
|
2016-09-27 08:44:31 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->IP += args[0];
|
|
|
|
if ( exc->IP < 0 ||
|
|
|
|
( exc->callTop > 0 &&
|
|
|
|
exc->IP > exc->callStack[exc->callTop - 1].Def->end ) )
|
2016-09-27 08:44:31 +02:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Bad_Argument );
|
2016-09-27 08:44:31 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->step_ins = FALSE;
|
2016-09-27 08:44:31 +02:00
|
|
|
|
|
|
|
if ( args[0] < 0 )
|
|
|
|
{
|
|
|
|
if ( ++exc->neg_jump_counter > exc->neg_jump_counter_max )
|
|
|
|
exc->error = FT_THROW( Execution_Too_Long );
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* JROT[]: Jump Relative On True */
|
|
|
|
/* Opcode range: 0x78 */
|
|
|
|
/* Stack: StkElt int32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_JROT( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( args[1] != 0 )
|
|
|
|
Ins_JMPR( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* JROF[]: Jump Relative On False */
|
|
|
|
/* Opcode range: 0x79 */
|
|
|
|
/* Stack: StkElt int32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_JROF( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 00:23:27 +01:00
|
|
|
if ( args[1] == 0 )
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_JMPR( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* DEFINING AND USING FUNCTIONS AND INSTRUCTIONS */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* FDEF[]: Function DEFinition */
|
|
|
|
/* Opcode range: 0x2C */
|
|
|
|
/* Stack: uint32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_FDEF( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_ULong n;
|
|
|
|
TT_DefRecord* rec;
|
|
|
|
TT_DefRecord* limit;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2015-01-11 10:08:09 +01:00
|
|
|
/* arguments to opcodes are skipped by `SKIP_Code' */
|
|
|
|
FT_Byte opcode_pattern[9][12] = {
|
|
|
|
/* #0 inline delta function 1 */
|
|
|
|
{
|
|
|
|
0x4B, /* PPEM */
|
|
|
|
0x53, /* GTEQ */
|
|
|
|
0x23, /* SWAP */
|
|
|
|
0x4B, /* PPEM */
|
|
|
|
0x51, /* LTEQ */
|
|
|
|
0x5A, /* AND */
|
|
|
|
0x58, /* IF */
|
|
|
|
0x38, /* SHPIX */
|
|
|
|
0x1B, /* ELSE */
|
|
|
|
0x21, /* POP */
|
|
|
|
0x21, /* POP */
|
|
|
|
0x59 /* EIF */
|
|
|
|
},
|
|
|
|
/* #1 inline delta function 2 */
|
|
|
|
{
|
|
|
|
0x4B, /* PPEM */
|
|
|
|
0x54, /* EQ */
|
|
|
|
0x58, /* IF */
|
|
|
|
0x38, /* SHPIX */
|
|
|
|
0x1B, /* ELSE */
|
|
|
|
0x21, /* POP */
|
|
|
|
0x21, /* POP */
|
|
|
|
0x59 /* EIF */
|
|
|
|
},
|
|
|
|
/* #2 diagonal stroke function */
|
|
|
|
{
|
|
|
|
0x20, /* DUP */
|
|
|
|
0x20, /* DUP */
|
|
|
|
0xB0, /* PUSHB_1 */
|
|
|
|
/* 1 */
|
|
|
|
0x60, /* ADD */
|
|
|
|
0x46, /* GC_cur */
|
|
|
|
0xB0, /* PUSHB_1 */
|
|
|
|
/* 64 */
|
|
|
|
0x23, /* SWAP */
|
|
|
|
0x42 /* WS */
|
|
|
|
},
|
|
|
|
/* #3 VacuFormRound function */
|
|
|
|
{
|
|
|
|
0x45, /* RCVT */
|
|
|
|
0x23, /* SWAP */
|
|
|
|
0x46, /* GC_cur */
|
|
|
|
0x60, /* ADD */
|
|
|
|
0x20, /* DUP */
|
|
|
|
0xB0 /* PUSHB_1 */
|
|
|
|
/* 38 */
|
|
|
|
},
|
|
|
|
/* #4 TTFautohint bytecode (old) */
|
|
|
|
{
|
|
|
|
0x20, /* DUP */
|
|
|
|
0x64, /* ABS */
|
|
|
|
0xB0, /* PUSHB_1 */
|
|
|
|
/* 32 */
|
|
|
|
0x60, /* ADD */
|
|
|
|
0x66, /* FLOOR */
|
|
|
|
0x23, /* SWAP */
|
|
|
|
0xB0 /* PUSHB_1 */
|
|
|
|
},
|
|
|
|
/* #5 spacing function 1 */
|
|
|
|
{
|
|
|
|
0x01, /* SVTCA_x */
|
|
|
|
0xB0, /* PUSHB_1 */
|
|
|
|
/* 24 */
|
|
|
|
0x43, /* RS */
|
|
|
|
0x58 /* IF */
|
|
|
|
},
|
|
|
|
/* #6 spacing function 2 */
|
|
|
|
{
|
|
|
|
0x01, /* SVTCA_x */
|
|
|
|
0x18, /* RTG */
|
|
|
|
0xB0, /* PUSHB_1 */
|
|
|
|
/* 24 */
|
|
|
|
0x43, /* RS */
|
|
|
|
0x58 /* IF */
|
|
|
|
},
|
|
|
|
/* #7 TypeMan Talk DiagEndCtrl function */
|
|
|
|
{
|
|
|
|
0x01, /* SVTCA_x */
|
|
|
|
0x20, /* DUP */
|
|
|
|
0xB0, /* PUSHB_1 */
|
|
|
|
/* 3 */
|
|
|
|
0x25, /* CINDEX */
|
|
|
|
},
|
|
|
|
/* #8 TypeMan Talk Align */
|
|
|
|
{
|
|
|
|
0x06, /* SPVTL */
|
|
|
|
0x7D, /* RDTG */
|
|
|
|
},
|
|
|
|
};
|
|
|
|
FT_UShort opcode_patterns = 9;
|
|
|
|
FT_UShort opcode_pointer[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
|
|
FT_UShort opcode_size[9] = { 12, 8, 8, 6, 7, 4, 5, 4, 2 };
|
|
|
|
FT_UShort i;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2015-01-11 00:23:27 +01:00
|
|
|
|
|
|
|
|
2017-04-03 11:37:33 +02:00
|
|
|
/* FDEF is only allowed in `prep' or `fpgm' */
|
|
|
|
if ( exc->curRange == tt_coderange_glyph )
|
|
|
|
{
|
|
|
|
exc->error = FT_THROW( DEF_In_Glyf_Bytecode );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* some font programs are broken enough to redefine functions! */
|
|
|
|
/* We will then parse the current table. */
|
2015-01-11 00:23:27 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
rec = exc->FDefs;
|
|
|
|
limit = rec + exc->numFDefs;
|
2015-02-17 09:21:26 +01:00
|
|
|
n = (FT_ULong)args[0];
|
2015-01-11 10:08:09 +01:00
|
|
|
|
|
|
|
for ( ; rec < limit; rec++ )
|
2015-01-11 00:23:27 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( rec->opc == n )
|
|
|
|
break;
|
2015-01-11 00:23:27 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( rec == limit )
|
2015-01-11 00:23:27 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
/* check that there is enough room for new functions */
|
|
|
|
if ( exc->numFDefs >= exc->maxFDefs )
|
|
|
|
{
|
|
|
|
exc->error = FT_THROW( Too_Many_Function_Defs );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
exc->numFDefs++;
|
2015-01-11 00:23:27 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Although FDEF takes unsigned 32-bit integer, */
|
|
|
|
/* func # must be within unsigned 16-bit integer */
|
|
|
|
if ( n > 0xFFFFU )
|
2015-01-11 00:23:27 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Too_Many_Function_Defs );
|
|
|
|
return;
|
2015-01-11 00:23:27 +01:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
rec->range = exc->curRange;
|
|
|
|
rec->opc = (FT_UInt16)n;
|
|
|
|
rec->start = exc->IP + 1;
|
|
|
|
rec->active = TRUE;
|
|
|
|
rec->inline_delta = FALSE;
|
|
|
|
rec->sph_fdef_flags = 0x0000;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( n > exc->maxFunc )
|
|
|
|
exc->maxFunc = (FT_UInt16)n;
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2015-01-11 10:08:09 +01:00
|
|
|
/* We don't know for sure these are typeman functions, */
|
|
|
|
/* however they are only active when RS 22 is called */
|
|
|
|
if ( n >= 64 && n <= 66 )
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_STROKES;
|
|
|
|
#endif
|
2015-01-11 00:23:27 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Now skip the whole function definition. */
|
|
|
|
/* We don't allow nested IDEFS & FDEFs. */
|
2015-01-11 00:23:27 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
while ( SkipCode( exc ) == SUCCESS )
|
2015-01-11 00:23:27 +01:00
|
|
|
{
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY )
|
2015-01-11 10:08:09 +01:00
|
|
|
{
|
|
|
|
for ( i = 0; i < opcode_patterns; i++ )
|
|
|
|
{
|
|
|
|
if ( opcode_pointer[i] < opcode_size[i] &&
|
|
|
|
exc->opcode == opcode_pattern[i][opcode_pointer[i]] )
|
|
|
|
{
|
|
|
|
opcode_pointer[i] += 1;
|
2015-01-11 00:23:27 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( opcode_pointer[i] == opcode_size[i] )
|
|
|
|
{
|
2015-06-01 12:12:06 +02:00
|
|
|
FT_TRACE6(( "sph: Function %d, opcode ptrn: %d, %s %s\n",
|
2015-01-11 10:08:09 +01:00
|
|
|
i, n,
|
|
|
|
exc->face->root.family_name,
|
|
|
|
exc->face->root.style_name ));
|
2015-01-11 00:23:27 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
switch ( i )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_1;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_1;
|
|
|
|
break;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
case 1:
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_2;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_2;
|
|
|
|
break;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
case 2:
|
|
|
|
switch ( n )
|
|
|
|
{
|
|
|
|
/* needs to be implemented still */
|
|
|
|
case 58:
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_DIAGONAL_STROKE;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_DIAGONAL_STROKE;
|
|
|
|
}
|
|
|
|
break;
|
2015-01-11 00:23:27 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
case 3:
|
|
|
|
switch ( n )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_VACUFORM_ROUND_1;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_VACUFORM_ROUND_1;
|
|
|
|
}
|
|
|
|
break;
|
2015-01-11 00:23:27 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
case 4:
|
|
|
|
/* probably not necessary to detect anymore */
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_TTFAUTOHINT_1;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_TTFAUTOHINT_1;
|
|
|
|
break;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
case 5:
|
|
|
|
switch ( n )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_SPACING_1;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_SPACING_1;
|
|
|
|
}
|
|
|
|
break;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
case 6:
|
|
|
|
switch ( n )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_SPACING_2;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_SPACING_2;
|
|
|
|
}
|
|
|
|
break;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
case 7:
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
|
|
|
|
break;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
case 8:
|
|
|
|
#if 0
|
|
|
|
rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
|
|
|
|
exc->face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
opcode_pointer[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
else
|
|
|
|
opcode_pointer[i] = 0;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Set sph_compatibility_mode only when deltas are detected */
|
|
|
|
exc->face->sph_compatibility_mode =
|
|
|
|
( ( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_1 ) |
|
|
|
|
( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) );
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
switch ( exc->opcode )
|
|
|
|
{
|
|
|
|
case 0x89: /* IDEF */
|
|
|
|
case 0x2C: /* FDEF */
|
|
|
|
exc->error = FT_THROW( Nested_DEFS );
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 0x2D: /* ENDF */
|
|
|
|
rec->end = exc->IP;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* ENDF[]: END Function definition */
|
|
|
|
/* Opcode range: 0x2D */
|
|
|
|
/* Stack: --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_ENDF( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
TT_CallRec* pRec;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->sph_in_func_flags = 0x0000;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( exc->callTop <= 0 ) /* We encountered an ENDF without a call */
|
|
|
|
{
|
|
|
|
exc->error = FT_THROW( ENDF_In_Exec_Stream );
|
|
|
|
return;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->callTop--;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
pRec = &exc->callStack[exc->callTop];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
pRec->Cur_Count--;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->step_ins = FALSE;
|
|
|
|
|
|
|
|
if ( pRec->Cur_Count > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->callTop++;
|
|
|
|
exc->IP = pRec->Def->start;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2011-01-31 18:51:07 +01:00
|
|
|
else
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Loop through the current function */
|
|
|
|
Ins_Goto_CodeRange( exc, pRec->Caller_Range, pRec->Caller_IP );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Exit the current call frame. */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* NOTE: If the last instruction 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! */
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* CALL[]: CALL function */
|
|
|
|
/* Opcode range: 0x2B */
|
|
|
|
/* Stack: uint32? --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_CALL( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_ULong F;
|
|
|
|
TT_CallRec* pCrec;
|
|
|
|
TT_DefRecord* def;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* first of all, check the index */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-02-17 09:21:26 +01:00
|
|
|
F = (FT_ULong)args[0];
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDSL( F, exc->maxFunc + 1 ) )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Except for some old Apple fonts, all functions in a TrueType */
|
|
|
|
/* font are defined in increasing order, starting from 0. This */
|
|
|
|
/* means that we normally have */
|
|
|
|
/* */
|
|
|
|
/* exc->maxFunc+1 == exc->numFDefs */
|
|
|
|
/* exc->FDefs[n].opc == n for n in 0..exc->maxFunc */
|
|
|
|
/* */
|
|
|
|
/* If this isn't true, we need to look up the function table. */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
def = exc->FDefs + F;
|
|
|
|
if ( exc->maxFunc + 1 != exc->numFDefs || def->opc != F )
|
|
|
|
{
|
|
|
|
/* look up the FDefs table */
|
|
|
|
TT_DefRecord* limit;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
def = exc->FDefs;
|
|
|
|
limit = def + exc->numFDefs;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
while ( def < limit && def->opc != F )
|
|
|
|
def++;
|
|
|
|
|
|
|
|
if ( def == limit )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* check that the function is active */
|
|
|
|
if ( !def->active )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
( ( exc->iup_called &&
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_NO_CALL_AFTER_IUP ) ) ||
|
|
|
|
( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) ) )
|
|
|
|
goto Fail;
|
|
|
|
else
|
|
|
|
exc->sph_in_func_flags = def->sph_fdef_flags;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* check the call stack */
|
|
|
|
if ( exc->callTop >= exc->callSize )
|
|
|
|
{
|
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
|
|
|
return;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
pCrec = exc->callStack + exc->callTop;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
pCrec->Caller_Range = exc->curRange;
|
|
|
|
pCrec->Caller_IP = exc->IP + 1;
|
|
|
|
pCrec->Cur_Count = 1;
|
|
|
|
pCrec->Def = def;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->callTop++;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_Goto_CodeRange( exc, def->range, def->start );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->step_ins = FALSE;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
return;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
Fail:
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* LOOPCALL[]: LOOP and CALL function */
|
|
|
|
/* Opcode range: 0x2A */
|
|
|
|
/* Stack: uint32? Eint16? --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_LOOPCALL( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_ULong F;
|
|
|
|
TT_CallRec* pCrec;
|
|
|
|
TT_DefRecord* def;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* first of all, check the index */
|
2015-02-17 09:21:26 +01:00
|
|
|
F = (FT_ULong)args[1];
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDSL( F, exc->maxFunc + 1 ) )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Except for some old Apple fonts, all functions in a TrueType */
|
|
|
|
/* font are defined in increasing order, starting from 0. This */
|
|
|
|
/* means that we normally have */
|
|
|
|
/* */
|
|
|
|
/* exc->maxFunc+1 == exc->numFDefs */
|
|
|
|
/* exc->FDefs[n].opc == n for n in 0..exc->maxFunc */
|
|
|
|
/* */
|
|
|
|
/* If this isn't true, we need to look up the function table. */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
def = exc->FDefs + F;
|
|
|
|
if ( exc->maxFunc + 1 != exc->numFDefs || def->opc != F )
|
|
|
|
{
|
|
|
|
/* look up the FDefs table */
|
|
|
|
TT_DefRecord* limit;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
def = exc->FDefs;
|
|
|
|
limit = def + exc->numFDefs;
|
2012-12-18 02:17:30 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
while ( def < limit && def->opc != F )
|
|
|
|
def++;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( def == limit )
|
|
|
|
goto Fail;
|
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* check that the function is active */
|
|
|
|
if ( !def->active )
|
|
|
|
goto Fail;
|
2000-06-12 21:36:41 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) )
|
|
|
|
goto Fail;
|
|
|
|
else
|
|
|
|
exc->sph_in_func_flags = def->sph_fdef_flags;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* check stack */
|
|
|
|
if ( exc->callTop >= exc->callSize )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
|
|
|
return;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( args[0] > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
pCrec = exc->callStack + exc->callTop;
|
|
|
|
|
|
|
|
pCrec->Caller_Range = exc->curRange;
|
|
|
|
pCrec->Caller_IP = exc->IP + 1;
|
|
|
|
pCrec->Cur_Count = (FT_Int)args[0];
|
|
|
|
pCrec->Def = def;
|
|
|
|
|
|
|
|
exc->callTop++;
|
|
|
|
|
|
|
|
Ins_Goto_CodeRange( exc, def->range, def->start );
|
|
|
|
|
|
|
|
exc->step_ins = FALSE;
|
2016-09-27 08:44:31 +02:00
|
|
|
|
2016-10-29 00:18:56 +02:00
|
|
|
exc->loopcall_counter += (FT_ULong)args[0];
|
2016-09-27 08:44:31 +02:00
|
|
|
if ( exc->loopcall_counter > exc->loopcall_counter_max )
|
|
|
|
exc->error = FT_THROW( Execution_Too_Long );
|
2015-01-11 10:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* IDEF[]: Instruction DEFinition */
|
|
|
|
/* Opcode range: 0x89 */
|
|
|
|
/* Stack: Eint8 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_IDEF( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
TT_DefRecord* def;
|
|
|
|
TT_DefRecord* limit;
|
|
|
|
|
|
|
|
|
2017-04-03 11:37:33 +02:00
|
|
|
/* we enable IDEF only in `prep' or `fpgm' */
|
|
|
|
if ( exc->curRange == tt_coderange_glyph )
|
|
|
|
{
|
|
|
|
exc->error = FT_THROW( DEF_In_Glyf_Bytecode );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* First of all, look for the same function in our table */
|
|
|
|
|
|
|
|
def = exc->IDefs;
|
|
|
|
limit = def + exc->numIDefs;
|
|
|
|
|
|
|
|
for ( ; def < limit; def++ )
|
|
|
|
if ( def->opc == (FT_ULong)args[0] )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ( def == limit )
|
|
|
|
{
|
|
|
|
/* check that there is enough room for a new instruction */
|
|
|
|
if ( exc->numIDefs >= exc->maxIDefs )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Too_Many_Instruction_Defs );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->numIDefs++;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* opcode must be unsigned 8-bit integer */
|
|
|
|
if ( 0 > args[0] || args[0] > 0x00FF )
|
2009-07-31 17:32:17 +02:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Too_Many_Instruction_Defs );
|
2009-07-31 17:32:17 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
def->opc = (FT_Byte)args[0];
|
|
|
|
def->start = exc->IP + 1;
|
|
|
|
def->range = exc->curRange;
|
|
|
|
def->active = TRUE;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( (FT_ULong)args[0] > exc->maxIns )
|
|
|
|
exc->maxIns = (FT_Byte)args[0];
|
2013-01-26 19:29:52 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* Now skip the whole function definition. */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* We don't allow nested IDEFs & FDEFs. */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
while ( SkipCode( exc ) == SUCCESS )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
switch ( exc->opcode )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
case 0x89: /* IDEF */
|
|
|
|
case 0x2C: /* FDEF */
|
|
|
|
exc->error = FT_THROW( Nested_DEFS );
|
|
|
|
return;
|
|
|
|
case 0x2D: /* ENDF */
|
2016-07-22 06:59:36 +02:00
|
|
|
def->end = exc->IP;
|
2015-01-11 10:08:09 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-26 19:29:52 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* PUSHING DATA ONTO THE INTERPRETER STACK */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
2013-01-26 19:29:52 +01:00
|
|
|
|
2013-05-17 13:51:07 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* NPUSHB[]: PUSH N Bytes */
|
|
|
|
/* Opcode range: 0x40 */
|
|
|
|
/* Stack: --> uint32... */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_NPUSHB( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
FT_UShort L, K;
|
2013-05-17 13:51:07 +02:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
L = (FT_UShort)exc->code[exc->IP + 1];
|
2013-05-17 13:51:07 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
|
|
|
|
{
|
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
|
|
|
return;
|
|
|
|
}
|
2013-05-20 07:38:21 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
for ( K = 1; K <= L; K++ )
|
|
|
|
args[K - 1] = exc->code[exc->IP + K + 1];
|
2013-05-20 07:38:21 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->new_top += L;
|
|
|
|
}
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* NPUSHW[]: PUSH N Words */
|
|
|
|
/* Opcode range: 0x41 */
|
|
|
|
/* Stack: --> int32... */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_NPUSHW( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
FT_UShort L, K;
|
2012-12-17 02:52:01 +01:00
|
|
|
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
L = (FT_UShort)exc->code[exc->IP + 1];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
|
|
|
|
{
|
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
|
|
|
return;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2015-01-11 10:08:09 +01:00
|
|
|
|
|
|
|
exc->IP += 2;
|
|
|
|
|
|
|
|
for ( K = 0; K < L; K++ )
|
|
|
|
args[K] = GetShortIns( exc );
|
|
|
|
|
|
|
|
exc->step_ins = FALSE;
|
|
|
|
exc->new_top += L;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* PUSHB[abc]: PUSH Bytes */
|
|
|
|
/* Opcode range: 0xB0-0xB7 */
|
|
|
|
/* Stack: --> uint32... */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_PUSHB( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_UShort L, K;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
L = (FT_UShort)( exc->opcode - 0xB0 + 1 );
|
2013-05-20 07:38:21 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
for ( K = 1; K <= L; K++ )
|
|
|
|
args[K - 1] = exc->code[exc->IP + K];
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* PUSHW[abc]: PUSH Words */
|
|
|
|
/* Opcode range: 0xB8-0xBF */
|
|
|
|
/* Stack: --> int32... */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_PUSHW( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
FT_UShort L, K;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
L = (FT_UShort)( exc->opcode - 0xB8 + 1 );
|
|
|
|
|
|
|
|
if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
|
|
|
return;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->IP++;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
for ( K = 0; K < L; K++ )
|
|
|
|
args[K] = GetShortIns( exc );
|
|
|
|
|
|
|
|
exc->step_ins = FALSE;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* MANAGING THE GRAPHICS STATE */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
static FT_Bool
|
|
|
|
Ins_SxVTL( TT_ExecContext exc,
|
|
|
|
FT_UShort aIdx1,
|
|
|
|
FT_UShort aIdx2,
|
|
|
|
FT_UnitVector* Vec )
|
|
|
|
{
|
|
|
|
FT_Long A, B, C;
|
|
|
|
FT_Vector* p1;
|
|
|
|
FT_Vector* p2;
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_Byte opcode = exc->opcode;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( BOUNDS( aIdx1, exc->zp2.n_points ) ||
|
|
|
|
BOUNDS( aIdx2, exc->zp1.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
p1 = exc->zp1.cur + aIdx2;
|
|
|
|
p2 = exc->zp2.cur + aIdx1;
|
2000-06-12 21:36:41 +02:00
|
|
|
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
A = SUB_LONG( p1->x, p2->x );
|
|
|
|
B = SUB_LONG( p1->y, p2->y );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* If p1 == p2, SPvTL and SFvTL behave the same as */
|
|
|
|
/* SPvTCA[X] and SFvTCA[X], respectively. */
|
|
|
|
/* */
|
|
|
|
/* Confirmed by Greg Hitchcock. */
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( A == 0 && B == 0 )
|
|
|
|
{
|
|
|
|
A = 0x4000;
|
|
|
|
opcode = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( ( opcode & 1 ) != 0 )
|
|
|
|
{
|
2017-06-27 06:16:04 +02:00
|
|
|
C = B; /* counter clockwise rotation */
|
|
|
|
B = A;
|
|
|
|
A = NEG_LONG( C );
|
2015-01-11 10:08:09 +01:00
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
Normalize( A, B, Vec );
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SVTCA[a]: Set (F and P) Vectors to Coordinate Axis */
|
|
|
|
/* Opcode range: 0x00-0x01 */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
/* SPvTCA[a]: Set PVector to Coordinate Axis */
|
|
|
|
/* Opcode range: 0x02-0x03 */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
/* SFvTCA[a]: Set FVector to Coordinate Axis */
|
|
|
|
/* Opcode range: 0x04-0x05 */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SxyTCA( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
FT_Short AA, BB;
|
|
|
|
|
|
|
|
FT_Byte opcode = exc->opcode;
|
|
|
|
|
|
|
|
|
|
|
|
AA = (FT_Short)( ( opcode & 1 ) << 14 );
|
|
|
|
BB = (FT_Short)( AA ^ 0x4000 );
|
|
|
|
|
|
|
|
if ( opcode < 4 )
|
|
|
|
{
|
|
|
|
exc->GS.projVector.x = AA;
|
|
|
|
exc->GS.projVector.y = BB;
|
|
|
|
|
|
|
|
exc->GS.dualVector.x = AA;
|
|
|
|
exc->GS.dualVector.y = BB;
|
|
|
|
}
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
if ( ( opcode & 2 ) == 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->GS.freeVector.x = AA;
|
|
|
|
exc->GS.freeVector.y = BB;
|
|
|
|
}
|
|
|
|
|
|
|
|
Compute_Funcs( exc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SPvTL[a]: Set PVector To Line */
|
|
|
|
/* Opcode range: 0x06-0x07 */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SPVTL( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
if ( Ins_SxVTL( exc,
|
|
|
|
(FT_UShort)args[1],
|
|
|
|
(FT_UShort)args[0],
|
|
|
|
&exc->GS.projVector ) == SUCCESS )
|
|
|
|
{
|
|
|
|
exc->GS.dualVector = exc->GS.projVector;
|
|
|
|
Compute_Funcs( exc );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SFvTL[a]: Set FVector To Line */
|
|
|
|
/* Opcode range: 0x08-0x09 */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SFVTL( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
if ( Ins_SxVTL( exc,
|
|
|
|
(FT_UShort)args[1],
|
|
|
|
(FT_UShort)args[0],
|
|
|
|
&exc->GS.freeVector ) == SUCCESS )
|
|
|
|
{
|
|
|
|
Compute_Funcs( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2015-01-11 10:08:09 +01:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SFvTPv[]: Set FVector To PVector */
|
|
|
|
/* Opcode range: 0x0E */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SFVTPV( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
exc->GS.freeVector = exc->GS.projVector;
|
|
|
|
Compute_Funcs( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SPvFS[]: Set PVector From Stack */
|
|
|
|
/* Opcode range: 0x0A */
|
|
|
|
/* Stack: f2.14 f2.14 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_SPVFS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
FT_Short S;
|
|
|
|
FT_Long X, Y;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Only use low 16bits, then sign extend */
|
|
|
|
S = (FT_Short)args[1];
|
|
|
|
Y = (FT_Long)S;
|
|
|
|
S = (FT_Short)args[0];
|
|
|
|
X = (FT_Long)S;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
Normalize( X, Y, &exc->GS.projVector );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->GS.dualVector = exc->GS.projVector;
|
|
|
|
Compute_Funcs( exc );
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SFvFS[]: Set FVector From Stack */
|
|
|
|
/* Opcode range: 0x0B */
|
|
|
|
/* Stack: f2.14 f2.14 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SFVFS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
FT_Short S;
|
|
|
|
FT_Long X, Y;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/* Only use low 16bits, then sign extend */
|
|
|
|
S = (FT_Short)args[1];
|
|
|
|
Y = (FT_Long)S;
|
|
|
|
S = (FT_Short)args[0];
|
|
|
|
X = S;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
Normalize( X, Y, &exc->GS.freeVector );
|
|
|
|
Compute_Funcs( exc );
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2013-01-26 19:29:52 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* GPv[]: Get Projection Vector */
|
|
|
|
/* Opcode range: 0x0C */
|
|
|
|
/* Stack: ef2.14 --> ef2.14 */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_GPV( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
args[0] = exc->GS.projVector.x;
|
|
|
|
args[1] = exc->GS.projVector.y;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* GFv[]: Get Freedom Vector */
|
|
|
|
/* Opcode range: 0x0D */
|
|
|
|
/* Stack: ef2.14 --> ef2.14 */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_GFV( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
args[0] = exc->GS.freeVector.x;
|
|
|
|
args[1] = exc->GS.freeVector.y;
|
|
|
|
}
|
2009-07-31 17:32:18 +02:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SRP0[]: Set Reference Point 0 */
|
|
|
|
/* Opcode range: 0x10 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SRP0( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
exc->GS.rp0 = (FT_UShort)args[0];
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SRP1[]: Set Reference Point 1 */
|
|
|
|
/* Opcode range: 0x11 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SRP1( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
exc->GS.rp1 = (FT_UShort)args[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SRP2[]: Set Reference Point 2 */
|
|
|
|
/* Opcode range: 0x12 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SRP2( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
exc->GS.rp2 = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SMD[]: Set Minimum Distance */
|
|
|
|
/* Opcode range: 0x1A */
|
|
|
|
/* Stack: f26.6 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
static void
|
|
|
|
Ins_SMD( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
exc->GS.minimum_distance = args[0];
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SCVTCI[]: Set Control Value Table Cut In */
|
|
|
|
/* Opcode range: 0x1D */
|
|
|
|
/* Stack: f26.6 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_SCVTCI( TT_ExecContext exc,
|
2015-01-11 08:39:14 +01:00
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->GS.control_value_cutin = (FT_F26Dot6)args[0];
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SSWCI[]: Set Single Width Cut In */
|
|
|
|
/* Opcode range: 0x1E */
|
|
|
|
/* Stack: f26.6 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SSWCI( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
exc->GS.single_width_cutin = (FT_F26Dot6)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SSW[]: Set Single Width */
|
|
|
|
/* Opcode range: 0x1F */
|
|
|
|
/* Stack: int32? --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_SSW( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->GS.single_width_value = FT_MulFix( args[0],
|
|
|
|
exc->tt_metrics.scale );
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* FLIPON[]: Set auto-FLIP to ON */
|
|
|
|
/* Opcode range: 0x4D */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_FLIPON( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
exc->GS.auto_flip = TRUE;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* FLIPOFF[]: Set auto-FLIP to OFF */
|
|
|
|
/* Opcode range: 0x4E */
|
2016-08-12 05:03:09 +02:00
|
|
|
/* Stack: --> */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_FLIPOFF( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
exc->GS.auto_flip = FALSE;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SANGW[]: Set ANGle Weight */
|
|
|
|
/* Opcode range: 0x7E */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SANGW( void )
|
|
|
|
{
|
|
|
|
/* instruction not supported anymore */
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SDB[]: Set Delta Base */
|
|
|
|
/* Opcode range: 0x5E */
|
|
|
|
/* Stack: uint32 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_SDB( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->GS.delta_base = (FT_UShort)args[0];
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SDS[]: Set Delta Shift */
|
|
|
|
/* Opcode range: 0x5F */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_SDS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
if ( (FT_ULong)args[0] > 6UL )
|
|
|
|
exc->error = FT_THROW( Bad_Argument );
|
|
|
|
else
|
|
|
|
exc->GS.delta_shift = (FT_UShort)args[0];
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* RTHG[]: Round To Half Grid */
|
|
|
|
/* Opcode range: 0x19 */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_RTHG( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
exc->GS.round_state = TT_Round_To_Half_Grid;
|
|
|
|
exc->func_round = (TT_Round_Func)Round_To_Half_Grid;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* RTG[]: Round To Grid */
|
|
|
|
/* Opcode range: 0x18 */
|
|
|
|
/* Stack: --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 10:08:09 +01:00
|
|
|
Ins_RTG( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 10:08:09 +01:00
|
|
|
exc->GS.round_state = TT_Round_To_Grid;
|
|
|
|
exc->func_round = (TT_Round_Func)Round_To_Grid;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* RTDG[]: Round To Double Grid */
|
|
|
|
/* Opcode range: 0x3D */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_RTDG( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
exc->GS.round_state = TT_Round_To_Double_Grid;
|
|
|
|
exc->func_round = (TT_Round_Func)Round_To_Double_Grid;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* RUTG[]: Round Up To Grid */
|
|
|
|
/* Opcode range: 0x7C */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_RUTG( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
exc->GS.round_state = TT_Round_Up_To_Grid;
|
|
|
|
exc->func_round = (TT_Round_Func)Round_Up_To_Grid;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-11 10:08:09 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* RDTG[]: Round Down To Grid */
|
|
|
|
/* Opcode range: 0x7D */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_RDTG( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
exc->GS.round_state = TT_Round_Down_To_Grid;
|
|
|
|
exc->func_round = (TT_Round_Func)Round_Down_To_Grid;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* ROFF[]: Round OFF */
|
|
|
|
/* Opcode range: 0x7A */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_ROFF( TT_ExecContext exc )
|
|
|
|
{
|
|
|
|
exc->GS.round_state = TT_Round_Off;
|
|
|
|
exc->func_round = (TT_Round_Func)Round_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
/* SROUND[]: Super ROUND */
|
|
|
|
/* Opcode range: 0x76 */
|
|
|
|
/* Stack: Eint8 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2015-01-11 10:08:09 +01:00
|
|
|
static void
|
|
|
|
Ins_SROUND( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
SetSuperRound( exc, 0x4000, args[0] );
|
|
|
|
|
|
|
|
exc->GS.round_state = TT_Round_Super;
|
|
|
|
exc->func_round = (TT_Round_Func)Round_Super;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
2015-01-11 10:08:09 +01:00
|
|
|
/* */
|
|
|
|
/* S45ROUND[]: Super ROUND 45 degrees */
|
|
|
|
/* Opcode range: 0x77 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_S45ROUND( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
SetSuperRound( exc, 0x2D41, args[0] );
|
|
|
|
|
|
|
|
exc->GS.round_state = TT_Round_Super_45;
|
|
|
|
exc->func_round = (TT_Round_Func)Round_Super_45;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* GC[a]: Get Coordinate projected onto */
|
|
|
|
/* Opcode range: 0x46-0x47 */
|
|
|
|
/* Stack: uint32 --> f26.6 */
|
|
|
|
/* */
|
2012-02-29 13:59:49 +01:00
|
|
|
/* XXX: UNDOCUMENTED: Measures from the original glyph must be taken */
|
|
|
|
/* along the dual projection vector! */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_GC( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_ULong L;
|
|
|
|
FT_F26Dot6 R;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
L = (FT_ULong)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDSL( L, exc->zp2.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-31 18:51:07 +01:00
|
|
|
R = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->opcode & 1 )
|
2015-01-11 09:50:49 +01:00
|
|
|
R = FAST_DUALPROJ( &exc->zp2.org[L] );
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-11 09:50:49 +01:00
|
|
|
R = FAST_PROJECT( &exc->zp2.cur[L] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
args[0] = R;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SCFS[]: Set Coordinate From Stack */
|
|
|
|
/* Opcode range: 0x48 */
|
|
|
|
/* Stack: f26.6 uint32 --> */
|
|
|
|
/* */
|
|
|
|
/* Formula: */
|
|
|
|
/* */
|
|
|
|
/* OA := OA + ( value - OA.p )/( f.p ) * f */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SCFS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Long K;
|
|
|
|
FT_UShort L;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
L = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( L, exc->zp2.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
K = FAST_PROJECT( &exc->zp2.cur[L] );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2017-07-03 06:27:52 +02:00
|
|
|
exc->func_move( exc, &exc->zp2, L, SUB_LONG( args[1], K ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2011-08-05 09:07:21 +02:00
|
|
|
/* UNDOCUMENTED! The MS rasterizer does that with */
|
|
|
|
/* twilight points (confirmed by Greg Hitchcock) */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep2 == 0 )
|
|
|
|
exc->zp2.org[L] = exc->zp2.cur[L];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* MD[a]: Measure Distance */
|
|
|
|
/* Opcode range: 0x49-0x4A */
|
|
|
|
/* Stack: uint32 uint32 --> f26.6 */
|
|
|
|
/* */
|
2012-02-29 13:59:49 +01:00
|
|
|
/* XXX: UNDOCUMENTED: Measure taken in the original glyph must be along */
|
|
|
|
/* the dual projection vector. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2012-02-29 13:59:49 +01:00
|
|
|
/* XXX: UNDOCUMENTED: Flag attributes are inverted! */
|
|
|
|
/* 0 => measure distance in original outline */
|
|
|
|
/* 1 => measure distance in grid-fitted outline */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2012-02-29 13:59:49 +01:00
|
|
|
/* XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MD( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort K, L;
|
|
|
|
FT_F26Dot6 D;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
K = (FT_UShort)args[1];
|
|
|
|
L = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( L, exc->zp0.n_points ) ||
|
|
|
|
BOUNDS( K, exc->zp1.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
D = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->opcode & 1 )
|
2015-01-11 09:50:49 +01:00
|
|
|
D = PROJECT( exc->zp0.cur + L, exc->zp1.cur + K );
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2008-05-28 01:24:07 +02:00
|
|
|
{
|
2011-10-25 20:25:32 +02:00
|
|
|
/* XXX: UNDOCUMENTED: twilight zone special case */
|
2008-05-28 01:24:07 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 )
|
2008-05-28 01:24:07 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
FT_Vector* vec1 = exc->zp0.org + L;
|
|
|
|
FT_Vector* vec2 = exc->zp1.org + K;
|
2011-10-25 20:25:32 +02:00
|
|
|
|
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
D = DUALPROJ( vec1, vec2 );
|
2008-05-28 01:24:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
FT_Vector* vec1 = exc->zp0.orus + L;
|
|
|
|
FT_Vector* vec2 = exc->zp1.orus + K;
|
2008-05-28 01:24:07 +02:00
|
|
|
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->metrics.x_scale == exc->metrics.y_scale )
|
2011-10-25 20:25:32 +02:00
|
|
|
{
|
|
|
|
/* this should be faster */
|
2015-01-11 09:50:49 +01:00
|
|
|
D = DUALPROJ( vec1, vec2 );
|
2015-01-10 19:56:28 +01:00
|
|
|
D = FT_MulFix( D, exc->metrics.x_scale );
|
2011-10-25 20:25:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_Vector vec;
|
|
|
|
|
2008-05-28 01:24:07 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
vec.x = FT_MulFix( vec1->x - vec2->x, exc->metrics.x_scale );
|
|
|
|
vec.y = FT_MulFix( vec1->y - vec2->y, exc->metrics.y_scale );
|
2011-10-25 20:25:32 +02:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
D = FAST_DUALPROJ( &vec );
|
2011-10-25 20:25:32 +02:00
|
|
|
}
|
2008-05-28 01:24:07 +02:00
|
|
|
}
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
/* Disable Type 2 Vacuform Rounds - e.g. Arial Narrow */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
|
|
|
exc->ignore_x_mode &&
|
|
|
|
FT_ABS( D ) == 64 )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
D += 1;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
args[0] = D;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2015-01-11 00:56:55 +01:00
|
|
|
/* SDPvTL[a]: Set Dual PVector to Line */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* Opcode range: 0x86-0x87 */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SDPVTL( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Long A, B, C;
|
2011-08-12 19:50:13 +02:00
|
|
|
FT_UShort p1, p2; /* was FT_Int in pas type ERROR */
|
2015-01-11 08:53:31 +01:00
|
|
|
|
|
|
|
FT_Byte opcode = exc->opcode;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
p1 = (FT_UShort)args[1];
|
|
|
|
p2 = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( p2, exc->zp1.n_points ) ||
|
|
|
|
BOUNDS( p1, exc->zp2.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2017-06-22 11:52:43 +02:00
|
|
|
FT_Vector* v1 = exc->zp1.org + p2;
|
|
|
|
FT_Vector* v2 = exc->zp2.org + p1;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2017-06-22 11:52:43 +02:00
|
|
|
A = SUB_LONG( v1->x, v2->x );
|
|
|
|
B = SUB_LONG( v1->y, v2->y );
|
2011-08-12 19:50:13 +02:00
|
|
|
|
2015-01-11 00:56:55 +01:00
|
|
|
/* If v1 == v2, SDPvTL behaves the same as */
|
2011-08-12 19:50:13 +02:00
|
|
|
/* SVTCA[X], respectively. */
|
|
|
|
/* */
|
|
|
|
/* Confirmed by Greg Hitchcock. */
|
|
|
|
|
|
|
|
if ( A == 0 && B == 0 )
|
|
|
|
{
|
2015-01-11 08:53:31 +01:00
|
|
|
A = 0x4000;
|
|
|
|
opcode = 0;
|
2011-08-12 19:50:13 +02:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 08:53:31 +01:00
|
|
|
if ( ( opcode & 1 ) != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2017-06-22 11:52:43 +02:00
|
|
|
C = B; /* counter clockwise rotation */
|
|
|
|
B = A;
|
|
|
|
A = NEG_LONG( C );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 08:45:50 +01:00
|
|
|
Normalize( A, B, &exc->GS.dualVector );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
FT_Vector* v1 = exc->zp1.cur + p2;
|
|
|
|
FT_Vector* v2 = exc->zp2.cur + p1;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2017-06-22 11:52:43 +02:00
|
|
|
A = SUB_LONG( v1->x, v2->x );
|
|
|
|
B = SUB_LONG( v1->y, v2->y );
|
2013-06-10 01:44:37 +02:00
|
|
|
|
|
|
|
if ( A == 0 && B == 0 )
|
|
|
|
{
|
2015-01-11 08:53:31 +01:00
|
|
|
A = 0x4000;
|
|
|
|
opcode = 0;
|
2013-06-10 01:44:37 +02:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 08:53:31 +01:00
|
|
|
if ( ( opcode & 1 ) != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2017-06-22 11:52:43 +02:00
|
|
|
C = B; /* counter clockwise rotation */
|
|
|
|
B = A;
|
|
|
|
A = NEG_LONG( C );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 08:45:50 +01:00
|
|
|
Normalize( A, B, &exc->GS.projVector );
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Compute_Funcs( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SZP0[]: Set Zone Pointer 0 */
|
|
|
|
/* Opcode range: 0x13 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SZP0( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
switch ( (FT_Int)args[0] )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp0 = exc->twilight;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp0 = exc->pts;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.gep0 = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SZP1[]: Set Zone Pointer 1 */
|
|
|
|
/* Opcode range: 0x14 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SZP1( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
switch ( (FT_Int)args[0] )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp1 = exc->twilight;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp1 = exc->pts;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.gep1 = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SZP2[]: Set Zone Pointer 2 */
|
|
|
|
/* Opcode range: 0x15 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SZP2( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
switch ( (FT_Int)args[0] )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp2 = exc->twilight;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp2 = exc->pts;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.gep2 = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SZPS[]: Set Zone PointerS */
|
|
|
|
/* Opcode range: 0x16 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SZPS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
switch ( (FT_Int)args[0] )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp0 = exc->twilight;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp0 = exc->pts;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp1 = exc->zp0;
|
|
|
|
exc->zp2 = exc->zp0;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.gep0 = (FT_UShort)args[0];
|
|
|
|
exc->GS.gep1 = (FT_UShort)args[0];
|
|
|
|
exc->GS.gep2 = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* INSTCTRL[]: INSTruction ConTRoL */
|
2014-12-07 11:03:57 +01:00
|
|
|
/* Opcode range: 0x8E */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* Stack: int32 int32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_INSTCTRL( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-06-30 09:46:39 +02:00
|
|
|
FT_ULong K, L, Kf;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-06-30 09:46:39 +02:00
|
|
|
K = (FT_ULong)args[1];
|
|
|
|
L = (FT_ULong)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-05-22 22:02:15 +02:00
|
|
|
/* selector values cannot be `OR'ed; */
|
|
|
|
/* they are indices starting with index 1, not flags */
|
|
|
|
if ( K < 1 || K > 3 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-22 22:02:15 +02:00
|
|
|
/* convert index to flag value */
|
|
|
|
Kf = 1 << ( K - 1 );
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( L != 0 )
|
2015-05-22 22:02:15 +02:00
|
|
|
{
|
|
|
|
/* arguments to selectors look like flag values */
|
|
|
|
if ( L != Kf )
|
|
|
|
{
|
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-05-22 22:02:15 +02:00
|
|
|
exc->GS.instruct_control &= ~(FT_Byte)Kf;
|
|
|
|
exc->GS.instruct_control |= (FT_Byte)L;
|
|
|
|
|
|
|
|
if ( K == 3 )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
{
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
/* INSTCTRL modifying flag 3 also has an effect */
|
|
|
|
/* outside of the CVT program */
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY )
|
|
|
|
exc->ignore_x_mode = FT_BOOL( L == 4 );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
/* Native ClearType fonts sign a waiver that turns off all backward */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
/* compatibility hacks and lets them program points to the grid like */
|
|
|
|
/* it's 1996. They might sign a waiver for just one glyph, though. */
|
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL )
|
2017-05-03 23:54:29 +02:00
|
|
|
exc->backward_compatibility = !FT_BOOL( L == 4 );
|
2015-05-24 23:29:23 +02:00
|
|
|
#endif
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SCANCTRL[]: SCAN ConTRoL */
|
|
|
|
/* Opcode range: 0x85 */
|
|
|
|
/* Stack: uint32? --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SCANCTRL( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int A;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Get Threshold */
|
2000-06-16 21:34:52 +02:00
|
|
|
A = (FT_Int)( args[0] & 0xFF );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( A == 0xFF )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.scan_control = TRUE;
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if ( A == 0 )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.scan_control = FALSE;
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 0x100 ) != 0 && exc->tt_metrics.ppem <= A )
|
|
|
|
exc->GS.scan_control = TRUE;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 0x200 ) != 0 && exc->tt_metrics.rotated )
|
|
|
|
exc->GS.scan_control = TRUE;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 0x400 ) != 0 && exc->tt_metrics.stretched )
|
|
|
|
exc->GS.scan_control = TRUE;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 0x800 ) != 0 && exc->tt_metrics.ppem > A )
|
|
|
|
exc->GS.scan_control = FALSE;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 0x1000 ) != 0 && exc->tt_metrics.rotated )
|
|
|
|
exc->GS.scan_control = FALSE;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 0x2000 ) != 0 && exc->tt_metrics.stretched )
|
|
|
|
exc->GS.scan_control = FALSE;
|
2001-06-28 09:17:51 +02:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SCANTYPE[]: SCAN TYPE */
|
|
|
|
/* Opcode range: 0x8D */
|
2016-10-22 19:16:08 +02:00
|
|
|
/* Stack: uint16 --> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SCANTYPE( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2008-06-24 13:19:03 +02:00
|
|
|
if ( args[0] >= 0 )
|
2016-10-29 00:18:56 +02:00
|
|
|
exc->GS.scan_type = (FT_Int)args[0] & 0xFFFF;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* MANAGING OUTLINES */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* FLIPPT[]: FLIP PoinT */
|
|
|
|
/* Opcode range: 0x80 */
|
|
|
|
/* Stack: uint32... --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_FLIPPT( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort point;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-07-02 15:53:16 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
/* See `ttinterp.h' for details on backward compatibility mode. */
|
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility &&
|
|
|
|
exc->iupx_called &&
|
|
|
|
exc->iupy_called )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
goto Fail;
|
|
|
|
#endif
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->top < exc->GS.loop )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Too_Few_Arguments );
|
2011-01-31 18:51:07 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
while ( exc->GS.loop > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->args--;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
point = (FT_UShort)exc->stack[exc->args];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->pts.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->pts.tags[point] ^= FT_CURVE_TAG_ON;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop--;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 18:51:07 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop = 1;
|
|
|
|
exc->new_top = exc->args;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* FLIPRGON[]: FLIP RanGe ON */
|
|
|
|
/* Opcode range: 0x81 */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_FLIPRGON( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort I, K, L;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
/* See `ttinterp.h' for details on backward compatibility mode. */
|
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility &&
|
|
|
|
exc->iupx_called &&
|
|
|
|
exc->iupy_called )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
K = (FT_UShort)args[1];
|
|
|
|
L = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( K, exc->pts.n_points ) ||
|
|
|
|
BOUNDS( L, exc->pts.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( I = L; I <= K; I++ )
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->pts.tags[I] |= FT_CURVE_TAG_ON;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* FLIPRGOFF: FLIP RanGe OFF */
|
|
|
|
/* Opcode range: 0x82 */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_FLIPRGOFF( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort I, K, L;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
/* See `ttinterp.h' for details on backward compatibility mode. */
|
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility &&
|
|
|
|
exc->iupx_called &&
|
|
|
|
exc->iupy_called )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
K = (FT_UShort)args[1];
|
|
|
|
L = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( K, exc->pts.n_points ) ||
|
|
|
|
BOUNDS( L, exc->pts.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( I = L; I <= K; I++ )
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->pts.tags[I] &= ~FT_CURVE_TAG_ON;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_Bool
|
2015-01-10 20:23:10 +01:00
|
|
|
Compute_Point_Displacement( TT_ExecContext exc,
|
|
|
|
FT_F26Dot6* x,
|
|
|
|
FT_F26Dot6* y,
|
|
|
|
TT_GlyphZone zone,
|
|
|
|
FT_UShort* refp )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-14 12:26:29 +01:00
|
|
|
TT_GlyphZoneRec zp;
|
2002-04-01 16:25:28 +02:00
|
|
|
FT_UShort p;
|
|
|
|
FT_F26Dot6 d;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->opcode & 1 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
zp = exc->zp0;
|
|
|
|
p = exc->GS.rp1;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
zp = exc->zp1;
|
|
|
|
p = exc->GS.rp2;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( BOUNDS( p, zp.n_points ) )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2007-01-15 07:42:40 +01:00
|
|
|
*refp = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*zone = zp;
|
|
|
|
*refp = p;
|
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
d = PROJECT( zp.cur + p, zp.org + p );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2016-01-28 12:24:36 +01:00
|
|
|
*x = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.x, exc->F_dot_P );
|
|
|
|
*y = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.y, exc->F_dot_P );
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-03 23:54:29 +02:00
|
|
|
/* See `ttinterp.h' for details on backward compatibility mode. */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-10 20:23:10 +01:00
|
|
|
Move_Zp2_Point( TT_ExecContext exc,
|
|
|
|
FT_UShort point,
|
|
|
|
FT_F26Dot6 dx,
|
|
|
|
FT_F26Dot6 dy,
|
|
|
|
FT_Bool touch )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.x != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
if ( !( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility ) )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif
|
2017-06-09 11:21:58 +02:00
|
|
|
exc->zp2.cur[point].x = ADD_LONG( exc->zp2.cur[point].x, dx );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( touch )
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.y != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
if ( !( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility &&
|
|
|
|
exc->iupx_called &&
|
|
|
|
exc->iupy_called ) )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif
|
2017-06-09 11:21:58 +02:00
|
|
|
exc->zp2.cur[point].y = ADD_LONG( exc->zp2.cur[point].y, dy );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( touch )
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SHP[a]: SHift Point by the last point */
|
|
|
|
/* Opcode range: 0x32-0x33 */
|
|
|
|
/* Stack: uint32... --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SHP( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-14 12:26:29 +01:00
|
|
|
TT_GlyphZoneRec zp;
|
2002-04-01 16:25:28 +02:00
|
|
|
FT_UShort refp;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 08:39:14 +01:00
|
|
|
FT_F26Dot6 dx, dy;
|
2002-04-01 16:25:28 +02:00
|
|
|
FT_UShort point;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->top < exc->GS.loop )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-31 18:51:07 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
if ( Compute_Point_Displacement( exc, &dx, &dy, &zp, &refp ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
while ( exc->GS.loop > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->args--;
|
|
|
|
point = (FT_UShort)exc->stack[exc->args];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp2.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2013-05-22 03:51:15 +02:00
|
|
|
/* doesn't follow Cleartype spec but produces better result */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Move_Zp2_Point( exc, point, 0, dy, TRUE );
|
2013-05-22 03:51:15 +02:00
|
|
|
else
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Move_Zp2_Point( exc, point, dx, dy, TRUE );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop--;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 18:51:07 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop = 1;
|
|
|
|
exc->new_top = exc->args;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SHC[a]: SHift Contour */
|
|
|
|
/* Opcode range: 0x34-35 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2012-02-29 14:47:47 +01:00
|
|
|
/* UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) */
|
|
|
|
/* contour in the twilight zone, namely contour number */
|
2012-03-10 09:30:27 +01:00
|
|
|
/* zero which includes all points of it. */
|
2012-02-29 14:47:47 +01:00
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SHC( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2012-02-26 08:47:20 +01:00
|
|
|
TT_GlyphZoneRec zp;
|
|
|
|
FT_UShort refp;
|
|
|
|
FT_F26Dot6 dx, dy;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2012-02-29 14:47:47 +01:00
|
|
|
FT_Short contour, bounds;
|
|
|
|
FT_UShort start, limit, i;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-02-17 09:21:26 +01:00
|
|
|
contour = (FT_Short)args[0];
|
2015-01-10 19:56:28 +01:00
|
|
|
bounds = ( exc->GS.gep2 == 0 ) ? 1 : exc->zp2.n_contours;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2012-02-29 14:47:47 +01:00
|
|
|
if ( BOUNDS( contour, bounds ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
if ( Compute_Point_Displacement( exc, &dx, &dy, &zp, &refp ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( contour == 0 )
|
2012-02-29 14:47:47 +01:00
|
|
|
start = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
start = (FT_UShort)( exc->zp2.contours[contour - 1] + 1 -
|
|
|
|
exc->zp2.first_point );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2012-02-29 14:47:47 +01:00
|
|
|
/* we use the number of points if in the twilight zone */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep2 == 0 )
|
|
|
|
limit = exc->zp2.n_points;
|
2012-02-29 14:47:47 +01:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
limit = (FT_UShort)( exc->zp2.contours[contour] -
|
|
|
|
exc->zp2.first_point + 1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2012-02-29 14:47:47 +01:00
|
|
|
for ( i = start; i < limit; i++ )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( zp.cur != exc->zp2.cur || refp != i )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Move_Zp2_Point( exc, i, dx, dy, TRUE );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SHZ[a]: SHift Zone */
|
|
|
|
/* Opcode range: 0x36-37 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SHZ( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2010-08-06 00:47:57 +02:00
|
|
|
TT_GlyphZoneRec zp;
|
|
|
|
FT_UShort refp;
|
|
|
|
FT_F26Dot6 dx,
|
|
|
|
dy;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2012-02-29 17:58:57 +01:00
|
|
|
FT_UShort limit, i;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( BOUNDS( args[0], 2 ) )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
if ( Compute_Point_Displacement( exc, &dx, &dy, &zp, &refp ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
|
2012-02-29 13:59:49 +01:00
|
|
|
/* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points. */
|
|
|
|
/* Twilight zone has no real contours, so use `n_points'. */
|
|
|
|
/* Normal zone's `n_points' includes phantoms, so must */
|
|
|
|
/* use end of last contour. */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep2 == 0 )
|
|
|
|
limit = (FT_UShort)exc->zp2.n_points;
|
|
|
|
else if ( exc->GS.gep2 == 1 && exc->zp2.n_contours > 0 )
|
|
|
|
limit = (FT_UShort)( exc->zp2.contours[exc->zp2.n_contours - 1] + 1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2012-02-29 17:58:57 +01:00
|
|
|
limit = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* XXX: UNDOCUMENTED! SHZ doesn't touch the points */
|
2012-02-29 17:58:57 +01:00
|
|
|
for ( i = 0; i < limit; i++ )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( zp.cur != exc->zp2.cur || refp != i )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Move_Zp2_Point( exc, i, dx, dy, FALSE );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* SHPIX[]: SHift points by a PIXel amount */
|
|
|
|
/* Opcode range: 0x38 */
|
|
|
|
/* Stack: f26.6 uint32... --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SHPIX( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 dx, dy;
|
|
|
|
FT_UShort point;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
FT_Int B1, B2;
|
|
|
|
#endif
|
2016-05-31 08:39:52 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2016-12-25 22:55:25 +01:00
|
|
|
FT_Bool in_twilight = FT_BOOL( exc->GS.gep0 == 0 ||
|
|
|
|
exc->GS.gep1 == 0 ||
|
|
|
|
exc->GS.gep2 == 0 );
|
2016-05-31 08:39:52 +02:00
|
|
|
#endif
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->top < exc->GS.loop + 1 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-31 18:51:07 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2016-01-28 12:24:36 +01:00
|
|
|
dx = TT_MulFix14( args[0], exc->GS.freeVector.x );
|
|
|
|
dy = TT_MulFix14( args[0], exc->GS.freeVector.y );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
while ( exc->GS.loop > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->args--;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
point = (FT_UShort)exc->stack[exc->args];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp2.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2015-01-11 09:50:49 +01:00
|
|
|
/* If not using ignore_x_mode rendering, allow ZP2 move. */
|
|
|
|
/* If inline deltas aren't allowed, skip ZP2 move. */
|
|
|
|
/* If using ignore_x_mode rendering, allow ZP2 point move if: */
|
|
|
|
/* - freedom vector is y and sph_compatibility_mode is off */
|
|
|
|
/* - the glyph is composite and the move is in the Y direction */
|
|
|
|
/* - the glyph is specifically set to allow SHPIX moves */
|
|
|
|
/* - the move is on a previously Y-touched point */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( exc->ignore_x_mode )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
|
|
|
/* save point for later comparison */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.y != 0 )
|
|
|
|
B1 = exc->zp2.cur[point].y;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
B1 = exc->zp2.cur[point].x;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( !exc->face->sph_compatibility_mode &&
|
|
|
|
exc->GS.freeVector.y != 0 )
|
2013-05-20 07:38:21 +02:00
|
|
|
{
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Move_Zp2_Point( exc, point, dx, dy, TRUE );
|
2013-05-20 07:38:21 +02:00
|
|
|
|
2013-05-22 03:51:15 +02:00
|
|
|
/* save new point */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.y != 0 )
|
2013-05-22 03:51:15 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
B2 = exc->zp2.cur[point].y;
|
2013-05-22 03:51:15 +02:00
|
|
|
|
|
|
|
/* reverse any disallowed moves */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
|
|
|
|
( B1 & 63 ) != 0 &&
|
|
|
|
( B2 & 63 ) != 0 &&
|
2015-01-11 09:50:49 +01:00
|
|
|
B1 != B2 )
|
2017-09-20 08:00:05 +02:00
|
|
|
Move_Zp2_Point( exc,
|
|
|
|
point,
|
|
|
|
NEG_LONG( dx ),
|
|
|
|
NEG_LONG( dy ),
|
|
|
|
TRUE );
|
2013-05-22 03:51:15 +02:00
|
|
|
}
|
|
|
|
}
|
2015-01-10 19:56:28 +01:00
|
|
|
else if ( exc->face->sph_compatibility_mode )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
|
|
|
dx = FT_PIX_ROUND( B1 + dx ) - B1;
|
|
|
|
dy = FT_PIX_ROUND( B1 + dy ) - B1;
|
|
|
|
}
|
|
|
|
|
2013-05-20 07:38:21 +02:00
|
|
|
/* skip post-iup deltas */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->iup_called &&
|
|
|
|
( ( exc->sph_in_func_flags & SPH_FDEF_INLINE_DELTA_1 ) ||
|
|
|
|
( exc->sph_in_func_flags & SPH_FDEF_INLINE_DELTA_2 ) ) )
|
2013-05-20 07:38:21 +02:00
|
|
|
goto Skip;
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( !( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) &&
|
|
|
|
( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
|
|
|
|
( exc->zp2.tags[point] & FT_CURVE_TAG_TOUCH_Y ) ||
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_DO_SHPIX ) ) )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Move_Zp2_Point( exc, point, 0, dy, TRUE );
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2013-05-22 03:51:15 +02:00
|
|
|
/* save new point */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.y != 0 )
|
2013-05-22 03:51:15 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
B2 = exc->zp2.cur[point].y;
|
2013-05-22 03:51:15 +02:00
|
|
|
|
|
|
|
/* reverse any disallowed moves */
|
2013-05-22 04:03:00 +02:00
|
|
|
if ( ( B1 & 63 ) == 0 &&
|
|
|
|
( B2 & 63 ) != 0 &&
|
|
|
|
B1 != B2 )
|
2017-09-20 08:00:05 +02:00
|
|
|
Move_Zp2_Point( exc, point, 0, NEG_LONG( dy ), TRUE );
|
2013-05-22 03:51:15 +02:00
|
|
|
}
|
|
|
|
}
|
2015-01-10 19:56:28 +01:00
|
|
|
else if ( exc->sph_in_func_flags & SPH_FDEF_TYPEMAN_DIAGENDCTRL )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Move_Zp2_Point( exc, point, dx, dy, TRUE );
|
2013-05-17 13:51:07 +02:00
|
|
|
}
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
else
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Move_Zp2_Point( exc, point, dx, dy, TRUE );
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
}
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
{
|
2016-05-31 08:39:52 +02:00
|
|
|
/* Special case: allow SHPIX to move points in the twilight zone. */
|
|
|
|
/* Otherwise, treat SHPIX the same as DELTAP. Unbreaks various */
|
|
|
|
/* fonts such as older versions of Rokkitt and DTL Argo T Light */
|
2017-01-19 05:12:31 +01:00
|
|
|
/* that would glitch severely after calling ALIGNRP after a */
|
|
|
|
/* blocked SHPIX. */
|
2016-05-31 08:39:52 +02:00
|
|
|
if ( in_twilight ||
|
|
|
|
( !( exc->iupx_called && exc->iupy_called ) &&
|
|
|
|
( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
|
|
|
|
( exc->zp2.tags[point] & FT_CURVE_TAG_TOUCH_Y ) ) ) )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
Move_Zp2_Point( exc, point, 0, dy, TRUE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
Move_Zp2_Point( exc, point, dx, dy, TRUE );
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2013-05-17 13:51:07 +02:00
|
|
|
Skip:
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop--;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 18:51:07 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop = 1;
|
|
|
|
exc->new_top = exc->args;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* MSIRP[a]: Move Stack Indirect Relative Position */
|
|
|
|
/* Opcode range: 0x3A-0x3B */
|
|
|
|
/* Stack: f26.6 uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MSIRP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
FT_UShort point = 0;
|
2012-06-27 08:16:06 +02:00
|
|
|
FT_F26Dot6 distance;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
FT_F26Dot6 control_value_cutin = 0;
|
2018-02-06 02:23:19 +01:00
|
|
|
FT_F26Dot6 delta;
|
2013-05-17 13:51:07 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY )
|
2013-05-17 13:51:07 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
control_value_cutin = exc->GS.control_value_cutin;
|
2013-05-17 13:51:07 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.x != 0 &&
|
|
|
|
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
|
2013-05-17 13:51:07 +02:00
|
|
|
control_value_cutin = 0;
|
|
|
|
}
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
point = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp1.n_points ) ||
|
|
|
|
BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-05 09:07:21 +02:00
|
|
|
/* UNDOCUMENTED! The MS rasterizer does that with */
|
|
|
|
/* twilight points (confirmed by Greg Hitchcock) */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep1 == 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp1.org[point] = exc->zp0.org[exc->GS.rp0];
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_move_orig( exc, &exc->zp1, point, args[1] );
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp1.cur[point] = exc->zp1.org[point];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2018-02-06 02:23:19 +01:00
|
|
|
delta = SUB_LONG( distance, args[1] );
|
|
|
|
if ( delta < 0 )
|
|
|
|
delta = NEG_LONG( delta );
|
|
|
|
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
/* subpixel hinting - make MSIRP respect CVT cut-in; */
|
2018-02-06 02:23:19 +01:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.x != 0 &&
|
|
|
|
delta >= control_value_cutin )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
distance = args[1];
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
[base, cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2060
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2062
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2063
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2068
* src/base/ftobjs.c (ft_glyphslot_grid_fit_metrics): Use
OVERFLOW_ADD_LONG and OVERFLOW_SUB_LONG.
* src/cff/cf2blues.c (cf2_blues_capture), src/cff/cf2hints.c
(cf2_hintmap_adjustHints): Use OVERFLOW_SUB_INT32.
* src/truetype/ttgload.c (compute_glyph_metrics): User
OVERFLOW_SUB_LONG.
* src/truetype/ttinterp.c (Direct_Move, Direct_Move_Orig,
Direct_Move_X, Direct_Move_Y, Direct_Move_Orig_X,
Direct_Move_Orig_Y, Move_Zp2_Point, Ins_MSIRP): Use
OVERFLOW_ADD_LONG and OVERFLOW_SUB_LONG.
2017-06-03 21:05:42 +02:00
|
|
|
exc->func_move( exc,
|
|
|
|
&exc->zp1,
|
|
|
|
point,
|
2017-06-09 11:21:58 +02:00
|
|
|
SUB_LONG( args[1], distance ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.rp1 = exc->GS.rp0;
|
|
|
|
exc->GS.rp2 = point;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 1 ) != 0 )
|
|
|
|
exc->GS.rp0 = point;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* MDAP[a]: Move Direct Absolute Point */
|
|
|
|
/* Opcode range: 0x2E-0x2F */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MDAP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort point;
|
2012-06-27 08:16:06 +02:00
|
|
|
FT_F26Dot6 cur_dist;
|
|
|
|
FT_F26Dot6 distance;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
point = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp0.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 1 ) != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-11 09:50:49 +01:00
|
|
|
cur_dist = FAST_PROJECT( &exc->zp0.cur[point] );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.x != 0 )
|
2018-04-14 07:20:31 +02:00
|
|
|
distance = SUB_LONG(
|
|
|
|
Round_None( exc,
|
|
|
|
cur_dist,
|
|
|
|
exc->tt_metrics.compensations[0] ),
|
|
|
|
cur_dist );
|
2012-06-27 00:20:27 +02:00
|
|
|
else
|
|
|
|
#endif
|
2018-04-14 07:20:31 +02:00
|
|
|
distance = SUB_LONG(
|
|
|
|
exc->func_round( exc,
|
|
|
|
cur_dist,
|
|
|
|
exc->tt_metrics.compensations[0] ),
|
|
|
|
cur_dist );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
distance = 0;
|
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_move( exc, &exc->zp0, point, distance );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.rp0 = point;
|
|
|
|
exc->GS.rp1 = point;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* MIAP[a]: Move Indirect Absolute Point */
|
|
|
|
/* Opcode range: 0x3E-0x3F */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MIAP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_ULong cvtEntry;
|
|
|
|
FT_UShort point;
|
2012-06-27 08:16:06 +02:00
|
|
|
FT_F26Dot6 distance;
|
|
|
|
FT_F26Dot6 org_dist;
|
|
|
|
FT_F26Dot6 control_value_cutin;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
control_value_cutin = exc->GS.control_value_cutin;
|
2012-06-27 08:16:06 +02:00
|
|
|
cvtEntry = (FT_ULong)args[1];
|
|
|
|
point = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.x != 0 &&
|
|
|
|
exc->GS.freeVector.y == 0 &&
|
|
|
|
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
|
2012-06-27 08:16:06 +02:00
|
|
|
control_value_cutin = 0;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2012-06-27 00:20:27 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp0.n_points ) ||
|
|
|
|
BOUNDSL( cvtEntry, exc->cvtSize ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-30 16:29:45 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2011-08-05 09:07:21 +02:00
|
|
|
/* UNDOCUMENTED! */
|
|
|
|
/* */
|
|
|
|
/* The behaviour of an MIAP instruction is quite different when used */
|
|
|
|
/* in the twilight zone. */
|
|
|
|
/* */
|
|
|
|
/* First, no control value cut-in test is performed as it would fail */
|
|
|
|
/* anyway. Second, the original point, i.e. (org_x,org_y) of */
|
|
|
|
/* zp0.point, is set to the absolute, unrounded distance found in the */
|
|
|
|
/* CVT. */
|
|
|
|
/* */
|
|
|
|
/* This is used in the CVT programs of the Microsoft fonts Arial, */
|
|
|
|
/* Times, etc., in order to re-adjust some key font heights. It */
|
|
|
|
/* allows the use of the IP instruction in the twilight zone, which */
|
|
|
|
/* otherwise would be invalid according to the specification. */
|
|
|
|
/* */
|
|
|
|
/* We implement it with a special sequence for the twilight zone. */
|
|
|
|
/* This is a bad hack, but it seems to work. */
|
|
|
|
/* */
|
|
|
|
/* Confirmed by Greg Hitchcock. */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
distance = exc->func_read_cvt( exc, cvtEntry );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep0 == 0 ) /* If in twilight zone */
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2013-01-28 13:56:23 +01:00
|
|
|
/* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */
|
|
|
|
/* Determined via experimentation and may be incorrect... */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( !( SUBPIXEL_HINTING_INFINALITY &&
|
|
|
|
( exc->ignore_x_mode &&
|
|
|
|
exc->face->sph_compatibility_mode ) ) )
|
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2015-02-17 09:21:26 +01:00
|
|
|
exc->zp0.org[point].x = TT_MulFix14( distance,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.freeVector.x );
|
2015-02-17 09:21:26 +01:00
|
|
|
exc->zp0.org[point].y = TT_MulFix14( distance,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.freeVector.y ),
|
|
|
|
exc->zp0.cur[point] = exc->zp0.org[point];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_MIAP_HACK ) &&
|
|
|
|
distance > 0 &&
|
|
|
|
exc->GS.freeVector.y != 0 )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
distance = 0;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = FAST_PROJECT( &exc->zp0.cur[point] );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 1 ) != 0 ) /* rounding and control cut-in flag */
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2018-02-06 02:23:19 +01:00
|
|
|
FT_F26Dot6 delta;
|
|
|
|
|
|
|
|
|
|
|
|
delta = SUB_LONG( distance, org_dist );
|
|
|
|
if ( delta < 0 )
|
|
|
|
delta = NEG_LONG( delta );
|
|
|
|
|
|
|
|
if ( delta > control_value_cutin )
|
1999-12-17 00:11:37 +01:00
|
|
|
distance = org_dist;
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.x != 0 )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
distance = Round_None( exc,
|
|
|
|
distance,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->tt_metrics.compensations[0] );
|
2012-06-27 00:20:27 +02:00
|
|
|
else
|
|
|
|
#endif
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
distance = exc->func_round( exc,
|
|
|
|
distance,
|
|
|
|
exc->tt_metrics.compensations[0] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2017-09-20 08:00:05 +02:00
|
|
|
exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2011-01-30 16:29:45 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.rp0 = point;
|
|
|
|
exc->GS.rp1 = point;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* MDRP[abcde]: Move Direct Relative Point */
|
|
|
|
/* Opcode range: 0xC0-0xDF */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MDRP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
FT_UShort point = 0;
|
2012-06-27 00:20:27 +02:00
|
|
|
FT_F26Dot6 org_dist, distance, minimum_distance;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
minimum_distance = exc->GS.minimum_distance;
|
2012-06-27 00:20:27 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.x != 0 &&
|
|
|
|
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
|
2012-06-27 08:16:06 +02:00
|
|
|
minimum_distance = 0;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
point = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp1.n_points ) ||
|
|
|
|
BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-31 18:51:07 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: Is there some undocumented feature while in the */
|
|
|
|
/* twilight zone? */
|
|
|
|
|
2007-03-21 14:30:14 +01:00
|
|
|
/* XXX: UNDOCUMENTED: twilight zone special case */
|
2007-03-18 08:19:31 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 )
|
2007-03-18 08:19:31 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
FT_Vector* vec1 = &exc->zp1.org[point];
|
|
|
|
FT_Vector* vec2 = &exc->zp0.org[exc->GS.rp0];
|
2007-03-18 08:19:31 +01:00
|
|
|
|
2007-03-21 14:30:14 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = DUALPROJ( vec1, vec2 );
|
2007-03-18 08:19:31 +01:00
|
|
|
}
|
|
|
|
else
|
2006-08-16 18:50:55 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
FT_Vector* vec1 = &exc->zp1.orus[point];
|
|
|
|
FT_Vector* vec2 = &exc->zp0.orus[exc->GS.rp0];
|
2006-08-16 18:50:55 +02:00
|
|
|
|
2006-08-19 13:18:09 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->metrics.x_scale == exc->metrics.y_scale )
|
2007-02-14 16:08:47 +01:00
|
|
|
{
|
|
|
|
/* this should be faster */
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = DUALPROJ( vec1, vec2 );
|
2015-01-10 19:56:28 +01:00
|
|
|
org_dist = FT_MulFix( org_dist, exc->metrics.x_scale );
|
2007-02-14 16:08:47 +01:00
|
|
|
}
|
2007-03-17 18:48:57 +01:00
|
|
|
else
|
2007-02-14 16:08:47 +01:00
|
|
|
{
|
|
|
|
FT_Vector vec;
|
2006-08-16 18:50:55 +02:00
|
|
|
|
2007-03-21 14:30:14 +01:00
|
|
|
|
2017-06-16 13:33:09 +02:00
|
|
|
vec.x = FT_MulFix( SUB_LONG( vec1->x, vec2->x ),
|
|
|
|
exc->metrics.x_scale );
|
|
|
|
vec.y = FT_MulFix( SUB_LONG( vec1->y, vec2->y ),
|
|
|
|
exc->metrics.y_scale );
|
2006-08-16 18:50:55 +02:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = FAST_DUALPROJ( &vec );
|
2007-02-14 16:08:47 +01:00
|
|
|
}
|
2006-08-16 18:50:55 +02:00
|
|
|
}
|
2006-08-19 13:18:09 +02:00
|
|
|
|
|
|
|
/* single width cut-in test */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2017-09-21 21:22:51 +02:00
|
|
|
/* |org_dist - single_width_value| < single_width_cutin */
|
2017-09-28 19:08:38 +02:00
|
|
|
if ( exc->GS.single_width_cutin > 0 &&
|
|
|
|
org_dist < exc->GS.single_width_value +
|
|
|
|
exc->GS.single_width_cutin &&
|
|
|
|
org_dist > exc->GS.single_width_value -
|
|
|
|
exc->GS.single_width_cutin )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
if ( org_dist >= 0 )
|
2015-01-10 19:56:28 +01:00
|
|
|
org_dist = exc->GS.single_width_value;
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
org_dist = -exc->GS.single_width_value;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* round flag */
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 4 ) != 0 )
|
2012-06-27 00:20:27 +02:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.x != 0 )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
distance = Round_None(
|
|
|
|
exc,
|
2012-06-27 00:20:27 +02:00
|
|
|
org_dist,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->tt_metrics.compensations[exc->opcode & 3] );
|
2012-06-27 00:20:27 +02:00
|
|
|
else
|
|
|
|
#endif
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
distance = exc->func_round(
|
|
|
|
exc,
|
|
|
|
org_dist,
|
|
|
|
exc->tt_metrics.compensations[exc->opcode & 3] );
|
2012-06-27 00:20:27 +02:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
distance = Round_None(
|
|
|
|
exc,
|
2000-06-12 21:36:41 +02:00
|
|
|
org_dist,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->tt_metrics.compensations[exc->opcode & 3] );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* minimum distance flag */
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 8 ) != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
if ( org_dist >= 0 )
|
|
|
|
{
|
2012-06-27 00:20:27 +02:00
|
|
|
if ( distance < minimum_distance )
|
|
|
|
distance = minimum_distance;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-22 08:25:14 +02:00
|
|
|
if ( distance > NEG_LONG( minimum_distance ) )
|
|
|
|
distance = NEG_LONG( minimum_distance );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now move the point */
|
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2017-06-16 13:33:09 +02:00
|
|
|
exc->func_move( exc, &exc->zp1, point, SUB_LONG( distance, org_dist ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2011-01-31 18:51:07 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.rp1 = exc->GS.rp0;
|
|
|
|
exc->GS.rp2 = point;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 16 ) != 0 )
|
|
|
|
exc->GS.rp0 = point;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* MIRP[abcde]: Move Indirect Relative Point */
|
|
|
|
/* Opcode range: 0xE0-0xFF */
|
|
|
|
/* Stack: int32? uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MIRP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort point;
|
|
|
|
FT_ULong cvtEntry;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 cvt_dist,
|
1999-12-17 00:11:37 +01:00
|
|
|
distance,
|
|
|
|
cur_dist,
|
2012-06-27 00:20:27 +02:00
|
|
|
org_dist,
|
|
|
|
control_value_cutin,
|
|
|
|
minimum_distance;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
* Version 2.5.0 released.
=========================
Tag sources with `VER-2-5-0'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.5.0.
* README, Jamfile (RefDoc),
builds/win32/vc2005/freetype.vcproj, builds/win32/vc2005/index.html,
builds/win32/vc2008/freetype.vcproj, builds/win32/vc2008/index.html,
builds/win32/vc2010/freetype.vcxproj, builds/win32/vc2010/index.html,
builds/win32/visualc/freetype.dsp,
builds/win32/visualc/freetype.vcproj,
builds/win32/visualc/index.html, builds/win32/visualce/freetype.dsp,
builds/win32/visualce/freetype.vcproj,
builds/win32/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.4.12/2.5.0/, s/2412/250/.
* include/freetype/freetype.h (FREETYPE_MINOR): Set to 5.
(FREETYPE_PATCH): Set to 0.
* builds/unix/configure.raw (version_info): Set to 16:2:10.
* src/base/ftobjs.c (FT_Open_Face): Pacify compiler.
* src/truetype/ttinterp.c (Ins_MSIRP, Ins_MIRP): Ditto.
2013-06-19 10:23:36 +02:00
|
|
|
FT_Int B1 = 0; /* pacify compiler */
|
|
|
|
FT_Int B2 = 0;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
FT_Bool reverse_move = FALSE;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
minimum_distance = exc->GS.minimum_distance;
|
|
|
|
control_value_cutin = exc->GS.control_value_cutin;
|
2012-06-27 08:16:06 +02:00
|
|
|
point = (FT_UShort)args[0];
|
|
|
|
cvtEntry = (FT_ULong)( args[1] + 1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.x != 0 &&
|
|
|
|
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
|
2012-06-27 08:16:06 +02:00
|
|
|
control_value_cutin = minimum_distance = 0;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp1.n_points ) ||
|
|
|
|
BOUNDSL( cvtEntry, exc->cvtSize + 1 ) ||
|
|
|
|
BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-31 18:51:07 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !cvtEntry )
|
|
|
|
cvt_dist = 0;
|
|
|
|
else
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
cvt_dist = exc->func_read_cvt( exc, cvtEntry - 1 );
|
2013-05-17 13:51:07 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* single width test */
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( FT_ABS( cvt_dist - exc->GS.single_width_value ) <
|
|
|
|
exc->GS.single_width_cutin )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
if ( cvt_dist >= 0 )
|
2015-01-10 19:56:28 +01:00
|
|
|
cvt_dist = exc->GS.single_width_value;
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
cvt_dist = -exc->GS.single_width_value;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2011-08-05 09:07:21 +02:00
|
|
|
/* UNDOCUMENTED! The MS rasterizer does that with */
|
|
|
|
/* twilight points (confirmed by Greg Hitchcock) */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep1 == 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp1.org[point].x = exc->zp0.org[exc->GS.rp0].x +
|
2015-02-17 09:21:26 +01:00
|
|
|
TT_MulFix14( cvt_dist,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.freeVector.x );
|
|
|
|
exc->zp1.org[point].y = exc->zp0.org[exc->GS.rp0].y +
|
2015-02-17 09:21:26 +01:00
|
|
|
TT_MulFix14( cvt_dist,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.freeVector.y );
|
|
|
|
exc->zp1.cur[point] = exc->zp1.org[point];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = DUALPROJ( &exc->zp1.org[point], &exc->zp0.org[exc->GS.rp0] );
|
|
|
|
cur_dist = PROJECT ( &exc->zp1.cur[point], &exc->zp0.cur[exc->GS.rp0] );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* auto-flip test */
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.auto_flip )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-12 21:36:41 +02:00
|
|
|
if ( ( org_dist ^ cvt_dist ) < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
cvt_dist = -cvt_dist;
|
|
|
|
}
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.y != 0 &&
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_TIMES_NEW_ROMAN_HACK ) )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
|
|
|
if ( cur_dist < -64 )
|
|
|
|
cvt_dist -= 16;
|
|
|
|
else if ( cur_dist > 64 && cur_dist < 84 )
|
|
|
|
cvt_dist += 32;
|
|
|
|
}
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
/* control value cut-in and round */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 4 ) != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
/* XXX: UNDOCUMENTED! Only perform cut-in test when both points */
|
|
|
|
/* refer to the same zone. */
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.gep0 == exc->GS.gep1 )
|
2011-01-18 07:35:26 +01:00
|
|
|
{
|
2018-02-06 02:23:19 +01:00
|
|
|
FT_F26Dot6 delta;
|
|
|
|
|
|
|
|
|
2011-01-18 07:35:26 +01:00
|
|
|
/* XXX: According to Greg Hitchcock, the following wording is */
|
|
|
|
/* the right one: */
|
|
|
|
/* */
|
|
|
|
/* When the absolute difference between the value in */
|
|
|
|
/* the table [CVT] and the measurement directly from */
|
|
|
|
/* the outline is _greater_ than the cut_in value, the */
|
|
|
|
/* outline measurement is used. */
|
|
|
|
/* */
|
|
|
|
/* This is from `instgly.doc'. The description in */
|
|
|
|
/* `ttinst2.doc', version 1.66, is thus incorrect since */
|
|
|
|
/* it implies `>=' instead of `>'. */
|
|
|
|
|
2018-02-06 02:23:19 +01:00
|
|
|
delta = SUB_LONG( cvt_dist, org_dist );
|
|
|
|
if ( delta < 0 )
|
|
|
|
delta = NEG_LONG( delta );
|
|
|
|
|
|
|
|
if ( delta > control_value_cutin )
|
1999-12-17 00:11:37 +01:00
|
|
|
cvt_dist = org_dist;
|
2011-01-18 07:35:26 +01:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
distance = exc->func_round(
|
|
|
|
exc,
|
2000-06-12 21:36:41 +02:00
|
|
|
cvt_dist,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->tt_metrics.compensations[exc->opcode & 3] );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
2013-01-26 19:29:52 +01:00
|
|
|
{
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2013-01-26 19:29:52 +01:00
|
|
|
/* do cvt cut-in always in MIRP for sph */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->GS.gep0 == exc->GS.gep1 )
|
2013-01-26 19:29:52 +01:00
|
|
|
{
|
2018-02-06 02:23:19 +01:00
|
|
|
FT_F26Dot6 delta;
|
|
|
|
|
|
|
|
|
|
|
|
delta = SUB_LONG( cvt_dist, org_dist );
|
|
|
|
if ( delta < 0 )
|
|
|
|
delta = NEG_LONG( delta );
|
|
|
|
|
|
|
|
if ( delta > control_value_cutin )
|
2013-01-26 19:29:52 +01:00
|
|
|
cvt_dist = org_dist;
|
|
|
|
}
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
distance = Round_None(
|
|
|
|
exc,
|
2013-01-26 19:29:52 +01:00
|
|
|
cvt_dist,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->tt_metrics.compensations[exc->opcode & 3] );
|
2013-01-26 19:29:52 +01:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* minimum distance test */
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 8 ) != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
if ( org_dist >= 0 )
|
|
|
|
{
|
2012-06-27 00:20:27 +02:00
|
|
|
if ( distance < minimum_distance )
|
|
|
|
distance = minimum_distance;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-22 08:25:14 +02:00
|
|
|
if ( distance > NEG_LONG( minimum_distance ) )
|
|
|
|
distance = NEG_LONG( minimum_distance );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY )
|
2013-05-17 13:51:07 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
B1 = exc->zp1.cur[point].y;
|
2013-05-17 13:51:07 +02:00
|
|
|
|
|
|
|
/* Round moves if necessary */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.y != 0 &&
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) )
|
2013-05-17 13:51:07 +02:00
|
|
|
distance = FT_PIX_ROUND( B1 + distance - cur_dist ) - B1 + cur_dist;
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->ignore_x_mode &&
|
|
|
|
exc->GS.freeVector.y != 0 &&
|
|
|
|
( exc->opcode & 16 ) == 0 &&
|
|
|
|
( exc->opcode & 8 ) == 0 &&
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_COURIER_NEW_2_HACK ) )
|
2013-05-17 13:51:07 +02:00
|
|
|
distance += 64;
|
|
|
|
}
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
exc->func_move( exc,
|
|
|
|
&exc->zp1,
|
|
|
|
point,
|
|
|
|
SUB_LONG( distance, cur_dist ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
B2 = exc->zp1.cur[point].y;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2013-05-17 13:51:07 +02:00
|
|
|
/* Reverse move if necessary */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->ignore_x_mode )
|
2013-05-17 13:51:07 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->face->sph_compatibility_mode &&
|
|
|
|
exc->GS.freeVector.y != 0 &&
|
|
|
|
( B1 & 63 ) == 0 &&
|
|
|
|
( B2 & 63 ) != 0 )
|
2013-05-17 13:51:07 +02:00
|
|
|
reverse_move = TRUE;
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
|
|
|
|
exc->GS.freeVector.y != 0 &&
|
|
|
|
( B2 & 63 ) != 0 &&
|
|
|
|
( B1 & 63 ) != 0 )
|
2013-05-17 13:51:07 +02:00
|
|
|
reverse_move = TRUE;
|
|
|
|
}
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2013-05-17 13:51:07 +02:00
|
|
|
if ( reverse_move )
|
2017-08-22 08:25:14 +02:00
|
|
|
exc->func_move( exc,
|
|
|
|
&exc->zp1,
|
|
|
|
point,
|
|
|
|
SUB_LONG( cur_dist, distance ) );
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
}
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2011-01-31 18:51:07 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.rp1 = exc->GS.rp0;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->opcode & 16 ) != 0 )
|
|
|
|
exc->GS.rp0 = point;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.rp2 = point;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ALIGNRP[]: ALIGN Relative Point */
|
|
|
|
/* Opcode range: 0x3C */
|
|
|
|
/* Stack: uint32 uint32... --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ALIGNRP( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort point;
|
|
|
|
FT_F26Dot6 distance;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->iup_called &&
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_NO_ALIGNRP_AFTER_IUP ) )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
goto Fail;
|
|
|
|
}
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2015-01-11 00:56:55 +01:00
|
|
|
if ( exc->top < exc->GS.loop ||
|
2015-01-10 19:56:28 +01:00
|
|
|
BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-31 18:51:07 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
while ( exc->GS.loop > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->args--;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
point = (FT_UShort)exc->stack[exc->args];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp1.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-11 09:50:49 +01:00
|
|
|
distance = PROJECT( exc->zp1.cur + point,
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->zp0.cur + exc->GS.rp0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2017-08-05 18:58:34 +02:00
|
|
|
exc->func_move( exc, &exc->zp1, point, NEG_LONG( distance ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop--;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 18:51:07 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop = 1;
|
|
|
|
exc->new_top = exc->args;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ISECT[]: moves point to InterSECTion */
|
|
|
|
/* Opcode range: 0x0F */
|
|
|
|
/* Stack: 5 * uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ISECT( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort point,
|
1999-12-17 00:11:37 +01:00
|
|
|
a0, a1,
|
|
|
|
b0, b1;
|
|
|
|
|
2012-10-21 04:23:01 +02:00
|
|
|
FT_F26Dot6 discriminant, dotproduct;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 dx, dy,
|
1999-12-17 00:11:37 +01:00
|
|
|
dax, day,
|
|
|
|
dbx, dby;
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_F26Dot6 val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Vector R;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
point = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
a0 = (FT_UShort)args[1];
|
|
|
|
a1 = (FT_UShort)args[2];
|
|
|
|
b0 = (FT_UShort)args[3];
|
|
|
|
b1 = (FT_UShort)args[4];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( b0, exc->zp0.n_points ) ||
|
|
|
|
BOUNDS( b1, exc->zp0.n_points ) ||
|
|
|
|
BOUNDS( a0, exc->zp1.n_points ) ||
|
|
|
|
BOUNDS( a1, exc->zp1.n_points ) ||
|
|
|
|
BOUNDS( point, exc->zp2.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-17 11:34:22 +02:00
|
|
|
/* Cramer's rule */
|
|
|
|
|
2017-06-09 11:21:58 +02:00
|
|
|
dbx = SUB_LONG( exc->zp0.cur[b1].x, exc->zp0.cur[b0].x );
|
|
|
|
dby = SUB_LONG( exc->zp0.cur[b1].y, exc->zp0.cur[b0].y );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2017-06-09 11:21:58 +02:00
|
|
|
dax = SUB_LONG( exc->zp1.cur[a1].x, exc->zp1.cur[a0].x );
|
|
|
|
day = SUB_LONG( exc->zp1.cur[a1].y, exc->zp1.cur[a0].y );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2017-06-09 11:21:58 +02:00
|
|
|
dx = SUB_LONG( exc->zp0.cur[b0].x, exc->zp1.cur[a0].x );
|
|
|
|
dy = SUB_LONG( exc->zp0.cur[b0].y, exc->zp1.cur[a0].y );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2017-06-24 20:17:46 +02:00
|
|
|
discriminant = ADD_LONG( FT_MulDiv( dax, NEG_LONG( dby ), 0x40 ),
|
2017-06-09 11:21:58 +02:00
|
|
|
FT_MulDiv( day, dbx, 0x40 ) );
|
|
|
|
dotproduct = ADD_LONG( FT_MulDiv( dax, dbx, 0x40 ),
|
|
|
|
FT_MulDiv( day, dby, 0x40 ) );
|
2012-10-21 04:23:01 +02:00
|
|
|
|
|
|
|
/* The discriminant above is actually a cross product of vectors */
|
|
|
|
/* da and db. Together with the dot product, they can be used as */
|
|
|
|
/* surrogates for sine and cosine of the angle between the vectors. */
|
|
|
|
/* Indeed, */
|
|
|
|
/* dotproduct = |da||db|cos(angle) */
|
|
|
|
/* discriminant = |da||db|sin(angle) . */
|
|
|
|
/* We use these equations to reject grazing intersections by */
|
|
|
|
/* thresholding abs(tan(angle)) at 1/19, corresponding to 3 degrees. */
|
2017-06-09 11:21:58 +02:00
|
|
|
if ( MUL_LONG( 19, FT_ABS( discriminant ) ) > FT_ABS( dotproduct ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2017-06-24 20:17:46 +02:00
|
|
|
val = ADD_LONG( FT_MulDiv( dx, NEG_LONG( dby ), 0x40 ),
|
2017-06-09 11:21:58 +02:00
|
|
|
FT_MulDiv( dy, dbx, 0x40 ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2012-12-06 05:05:47 +01:00
|
|
|
R.x = FT_MulDiv( val, dax, discriminant );
|
|
|
|
R.y = FT_MulDiv( val, day, discriminant );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2017-05-03 23:54:29 +02:00
|
|
|
/* XXX: Block in backward_compatibility and/or post-IUP? */
|
2017-06-09 11:21:58 +02:00
|
|
|
exc->zp2.cur[point].x = ADD_LONG( exc->zp1.cur[a0].x, R.x );
|
|
|
|
exc->zp2.cur[point].y = ADD_LONG( exc->zp1.cur[a0].y, R.y );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* else, take the middle of the middles of A and B */
|
|
|
|
|
2017-05-03 23:54:29 +02:00
|
|
|
/* XXX: Block in backward_compatibility and/or post-IUP? */
|
2017-06-04 20:43:08 +02:00
|
|
|
exc->zp2.cur[point].x =
|
2017-06-09 11:21:58 +02:00
|
|
|
ADD_LONG( ADD_LONG( exc->zp1.cur[a0].x, exc->zp1.cur[a1].x ),
|
|
|
|
ADD_LONG( exc->zp0.cur[b0].x, exc->zp0.cur[b1].x ) ) / 4;
|
2017-06-04 20:43:08 +02:00
|
|
|
exc->zp2.cur[point].y =
|
2017-06-09 11:21:58 +02:00
|
|
|
ADD_LONG( ADD_LONG( exc->zp1.cur[a0].y, exc->zp1.cur[a1].y ),
|
|
|
|
ADD_LONG( exc->zp0.cur[b0].y, exc->zp0.cur[b1].y ) ) / 4;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2015-09-01 05:14:46 +02:00
|
|
|
|
|
|
|
exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ALIGNPTS[]: ALIGN PoinTS */
|
|
|
|
/* Opcode range: 0x27 */
|
|
|
|
/* Stack: uint32 uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ALIGNPTS( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort p1, p2;
|
|
|
|
FT_F26Dot6 distance;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
p1 = (FT_UShort)args[0];
|
|
|
|
p2 = (FT_UShort)args[1];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( p1, exc->zp1.n_points ) ||
|
|
|
|
BOUNDS( p2, exc->zp0.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
distance = PROJECT( exc->zp0.cur + p2, exc->zp1.cur + p1 ) / 2;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_move( exc, &exc->zp1, p1, distance );
|
2017-08-22 08:25:14 +02:00
|
|
|
exc->func_move( exc, &exc->zp0, p2, NEG_LONG( distance ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* IP[]: Interpolate Point */
|
|
|
|
/* Opcode range: 0x39 */
|
|
|
|
/* Stack: uint32... --> */
|
|
|
|
/* */
|
2007-02-14 16:08:47 +01:00
|
|
|
|
|
|
|
/* SOMETIMES, DUMBER CODE IS BETTER CODE */
|
2007-02-16 09:10:17 +01:00
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_IP( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2007-02-14 16:08:47 +01:00
|
|
|
FT_F26Dot6 old_range, cur_range;
|
|
|
|
FT_Vector* orus_base;
|
|
|
|
FT_Vector* cur_base;
|
2007-03-17 18:48:57 +01:00
|
|
|
FT_Int twilight;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->top < exc->GS.loop )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-31 18:51:07 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2007-02-16 09:10:17 +01:00
|
|
|
/*
|
2007-03-17 18:48:57 +01:00
|
|
|
* We need to deal in a special way with the twilight zone.
|
2015-01-10 19:56:28 +01:00
|
|
|
* Otherwise, by definition, the value of exc->twilight.orus[n] is (0,0),
|
2007-03-17 18:48:57 +01:00
|
|
|
* for every n.
|
2007-02-16 09:10:17 +01:00
|
|
|
*/
|
2016-12-25 22:55:25 +01:00
|
|
|
twilight = ( exc->GS.gep0 == 0 ||
|
|
|
|
exc->GS.gep1 == 0 ||
|
|
|
|
exc->GS.gep2 == 0 );
|
2007-03-17 18:48:57 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) )
|
2007-06-16 19:07:20 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2011-01-31 18:51:07 +01:00
|
|
|
goto Fail;
|
2007-06-16 19:07:20 +02:00
|
|
|
}
|
|
|
|
|
2007-03-21 14:30:14 +01:00
|
|
|
if ( twilight )
|
2015-01-10 19:56:28 +01:00
|
|
|
orus_base = &exc->zp0.org[exc->GS.rp1];
|
2007-03-17 18:48:57 +01:00
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
orus_base = &exc->zp0.orus[exc->GS.rp1];
|
2006-08-19 13:18:09 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
cur_base = &exc->zp0.cur[exc->GS.rp1];
|
2006-08-16 18:50:55 +02:00
|
|
|
|
2007-03-21 14:30:14 +01:00
|
|
|
/* XXX: There are some glyphs in some braindead but popular */
|
|
|
|
/* fonts out there (e.g. [aeu]grave in monotype.ttf) */
|
|
|
|
/* calling IP[] with bad values of rp[12]. */
|
|
|
|
/* Do something sane when this odd thing happens. */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) ||
|
|
|
|
BOUNDS( exc->GS.rp2, exc->zp1.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2007-02-14 16:08:47 +01:00
|
|
|
old_range = 0;
|
|
|
|
cur_range = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-21 14:30:14 +01:00
|
|
|
if ( twilight )
|
2015-01-11 09:50:49 +01:00
|
|
|
old_range = DUALPROJ( &exc->zp1.org[exc->GS.rp2], orus_base );
|
2015-01-10 19:56:28 +01:00
|
|
|
else if ( exc->metrics.x_scale == exc->metrics.y_scale )
|
2015-01-11 09:50:49 +01:00
|
|
|
old_range = DUALPROJ( &exc->zp1.orus[exc->GS.rp2], orus_base );
|
2012-01-04 18:27:16 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_Vector vec;
|
|
|
|
|
|
|
|
|
2017-06-13 06:56:48 +02:00
|
|
|
vec.x = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].x,
|
|
|
|
orus_base->x ),
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->metrics.x_scale );
|
2017-06-13 06:56:48 +02:00
|
|
|
vec.y = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].y,
|
|
|
|
orus_base->y ),
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->metrics.y_scale );
|
2012-01-04 18:27:16 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
old_range = FAST_DUALPROJ( &vec );
|
2012-01-04 18:27:16 +01:00
|
|
|
}
|
2007-03-17 18:48:57 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
cur_range = PROJECT( &exc->zp1.cur[exc->GS.rp2], cur_base );
|
2007-02-14 16:08:47 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 23:57:45 +01:00
|
|
|
for ( ; exc->GS.loop > 0; exc->GS.loop-- )
|
2007-02-14 16:08:47 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
FT_UInt point = (FT_UInt)exc->stack[--exc->args];
|
2007-02-14 16:08:47 +01:00
|
|
|
FT_F26Dot6 org_dist, cur_dist, new_dist;
|
2006-08-19 13:18:09 +02:00
|
|
|
|
2007-02-16 09:10:17 +01:00
|
|
|
|
2007-02-14 16:08:47 +01:00
|
|
|
/* check point bounds */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp2.n_points ) )
|
2007-02-14 16:08:47 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
2007-02-14 16:08:47 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
2007-02-14 16:08:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2006-08-19 13:18:09 +02:00
|
|
|
|
2007-03-21 14:30:14 +01:00
|
|
|
if ( twilight )
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = DUALPROJ( &exc->zp2.org[point], orus_base );
|
2015-01-10 19:56:28 +01:00
|
|
|
else if ( exc->metrics.x_scale == exc->metrics.y_scale )
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = DUALPROJ( &exc->zp2.orus[point], orus_base );
|
2012-01-04 18:27:16 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_Vector vec;
|
|
|
|
|
|
|
|
|
2017-06-13 06:56:48 +02:00
|
|
|
vec.x = FT_MulFix( SUB_LONG( exc->zp2.orus[point].x,
|
|
|
|
orus_base->x ),
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->metrics.x_scale );
|
2017-06-13 06:56:48 +02:00
|
|
|
vec.y = FT_MulFix( SUB_LONG( exc->zp2.orus[point].y,
|
|
|
|
orus_base->y ),
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->metrics.y_scale );
|
2012-01-04 18:27:16 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
org_dist = FAST_DUALPROJ( &vec );
|
2012-01-04 18:27:16 +01:00
|
|
|
}
|
2007-03-17 18:48:57 +01:00
|
|
|
|
2015-01-11 09:50:49 +01:00
|
|
|
cur_dist = PROJECT( &exc->zp2.cur[point], cur_base );
|
2008-06-06 00:07:19 +02:00
|
|
|
|
|
|
|
if ( org_dist )
|
2013-02-01 12:55:44 +01:00
|
|
|
{
|
|
|
|
if ( old_range )
|
|
|
|
new_dist = FT_MulDiv( org_dist, cur_range, old_range );
|
|
|
|
else
|
|
|
|
{
|
2013-02-05 19:23:16 +01:00
|
|
|
/* This is the same as what MS does for the invalid case: */
|
|
|
|
/* */
|
|
|
|
/* delta = (Original_Pt - Original_RP1) - */
|
2013-12-21 19:33:15 +01:00
|
|
|
/* (Current_Pt - Current_RP1) ; */
|
2013-02-05 19:23:16 +01:00
|
|
|
/* */
|
|
|
|
/* In FreeType speak: */
|
|
|
|
/* */
|
2013-12-21 19:33:15 +01:00
|
|
|
/* delta = org_dist - cur_dist . */
|
|
|
|
/* */
|
|
|
|
/* We move `point' by `new_dist - cur_dist' after leaving */
|
|
|
|
/* this block, thus we have */
|
|
|
|
/* */
|
|
|
|
/* new_dist - cur_dist = delta , */
|
|
|
|
/* new_dist - cur_dist = org_dist - cur_dist , */
|
|
|
|
/* new_dist = org_dist . */
|
2013-02-05 19:23:16 +01:00
|
|
|
|
2013-12-21 19:33:15 +01:00
|
|
|
new_dist = org_dist;
|
2013-02-01 12:55:44 +01:00
|
|
|
}
|
|
|
|
}
|
2008-06-06 00:07:19 +02:00
|
|
|
else
|
|
|
|
new_dist = 0;
|
2006-08-16 18:50:55 +02:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_move( exc,
|
|
|
|
&exc->zp2,
|
|
|
|
(FT_UShort)point,
|
2017-06-13 06:56:48 +02:00
|
|
|
SUB_LONG( new_dist, cur_dist ) );
|
2007-02-14 16:08:47 +01:00
|
|
|
}
|
2011-01-31 18:51:07 +01:00
|
|
|
|
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->GS.loop = 1;
|
|
|
|
exc->new_top = exc->args;
|
2007-02-14 16:08:47 +01:00
|
|
|
}
|
2007-02-16 09:10:17 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* UTP[a]: UnTouch Point */
|
|
|
|
/* Opcode range: 0x29 */
|
|
|
|
/* Stack: uint32 --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_UTP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort point;
|
|
|
|
FT_Byte mask;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
point = (FT_UShort)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( point, exc->zp0.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mask = 0xFF;
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.x != 0 )
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
mask &= ~FT_CURVE_TAG_TOUCH_X;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.y != 0 )
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
mask &= ~FT_CURVE_TAG_TOUCH_Y;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->zp0.tags[point] &= mask;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Local variables for Ins_IUP: */
|
2008-05-29 00:17:28 +02:00
|
|
|
typedef struct IUP_WorkerRec_
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Vector* orgs; /* original and current coordinate */
|
|
|
|
FT_Vector* curs; /* arrays */
|
2006-08-16 18:50:55 +02:00
|
|
|
FT_Vector* orus;
|
2007-06-16 19:07:20 +02:00
|
|
|
FT_UInt max_points;
|
2006-08-16 18:50:55 +02:00
|
|
|
|
|
|
|
} IUP_WorkerRec, *IUP_Worker;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2006-08-16 18:50:55 +02:00
|
|
|
_iup_worker_shift( IUP_Worker worker,
|
|
|
|
FT_UInt p1,
|
|
|
|
FT_UInt p2,
|
|
|
|
FT_UInt p )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UInt i;
|
2006-08-16 18:50:55 +02:00
|
|
|
FT_F26Dot6 dx;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
dx = SUB_LONG( worker->curs[p].x, worker->orgs[p].x );
|
2006-08-16 18:50:55 +02:00
|
|
|
if ( dx != 0 )
|
|
|
|
{
|
|
|
|
for ( i = p1; i < p; i++ )
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
worker->curs[i].x = ADD_LONG( worker->curs[i].x, dx );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2006-08-16 18:50:55 +02:00
|
|
|
for ( i = p + 1; i <= p2; i++ )
|
[cff, truetype] Integer overflows.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2144
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2151
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2153
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2173
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2186
* src/cff/cf2blues.c (cf2_blues_init): Use SUB_INT32.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_To_Half_Grid, Round_Down_To_Grid, Round_Up_To_Grid,
Round_To_Double_Grid, Round_Super, Round_Super_45): Use ADD_LONG,
SUB_LONG, NEG_LONG, FT_PIX_ROUND_LONG, FT_PIX_CEIL_LONG,
FT_PAD_ROUND_LONG
(Ins_SxVTL, Ins_MIRP): Use SUB_LONG.
(_iup_worker_shift): Use SUB_LONG and ADD_LONG.
2017-06-09 20:42:46 +02:00
|
|
|
worker->curs[i].x = ADD_LONG( worker->curs[i].x, dx );
|
2006-08-16 18:50:55 +02:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2006-08-16 18:50:55 +02:00
|
|
|
_iup_worker_interpolate( IUP_Worker worker,
|
|
|
|
FT_UInt p1,
|
|
|
|
FT_UInt p2,
|
|
|
|
FT_UInt ref1,
|
|
|
|
FT_UInt ref2 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UInt i;
|
2015-04-28 04:27:00 +02:00
|
|
|
FT_F26Dot6 orus1, orus2, org1, org2, cur1, cur2, delta1, delta2;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( p1 > p2 )
|
|
|
|
return;
|
|
|
|
|
2007-06-17 07:31:23 +02:00
|
|
|
if ( BOUNDS( ref1, worker->max_points ) ||
|
|
|
|
BOUNDS( ref2, worker->max_points ) )
|
2007-06-16 19:07:20 +02:00
|
|
|
return;
|
|
|
|
|
2006-08-16 18:50:55 +02:00
|
|
|
orus1 = worker->orus[ref1].x;
|
|
|
|
orus2 = worker->orus[ref2].x;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2006-08-19 13:18:09 +02:00
|
|
|
if ( orus1 > orus2 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2006-08-16 18:50:55 +02:00
|
|
|
FT_F26Dot6 tmp_o;
|
|
|
|
FT_UInt tmp_r;
|
|
|
|
|
2006-08-19 13:18:09 +02:00
|
|
|
|
|
|
|
tmp_o = orus1;
|
|
|
|
orus1 = orus2;
|
|
|
|
orus2 = tmp_o;
|
|
|
|
|
|
|
|
tmp_r = ref1;
|
|
|
|
ref1 = ref2;
|
|
|
|
ref2 = tmp_r;
|
2006-08-16 18:50:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
org1 = worker->orgs[ref1].x;
|
|
|
|
org2 = worker->orgs[ref2].x;
|
2015-04-28 04:27:00 +02:00
|
|
|
cur1 = worker->curs[ref1].x;
|
|
|
|
cur2 = worker->curs[ref2].x;
|
2017-06-16 13:33:09 +02:00
|
|
|
delta1 = SUB_LONG( cur1, org1 );
|
|
|
|
delta2 = SUB_LONG( cur2, org2 );
|
2006-08-16 18:50:55 +02:00
|
|
|
|
2015-04-28 04:27:00 +02:00
|
|
|
if ( cur1 == cur2 || orus1 == orus2 )
|
2006-08-16 18:50:55 +02:00
|
|
|
{
|
2015-04-28 04:27:00 +02:00
|
|
|
|
|
|
|
/* trivial snap or shift of untouched points */
|
1999-12-17 00:11:37 +01:00
|
|
|
for ( i = p1; i <= p2; i++ )
|
|
|
|
{
|
2006-08-16 18:50:55 +02:00
|
|
|
FT_F26Dot6 x = worker->orgs[i].x;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2006-08-19 13:18:09 +02:00
|
|
|
|
2006-08-16 18:50:55 +02:00
|
|
|
if ( x <= org1 )
|
2017-06-16 13:33:09 +02:00
|
|
|
x = ADD_LONG( x, delta1 );
|
2015-04-28 04:27:00 +02:00
|
|
|
|
|
|
|
else if ( x >= org2 )
|
2017-06-16 13:33:09 +02:00
|
|
|
x = ADD_LONG( x, delta2 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-04-28 04:27:00 +02:00
|
|
|
else
|
|
|
|
x = cur1;
|
|
|
|
|
2006-08-16 18:50:55 +02:00
|
|
|
worker->curs[i].x = x;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
2006-08-16 18:50:55 +02:00
|
|
|
else
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2006-08-16 18:50:55 +02:00
|
|
|
FT_Fixed scale = 0;
|
|
|
|
FT_Bool scale_valid = 0;
|
|
|
|
|
2006-08-19 13:18:09 +02:00
|
|
|
|
2006-08-16 18:50:55 +02:00
|
|
|
/* interpolation */
|
1999-12-17 00:11:37 +01:00
|
|
|
for ( i = p1; i <= p2; i++ )
|
|
|
|
{
|
2006-08-16 18:50:55 +02:00
|
|
|
FT_F26Dot6 x = worker->orgs[i].x;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2006-08-19 13:18:09 +02:00
|
|
|
|
2006-08-16 18:50:55 +02:00
|
|
|
if ( x <= org1 )
|
2017-06-16 13:33:09 +02:00
|
|
|
x = ADD_LONG( x, delta1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2006-08-16 18:50:55 +02:00
|
|
|
else if ( x >= org2 )
|
2017-06-16 13:33:09 +02:00
|
|
|
x = ADD_LONG( x, delta2 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
else
|
2006-08-16 18:50:55 +02:00
|
|
|
{
|
|
|
|
if ( !scale_valid )
|
|
|
|
{
|
|
|
|
scale_valid = 1;
|
2017-06-16 13:33:09 +02:00
|
|
|
scale = FT_DivFix( SUB_LONG( cur2, cur1 ),
|
|
|
|
SUB_LONG( orus2, orus1 ) );
|
2006-08-16 18:50:55 +02:00
|
|
|
}
|
|
|
|
|
2017-06-16 13:33:09 +02:00
|
|
|
x = ADD_LONG( cur1,
|
|
|
|
FT_MulFix( SUB_LONG( worker->orus[i].x, orus1 ),
|
|
|
|
scale ) );
|
2006-08-16 18:50:55 +02:00
|
|
|
}
|
|
|
|
worker->curs[i].x = x;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* IUP[a]: Interpolate Untouched Points */
|
|
|
|
/* Opcode range: 0x30-0x31 */
|
|
|
|
/* Stack: --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_IUP( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2006-08-16 18:50:55 +02:00
|
|
|
IUP_WorkerRec V;
|
|
|
|
FT_Byte mask;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UInt first_point; /* first point of contour */
|
|
|
|
FT_UInt end_point; /* end point (last+1) of contour */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UInt first_touched; /* first touched point in contour */
|
|
|
|
FT_UInt cur_touched; /* current touched point in contour */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UInt point; /* current point */
|
|
|
|
FT_Short contour; /* current contour */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2007-06-17 07:31:23 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
/* See `ttinterp.h' for details on backward compatibility mode. */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
/* Allow IUP until it has been called on both axes. Immediately */
|
|
|
|
/* return on subsequent ones. */
|
2017-05-03 23:54:29 +02:00
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
{
|
|
|
|
if ( exc->iupx_called && exc->iupy_called )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( exc->opcode & 1 )
|
|
|
|
exc->iupx_called = TRUE;
|
|
|
|
else
|
|
|
|
exc->iupy_called = TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-06-16 19:07:20 +02:00
|
|
|
/* ignore empty outlines */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pts.n_contours == 0 )
|
2007-06-16 19:07:20 +02:00
|
|
|
return;
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->opcode & 1 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
mask = FT_CURVE_TAG_TOUCH_X;
|
2015-01-10 19:56:28 +01:00
|
|
|
V.orgs = exc->pts.org;
|
|
|
|
V.curs = exc->pts.cur;
|
|
|
|
V.orus = exc->pts.orus;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
mask = FT_CURVE_TAG_TOUCH_Y;
|
2015-01-10 19:56:28 +01:00
|
|
|
V.orgs = (FT_Vector*)( (FT_Pos*)exc->pts.org + 1 );
|
|
|
|
V.curs = (FT_Vector*)( (FT_Pos*)exc->pts.cur + 1 );
|
|
|
|
V.orus = (FT_Vector*)( (FT_Pos*)exc->pts.orus + 1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2015-01-10 19:56:28 +01:00
|
|
|
V.max_points = exc->pts.n_points;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
contour = 0;
|
|
|
|
point = 0;
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
|
|
|
exc->ignore_x_mode )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->iup_called = TRUE;
|
|
|
|
if ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_IUP )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
return;
|
|
|
|
}
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
do
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
end_point = exc->pts.contours[contour] - exc->pts.first_point;
|
1999-12-17 00:11:37 +01:00
|
|
|
first_point = point;
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDS( end_point, exc->pts.n_points ) )
|
|
|
|
end_point = exc->pts.n_points - 1;
|
2008-02-18 21:34:42 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
while ( point <= end_point && ( exc->pts.tags[point] & mask ) == 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
point++;
|
|
|
|
|
|
|
|
if ( point <= end_point )
|
|
|
|
{
|
|
|
|
first_touched = point;
|
|
|
|
cur_touched = point;
|
|
|
|
|
|
|
|
point++;
|
|
|
|
|
|
|
|
while ( point <= end_point )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->pts.tags[point] & mask ) != 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2010-09-13 07:32:22 +02:00
|
|
|
_iup_worker_interpolate( &V,
|
|
|
|
cur_touched + 1,
|
|
|
|
point - 1,
|
|
|
|
cur_touched,
|
|
|
|
point );
|
1999-12-17 00:11:37 +01:00
|
|
|
cur_touched = point;
|
|
|
|
}
|
|
|
|
|
|
|
|
point++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( cur_touched == first_touched )
|
2006-08-16 18:50:55 +02:00
|
|
|
_iup_worker_shift( &V, first_point, end_point, cur_touched );
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
|
|
|
{
|
2006-08-16 18:50:55 +02:00
|
|
|
_iup_worker_interpolate( &V,
|
|
|
|
(FT_UShort)( cur_touched + 1 ),
|
|
|
|
end_point,
|
|
|
|
cur_touched,
|
|
|
|
first_touched );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( first_touched > 0 )
|
2006-08-16 18:50:55 +02:00
|
|
|
_iup_worker_interpolate( &V,
|
|
|
|
first_point,
|
|
|
|
first_touched - 1,
|
|
|
|
cur_touched,
|
|
|
|
first_touched );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
contour++;
|
2015-01-10 19:56:28 +01:00
|
|
|
} while ( contour < exc->pts.n_contours );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* DELTAPn[]: DELTA exceptions P1, P2, P3 */
|
|
|
|
/* Opcode range: 0x5D,0x71,0x72 */
|
|
|
|
/* Stack: uint32 (2 * uint32)... --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_DELTAP( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2014-08-25 04:14:01 +02:00
|
|
|
FT_ULong nump, k;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort A;
|
2014-08-25 04:14:01 +02:00
|
|
|
FT_ULong C, P;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Long B;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
FT_UShort B1, B2;
|
2013-05-20 07:38:21 +02:00
|
|
|
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->ignore_x_mode &&
|
|
|
|
exc->iup_called &&
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_NO_DELTAP_AFTER_IUP ) )
|
2013-05-20 07:38:21 +02:00
|
|
|
goto Fail;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
P = (FT_ULong)exc->func_cur_ppem( exc );
|
2000-06-16 21:34:52 +02:00
|
|
|
nump = (FT_ULong)args[0]; /* some points theoretically may occur more
|
1999-12-17 00:11:37 +01:00
|
|
|
than once, thus UShort isn't enough */
|
|
|
|
|
|
|
|
for ( k = 1; k <= nump; k++ )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->args < 2 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Too_Few_Arguments );
|
|
|
|
exc->args = 0;
|
2011-01-31 10:24:32 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->args -= 2;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
A = (FT_UShort)exc->stack[exc->args + 1];
|
|
|
|
B = exc->stack[exc->args];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
/* 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. */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( !BOUNDS( A, exc->zp0.n_points ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
C = ( (FT_ULong)B & 0xF0 ) >> 4;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
switch ( exc->opcode )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
case 0x5D:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x71:
|
|
|
|
C += 16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x72:
|
|
|
|
C += 32;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
C += exc->GS.delta_base;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2014-08-25 04:14:01 +02:00
|
|
|
if ( P == C )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
B = ( (FT_ULong)B & 0xF ) - 8;
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( B >= 0 )
|
|
|
|
B++;
|
2015-01-10 19:56:28 +01:00
|
|
|
B *= 1L << ( 6 - exc->GS.delta_shift );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2013-05-17 13:51:07 +02:00
|
|
|
/*
|
|
|
|
* Allow delta move if
|
|
|
|
*
|
2014-11-03 07:20:57 +01:00
|
|
|
* - not using ignore_x_mode rendering,
|
|
|
|
* - glyph is specifically set to allow it, or
|
|
|
|
* - glyph is composite and freedom vector is not in subpixel
|
|
|
|
* direction.
|
2013-05-17 13:51:07 +02:00
|
|
|
*/
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( !exc->ignore_x_mode ||
|
|
|
|
( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) ||
|
|
|
|
( exc->is_composite && exc->GS.freeVector.y != 0 ) )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_move( exc, &exc->zp0, A, B );
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2014-11-03 07:20:57 +01:00
|
|
|
/* Otherwise, apply subpixel hinting and compatibility mode */
|
|
|
|
/* rules, always skipping deltas in subpixel direction. */
|
2015-01-10 19:56:28 +01:00
|
|
|
else if ( exc->ignore_x_mode && exc->GS.freeVector.y != 0 )
|
2013-05-17 13:51:07 +02:00
|
|
|
{
|
2014-11-03 07:20:57 +01:00
|
|
|
/* save the y value of the point now; compare after move */
|
2015-01-10 19:56:28 +01:00
|
|
|
B1 = (FT_UShort)exc->zp0.cur[A].y;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2014-11-03 07:20:57 +01:00
|
|
|
/* Standard subpixel hinting: Allow y move for y-touched */
|
|
|
|
/* points. This messes up DejaVu ... */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( !exc->face->sph_compatibility_mode &&
|
|
|
|
( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_move( exc, &exc->zp0, A, B );
|
2013-05-17 13:51:07 +02:00
|
|
|
|
2014-11-03 07:20:57 +01:00
|
|
|
/* compatibility mode */
|
2015-01-10 19:56:28 +01:00
|
|
|
else if ( exc->face->sph_compatibility_mode &&
|
|
|
|
!( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
|
2013-05-17 13:51:07 +02:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
|
2013-05-17 13:51:07 +02:00
|
|
|
B = FT_PIX_ROUND( B1 + B ) - B1;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2013-05-17 13:51:07 +02:00
|
|
|
/* Allow delta move if using sph_compatibility_mode, */
|
|
|
|
/* IUP has not been called, and point is touched on Y. */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( !exc->iup_called &&
|
|
|
|
( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_move( exc, &exc->zp0, A, B );
|
2013-05-17 13:51:07 +02:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
B2 = (FT_UShort)exc->zp0.cur[A].y;
|
2013-05-17 13:51:07 +02:00
|
|
|
|
|
|
|
/* Reverse this move if it results in a disallowed move */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->GS.freeVector.y != 0 &&
|
|
|
|
( ( exc->face->sph_compatibility_mode &&
|
2013-05-20 07:38:21 +02:00
|
|
|
( B1 & 63 ) == 0 &&
|
|
|
|
( B2 & 63 ) != 0 ) ||
|
2015-01-10 19:56:28 +01:00
|
|
|
( ( exc->sph_tweak_flags &
|
2013-05-20 07:38:21 +02:00
|
|
|
SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP ) &&
|
|
|
|
( B1 & 63 ) != 0 &&
|
|
|
|
( B2 & 63 ) != 0 ) ) )
|
2017-09-20 08:00:05 +02:00
|
|
|
exc->func_move( exc, &exc->zp0, A, NEG_LONG( B ) );
|
2013-05-17 13:51:07 +02:00
|
|
|
}
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
}
|
2013-05-17 13:51:07 +02:00
|
|
|
else
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-03 23:54:29 +02:00
|
|
|
/* See `ttinterp.h' for details on backward compatibility */
|
|
|
|
/* mode. */
|
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL &&
|
|
|
|
exc->backward_compatibility )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
{
|
|
|
|
if ( !( exc->iupx_called && exc->iupy_called ) &&
|
|
|
|
( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
|
|
|
|
( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) )
|
|
|
|
exc->func_move( exc, &exc->zp0, A, B );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
exc->func_move( exc, &exc->zp0, A, B );
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 10:24:32 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->new_top = exc->args;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* DELTACn[]: DELTA exceptions C1, C2, C3 */
|
|
|
|
/* Opcode range: 0x73,0x74,0x75 */
|
|
|
|
/* Stack: uint32 (2 * uint32)... --> */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_DELTAC( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_ULong nump, k;
|
2014-08-25 04:14:01 +02:00
|
|
|
FT_ULong A, C, P;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Long B;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2003-04-29 15:23:47 +02:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
P = (FT_ULong)exc->func_cur_ppem( exc );
|
2000-06-16 21:34:52 +02:00
|
|
|
nump = (FT_ULong)args[0];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
for ( k = 1; k <= nump; k++ )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->args < 2 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
|
|
|
exc->error = FT_THROW( Too_Few_Arguments );
|
|
|
|
exc->args = 0;
|
2011-01-31 10:24:32 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->args -= 2;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
A = (FT_ULong)exc->stack[exc->args + 1];
|
|
|
|
B = exc->stack[exc->args];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( BOUNDSL( A, exc->cvtSize ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
C = ( (FT_ULong)B & 0xF0 ) >> 4;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
switch ( exc->opcode )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
case 0x73:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x74:
|
|
|
|
C += 16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x75:
|
|
|
|
C += 32;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
C += exc->GS.delta_base;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2014-08-25 04:14:01 +02:00
|
|
|
if ( P == C )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
B = ( (FT_ULong)B & 0xF ) - 8;
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( B >= 0 )
|
|
|
|
B++;
|
2015-01-10 19:56:28 +01:00
|
|
|
B *= 1L << ( 6 - exc->GS.delta_shift );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
exc->func_move_cvt( exc, A, B );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-31 10:24:32 +01:00
|
|
|
Fail:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->new_top = exc->args;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* MISC. INSTRUCTIONS */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* GETINFO[]: GET INFOrmation */
|
|
|
|
/* Opcode range: 0x88 */
|
|
|
|
/* Stack: uint32 --> uint32 */
|
|
|
|
/* */
|
2015-05-24 09:50:24 +02:00
|
|
|
/* XXX: UNDOCUMENTED: Selector bits higher than 9 are currently (May */
|
|
|
|
/* 2015) not documented in the OpenType specification. */
|
|
|
|
/* */
|
|
|
|
/* Selector bit 11 is incorrectly described as bit 8, while the */
|
|
|
|
/* real meaning of bit 8 (vertical LCD subpixels) stays */
|
|
|
|
/* undocumented. The same mistake can be found in Greg Hitchcock's */
|
|
|
|
/* whitepaper. */
|
|
|
|
/* */
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_GETINFO( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
FT_Long K;
|
|
|
|
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( exc->face );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
K = 0;
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
/********************************/
|
|
|
|
/* RASTERIZER VERSION */
|
|
|
|
/* Selector Bit: 0 */
|
|
|
|
/* Return Bit(s): 0-7 */
|
|
|
|
/* */
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
|
|
|
( args[0] & 1 ) != 0 &&
|
|
|
|
exc->subpixel_hinting )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2015-05-22 22:02:15 +02:00
|
|
|
if ( exc->ignore_x_mode )
|
|
|
|
{
|
2017-05-03 23:54:29 +02:00
|
|
|
/* if in ClearType backward compatibility mode, */
|
2015-05-22 22:02:15 +02:00
|
|
|
/* we sometimes change the TrueType version dynamically */
|
|
|
|
K = exc->rasterizer_version;
|
2015-06-01 12:12:06 +02:00
|
|
|
FT_TRACE6(( "Setting rasterizer version %d\n",
|
2015-05-22 22:02:15 +02:00
|
|
|
exc->rasterizer_version ));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
K = TT_INTERPRETER_VERSION_38;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
}
|
|
|
|
else
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
if ( ( args[0] & 1 ) != 0 )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
K = driver->interpreter_version;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* GLYPH ROTATED */
|
|
|
|
/* Selector Bit: 1 */
|
|
|
|
/* Return Bit(s): 8 */
|
|
|
|
/* */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated )
|
2016-07-16 16:39:26 +02:00
|
|
|
K |= 1 << 8;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
/********************************/
|
|
|
|
/* GLYPH STRETCHED */
|
|
|
|
/* Selector Bit: 2 */
|
|
|
|
/* Return Bit(s): 9 */
|
|
|
|
/* */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched )
|
2016-07-16 16:39:26 +02:00
|
|
|
K |= 1 << 9;
|
2004-08-07 17:08:33 +02:00
|
|
|
|
2016-07-16 18:46:28 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
/********************************/
|
|
|
|
/* VARIATION GLYPH */
|
|
|
|
/* Selector Bit: 3 */
|
|
|
|
/* Return Bit(s): 10 */
|
|
|
|
/* */
|
|
|
|
/* XXX: UNDOCUMENTED! */
|
|
|
|
if ( (args[0] & 8 ) != 0 && exc->face->blend )
|
|
|
|
K |= 1 << 10;
|
|
|
|
#endif
|
|
|
|
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
/********************************/
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
/* BI-LEVEL HINTING AND */
|
|
|
|
/* GRAYSCALE RENDERING */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
/* Selector Bit: 5 */
|
|
|
|
/* Return Bit(s): 12 */
|
|
|
|
/* */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 32 ) != 0 && exc->grayscale )
|
2006-11-22 10:37:03 +01:00
|
|
|
K |= 1 << 12;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-08-03 06:15:30 +02:00
|
|
|
/* Toggle the following flags only outside of monochrome mode. */
|
|
|
|
/* Otherwise, instructions may behave weirdly and rendering results */
|
|
|
|
/* may differ between v35 and v40 mode, e.g., in `Times New Roman */
|
|
|
|
/* Bold Italic'. */
|
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
{
|
|
|
|
/********************************/
|
|
|
|
/* HINTING FOR SUBPIXEL */
|
|
|
|
/* Selector Bit: 6 */
|
|
|
|
/* Return Bit(s): 13 */
|
|
|
|
/* */
|
|
|
|
/* v40 does subpixel hinting by default. */
|
|
|
|
if ( ( args[0] & 64 ) != 0 )
|
|
|
|
K |= 1 << 13;
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* VERTICAL LCD SUBPIXELS? */
|
|
|
|
/* Selector Bit: 8 */
|
|
|
|
/* Return Bit(s): 15 */
|
|
|
|
/* */
|
|
|
|
if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean )
|
|
|
|
K |= 1 << 15;
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* SUBPIXEL POSITIONED? */
|
|
|
|
/* Selector Bit: 10 */
|
|
|
|
/* Return Bit(s): 17 */
|
|
|
|
/* */
|
|
|
|
/* XXX: FreeType supports it, dependent on what client does? */
|
|
|
|
if ( ( args[0] & 1024 ) != 0 )
|
|
|
|
K |= 1 << 17;
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* SYMMETRICAL SMOOTHING */
|
|
|
|
/* Selector Bit: 11 */
|
|
|
|
/* Return Bit(s): 18 */
|
|
|
|
/* */
|
|
|
|
/* The only smoothing method FreeType supports unless someone sets */
|
|
|
|
/* FT_LOAD_TARGET_MONO. */
|
2017-05-20 07:28:46 +02:00
|
|
|
if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean )
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
K |= 1 << 18;
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* CLEARTYPE HINTING AND */
|
|
|
|
/* GRAYSCALE RENDERING */
|
|
|
|
/* Selector Bit: 12 */
|
|
|
|
/* Return Bit(s): 19 */
|
|
|
|
/* */
|
|
|
|
/* Grayscale rendering is what FreeType does anyway unless someone */
|
|
|
|
/* sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) */
|
|
|
|
if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype )
|
|
|
|
K |= 1 << 19;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY &&
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->rasterizer_version >= TT_INTERPRETER_VERSION_35 )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->rasterizer_version >= 37 )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
2013-11-02 11:36:37 +01:00
|
|
|
/********************************/
|
|
|
|
/* HINTING FOR SUBPIXEL */
|
|
|
|
/* Selector Bit: 6 */
|
|
|
|
/* Return Bit(s): 13 */
|
|
|
|
/* */
|
2015-05-23 07:21:25 +02:00
|
|
|
if ( ( args[0] & 64 ) != 0 && exc->subpixel_hinting )
|
2013-11-02 11:36:37 +01:00
|
|
|
K |= 1 << 13;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* COMPATIBLE WIDTHS ENABLED */
|
|
|
|
/* Selector Bit: 7 */
|
|
|
|
/* Return Bit(s): 14 */
|
|
|
|
/* */
|
|
|
|
/* Functionality still needs to be added */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 128 ) != 0 && exc->compatible_widths )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
K |= 1 << 14;
|
|
|
|
|
|
|
|
/********************************/
|
2015-05-24 09:50:24 +02:00
|
|
|
/* VERTICAL LCD SUBPIXELS? */
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
/* Selector Bit: 8 */
|
|
|
|
/* Return Bit(s): 15 */
|
|
|
|
/* */
|
|
|
|
/* Functionality still needs to be added */
|
2015-05-24 09:50:24 +02:00
|
|
|
if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
K |= 1 << 15;
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* HINTING FOR BGR? */
|
|
|
|
/* Selector Bit: 9 */
|
|
|
|
/* Return Bit(s): 16 */
|
|
|
|
/* */
|
|
|
|
/* Functionality still needs to be added */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 512 ) != 0 && exc->bgr )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
K |= 1 << 16;
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->rasterizer_version >= 38 )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
{
|
|
|
|
/********************************/
|
|
|
|
/* SUBPIXEL POSITIONED? */
|
|
|
|
/* Selector Bit: 10 */
|
|
|
|
/* Return Bit(s): 17 */
|
|
|
|
/* */
|
|
|
|
/* Functionality still needs to be added */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( args[0] & 1024 ) != 0 && exc->subpixel_positioned )
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
K |= 1 << 17;
|
2015-05-24 09:50:24 +02:00
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* SYMMETRICAL SMOOTHING */
|
|
|
|
/* Selector Bit: 11 */
|
|
|
|
/* Return Bit(s): 18 */
|
|
|
|
/* */
|
|
|
|
/* Functionality still needs to be added */
|
|
|
|
if ( ( args[0] & 2048 ) != 0 && exc->symmetrical_smoothing )
|
|
|
|
K |= 1 << 18;
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* GRAY CLEARTYPE */
|
|
|
|
/* Selector Bit: 12 */
|
|
|
|
/* Return Bit(s): 19 */
|
|
|
|
/* */
|
|
|
|
/* Functionality still needs to be added */
|
|
|
|
if ( ( args[0] & 4096 ) != 0 && exc->gray_cleartype )
|
|
|
|
K |= 1 << 19;
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-17 13:51:07 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2013-05-17 13:51:07 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
args[0] = K;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-16 18:46:28 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* GETVARIATION[]: get normalized variation (blend) coordinates */
|
2016-08-12 05:03:09 +02:00
|
|
|
/* Opcode range: 0x91 */
|
|
|
|
/* Stack: --> f2.14... */
|
2016-07-16 18:46:28 +02:00
|
|
|
/* */
|
2016-07-30 00:27:48 +02:00
|
|
|
/* XXX: UNDOCUMENTED! There is no official documentation from Apple for */
|
|
|
|
/* this bytecode instruction. Active only if a font has GX */
|
|
|
|
/* variation axes. */
|
2016-07-16 18:46:28 +02:00
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_GETVARIATION( TT_ExecContext exc,
|
|
|
|
FT_Long* args )
|
|
|
|
{
|
|
|
|
FT_UInt num_axes = exc->face->blend->num_axis;
|
|
|
|
FT_Fixed* coords = exc->face->blend->normalizedcoords;
|
|
|
|
|
|
|
|
FT_UInt i;
|
|
|
|
|
|
|
|
|
|
|
|
if ( BOUNDS( num_axes, exc->stackSize + 1 - exc->top ) )
|
|
|
|
{
|
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-27 14:43:43 +01:00
|
|
|
if ( coords )
|
|
|
|
{
|
|
|
|
for ( i = 0; i < num_axes; i++ )
|
|
|
|
args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( i = 0; i < num_axes; i++ )
|
|
|
|
args[i] = 0;
|
|
|
|
}
|
2016-07-16 18:46:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-17 22:40:31 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* GETDATA[]: no idea what this is good for */
|
|
|
|
/* Opcode range: 0x92 */
|
|
|
|
/* Stack: --> 17 */
|
|
|
|
/* */
|
|
|
|
/* XXX: UNDOCUMENTED! There is no documentation from Apple for this */
|
|
|
|
/* very weird bytecode instruction. */
|
|
|
|
/* */
|
|
|
|
static void
|
|
|
|
Ins_GETDATA( FT_Long* args )
|
|
|
|
{
|
|
|
|
args[0] = 17;
|
|
|
|
}
|
|
|
|
|
2016-07-18 06:23:36 +02:00
|
|
|
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
|
|
|
|
|
2016-07-16 18:46:28 +02:00
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
static void
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_UNKNOWN( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
TT_DefRecord* def = exc->IDefs;
|
|
|
|
TT_DefRecord* limit = def + exc->numIDefs;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
for ( ; def < limit; def++ )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( (FT_Byte)def->opc == exc->opcode && def->active )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
TT_CallRec* call;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->callTop >= exc->callSize )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
call = exc->callStack + exc->callTop++;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
call->Caller_Range = exc->curRange;
|
|
|
|
call->Caller_IP = exc->IP + 1;
|
1999-12-17 00:11:37 +01:00
|
|
|
call->Cur_Count = 1;
|
[truetype] Minor code refactoring.
Two benefits: The allocated FDEF (and IDEF) array gets slightly
smaller, and the `ttdebug' demo program has access to function
numbers without additional costs.
Fortunately, no changes to FontForge are necessary – this is the
only external TrueType debugger I know of, but others may exist and
should check the code accordingly.
* src/truetype/ttinterp.h (TT_CallRec): Replace `Cur_Restart' and
`Cur_End' with a pointer to the corresponding `TT_DefRecord'
structure.
* src/truetype/ttinterp.c (DO_JROT, DO_JMPR, DO_JROF, Ins_ENDF,
Ins_CALL, Ins_LOOPCALL, Ins_UNKNOWN, TT_RunIns <Invalid_Opcode>):
Updated.
2013-11-01 13:26:28 +01:00
|
|
|
call->Def = def;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Ins_Goto_CodeRange( exc, def->range, def->start );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->step_ins = FALSE;
|
1999-12-17 00:11:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Opcode );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* RUN */
|
|
|
|
/* */
|
|
|
|
/* This function executes a run of opcodes. It will exit in the */
|
|
|
|
/* following cases: */
|
|
|
|
/* */
|
|
|
|
/* - Errors (in which case it returns FALSE). */
|
|
|
|
/* */
|
|
|
|
/* - Reaching the end of the main code range (returns TRUE). */
|
|
|
|
/* Reaching the end of a code range within a function call is an */
|
|
|
|
/* error. */
|
|
|
|
/* */
|
|
|
|
/* - After executing one single opcode, if the flag `Instruction_Trap' */
|
|
|
|
/* is set to TRUE (returns TRUE). */
|
|
|
|
/* */
|
2007-01-26 23:18:56 +01:00
|
|
|
/* On exit with TRUE, test IP < CodeSize to know whether it comes from */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* an instruction trap or a normal termination. */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* Note: The documented DEBUG opcode pops a value from the stack. This */
|
2000-06-12 21:36:41 +02:00
|
|
|
/* behaviour is unsupported; here a DEBUG opcode is always an */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* error. */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* THIS IS THE INTERPRETER'S MAIN LOOP. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ttinterp.h */
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
TT_RunIns( TT_ExecContext exc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2016-10-29 00:18:56 +02:00
|
|
|
FT_ULong ins_counter = 0; /* executed instructions counter */
|
|
|
|
FT_ULong num_twilight_points;
|
2013-05-23 08:01:20 +02:00
|
|
|
FT_UShort i;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2013-05-20 07:38:21 +02:00
|
|
|
FT_Byte opcode_pattern[1][2] = {
|
|
|
|
/* #8 TypeMan Talk Align */
|
|
|
|
{
|
|
|
|
0x06, /* SPVTL */
|
|
|
|
0x7D, /* RDTG */
|
|
|
|
},
|
|
|
|
};
|
|
|
|
FT_UShort opcode_patterns = 1;
|
|
|
|
FT_UShort opcode_pointer[1] = { 0 };
|
|
|
|
FT_UShort opcode_size[1] = { 1 };
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2013-05-20 07:38:21 +02:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->iup_called = FALSE;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
|
|
|
|
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
2017-05-20 07:28:46 +02:00
|
|
|
/*
|
|
|
|
* Toggle backward compatibility according to what font wants, except
|
|
|
|
* when
|
|
|
|
*
|
|
|
|
* 1) we have a `tricky' font that heavily relies on the interpreter to
|
|
|
|
* render glyphs correctly, for example DFKai-SB, or
|
|
|
|
* 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested.
|
|
|
|
*
|
|
|
|
* In those cases, backward compatibility needs to be turned off to get
|
|
|
|
* correct rendering. The rendering is then completely up to the
|
|
|
|
* font's programming.
|
|
|
|
*
|
|
|
|
*/
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_MINIMAL &&
|
2017-05-20 07:28:46 +02:00
|
|
|
exc->subpixel_hinting_lean &&
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
!FT_IS_TRICKY( &exc->face->root ) )
|
2017-05-03 23:54:29 +02:00
|
|
|
exc->backward_compatibility = !( exc->GS.instruct_control & 4 );
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
else
|
2017-05-03 23:54:29 +02:00
|
|
|
exc->backward_compatibility = FALSE;
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
|
|
|
|
exc->iupx_called = FALSE;
|
|
|
|
exc->iupy_called = FALSE;
|
|
|
|
#endif
|
[truetype] Support subpixel hinting.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
2012-06-18 10:36:06 +02:00
|
|
|
|
2016-09-27 08:44:31 +02:00
|
|
|
/* We restrict the number of twilight points to a reasonable, */
|
|
|
|
/* heuristic value to avoid slow execution of malformed bytecode. */
|
|
|
|
num_twilight_points = FT_MAX( 30,
|
|
|
|
2 * ( exc->pts.n_points + exc->cvtSize ) );
|
|
|
|
if ( exc->twilight.n_points > num_twilight_points )
|
|
|
|
{
|
2016-10-29 00:18:56 +02:00
|
|
|
if ( num_twilight_points > 0xFFFFU )
|
|
|
|
num_twilight_points = 0xFFFFU;
|
|
|
|
|
2016-09-27 08:44:31 +02:00
|
|
|
FT_TRACE5(( "TT_RunIns: Resetting number of twilight points\n"
|
|
|
|
" from %d to the more reasonable value %d\n",
|
|
|
|
exc->twilight.n_points,
|
|
|
|
num_twilight_points ));
|
2016-10-29 00:18:56 +02:00
|
|
|
exc->twilight.n_points = (FT_UShort)num_twilight_points;
|
2016-09-27 08:44:31 +02:00
|
|
|
}
|
|
|
|
|
2017-03-18 09:42:58 +01:00
|
|
|
/* Set up loop detectors. We restrict the number of LOOPCALL loops */
|
|
|
|
/* and the number of JMPR, JROT, and JROF calls with a negative */
|
|
|
|
/* argument to values that depend on various parameters like the */
|
|
|
|
/* size of the CVT table or the number of points in the current */
|
|
|
|
/* glyph (if applicable). */
|
|
|
|
/* */
|
|
|
|
/* The idea is that in real-world bytecode you either iterate over */
|
|
|
|
/* all CVT entries (in the `prep' table), or over all points (or */
|
|
|
|
/* contours, in the `glyf' table) of a glyph, and such iterations */
|
|
|
|
/* don't happen very often. */
|
2016-09-27 08:44:31 +02:00
|
|
|
exc->loopcall_counter = 0;
|
|
|
|
exc->neg_jump_counter = 0;
|
|
|
|
|
|
|
|
/* The maximum values are heuristic. */
|
2017-01-20 10:16:38 +01:00
|
|
|
if ( exc->pts.n_points )
|
|
|
|
exc->loopcall_counter_max = FT_MAX( 50,
|
|
|
|
10 * exc->pts.n_points ) +
|
|
|
|
FT_MAX( 50,
|
|
|
|
exc->cvtSize / 10 );
|
|
|
|
else
|
2017-06-01 07:09:44 +02:00
|
|
|
exc->loopcall_counter_max = 300 + 8 * exc->cvtSize;
|
2017-03-18 09:42:58 +01:00
|
|
|
|
|
|
|
/* as a protection against an unreasonable number of CVT entries */
|
|
|
|
/* we assume at most 100 control values per glyph for the counter */
|
|
|
|
if ( exc->loopcall_counter_max >
|
|
|
|
100 * (FT_ULong)exc->face->root.num_glyphs )
|
|
|
|
exc->loopcall_counter_max = 100 * (FT_ULong)exc->face->root.num_glyphs;
|
|
|
|
|
2016-09-27 08:44:31 +02:00
|
|
|
FT_TRACE5(( "TT_RunIns: Limiting total number of loops in LOOPCALL"
|
|
|
|
" to %d\n", exc->loopcall_counter_max ));
|
|
|
|
|
|
|
|
exc->neg_jump_counter_max = exc->loopcall_counter_max;
|
|
|
|
FT_TRACE5(( "TT_RunIns: Limiting total number of backward jumps"
|
|
|
|
" to %d\n", exc->neg_jump_counter_max ));
|
|
|
|
|
2014-09-03 04:38:59 +02:00
|
|
|
/* set PPEM and CVT functions */
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->tt_metrics.ratio = 0;
|
|
|
|
if ( exc->metrics.x_ppem != exc->metrics.y_ppem )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
/* non-square pixels, use the stretched routines */
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_cur_ppem = Current_Ppem_Stretched;
|
|
|
|
exc->func_read_cvt = Read_CVT_Stretched;
|
|
|
|
exc->func_write_cvt = Write_CVT_Stretched;
|
|
|
|
exc->func_move_cvt = Move_CVT_Stretched;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* square pixels, use normal routines */
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->func_cur_ppem = Current_Ppem;
|
|
|
|
exc->func_read_cvt = Read_CVT;
|
|
|
|
exc->func_write_cvt = Write_CVT;
|
|
|
|
exc->func_move_cvt = Move_CVT;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
Compute_Funcs( exc );
|
|
|
|
Compute_Round( exc, (FT_Byte)exc->GS.round_state );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->opcode = exc->code[exc->IP];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-06-01 12:12:06 +02:00
|
|
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
|
|
{
|
|
|
|
FT_Long cnt = FT_MIN( 8, exc->top );
|
|
|
|
FT_Long n;
|
|
|
|
|
|
|
|
|
|
|
|
/* if tracing level is 7, show current code position */
|
|
|
|
/* and the first few stack elements also */
|
|
|
|
FT_TRACE6(( " " ));
|
|
|
|
FT_TRACE7(( "%06d ", exc->IP ));
|
|
|
|
FT_TRACE6(( opcode_name[exc->opcode] + 2 ));
|
|
|
|
FT_TRACE7(( "%*s", *opcode_name[exc->opcode] == 'A'
|
|
|
|
? 2
|
|
|
|
: 12 - ( *opcode_name[exc->opcode] - '0' ),
|
|
|
|
"#" ));
|
2015-10-15 21:15:45 +02:00
|
|
|
for ( n = 1; n <= cnt; n++ )
|
2015-06-01 12:12:06 +02:00
|
|
|
FT_TRACE7(( " %d", exc->stack[exc->top - n] ));
|
|
|
|
FT_TRACE6(( "\n" ));
|
|
|
|
}
|
|
|
|
#endif /* FT_DEBUG_LEVEL_TRACE */
|
2010-07-01 11:28:43 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( ( exc->length = opcode_length[exc->opcode] ) < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->IP + 1 >= exc->codeSize )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto LErrorCodeOverflow_;
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->length = 2 - exc->length * exc->code[exc->IP + 1];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->IP + exc->length > exc->codeSize )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto LErrorCodeOverflow_;
|
|
|
|
|
|
|
|
/* First, let's check for empty stack and overflow */
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->args = exc->top - ( Pop_Push_Count[exc->opcode] >> 4 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* `args' is the top of the stack once arguments have been popped. */
|
|
|
|
/* One can also interpret it as the index of the last argument. */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->args < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->pedantic_hinting )
|
2011-01-31 10:24:32 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Too_Few_Arguments );
|
2011-01-31 10:24:32 +01:00
|
|
|
goto LErrorLabel_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* push zeroes onto the stack */
|
2015-01-10 19:56:28 +01:00
|
|
|
for ( i = 0; i < Pop_Push_Count[exc->opcode] >> 4; i++ )
|
|
|
|
exc->stack[i] = 0;
|
|
|
|
exc->args = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2016-07-16 18:46:28 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
if ( exc->opcode == 0x91 )
|
|
|
|
{
|
|
|
|
/* this is very special: GETVARIATION returns */
|
|
|
|
/* a variable number of arguments */
|
|
|
|
|
|
|
|
/* it is the job of the application to `activate' GX handling, */
|
|
|
|
/* this is, calling any of the GX API functions on the current */
|
|
|
|
/* font to select a variation instance */
|
|
|
|
if ( exc->face->blend )
|
|
|
|
exc->new_top = exc->args + exc->face->blend->num_axis;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* `new_top' is the new top of the stack, after the instruction's */
|
|
|
|
/* execution. `top' will be set to `new_top' after the `switch' */
|
|
|
|
/* statement. */
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->new_top > exc->stackSize )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Stack_Overflow );
|
1999-12-17 00:11:37 +01:00
|
|
|
goto LErrorLabel_;
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->step_ins = TRUE;
|
|
|
|
exc->error = FT_Err_Ok;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
2013-05-20 07:38:21 +02:00
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
if ( SUBPIXEL_HINTING_INFINALITY )
|
2013-05-20 07:38:21 +02:00
|
|
|
{
|
|
|
|
for ( i = 0; i < opcode_patterns; i++ )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( opcode_pointer[i] < opcode_size[i] &&
|
|
|
|
exc->opcode == opcode_pattern[i][opcode_pointer[i]] )
|
2013-05-20 07:38:21 +02:00
|
|
|
{
|
|
|
|
opcode_pointer[i] += 1;
|
|
|
|
|
|
|
|
if ( opcode_pointer[i] == opcode_size[i] )
|
|
|
|
{
|
2015-06-01 12:12:06 +02:00
|
|
|
FT_TRACE6(( "sph: opcode ptrn: %d, %s %s\n",
|
2013-05-20 07:38:21 +02:00
|
|
|
i,
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->face->root.family_name,
|
|
|
|
exc->face->root.style_name ));
|
2013-05-20 07:38:21 +02:00
|
|
|
|
|
|
|
switch ( i )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
opcode_pointer[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
opcode_pointer[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[truetype] New implementation of v38 bytecode interpreter [2/3].
This patch actually modifies the bytecode interpreter.
See added comments in `ttinterp.h' for more information on this and
the following commit in the series.
* src/truetype/ttinterp.c (SUBPIXEL_HINTING): Replaced by...
(NO_SUBPIXEL_HINTING, SUBPIXEL_HINTING_INFINALITY,
SUBPIXEL_HINTING_MINIMAL): ...new macros.
(Direct_Move, Direct_Move_X, Direct_Move_Y): Handle backwards
compatibility.
Updated.
(Ins_RS, Ins_FDEF, Ins_ENDF, Ins_CALL, Ins_LOOPCALL, Ins_MD):
Updated.
(Ins_INSTCTRL): Handle native ClearType mode flag.
Updated.
(Ins_FLIPPT, Ins_FLIPRGON, Ins_FLIPRGOFF): Handle backwards
compatibility.
(Move_Zp2_Point): Ditto.
(Ins_SHP): Updated.
(Ins_SHPIX): Handle backwards compatibility.
Updated.
(Ins_MSIRP, Ins_MDAP, Ins_MIAP, Ins_MDRP, Ins_MIRP): Updated.
(Ins_ALIGNRP): Updated.
(Ins_IUP, Ins_DELTAP): Handle backwards compatibility.
Updated.
(Ins_GETINFO): Handle v38 flags.
Updated.
(TT_RunIns): Handle backwards compatibility mode.
Updated.
2016-05-18 06:58:44 +02:00
|
|
|
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
|
2013-05-20 07:38:21 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
FT_Long* args = exc->stack + exc->args;
|
|
|
|
FT_Byte opcode = exc->opcode;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
switch ( opcode )
|
|
|
|
{
|
|
|
|
case 0x00: /* SVTCA y */
|
|
|
|
case 0x01: /* SVTCA x */
|
|
|
|
case 0x02: /* SPvTCA y */
|
|
|
|
case 0x03: /* SPvTCA x */
|
|
|
|
case 0x04: /* SFvTCA y */
|
|
|
|
case 0x05: /* SFvTCA x */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SxyTCA( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x06: /* SPvTL // */
|
|
|
|
case 0x07: /* SPvTL + */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SPVTL( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x08: /* SFvTL // */
|
|
|
|
case 0x09: /* SFvTL + */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SFVTL( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0A: /* SPvFS */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SPVFS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0B: /* SFvFS */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SFVFS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
2015-01-11 00:56:55 +01:00
|
|
|
case 0x0C: /* GPv */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_GPV( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
2015-01-11 00:56:55 +01:00
|
|
|
case 0x0D: /* GFv */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_GFV( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0E: /* SFvTPv */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SFVTPV( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0F: /* ISECT */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_ISECT( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x10: /* SRP0 */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SRP0( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x11: /* SRP1 */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SRP1( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x12: /* SRP2 */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SRP2( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x13: /* SZP0 */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SZP0( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x14: /* SZP1 */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SZP1( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x15: /* SZP2 */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SZP2( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x16: /* SZPS */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SZPS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x17: /* SLOOP */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SLOOP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x18: /* RTG */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_RTG( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x19: /* RTHG */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_RTHG( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x1A: /* SMD */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SMD( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x1B: /* ELSE */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ELSE( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x1C: /* JMPR */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_JMPR( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x1D: /* SCVTCI */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SCVTCI( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x1E: /* SSWCI */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SSWCI( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x1F: /* SSW */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SSW( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x20: /* DUP */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_DUP( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x21: /* POP */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_POP();
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x22: /* CLEAR */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_CLEAR( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x23: /* SWAP */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SWAP( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x24: /* DEPTH */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_DEPTH( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x25: /* CINDEX */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_CINDEX( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x26: /* MINDEX */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_MINDEX( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x27: /* ALIGNPTS */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_ALIGNPTS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
2016-08-12 05:03:09 +02:00
|
|
|
case 0x28: /* RAW */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_UNKNOWN( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x29: /* UTP */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_UTP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2A: /* LOOPCALL */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_LOOPCALL( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2B: /* CALL */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_CALL( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2C: /* FDEF */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_FDEF( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2D: /* ENDF */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ENDF( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2E: /* MDAP */
|
|
|
|
case 0x2F: /* MDAP */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_MDAP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x30: /* IUP */
|
|
|
|
case 0x31: /* IUP */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_IUP( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x32: /* SHP */
|
|
|
|
case 0x33: /* SHP */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SHP( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x34: /* SHC */
|
|
|
|
case 0x35: /* SHC */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SHC( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x36: /* SHZ */
|
|
|
|
case 0x37: /* SHZ */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SHZ( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x38: /* SHPIX */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SHPIX( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x39: /* IP */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_IP( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x3A: /* MSIRP */
|
|
|
|
case 0x3B: /* MSIRP */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_MSIRP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x3C: /* AlignRP */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ALIGNRP( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x3D: /* RTDG */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_RTDG( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x3E: /* MIAP */
|
|
|
|
case 0x3F: /* MIAP */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_MIAP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x40: /* NPUSHB */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_NPUSHB( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x41: /* NPUSHW */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_NPUSHW( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x42: /* WS */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_WS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x43: /* RS */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_RS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x44: /* WCVTP */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_WCVTP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x45: /* RCVT */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_RCVT( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x46: /* GC */
|
|
|
|
case 0x47: /* GC */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_GC( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x48: /* SCFS */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SCFS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x49: /* MD */
|
|
|
|
case 0x4A: /* MD */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_MD( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x4B: /* MPPEM */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_MPPEM( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x4C: /* MPS */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_MPS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x4D: /* FLIPON */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_FLIPON( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x4E: /* FLIPOFF */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_FLIPOFF( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x4F: /* DEBUG */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_DEBUG( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x50: /* LT */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_LT( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x51: /* LTEQ */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_LTEQ( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x52: /* GT */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_GT( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x53: /* GTEQ */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_GTEQ( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x54: /* EQ */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_EQ( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x55: /* NEQ */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_NEQ( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x56: /* ODD */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_ODD( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x57: /* EVEN */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_EVEN( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x58: /* IF */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_IF( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x59: /* EIF */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_EIF();
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x5A: /* AND */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_AND( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x5B: /* OR */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_OR( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x5C: /* NOT */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_NOT( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x5D: /* DELTAP1 */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_DELTAP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x5E: /* SDB */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SDB( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x5F: /* SDS */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SDS( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x60: /* ADD */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ADD( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x61: /* SUB */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SUB( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x62: /* DIV */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_DIV( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x63: /* MUL */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MUL( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x64: /* ABS */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ABS( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x65: /* NEG */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_NEG( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x66: /* FLOOR */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_FLOOR( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x67: /* CEILING */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_CEILING( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x68: /* ROUND */
|
|
|
|
case 0x69: /* ROUND */
|
|
|
|
case 0x6A: /* ROUND */
|
|
|
|
case 0x6B: /* ROUND */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_ROUND( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x6C: /* NROUND */
|
|
|
|
case 0x6D: /* NROUND */
|
|
|
|
case 0x6E: /* NRRUND */
|
|
|
|
case 0x6F: /* NROUND */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_NROUND( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x70: /* WCVTF */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_WCVTF( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x71: /* DELTAP2 */
|
|
|
|
case 0x72: /* DELTAP3 */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_DELTAP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x73: /* DELTAC0 */
|
|
|
|
case 0x74: /* DELTAC1 */
|
|
|
|
case 0x75: /* DELTAC2 */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_DELTAC( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x76: /* SROUND */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_SROUND( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x77: /* S45Round */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_S45ROUND( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x78: /* JROT */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_JROT( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x79: /* JROF */
|
2015-01-11 00:23:27 +01:00
|
|
|
Ins_JROF( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7A: /* ROFF */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ROFF( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7B: /* ???? */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_UNKNOWN( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7C: /* RUTG */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_RUTG( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7D: /* RDTG */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_RDTG( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7E: /* SANGW */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_SANGW();
|
2015-01-11 00:23:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7F: /* AA */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_AA();
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x80: /* FLIPPT */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_FLIPPT( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x81: /* FLIPRGON */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_FLIPRGON( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x82: /* FLIPRGOFF */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_FLIPRGOFF( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x83: /* UNKNOWN */
|
|
|
|
case 0x84: /* UNKNOWN */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_UNKNOWN( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x85: /* SCANCTRL */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SCANCTRL( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
2015-01-11 00:56:55 +01:00
|
|
|
case 0x86: /* SDPvTL */
|
|
|
|
case 0x87: /* SDPvTL */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SDPVTL( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x88: /* GETINFO */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_GETINFO( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x89: /* IDEF */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_IDEF( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x8A: /* ROLL */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_ROLL( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x8B: /* MAX */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MAX( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x8C: /* MIN */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_MIN( args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x8D: /* SCANTYPE */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_SCANTYPE( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x8E: /* INSTCTRL */
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_INSTCTRL( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
2016-08-12 05:03:09 +02:00
|
|
|
case 0x8F: /* ADJUST */
|
|
|
|
case 0x90: /* ADJUST */
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_UNKNOWN( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
2016-07-16 18:46:28 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
case 0x91:
|
|
|
|
/* it is the job of the application to `activate' GX handling, */
|
|
|
|
/* this is, calling any of the GX API functions on the current */
|
|
|
|
/* font to select a variation instance */
|
|
|
|
if ( exc->face->blend )
|
|
|
|
Ins_GETVARIATION( exc, args );
|
|
|
|
else
|
|
|
|
Ins_UNKNOWN( exc );
|
|
|
|
break;
|
|
|
|
|
2016-07-17 22:40:31 +02:00
|
|
|
case 0x92:
|
2016-07-18 06:23:36 +02:00
|
|
|
/* there is at least one MS font (LaoUI.ttf version 5.01) that */
|
|
|
|
/* uses IDEFs for 0x91 and 0x92; for this reason we activate */
|
|
|
|
/* GETDATA for GX fonts only, similar to GETVARIATION */
|
|
|
|
if ( exc->face->blend )
|
|
|
|
Ins_GETDATA( args );
|
|
|
|
else
|
|
|
|
Ins_UNKNOWN( exc );
|
2016-07-17 22:40:31 +02:00
|
|
|
break;
|
2016-07-18 06:23:36 +02:00
|
|
|
#endif
|
2016-07-17 22:40:31 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
default:
|
|
|
|
if ( opcode >= 0xE0 )
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_MIRP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
else if ( opcode >= 0xC0 )
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_MDRP( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
else if ( opcode >= 0xB8 )
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_PUSHW( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
else if ( opcode >= 0xB0 )
|
2015-01-10 21:56:59 +01:00
|
|
|
Ins_PUSHB( exc, args );
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2015-01-11 08:39:14 +01:00
|
|
|
Ins_UNKNOWN( exc );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->error )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
switch ( exc->error )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2013-03-14 17:50:49 +01:00
|
|
|
/* looking for redefined instructions */
|
|
|
|
case FT_ERR( Invalid_Opcode ):
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
TT_DefRecord* def = exc->IDefs;
|
|
|
|
TT_DefRecord* limit = def + exc->numIDefs;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
for ( ; def < limit; def++ )
|
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( def->active && exc->opcode == (FT_Byte)def->opc )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
TT_CallRec* callrec;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->callTop >= exc->callSize )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Reference );
|
1999-12-17 00:11:37 +01:00
|
|
|
goto LErrorLabel_;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
callrec = &exc->callStack[exc->callTop];
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
callrec->Caller_Range = exc->curRange;
|
|
|
|
callrec->Caller_IP = exc->IP + 1;
|
1999-12-17 00:11:37 +01:00
|
|
|
callrec->Cur_Count = 1;
|
[truetype] Minor code refactoring.
Two benefits: The allocated FDEF (and IDEF) array gets slightly
smaller, and the `ttdebug' demo program has access to function
numbers without additional costs.
Fortunately, no changes to FontForge are necessary – this is the
only external TrueType debugger I know of, but others may exist and
should check the code accordingly.
* src/truetype/ttinterp.h (TT_CallRec): Replace `Cur_Restart' and
`Cur_End' with a pointer to the corresponding `TT_DefRecord'
structure.
* src/truetype/ttinterp.c (DO_JROT, DO_JMPR, DO_JROF, Ins_ENDF,
Ins_CALL, Ins_LOOPCALL, Ins_UNKNOWN, TT_RunIns <Invalid_Opcode>):
Updated.
2013-11-01 13:26:28 +01:00
|
|
|
callrec->Def = def;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
[truetype] More macro expansions.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (SKIP_Code, GET_ShortIns, NORMalize,
SET_SuperRound, ROUND_None, INS_Goto_CodeRange, CUR_Func_move,
CUR_Func_move_orig, CUR_Func_round, CUR_Func_cur_ppem,
CUR_Func_read_cvt, CUR_Func_write_cvt, CUR_Func_move_cvt,
CURRENT_Ratio, INS_SxVTL, COMPUTE_Funcs, COMPUTE_Round,
COMPUTE_Point_Displacement, MOVE_Zp2_Point): Remove by replacing
with expansion.
(Cur_Func_project, CUR_Func_dualproj, CUR_fast_project,
CUR_fast_dualproj): Replace with macros `project', `dualproj',
`fast_project', `fast_dualproj'.
2015-01-10 21:53:48 +01:00
|
|
|
if ( Ins_Goto_CodeRange( exc,
|
|
|
|
def->range,
|
|
|
|
def->start ) == FAILURE )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto LErrorLabel_;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
goto LSuiteLabel_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Invalid_Opcode );
|
1999-12-17 00:11:37 +01:00
|
|
|
goto LErrorLabel_;
|
2000-06-12 21:36:41 +02:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
break; /* Unreachable code warning suppression. */
|
|
|
|
/* Leave to remind in case a later change the editor */
|
|
|
|
/* to consider break; */
|
|
|
|
#endif
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
goto LErrorLabel_;
|
2000-06-12 21:36:41 +02:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
break;
|
|
|
|
#endif
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->top = exc->new_top;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->step_ins )
|
|
|
|
exc->IP += exc->length;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
/* increment instruction counter and check if we didn't */
|
|
|
|
/* run this program for too long (e.g. infinite loops). */
|
2015-10-15 21:50:15 +02:00
|
|
|
if ( ++ins_counter > TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Execution_Too_Long );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
LSuiteLabel_:
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->IP >= exc->codeSize )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
if ( exc->callTop > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Code_Overflow );
|
1999-12-17 00:11:37 +01:00
|
|
|
goto LErrorLabel_;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
goto LNo_Error_;
|
|
|
|
}
|
2015-01-10 19:56:28 +01:00
|
|
|
} while ( !exc->instruction_trap );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
LNo_Error_:
|
2017-12-05 12:06:29 +01:00
|
|
|
FT_TRACE4(( " %d instruction%s executed\n",
|
2018-03-01 22:17:54 +01:00
|
|
|
ins_counter,
|
|
|
|
ins_counter == 1 ? "" : "s" ));
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
LErrorCodeOverflow_:
|
2015-01-10 19:56:28 +01:00
|
|
|
exc->error = FT_THROW( Code_Overflow );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
LErrorLabel_:
|
2017-04-03 11:37:33 +02:00
|
|
|
if ( exc->error && !exc->instruction_trap )
|
2015-01-10 19:56:28 +01:00
|
|
|
FT_TRACE1(( " The interpreter returned error 0x%x\n", exc->error ));
|
2010-08-30 18:23:30 +02:00
|
|
|
|
2015-01-10 19:56:28 +01:00
|
|
|
return exc->error;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
Improve `make multi'.
* src/autofit/aflatin2.c: Guard file with FT_OPTION_AUTOFIT2.
* src/base/ftmac.c: Guard more parts of the file with FT_MACINTOSH.
* src/psaux/afmparse.c: Guard file with T1_CONFIG_OPTION_NO_AFM.
* src/sfnt/pngshim.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS also.
* src/sfnt/ttbdf.c: Avoid empty source file.
* src/sfnt/ttpost.c: Guard file with
TT_CONFIG_OPTION_POSTSCRIPT_NAMES.
* src/sfnt/ttsbit.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS.
* src/truetype/ttgxvar.c, src/truetype/ttinterp.c: Avoid empty
source file.
* src/truetype/ttsubpix.c: Guard file with
TT_USE_BYTECODE_INTERPRETER also.
* src/type1/t1afm.c: Guard file with T1_CONFIG_OPTION_NO_AFM.
* src/autofit/autofit.c, src/base/ftbase.c, src/cache/ftcache.c,
src/cff/cff.c, src/cid/type1cid.c, src/gxvalid/gxvalid.c,
src/pcf/pcf.c, src/pfr/pfr.c, src/psaux/psaux.c,
src/pshinter/pshinter.c, src/psnames/psnames.c, src/raster/raster.c,
src/sfnt/sfnt.c, src/smooth/smooth.c, src/truetype/truetype.c,
src/type1/type1.c, src/type42/type42.c: Remove conditionals; sort
entries.
2017-03-18 07:06:49 +01:00
|
|
|
#else /* !TT_USE_BYTECODE_INTERPRETER */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
Improve `make multi'.
* src/autofit/aflatin2.c: Guard file with FT_OPTION_AUTOFIT2.
* src/base/ftmac.c: Guard more parts of the file with FT_MACINTOSH.
* src/psaux/afmparse.c: Guard file with T1_CONFIG_OPTION_NO_AFM.
* src/sfnt/pngshim.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS also.
* src/sfnt/ttbdf.c: Avoid empty source file.
* src/sfnt/ttpost.c: Guard file with
TT_CONFIG_OPTION_POSTSCRIPT_NAMES.
* src/sfnt/ttsbit.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS.
* src/truetype/ttgxvar.c, src/truetype/ttinterp.c: Avoid empty
source file.
* src/truetype/ttsubpix.c: Guard file with
TT_USE_BYTECODE_INTERPRETER also.
* src/type1/t1afm.c: Guard file with T1_CONFIG_OPTION_NO_AFM.
* src/autofit/autofit.c, src/base/ftbase.c, src/cache/ftcache.c,
src/cff/cff.c, src/cid/type1cid.c, src/gxvalid/gxvalid.c,
src/pcf/pcf.c, src/pfr/pfr.c, src/psaux/psaux.c,
src/pshinter/pshinter.c, src/psnames/psnames.c, src/raster/raster.c,
src/sfnt/sfnt.c, src/smooth/smooth.c, src/truetype/truetype.c,
src/type1/type1.c, src/type42/type42.c: Remove conditionals; sort
entries.
2017-03-18 07:06:49 +01:00
|
|
|
/* ANSI C doesn't like empty source files */
|
|
|
|
typedef int _tt_interp_dummy;
|
|
|
|
|
|
|
|
#endif /* !TT_USE_BYTECODE_INTERPRETER */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* END */
|