Commit Graph

363 Commits

Author SHA1 Message Date
Werner Lemberg 053943a757 [truetype] Comment. 2016-07-30 00:27:48 +02:00
Hin-Tak Leung 3a528bbe5a [truetype] Record the end of IDEFs.
To match the logic in FDEF.  The value of the end is only used for
bound-checking in `Ins_JMPR', so it may not have been obvious that
it was not recorded.  Tested (as part of Font Validator 2.0) all the
fonts on Fedora and did not see any change.

* src/truetype/ttinterp.c (Ins_IDEF): Updated.
2016-07-22 06:59:36 +02:00
Werner Lemberg a3b70d76ba [truetype] Make GETDATA work only for GX fonts.
* src/truetype/ttinterp.c (opcode_name): Updated.
(Ins_GETDATA): Only define for `TT_CONFIG_OPTION_GX_VAR_SUPPORT'.
(TT_RunIns): Updated.
2016-07-18 06:23:36 +02:00
Werner Lemberg 8c93013ca3 [truetype] Add support for Apple's
GETDATA[], opcode 0x92

bytecode instruction.  It always returns 17, and we have absolutely
no idea what it is good for...

* src/truetype/ttinterp.c (Pop_Push_Count, opcode_name): Updated.
(Ins_GETDATA): New function.
(TT_RunIns): Add it.
2016-07-17 22:40:31 +02:00
Werner Lemberg e084360961 [truetype] Add bytecode support for GX variation fonts.
This commit implements undocumented (but confirmed) stuff from
Apple's old bytecode engine.

  GETVARIATION[], opcode 0x91
    This opcode pushes normalized variation coordinates for all axes
    onto the stack (in 2.14 format).  Coordinate of first axis gets
    pushed first.

  GETINFO[], selector bit 3
    If GX variation support is enabled, bit 10 of the result is set
    to 1.

* src/truetype/ttinterp.c: Include FT_MULTIPLE_MASTERS_H.
(opcode_name) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Updated.
(Ins_GETINFO) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Handle selector
bit 3, checking support for variation glyph hinting.
(Ins_GETVARIATION) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: New function
to implement opcode 0x91.
(TT_RunIns) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Handle opcode 0x91.
2016-07-16 18:46:28 +02:00
Werner Lemberg 32a320625e [truetype] Fix GETINFO bytecode instruction.
* src/truetype/ttinterp.c (Ins_GETINFO): Fix return value for
stretching information.
2016-07-16 16:39:26 +02:00
Nikolaus Waxweiler 86eb43a994 * src/truetype/ttinterp.c (Ins_MIRP): Fix copy-and-paste error.
Problem reported by Hin-Tak Leung.
2016-07-16 06:37:57 +02:00
Werner Lemberg 474682ff87 * src/truetype/ttinterp.c (TInstruction_Function): Removed, unused. 2016-07-06 08:54:35 +02:00
Nikolaus Waxweiler b459882804 [truetype] Let SHPIX move points in the twilight zone in v40.
* src/truetype/ttinterp.c (Ins_SHPIX): 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 that would glitch severly after calling ALIGNRP after a
blocked SHPIX.
2016-05-31 08:39:52 +02:00
Nikolaus Waxweiler ed1d8983f3 [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
Alexei Podtelezhnikov e85422606d Typos. 2016-04-08 23:21:34 -04:00
Nikolaus Waxweiler 6875093a17 Remove unpatented hinter (1/3).
* src/truetype/ttinterp.c [TT_CONFIG_OPTION_UNPATENTED_HINTING]:
Remove all code related to this macro.
2016-01-28 12:24:36 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg 24a1fcdfce [truetype] Add TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES (#46208).
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES): New configuration macro.

* src/truetype/ttinterp.c (MAX_RUNNABLE_OPCODES): Removed.
(TT_RunIns): Updated.
2015-10-15 21:50:15 +02:00
Werner Lemberg 837ad9d411 * src/truetype/ttinterp.c (TT_RunIns): Fix bytecode stack tracing.
The used indices were off by 1.
2015-10-15 21:15:45 +02:00
Alexei Podtelezhnikov 0963526435 Minor. 2015-08-31 23:14:46 -04:00
Werner Lemberg eb1bba9be4 Fix some clang compiler warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY), src/cff/cf2intrp.c
(cf2_interpT2CharString), src/truetype/ttgload.c
(load_truetype_glyph), src/truetype/ttgxvar.c (tt_handle_deltas),
src/truetype/ttinterp.c (Ins_INSTCTRL): Fix signedness issues.
2015-06-30 09:46:39 +02:00
Alexei Podtelezhnikov 5aaabb44bc [truetype] Speed up bytecode interpreter.
* src/truetype/ttinterp.c (Normalize): Use `FT_Vector_NormLen'.
2015-06-29 22:46:54 -04:00
Werner Lemberg e186230678 * 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
Werner Lemberg 54d042861b [truetype] While tracing opcodes, show code position and stack.
* src/truetype/ttinterp.c: Change all existing TRACE7 calls to
TRACE6.
(opcode_name): Add string lengths.
(TT_RunIns): Implement display of code position and stack.
2015-06-01 12:12:06 +02:00
Werner Lemberg a5e1f6f39b [truetype] Fix commit from 2015-05-22.
* src/truetype/ttgload.c, src/truetype/ttinterp.c: Guard new code
with `TT_CONFIG_OPTION_SUBPIXEL_HINTING'.

