This flag activates `native ClearType hinting', disabling backwards
compatibility mode as described in Greg Hitchcocks whitepaper. In
other words, it enables unrestricted functionality of all TrueType
instructions in ClearType.
* src/truetype/ttgload.c (tt_get_metrics): Call `sph_set_tweaks'
unconditionally.
(tt_loader_init): Unset `ignore_x_mode' flag if bit 2 of
`GS.instruct_control' is active.
* src/truetype/ttinterp.c (Ins_INSTCTRL): Handle selector index 3.
(Ins_GETINFO): Updated.
* docs/CHANGES: Document it.
Previously the code had stipulation for using a per-TT_Size exec
context if `size->debug' was true. But there was no way that
`size->debug' could *ever* be true. As such, the code was always
using the singleton `TT_ExecContext' that was stored in `TT_Driver'.
This was, clearly, not threadsafe.
With this patch, loading glyphs from different faces from different
threads doesn't crash in the bytecode loader code.
* src/truetype/ttobjs.h (TT_SizeRec): Remove `debug' member.
(TT_DriverRec): Remove `context' member.
* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Remove
`TT_ExecContext' code related to a global `TT_Driver' object.
(tt_driver_done): Don't remove `TT_ExecContext' object here but ...
(tt_size_done_bytecode): ... here.
(tt_driver_init): Don't create `TT_ExecContext' object here but ...
(tt_size_init_bytecode): ... here, only on demand.
* src/truetype/ttinterp.c (TT_Run_Context): Remove defunct debug
code.
(TT_New_Context): Remove `TT_ExecContext' code related to a global
`TT_Driver' object.
* src/truetype/ttinterp.h: Updated.
* src/truetype/ttgload.c (TT_Hint_Glyph, tt_loader_init): Updated.
Based on a patch from Behdad.
* src/truetype/ttinterp.c (DO_*): Expand macros into corresponding
`Ins_*' functions.
(TT_RunIns): Replace `DO_*' macros with `Ins_*' function calls.
(ARRAY_BOUND_ERROR): Remove second definition, which is no longer
needed.
(Ins_SVTCA, Ins_SPVTCA, Ins_SFVTCA): Replaced with...
(Ins_SxyTCA): New function.
This is a follow-up patch.
* src/truetype/ttinterp.c, src/truetype/ttinterp.h
[TT_CONFIG_OPTION_STATIC_INTERPRETER,
TT_CONFIG_OPTION_STATIC_RASTER]: Remove macros and related code.
`API functions' are functions tagged with `FT_EXPORT_DEF'.
Besides trivial fixes, the following changes are included, too.
* src/base/ftbdf.c (FT_Get_BDF_Charset_ID, FT_Get_BDF_Property): Set
error code if no service is available.
* src/base/ftinit.c (FT_Done_FreeType): Change return value for
invalid `library' parameter to `Invalid_Library_Handle'.
* src/base/ftobjs.c (FT_New_Size): Change return value for invalid
`asize' parameter to `Invalid_Argument'.
* src/base/ftoutln.c (FT_Outline_Copy): Change return value for
invalid `source' and `target' parameters to `Invalid_Outline'.
(FT_Outline_Done_Internal): Change return value for invalid
`outline' parameter to `Invalid_Outline'.
Before this patch, it was impossible to ever call DELTAP[123] in
subpixel hinting mode as described in the ClearType whitepaper; it
only worked if in `compatibility mode'. However, compatibility mode
essentially disables SHPIX, completely ruining hinting of
ttfautohint output, for example.
We now follow the whitepaper more closely so that DELTAP[123]
instructions for touched points in the non-subpixel direction are
executed.
Zero distance does not have to be treated specially if you follow
specifications and check the sign as the very last step of rounding.
* src/truetype/ttinterp.c (Round_None, Round_To_Grid,
Round_Down_To_Grid, Round_Up_To_Grid, Round_To_Double_Grid): Use
macros when available, do not check for non-zero distance.
(Round_To_Half_Grid, Round_Super, Round_Super_45): Ditto, return phase
if sign changed.
The legal range for delta shift is zero through six. Negative values
are illegal according to
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#delta%20shift
* src/truetype/ttobjs.h (delta_shift, delta_base): Make unsigned.
* src/truetype/ttinterp.h (DO_SDS): Throw an error if delta_shift
out of range.
(Ins_DELTAP, Ins_DELTAC): Optimize for legal delta_shift.
* src/truetype/ttinterp.h (TT_ExecContextRec): New field
`cur_ppem_func' with a function pointer.
* src/truetype/ttinterp.c (TT_RunIns): Initialize `cur_ppem_func'
depending on the pixel geometry to either...
(Current_Ppem_Stretched): ... this for stretched pixels.
(Current_Ppem): ... or this for square pixels.
(DO_MPPEM, DO_MPS, Ins_DELTAP, Ins_DELTAC): Use `cur_ppem_func'.
In case of an error in the `prep' table, no longer try to execute it
again and again. This makes FreeType handle endless loops in buggy
fonts much faster.
* src/truetype/ttobjs.h (TT_SizeRec): The fields `bytecode_ready'
and `cvt_ready' are now negative if not initialized yet, otherwise
they indicate the error code of the last run.
* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep,
tt_size_done_bytecode, tt_size_init_bytecode,
tt_size_ready_bytecode, tt_size_init, tt_size_done, tt_size_reset):
Updated.
* src/truetype/ttgload.c (tt_loader_init): Updated.
* src/truetype/ttinterp.c (TT_RunIns): Force reexecution of `fpgm'
and `prep' only if we are in the `glyf' table.
This patch unifies the subpixel and non-subpixel cases.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove
`grayscale_hinting'; all code should refer to `grayscale' instead.
Remove unused `native_hinting' member.
Rename `subpixel_hinting' member to `subpixel.
* src/truetype/ttgload.c (TT_LOADER_SET_PP): Updated.
(tt_loader_init): Updated.
* src/truetype/ttinterp.c (Ins_GETINFO): Simplify.
Updated.
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.
When using `ADD' with an immediate operand, the instruction is
actually `ADD Rd, Rn, #<imm12>', that is, the maximum of the
immediate operand cannot exceed 4095. It will fail to compile with
LLVM.
However, in GCC, due to some legacy compatibility considerations,
`ADD.W' will be automatically emitted when the immediate operand is
larger than 4095.
* builds/unix/ftconfig.in, include/freetype/config/ftconfig.h
(FT_MulFix_arm) [__GNUC__]: Support clang compiler.
* src/truetype/ttinterp.c (TT_MulFix14_arm) [__GNUC__]: Ditto.
* src/truetype/ttinterp.c (TT_MulFix14_long_long,
TT_DotFix14_long_long): `#pragma gcc diagnostic {push,pop}' has been
introduced with gcc version 4.6.
This patch provides slightly optimized versions for ARM, x86, and
x86_64 CPUs if built with GCC.
Also remove some dead code.
* src/truetype/ttinterp.c (TT_MulFix14_arm, TT_MulFix14_long_long,
TT_DotFix14_long_long): New functions.
Some small enhancements have allowed the removal of many macros and
the simplification of existing rules in `ttsubpix.c'.
* src/truetype/ttsubpix.h (SPH_TWEAK_ALLOW_X_DMOVEX,
SPH_TWEAK_ALLOW_X_MOVE_ZP2,
SPH_TWEAK_DELTAP_SKIP_EXAGGERATED_VALUES,
SPH_TWEAK_SKIP_INLINE_DELTAS, SPH_TWEAK_MIRP_CVT_ZERO): Removed.
(SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP): New rule macro.
* src/truetype/ttsubpix.c: Updated affected rules.
* src/truetype/ttinterp.c (Direct_Move_X): Updated.
(INS_FDEF): Add additional function detection.
(INS_ENDF): Set runtime flag.
(Ins_CALL): Skip the call under certain conditions.
Remove bad code.
(Ins_LOOPCALL): Skip the call under certain conditions.
Remove bad code.
(Move_Zp2_Point): Updated.
(Ins_SHPIX): Updated.
Skip the move under some situations.
(Ins_MIAP): Improve conditions.
(Ins_MIRP): Updated.
(Ins_DELTAP): Skip move under certain conditions.
Simplify conditions.
(TT_RunIns): Updated.
Add code to handle new function detection.
Trace messages.