Problem reported by Nikolaus Waxweiler <madigens@gmail.com>.
2015-05-24 23:29:23 +02:00
Werner Lemberg 7f0994820b [truetype] Fix return values of GETINFO bytecode instruction.
* src/truetype/ttinterp.h (TT_ExecContextRec): New fields
`vertical_lcd' and `gray_cleartype'.

* src/truetype/ttgload.c (tt_loader_init): Initialize new fields.
Change `symmetrical smoothing' to TRUE, since FreeType produces
exactly this.

* src/truetype/ttinterp.c (Ins_GETINFO): Fix selector/return bit
values for symmetrical smoothing, namely 11/18.
Handle bits for vertical LCD subpixels (8/15) and Gray ClearType
(12/19).
2015-05-24 09:50:24 +02:00
Werner Lemberg bb435da213 [truetype] Minor.
* src/truetype/ttinterp.h (TT_ExecContext):
 s/subpixel/subpixel_hinting.

* src/truetype/ttgload.c, src/truetype/ttgload.h: Updated.
2015-05-23 07:21:25 +02:00
Werner Lemberg c61cad868b [truetype] Support selector index 3 of the INSTCTRL instruction.
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.
2015-05-22 22:02:15 +02:00
Werner Lemberg 790b8dfbff [truetype] Minor. 2015-05-20 12:33:40 +02:00
Alexei Podtelezhnikov 40623a1f3a [truetype] Speed up IUP.
* src/truetype/ttinterp.c (_iup_worker_interpolate): Separate trivial
snapping to the same position from true interpolation.
2015-04-27 22:27:00 -04:00
Werner Lemberg d9c3f15117 [truetype] More signedness fixes.
* include/internal/tttypes.h, src/truetype/ttinterp.h,
src/truetype/ttobjs.h, src/truetype/ttinterp.c,
src/truetype/ttobjs.c: Apply.
2015-02-17 09:21:26 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Werner Lemberg f796cf6c6b Normalize copyright notice format. 2015-01-17 20:11:10 +01:00
Behdad Esfahbod 531d463aed [truetype] Allocate TT_ExecContext in TT_Size instead of TT_Driver.
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.
2015-01-14 17:46:55 +01:00
Werner Lemberg 2af74c9b87 [truetype] Better grouping of functions in `ttinterp.c'.
No code change.
2015-01-11 10:08:09 +01:00
Werner Lemberg 95b5705273 [truetype] Prettyfing.
* src/truetype/ttinterp.c (project, dualproj, fast_project,
fast_dualproj): Rename to...
(PROJECT, DUALPROJ, FAST_PROJECT, FAST_DUALPROJ): ... this.
2015-01-11 09:50:49 +01:00
Werner Lemberg ea173c0493 * src/truetype/ttinterp.c (Ins_JROT, Ins_JROF): Simplify.
Based on a patch from Behdad.
2015-01-11 08:58:54 +01:00
Werner Lemberg 628578c655 * src/truetype/ttinterp.c (Ins_SxVTL): Simplify function call. 2015-01-11 08:53:31 +01:00
Werner Lemberg 08e7909a58 * src/truetype/ttinterp.c (Normalize): Remove unused argument. 2015-01-11 08:45:50 +01:00
Werner Lemberg 4aaadf4610 [truetype] More macro expansions.
* src/truetype/ttinterp.c (FT_UNUSED_EXEC): Remove macro by
expansion.
2015-01-11 08:42:28 +01:00
Werner Lemberg d03a67a12c [truetype] More macro expansions.
* src/truetype/ttinterp.c (INS_ARG): Remove macro by expansion,
adjusting funtion calls where necessary.
(FT_UNUSED_ARG): Removed, no longer needed.
2015-01-11 08:39:14 +01:00
Werner Lemberg 7e1db6d42d Formatting, typos. 2015-01-11 00:56:55 +01:00
Werner Lemberg eb3413684f [truetype] More macro expansions.
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.
2015-01-11 00:23:27 +01:00
Werner Lemberg 01be130d73 [truetype] Remove TT_CONFIG_OPTION_INTERPRETER_SWITCH.
Behdad suggested this code simplification, and nobody objected...

* include/config/ftoption.h, devel/ftoption.h
(TT_CONFIG_OPTION_INTERPRETER_SWITCH): Remove.

* src/truetype/ttinterp.c [TT_CONFIG_OPTION_INTERPRETER_SWITCH]:
Remove related code.
(ARRAY_BOUND_ERROR): Use do-while loop.
2015-01-10 23:05:37 +01:00
Werner Lemberg 6cc1f123aa [truetype] More macro expansions.
* src/truetype/ttinterp.c, src/truetype/ttinterp.h (EXEC_ARG_,
EXEC_ARG): Remove by replacing with expansion.
2015-01-10 21:56:59 +01:00
Werner Lemberg 246814554f [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
Werner Lemberg fae0c81f69 [truetype] More macro expansions.
* src/truetype/ttinterp.c (EXEC_OP_, EXEC_OP): Remove by replacing
with expansion.
2015-01-10 20:23:10 +01:00
Werner Lemberg 5a752f332c [truetype] Remove code for static TrueType interpreter.
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.
2015-01-10 20:08:35 +01:00
Werner Lemberg 1b4d68cf90 * src/truetype/ttinterp.c (CUR): Remove by replacing with expansion.
This starts a series of patches that simplifies the code of the
bytecode interpreter.
2015-01-10 19:56:28 +01:00
Werner Lemberg 0098d5502d Uppercase all hex digits for orthogonality. 2014-12-07 11:03:57 +01:00
Werner Lemberg ed6a9df0f6 Whitespace. 2014-12-06 23:28:58 +01:00
Werner Lemberg f34f192535 * src/*: Add checks for parameters of API functions where missing.
`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'.
2014-11-26 21:59:21 +01:00
Werner Lemberg ef439fd209 [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
Werner Lemberg 706f752b5e * src/truetype/ttinterp.c (Ins_DELTAP): Fix subpixel hinting.
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.
2014-11-03 07:20:57 +01:00
Alexei Podtelezhnikov 118e651b0b [truetype] Clean up bytecode rounding.
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.
2014-10-19 23:31:08 -04:00
Alexei Podtelezhnikov 7e83f06804 [truetype] Limit delta shift range.
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.
2014-10-14 23:03:56 -04:00
Alexei Podtelezhnikov 125c3ca8f0 [truetype] Shortcut ppem calculations for square pixels.
* 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'.
2014-09-02 22:38:59 -04:00
Behdad Esfahbod 1ec98b29ec Don't use `register' keyword. Fixes compiler warnings.
* src/base/ftcalc.c (FT_Add64) [!FT_LONG64]: Do it.
* src/gzip/inftrees.c (huft_build): Ditto.
* src/truetype/ttinterp.c (TT_MulFix14_arm): Ditto.
2014-08-31 08:47:11 +02:00
Alexei Podtelezhnikov a8bc49e141 [truetype] Optimize DELTAP and DELTAC.
* src/truetype/ttinterp.c (Ins_DELTAP, Ins_DELTAC): Move ppem
calculations outside of the loop.
2014-08-24 22:14:01 -04:00
Werner Lemberg 441b3f3898 [truetype] Improve handling of buggy `prep' tables.
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.
2014-07-13 02:28:14 +09:00
Werner Lemberg 6497b9c5a5 Fix compiler warnings.
Reported by Wojciech Mamrak <wmamrak@gmail.com>.

* src/autofit/afglobal.c (af_face_globals_compute_style_coverage),
src/autofit/afmodule.c (af_property_set): Fix `signed' vs.
`unsigned' issues.

* src/autofit/aflatin.c (af_latin_metrics_init_blues): Make compiler
happy.

* src/base/ftlcdfil.c (_ft_lcd_filter_fir): Use only four elements
for `fir'.
Fix `signed' vs. `unsigned' issues.

* src/sfnt/sfobjs.c (WRITE_BYTE): Removed, unused.
(WRITE_USHORT, WRITE_ULONG): Add proper casts.

* src/truetype/ttgload.c (TT_Get_VMetrics): Add proper casts.

* src/truetype/ttinterp.c (Ins_DELTAP): Add proper casts for `B1'
and `B2'.
2014-06-13 09:28:00 +02:00
Sean McBride 7be2a94a50 Fix clang static analyzer and compiler warnings.
* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c
(FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style),
src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c
(cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load),
src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c
(sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next,
tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead
code.

* src/autofit/afmodule.c (af_property_get_face_globals,
af_property_set, af_property_get), src/base/ftbitmap.c
(ft_gray_for_premultiplied_srgb_bgra): Make functions static.

* src/base/ftobjs.c (ft_remove_renderer): Protect against
library == NULL.
(ft_property_do): Make function static.

* src/base/ftrfork.c: Include `ftbase.h'.

* src/sfnt/ttsbit.c (tt_face_load_sbix_image)
[!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c
(T1_Compute_Max_Advance): Avoid compiler warning.

* src/truetype/ttinterp.c (TT_New_Context): Reduce scope of
variable.
2014-02-08 13:55:38 +01:00
Chongyu Zhu 94c669448a [arm] Fix Savannah bug #41138, part 2.
* builds/unix/ftconfig.in (FT_MulFix_arm), include/config/ftconfig.h
(FT_MulFix_arm), src/truetype/ttinterp.c (TT_MulFix14_arm): Fix
preprocessor conditionals for `add.w'.
2014-01-08 08:52:59 +01:00
Werner Lemberg b337fa25cf Fix Savannah bug #40975 (sort of).
* src/truetype/ttinterp.c (Ins_IP): Fix sign typo to make FreeType
behave the same as the Windows TrueType engine for the invalid case.
2013-12-21 19:33:15 +01:00
Infinality 8bb09b0fe4 [truetype] Simplify logic of rendering modes.
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.
2013-12-11 09:01:13 +01:00
Werner Lemberg 7d449436e6 [truetype] Fix GETINFO opcode handling of subpixel hinting bits.
* src/truetype/ttinterp.c (Ins_GETINFO): Don't request bit 6 set to
get info on subpixel hinting.

* docs/CHANGES: Updated.
2013-11-02 11:36:37 +01:00
Werner Lemberg ebf52d6a90 [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
Chongyu Zhu 41632b58ef [arm] Fix thumb2 inline assembly under LLVM.
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.
2013-10-15 11:40:34 +02:00
Werner Lemberg a32682f176 Fix gcc pragmas, part 2.
* 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.
2013-08-06 00:21:46 +02:00
Werner Lemberg 69e524d5fe Fix gcc pragmas.
* src/truetype/ttinterp.c (TT_MulFix14_long_long,
TT_DotFix14_long_long): Older gcc versions don't accept diagnostic
pragmas within a function body.
2013-08-05 23:38:32 +02:00
David Turner f66d48e923 Add assembler code for TT_MulFix14 and TT_DotFix14.
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.
2013-07-16 13:19:32 +02:00
Werner Lemberg 25b7da5348 * 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
Werner Lemberg 99e60d840d Fix Savannah bug #39160.
* src/truetype/ttinterp.c (Ins_SDPVTL): Set projection vector too
for the degenerate case.
2013-06-10 01:44:37 +02:00
Behdad Esfahbod 2d6e1fbce7 Compilation fix.
* src/truetype/ttinterp.c (TT_RunIns)
[!TT_CONFIG_OPTION_SUBPIXEL_HINTING]: Make it work.
2013-05-23 08:01:20 +02:00
Infinality 3c783c1b70 [truetype] Formatting and an additional subpixel tweak. 2013-05-21 21:03:00 -05:00
Infinality 18f35ed15a [truetype] Adjust subpixel zp2 moves and tweak rules. 2013-05-21 20:51:15 -05:00
Infinality 63bfa83257 [truetype] Simplify and improve subpixel function detection.
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.
2013-05-20 07:38:21 +02:00
Werner Lemberg f04951af8d [truetype] Add `interpreter-version' property.
This makes the option TT_CONFIG_OPTION_SUBPIXEL_HINTING controllable
at runtime.

* src/truetype/ttdriver.c: Include FT_TRUETYPE_DRIVER_H.
(tt_property_set, tt_property_get): Fill templates.

* src/truetype/ttobjs.h (TT_DriverRec): Add `interpreter_version'
member.
Remove unused `extension_component' member.

* src/truetype/ttgload.c: Include FT_TRUETYPE_DRIVER_H.
(tt_get_metrics, TT_Hint_Glyph, TT_Process_Simple_Glyph,
compute_glyph_metrics, tt_loader_init): Use `interpreter_version'.

* src/truetype/ttinterp.c: Include FT_TRUETYPE_DRIVER_H.
(SUBPIXEL_HINTING): New macro to check `interpreter_version' flag.
Update all affected functions to use it.
Use TT_INTERPRETER_VERSION_XXX where appropriate.

* src/truetype/ttobjs.c: Include FT_TRUETYPE_DRIVER_H.
(tt_driver_init): Initialize `interpreter_version'.

* src/truetype/ttsubpix.c: Include FT_TRUETYPE_DRIVER_H.
Use TT_INTERPRETER_VERSION_XXX where appropriate.
2013-05-17 13:51:07 +02:00
Werner Lemberg 94152819b0 More fixes for clang's `sanitize' feature.
* src/base/ftcalc.c (FT_DivFix): Use unsigned values for
computations which use the left shift operator and convert to signed
as the last step.
* src/base/fttrigon.c (ft_trig_prenorm, FT_Vector_Rotate,
FT_Vector_Length, FT_Vector_Polarize): Ditto.

* src/cff/cffgload.c (cff_decoder_parse_charstrings): Simplify.
* src/cff/cffload.c (cff_subfont_load): Fix constant.
* src/cff/cffparse.c (cff_parse_integer, cff_parse_real, do_fixed,
cff_parse_fixed_dynamic): Use unsigned values for computations which
use the left shift operator and convert to signed as the last step.

* src/cid/cidload.c (cid_get_offset): Ditto.

* src/psaux/psconv.c (PS_Conv_ToFixed): Ditto.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Ditto.

* src/truetype/ttinterp.c (TT_MulFix14, TT_DotFix14): Ditto.
2013-05-04 16:40:12 +02:00
Werner Lemberg 89f5064765 */*: Use FT_ERR_EQ, FT_ERR_NEQ, and FT_ERR where appropriate.
FT_Err_XXX and friends are no longer directly used in the source
code.
2013-03-14 17:50:49 +01:00
Werner Lemberg e3c9301581 */*: Use FT_Err_Ok only.
This is a purely mechanical conversion.
2013-03-14 11:21:17 +01:00
Werner Lemberg 059bc335ce */*: Use `FT_THROW'.
This is essentially a mechanical conversion, adding inclusion of
`FT_INTERNAL_DEBUG_H' where necessary, and providing the macros for
stand-alone compiling modes of the rasterizer modules.

To convert the remaining occurrences of FT_Err_XXX and friends it is
necessary to rewrite the code.  Note, however, that it doesn't harm
if some cases are not handled since FT_THROW is a no-op.
2013-03-14 10:27:35 +01:00
Werner Lemberg 00dfa3304e [truetype] A better fix for Savannah bug #38211.
* src/truetype/ttinterp.c (Ins_IP): Implement identical behaviour to
MS rasterizer if rp1 == rp2 (confirmed by Greg Hitchcock).
2013-02-05 19:23:16 +01:00
Werner Lemberg 4063320528 [truetype] Fix Savannah bug #38211.
* src/truetype/ttinterp.c (Ins_IP): Make FreeType behave identical
to other interpreters if rp1 == rp2 (which is invalid).
2013-02-01 12:55:44 +01:00
Werner Lemberg 6b9034f0fd Formatting, comment improvements. 2013-01-28 13:56:23 +01:00
Infinality c574d72ca8 [truetype] Minor formatting fix. 2013-01-26 17:40:44 -06:00
Infinality a5fe359596 [truetype] Align more to ClearType whitepaper for sph. 2013-01-26 12:29:52 -06:00
Alexei Podtelezhnikov b6de8e6612 [base, truetype] New internal FT_Hypot function.
* include/freetype/fttrigon.h (FT_Hypot): Declare it.
* src/base/fttrigon.c (FT_Hypot): Define it.
* src/truetype/ttgload.c (TT_Process_Composite_Component): Use it
instead of explicit expressions.
* src/truetype/ttinterp.c (Current_Ratio, Normalize): Use it instead
of TT_VecLen.
(TT_VecLen): Removed.
2013-01-23 23:31:41 -05:00
Alexei Podtelezhnikov 0e0fdc5dc8 [truetype] Improve accuracy of normalization of short vectors.
Unit vector components are stored as 2.14 fixed-point numbers. In
order to calculate all 14 bits accurately, a short vector to be
normalized has to be upscaled to at least 14 bits before its length
is calculated. This has been safe since accurate CORDIC algorithms
were adopted.

* src/truetype/ttinterp.c (Normalize): Scale short vectors by 0x4000.
2013-01-12 23:05:55 -05:00
Alexei Podtelezhnikov 081aba390a [truetype] Kill very old vector normalization hacks.
Back in the days, vector length calculations were not very accurate
and the vector normalization function, Normalize, had to meticulously
correct the errors for long vectors [commit b7ef2b0968]. It was no
longer necessary after accurate CORDIC algorithms were adopted, but
the code remained. It is time to kill it.

* src/truetype/ttinterp.c (Normalize): Remove error compensation.
(TT_VecLen): Remove any mention of old less accurate implementation.
2013-01-12 22:36:37 -05:00
Infinality 94b79e7453 [truetype] Remove unusued code and variables. 2012-12-17 19:17:30 -06:00
Infinality 461cc9365c Merge branch 'master' of ssh://git.sv.nongnu.org/srv/git/freetype/freetype2
Conflicts:
	src/truetype/ttinterp.c
2012-12-16 20:02:42 -06:00
Infinality 71f242c26a [truetype ] Remove unusued code. Add minor fixes. 2012-12-16 19:52:01 -06:00
Alexei Podtelezhnikov e2fa4a6c89 [truetype] Remove dead code. 2012-12-16 20:19:56 -05:00
Alexei Podtelezhnikov 65d6572105 [truetype] Scale F_dot_P down.
The dot product between freeVector and projVector or cosine of
the angle between these FT_F2Dot14 unit vectors used to be scaled up
by 4 and routinely occupied 32 bits in an FT_Long field F_dot_P.
This patch scales the value down by 2^14 instead, which simplifies
its use throughout the bytecode interpreter.

This does not lead to the loss of precision because the lower bits
are unreliable anyway. Consider two unit vectors (1,0) and (.6,.8)
for which the true value of F_dot_P is .6 * 0x40000000 = 0x26666666.
These vectors are stored as (0x4000,0) and (0x2666,0x3333) after
rounding and F_dot_P is assigned 0x26660000. The lower bits were
already lost while rounding the unit vector components.

Besides code simplification, this change can lead to better
performance when FT_MulDiv with the scaled-down F_dot_P is less
likely to use the costly 64-bit path. We are not changing the type
of F_dot_P to FT_F2Dot14 at this point.

* src/truetype/ttinterp.c (Compute_Funcs): Scale F_dot_P down by 14
bits and modify its use accordingly.
(Direct_Move, Direct_Move_Orig, Compute_Point_Displacement): Modify
the use of F_dot_P field.
* src/truetype/ttobjs.c (tt_size_run_fpgm): Change arbitrary
assignment of F_dot_P to its theoretical maximum in case we decide
to scale back its type later.
2012-12-10 06:59:29 -05:00
Alexei Podtelezhnikov 13e87e0426 Formatting. 2012-12-09 19:48:22 -05:00
Alexei Podtelezhnikov cece4d3b5d [truetype] Tweak the previous commit.
* src/truetype/ttinterp.c (Current_Ratio): Put unit vector
components as the second TT_MulFix14 arguments. This is required
on 16-bit systems.
2012-12-06 20:23:38 -05:00
Alexei Podtelezhnikov 5ad05f97b6 [truetype] Microoptimizations in bytecode interpreter.
* src/truetype/ttinterp.c (TT_DivFix14): New macro.
(Normalize): Use it here.
(Current_Ratio): Use TT_MulFix14 instead of FT_MulDiv.
(Ins_SHPIX): Cancel out two TT_MulFix14 calls.
2012-12-06 00:27:20 -05:00
Alexei Podtelezhnikov b50088bd9c [truetype] Cosmetic improvement in bytecode interpreter.
* src/truetype/ttinterp.c: Use explicit calls to FT_MulDiv,
FT_MulFix, and FT_DivFix instead of macros.
2012-12-05 23:05:47 -05:00
Alexei Podtelezhnikov 6a126e14c4 [truetype] Fix formatting and typo. 2012-11-28 23:32:02 -05:00
Alexei Podtelezhnikov 24e897db28 [truetype] Cheaper way to threshold angles between vectors.
* src/truetype/ttinterp.c (Ins_ISECT): Thresholding tangent is a lot
cheaper than thresholding sine.
2012-10-20 22:23:01 -04:00
Werner Lemberg 2df16761c9 [truetype] Fix Savannah bug #37572.
* src/truetype/ttinterp.c (Ins_ISECT): Use angle between vectors to
avoid grazing intersections.  The previous threshold was too coarse,
incorrectly rejecting short but valid vectors.
2012-10-17 11:34:22 +02:00
Werner Lemberg 83c0ebabc2 Fix conditional compilation.
* include/freetype/internal/ftcalc.h (FT_MulDiv_No_Round): Don't
enclose with `TT_USE_BYTECODE_INTERPRETER'; we now need the function
elsewhere also.

* src/autofit/afcjk.h: Use AF_CONFIG_OPTION_CJK.

* src/truetype/ttgload.c (tt_loader_init): Fix compiler warning.

* src/truetype/ttinterp.c (Ins_MSIRP): Fix compiler warning.

* src/truetype/ttinterp.h: Use
TT_CONFIG_OPTION_BYTECODE_INTERPRETER.
2012-06-27 08:16:06 +02:00
Infinality ed6508c41a [truetype] Remove unused rounding functionality. 2012-06-26 17:20:27 -05:00
Infinality 79e36baebb [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
Werner Lemberg f1ec084292 s/maximal/maximum/ everywhere, s/minimal/minimum/ where appropriate. 2012-03-11 13:48:25 +01:00
Werner Lemberg 1054bc298c [truetype] Improve comment. 2012-03-10 09:30:27 +01:00
Werner Lemberg e1899bcf6f [truetype] Fix SSW instruction.
* src/truetype/ttinterp.c (DO_SSW): SSW *does* use font units.  For
verification, it took some time to find a font which actually uses
this instruction.
2012-03-10 09:28:24 +01:00
Werner Lemberg a33c013fe2 [truetype] Fix Savannah bug #35646.
* src/truetype/ttinterp.c (Ins_MIRP): Typo, present since ages.  The
code is now in sync with the other operators (e.g. MSIRP) which
modify twilight points.
2012-03-01 14:04:30 +01:00
Werner Lemberg 5dddcc45a0 [truetype] Fix Savannah bug #35640.
* src/truetype/ttinterp.c (SkipCode, TT_RunIns): Fix boundary check
for NPUSHB and NPUSHW instructions.
2012-03-01 07:52:24 +01:00
Werner Lemberg 96cddb8d1d [truetype] Fix Savannah bug #35601.
* src/truetype/ttinterp.c (Ins_SHZ): Use number of points instead of
last point for loop.
Also remove redundant boundary check.
2012-02-29 17:58:57 +01:00
Werner Lemberg 9eacbb81bd [truetype] Make SHC instruction behave similar to MS rasterizer.
* src/truetype/ttinterp.c (Ins_SHC): Handle virtual contour in
twilight zone.
2012-02-29 14:47:47 +01:00
Werner Lemberg d74285d1dc [truetype] Improve comments. 2012-02-29 13:59:49 +01:00
Werner Lemberg 22fff25385 Whitespace. 2012-02-26 08:47:20 +01:00
Werner Lemberg b4e06818ed [truetype] Fix Savannah bug #35466.
Jump instructions are now bound to the current function.  The MS
Windows rasterizer behaves the same, as confirmed by Greg Hitchcock.

* src/truetype/ttinterp.h (TT_CallRec): Add `Cur_End' element.
* src/truetype/ttobjs.h (TT_DefRecord): Add `end' element.

* src/truetype/ttinterp.c (DO_JROT, DO_JMPR, DO_JROF): Check upper
bound of jump address.
(Ins_FDEF, Ins_CALL, Ins_LOOPCALL, Ins_UNKNOWN, TT_RunIns): Updated.
2012-02-11 20:56:10 +01:00
suzuki toshiya 1749d8bc6a Remove trailing spaces. 2012-01-17 02:00:24 +09:00
Tobias Ringström 21472de11d [truetype] Fix IP instruction if x_ppem != y_ppem.
* src/truetype/ttinterp.c (Ins_IP): Scale `orus' coordinates
properly.
2012-01-04 18:27:16 +01:00
Werner Lemberg f4ec60fdb8 [truetype] Fix MD instruction for twilight zone.
* src/truetype/ttinterp.c (Ins_MD): Without this fix, the MD
instruction applied to original coordinates of twilight points
always returns zero.
2011-10-25 20:25:32 +02:00
Werner Lemberg bad0160c16 [truetype] Fix degenerate case in S{P,F,DP}VTL opcodes.
* src/truetype/ttinterp.c (Ins_SxVTL): Handle p1 == p2 specially.
(Ins_SDPVTL): Handle v1 == v2 specially.
2011-08-12 19:50:13 +02:00
Werner Lemberg 22e44e067b [truetype] Remove incorrect comments. 2011-08-05 09:57:17 +02:00
Werner Lemberg f2573a0611 [truetype] Fix some comments in the bytecode interpreter.
Thanks to Greg Hitchcock!
2011-08-05 09:07:21 +02:00
Werner Lemberg f1a981b5ce [truetype] Protect jump instructions against endless loops.
* src/truetype/interp.c (DO_JROT, DO_JMPR, DO_JROF): Exit with error
if offset is zero.
2011-01-31 22:26:53 +01:00
Werner Lemberg d6a213f8ea [truetype] Improve handling of invalid references.
* src/truetype/interp.c: Set even more TT_Err_Invalid_Reference
error codes only if pedantic hinting is active.  At the same time,
try to provide sane values which hopefully allow useful
continuation.  Exception to this is CALL and LOOPCALL – due to
possible stack corruption it is necessary to bail out.
2011-01-31 18:51:07 +01:00
Werner Lemberg 96f0456483 [truetype] Improve handling of stack underflow.
* src/truetype/ttinterp.c (TT_RunIns, Ins_FLIPPT, Ins_DELTAP,
Ins_DELTAC): Exit with error only if `pedantic_hinting' is set.
Otherwise, try to do something sane.
2011-01-31 10:24:32 +01:00
Werner Lemberg 0682251e9f * src/sfnt/ttmtx.c (tt_face_load_hmtx): Fix tracing message. 2011-01-30 16:38:09 +01:00
LIU Sun-Liang c61b3596d4 [truetype]: Fix behaviour of MIAP for invalid arguments.
* src/truetype/ttinterp.c (Ins_MIAP): Set reference points even in
case of error.
2011-01-30 16:29:45 +01:00
Werner Lemberg dcdb3167dc [truetype] Fix handling of MIRP instruction.
Thanks to Greg Hitchcock who explained the issue.

* src/truetype/ttinterp.c (Ins_MIRP): Replace a `>=' operator with
`>' since the description in the specification is incorrect.
This fixes, for example, glyph `two' in font `Helvetica Neue LT Com
65 medium' at 15ppem.
2011-01-18 07:35:26 +01:00
Johnson Y. Yan 9073e7ceb6 [truetype] Better multi-threading support.
* src/truetype/ttinterp.c (TT_Load_Context): Reset glyph zone
references.
2010-11-26 11:58:08 +01:00
suzuki toshiya 46c371c2c7 Replace "%lx" for memory address by "%p", LLP64 platforms.
On LLP64 platforms (e.g. Win64), long (32-bit) cannot cover
the memory address (64-bit).  Also the casts from the pointer
type to long int should be removed to preserve the address
correctly.

* src/raster/ftraster.c (New_Profile): Replace "%lx" by "%p".
(End_Profile) Ditto.
* src/truetype/ttinterp.c (Init_Context): Ditto.
2010-10-25 00:14:13 +09:00
Werner Lemberg 0edf0986f3 [truetype] Improve error handling of `SHZ' bytecode instruction.
Problem reported by Chris Evans <scarybeasts@gmail.com>.

* src/truetype/ttinterp.c (Ins_SHZ): Check `last_point'.
2010-10-06 11:52:27 +02:00
suzuki toshiya 5edc2f339a Fix Savannah bug #31040.
* src/truetype/ttinterp.c (free_buffer_in_size): Remove.
(TT_RunIns): Updated.
2010-10-01 08:15:55 +02:00
suzuki toshiya db053ec9a5 [truetype] Don't duplicate size->twilight structure to be freed.
* src/truetype/ttinterp.c (free_buffer_in_size): Don't duplicate
FT_GlyphZoneRec size->twilight to be freed.  If duplicated,
FT_FREE() erases the duplicated pointers only and leave original
pointers.  They can cause the double-free crash when the burst
errors occur in TrueType interpreter and free_buffer_in_size()
is invoked repeatedly.  See Savannah bug #31040 for detail.
2010-09-17 23:20:00 +09:00
Werner Lemberg afd89d309d Make bytecode debugging with FontForge work again.
* src/truetype/ttinterp.c (TT_RunIns): Don't call
`free_buffer_in_size' in case of error if a debugger is active.
2010-09-15 13:02:35 +02:00
Werner Lemberg 6abb9232b6 Improve tracing messages.
* src/truetype/ttinterp.c (TT_RunIns): Improve wording of tracing
message.
* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Add
tracing message.
* src/truetype/ttgload.c (tt_loader_init): Add tracing message.
* src/cache/ftcsbits.c (ftc_snode_load): Emit tracing message if
glyph doesn't fit into a small bitmap container.
2010-09-14 09:02:10 +02:00
Werner Lemberg 5220ef58c5 Fix minor issues reported by <muktha.narayan@wipro.com>.
* src/autofit/aflatin.c (af_latin_compute_stem_width): Remove
redundant conditional check.
* src/base/ftsynth.c (FT_GlyphSlot_Embolden): Ditto.
* src/cff/cffload.c (cff_encoding_load): Remove conditional check
which always evaluates to `true'.
* src/pshinter/pshalgo.c (ps_glyph_interpolate_strong_points):
Ditto.
* src/truetype/ttinterp.c (Ins_IUP): Ditto.
* src/cid/cidgload.c (cid_slot_load_glyph): Don't check for NULL if
value is already dereferenced.
* src/winfonts/winfnt.c (FNT_Load_Glyph): Fix check of `face'.
2010-09-13 07:32:22 +02:00
suzuki toshiya 0eb657b0aa [truetype] Decrease the trace level catching the interpreter error.
* src/truetype/ttinterp.c (TT_RunIns): Decrease the trace level
showing the error when the interpreter returns with an error,
from FT_TRACE7() to FT_TRACE1().
2010-08-31 13:29:05 +09:00
suzuki toshiya 29e044a4af [truetype] Prevent bytecode reuse after the interpretation error.
* src/truetype/ttinterp.c (free_buffer_in_size): New function to
free the buffer allocated during the interpretation of this glyph.
(TT_RunIns): Unset FT_Face->size->{cvt_ready,bytecode_ready} if
an error occurs in the bytecode interpretation.  The interpretation
of invalid bytecode may break the function definitions and referring
them in later interpretation is danger.  By unsetting these flags,
`fpgm' and `prep' tables are executed again in next interpretation.

Fix Savannah bug #30798, reported by Robert Swiecki.
2010-08-31 01:23:30 +09:00
Werner Lemberg 346f1867fd Fix Savannah bug #30657.
* src/truetype/ttinterp.c (BOUNDSL): New macro.
Change `BOUNDS' to `BOUNDSL' where appropriate.

* src/truetype/ttinterp.h (TT_ExecContextRec): Fix type of
`cvtSize'.
2010-08-06 00:47:57 +02:00
Werner Lemberg 888cd1843e Fix Savannah bug #30361.
* src/truetype/ttinterp.c (Ins_IUP): Fix bounds check.
2010-07-08 07:29:42 +02:00
Werner Lemberg a2d225e322 [truetype] Protect against code range underflow.
* src/truetype/ttinterp.c (DO_JROT, DO_JMPR, DO_JROF): Don't allow
negative IP values.
2010-07-01 11:37:09 +02:00
Werner Lemberg 462ddb4072 [truetype] Add rudimentary tracing for bytecode instructions.
* src/truetype/ttinterp.c (opcode_name) [FT_DEBUG_LEVEL_TRACE]: New
array.
(TT_RunIns): Trace opcodes.
2010-07-01 11:28:43 +02:00
Werner Lemberg 370aea802c Formatting. 2010-06-08 08:37:11 +02:00
Werner Lemberg 6da023d1ff TrueType: Make FreeType ignore maxSizeOfInstructions in `maxp'.
Acroread does the same.

* src/truetype/ttgload.c (TT_Process_Composite_Glyph): Call
`Update_Max' to adjust size of instructions array if necessary and
add a rough safety check.

(load_truetype_glyph): Save `loader->byte_len' before recursive
call.

* src/truetype/ttinterp.h, src/truetype/ttinterp.c (Update_Max):
Declare it as FT_LOCAL.
2010-05-20 15:38:00 +02:00
suzuki toshiya a115142057 truetype: Check invalid function number in IDEF instruction. 2009-08-01 00:32:18 +09:00
suzuki toshiya d1c23082b6 truetype: Check invalid function number in FDEF instruction. 2009-08-01 00:32:17 +09:00
suzuki toshiya 6dc27526a9 truetype: Cast the numerical operands to 32-bit for LP64 systems. 2009-08-01 00:32:15 +09:00
suzuki toshiya 3b56c4d390 truetype: Cast the project vector to 32-bit for LP64 system. 2009-08-01 00:32:15 +09:00
Werner Lemberg c6788a389d Fix some potential out-of-memory crashes.
* src/base/ftobjs.c (ft_glyphslot_done): Check `slot->internal'.
* src/base/ftstream.c (FT_Stream_ReleaseFrame): Check `stream'.
* src/truetype/ttinterp.c (TT_New_Context): Avoid double-free of
`exec' in case of failure.
2009-06-07 13:09:21 +02:00
Werner Lemberg 1e5e7aa073 Fix SCANCTRL handling in TTFs.
Problem reported by Alexey Kryukov <anagnost@yandex.ru>.

* src/truetype/ttinterp.c (Ins_SCANCTRL): Fix threshold handling.
2009-01-25 16:27:04 +00:00
Werner Lemberg 1a5d561dce * src/autofit/afcjk.c, src/base/ftoutln.c, src/base/ftrfork.c,
src/bdf/bdfdrivr.c, src/gxvalid/gxvmorx.c, src/otvalid/otvmath.c,
src/pcf/pcfdrivr.c, src/psnames/pstables.h, src/smooth/ftgrays.c,
src/tools/glnames.py, src/truetype/ttinterp.c, src/type1/t1load.c,
src/type42/t42objs.c, src/winfonts/winfnt.c: Fix compiler warnings
(Atari PureC).
2008-11-29 22:50:24 +00:00
Werner Lemberg 105721a5a6 * src/truetype/ttinterp.c (tt_default_graphics_state): The default
value for `scan_type' is zero, as confirmed by Greg Hitchcock from
Microsoft.  Problem reported by Michal Nowakowski
<miszka@limes.com.pl>.
2008-11-15 10:35:51 +00:00
Werner Lemberg ce8853af81 * src/truetype/ttinterp. (Ins_SCANTYPE): Don't check rendering mode.
* src/raster/ftraster.c (Render_Glyph, Render_Gray_Glyph,
Draw_Sweep): No-dropout mode is value 2, not value 0.
(Draw_Sweep): Really skip dropout handling for no-dropout mode.
2008-06-24 11:19:03 +00:00
Werner Lemberg 5df5dbb722 Enable access to the various dropout rules of the B&W rasterizer.
Pass dropout rules from the TT bytecode interpreter to the
rasterizer; temporarily this is enabled only if
`USE_SCAN_CONVERSION_RULES' is defined.

* include/freetype/ftimage.h (FT_OUTLINE_SMART_DROPOUTS,
FT_OUTLINE_EXCLUDE_STUBS): New flags for for FT_Outline.

* src/raster/ftraster.c (Vertical_Sweep_Drop, Horizontal_Sweep_Drop,
Horizontal_Gray_Sweep_Drop): Use same mode numbers as given in the
OpenType specification.
Fix mode 4 computation.
(Render_Glyph, Render_Gray_Glyph): Handle new outline flags.

* src/truetype/ttgload.c (TT_Load_Glyph)
[USE_SCAN_CONVERSION_RULES]: Convert scan conversion mode to
FT_OUTLINE_XXX flags.

* src/truetype/ttinterp.c (Ins_SCANCTRL): Enable ppem check.
2008-06-22 13:40:08 +00:00
Werner Lemberg 7cb9ec0f1c * src/type1/t1parse.h (T1_ParserRec): Make `base_len' and
`private_len' unsigned.

* src/type1/t1parse.c (read_pfb_tag): Make `asize' unsigned and read
it as such.
(T1_New_Parser, T1_Get_Private_Dict): Make `size' unsigned.


* src/base/ftstream.c (FT_Stream_Skip): Reject negative values.


* src/type1/t1load.c (parse_blend_design_positions): Check `n_axis'
for sane value.
Fix typo.


* src/psaux/psobjs.c (ps_table_add): Check `idx' correctly.


* src/truetype/ttinterp (Ins_SHC): Use BOUNDS() to check
`last_point'.


* src/sfnt/ttload.c (tt_face_load_max_profile): Limit
`maxTwilightPoints'.
2008-06-09 20:49:29 +00:00