Commit Graph

179 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov 61d50756b6 * src/truetype/ttgxvar.c (ft_var_get_item_delta): Fixed logic.
Reported and tested by Behdad.
2018-11-02 20:42:25 -04:00
Alexei Podtelezhnikov 1e4496c54c [truetype] Speed up variation IUP.
* src/truetype/ttgxvar.c (tt_delta_interpolate): Separate trivial
snapping to the same position from true interpolation.
2018-10-31 23:17:33 -04:00
Alexei Podtelezhnikov 300da33d61 * src/truetype/ttgxvar.c (ft_var_get_item_delta): Optimized. 2018-10-31 21:55:40 -04:00
Werner Lemberg 10e54d04b9 [truetype] Some fixes for VF checks.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10317

* src/truetype/ttgxvar.c (ft_var_load_gvar): Properly exit memory
frame if we have invalid glyph variation data offsets.
(tt_face_vary_cvt): Protect against missing `tuplecoords' array.
Fix typo.
2018-09-13 21:47:35 +02:00
Werner Lemberg 65681e6dc1 [truetype] Improve VF check.
Triggered by

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10255

* src/truetype/ttgxvar.c (ft_var_load_gvar): Use better limit check
for `tupleCount'.
2018-09-12 07:40:49 +02:00
Werner Lemberg 53c5e4bd87 * src/truetype/ttgxvar.c (ft_var_load_gvar): Check `glyphoffsets'. 2018-09-12 07:27:30 +02:00
Werner Lemberg a0dd16fb3d Don't use `trace_' prefix for FT_COMPONENT arguments.
* include/freetype/internal/ftdebug.h (FT_TRACE_COMP,
FT_TRACE_COMP_): New auxiliary macros to add `trace_' prefix.
(FT_TRACE): Use `FT_TRACE_COMP'.

*/* (FT_COMPONENT): Updated.
2018-08-15 18:13:17 +02:00
Werner Lemberg c9edca8ee9 [truetype] Make `TT_Set_MM_Blend' idempotent (#54388).
* src/truetype/ttgxvar.c (tt_set_mm_blend): Correctly set
`face->doblend' if the current call to the function yields the same
blend coordinates as the previous call.
2018-07-27 10:44:01 +02:00
Werner Lemberg 839cb404cf * src/truetype/ttgxvar.c (tt_set_mm_blend): Fix off-by-one error.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9412
2018-07-16 05:47:27 +02:00
Werner Lemberg 6ceeb87f5d Fix more 32bit issues (#54208)
* src/cff/cffload.c (cff_blend_build_vector): Convert assertion into
run-time error.

* src/truetype/ttgxvar.c (ft_var_to_normalized): Protect against
numeric overflow.
2018-07-05 22:31:10 +02:00
Werner Lemberg 207ca38fb5 [truetype] Fix memory leak.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Add initializers.
Fix typo in `goto' destination.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9071
2018-06-25 18:50:00 +02:00
Werner Lemberg 589d1f0899 * src/truetype/ttgxvar.c (tt_face_vary_cvt): Add initializers.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9070
2018-06-25 18:38:04 +02:00
Werner Lemberg a632fb547e [truetype] Increase precision while applying VF deltas.
It turned out that we incorrectly round CVT and glyph point deltas
before accumulation, leading to severe positioning errors if there
are many delta values to sum up.

Problem reported by Akiem Helmling <akiem@underware.nl> and analyzed
by Behdad.

* src/truetype/ttgxvar.c (ft_var_readpackeddelta): Return deltas in
16.16 format.
(tt_face_var_cvt): Collect deltas in `cvt_deltas', which is a 16.16
format array, and add the accumulated values to the CVT at the end
of the function.
(TT_Vary_Apply_Glyph_Deltas): Store data in `points_org' and
`points_out' in 16.16 format.
Collect deltas in `point_deltas_x' and `point_deltas_y', which are
16.16 format arrays, and add the accumulated values to the glyph
coordinates at the end of the function.
2018-06-24 15:22:10 +02:00
Werner Lemberg 9ac9060df0 [GSoC] src/*.*: Convert block comments to `light' style.
This monster commit was created by applying Nikhil's scripts
`docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.

No change in functionality, of course.

I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
2018-06-03 09:08:41 +02:00
Werner Lemberg 597cb3b442 [truetype] Fix memory leak (only if tracing is on).
* src/truetype/ttgxvar.c (TT_Get_MM_Var) [FT_DEBUG_LEVEL_TRACE}: Fix
it.
2018-03-30 13:46:03 +02:00
Werner Lemberg 036bdc0c9a [truetype] Minor typo. 2018-01-28 00:05:46 +01:00
Werner Lemberg 68dddcdcbe [truetype] Better protection against invalid VF data.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5739

Bug introduced in commit 08cd62deed.

* src/truetype/ttgxvar.c (TT_Set_Var_Design): Always initialize
`normalizedcoords'.
2018-01-27 23:59:30 +01:00
Werner Lemberg f438e06972 * src/truetype/ttgxvar.c (tt_set_mm_blend): Minor. 2018-01-27 14:39:15 +01:00
Werner Lemberg ef48653023 [truetype] Better trace VF instances.
* src/truetype/ttgxvar.c (ft_var_to_normalized): Don't emit number
of coordinates.
(TT_Get_MM_Var): Trace instance indices names.
(TT_Set_Var_Design): Updated.
2018-01-27 13:58:02 +01:00
Werner Lemberg 50f693a78b [truetype] Beautify tracing of VF axis records.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): Show axis records in a
table-like manner.
2018-01-27 10:15:58 +01:00
Werner Lemberg 994eb2b349 [truetype] Fix multiple calls of `FT_Get_MM_Var' (#52955).
* src/truetype/ttgxvar.c (TT_Get_MM_Var): Set
`face->blend->num_axis' in case we have to initialize the
`face->blend'.
2018-01-26 23:17:43 +01:00
Werner Lemberg 55d6abea5d * src/truetype/ttgxvar.c (ft_var_to_design): Remove dead code.
This is a better fix than the previous commit, which is now
reverted.
2018-01-03 19:01:15 +01:00
Werner Lemberg ecfdfd4498 [truetype] Make blend/design coordinate round-tripping work.
Behdad reported that setting blend coordinates, then getting design
coordinates did incorrectly return the default instance's
coordinates.

* src/truetype/ttgxvar.c (tt_set_mm_blend): Fix it.
2018-01-03 00:20:11 +01:00
Werner Lemberg 0a0c22569d Update copyright year. 2018-01-02 09:33:57 +01:00
Werner Lemberg 08cd62deed Speed up FT_Set_Var_{Design,Blend}_Coordinates if curr == new.
We exit early if the current design or blend coordinates are
identical to the new ones.

* src/truetype/ttgxvar.c (tt_set_mm_blend, TT_Set_Var_Design):
Implement it, returning internal error code -1 if there will be no
variation change.

* src/type1/t1load.c (t1_set_mm_blend): Ditto.

* src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates): Updated.
2017-12-20 22:06:19 +01:00
Werner Lemberg 0579d545af Update incorrect ChangeLog entry. 2017-12-18 23:45:58 +01:00
Matthias Clasen bdab6578af [truetype] Minor code beautification.
* src/truetype/ttgxvar.c (ft_var_to_normalized): Trace number of
design coordinates.
Simplify code.
2017-12-18 20:45:17 +01:00
Werner Lemberg 2fe272aca6 * src/truetype/ttgxvar.c (tt_face_vary_cvt): Add size guard (#52688). 2017-12-18 19:43:18 +01:00
Werner Lemberg e7935f2910 [truetype] Don't apply HVAR and VVAR deltas twice (#52683).
* src/truetype/ttgload.c (TT_Process_Simple_Glyph): Always adjust
`pp1' to `pp4', except if we have an HVAR and/or VVAR table.

* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Handle
alternative code branch identically w.r.t. presence of an HVAR
and/or VVAR table.
2017-12-18 07:29:57 +01:00
Jonathan Kew 361af72eea [truetype] Correctly handle variation font phantom points (#52683).
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Fix phantom
point indices.
2017-12-18 07:28:31 +01:00
Werner Lemberg 71fecc539e Improve tracing messages by using singular and plural forms.
* src/*/*.c: Implement it.
2017-12-05 12:06:29 +01:00
Werner Lemberg 337e49cfe2 [truetype] Allow shared points in `cvar' table (#52532).
* src/truetype/ttgxvar.c (tt_face_vary_cvt): Implement it by copying
and adjusting the corresponding code from
`TT_Vary_Apply_Glyph_Deltas'.
2017-12-04 12:36:07 +01:00
Werner Lemberg f89c67f043 [cff, truetype] Adjust behaviour of named instances.
This commit completely separates the interaction between named
instances and variation functions.  In particular, resetting the
variation returns to the current named instance (if set) and not to
the base font.

As a side effect, variation functions no longer change the named
instance index.

* src/cff/cffobjs.c (cff_face_init): Use MM service's `set_instance'
function.
Also apply `MVAR' table to named instances.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Add cast.
(tt_set_mm_blend): No longer check whether requested variation
coincides with a named instance.
(TT_Set_Var_Design): Use current named instance for default
coordinates.
* src/truetype/ttobjs.c (tt_face_init): Use `TT_Set_Named_Instance'.
2017-10-07 13:10:53 +02:00
Werner Lemberg e9ef538a4f Make `FT_Set_Named_Instance' work.
* src/cff/cffdrivr.c (cff_set_instance): New function.
(cff_service_multi_masters): Register it.

* src/truetype/ttgxvar.c (TT_Set_Named_Instance): New function.
* src/truetype/ttgxvar.h: Updated.
* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Register
it.

* src/type1/t1load.c (T1_Reset_MM_Blend): New function.
* src/type1/t1load.h: Updated.
* src/type1/t1driver.c (t1_service_multi_masters): Register it.
2017-10-07 12:57:11 +02:00
Werner Lemberg 8c92f7622c Make `FT_FACE_FLAG_VARIATION' work.
* include/freetype/internal/tttypes.h (TT_Face): Remove
`is_default_instance'; this can be replaced with a combination of
`FT_IS_VARIATION' and `FT_IS_INSTANCE'.

* src/cff/cffdrivr.c (cff_get_advances): Updated.

* src/sfnt/sfdriver.c (sfnt_get_ps_name), src/sfnt/sfobjs.c
(sfnt_init_face): Updated.

* src/truetype/ttdriver.c (tt_get_advances), src/truetype/ttgload.c
(TT_Process_Simple_Glyph, load_truetype_glyph, IS_DEFAULT_INSTANCE),
src/truetype/ttgxvar.c (tt_set_mm_blend): Updated.
* src/truetype/ttgxvar.c (TT_Set_MM_Blend, TT_Set_Var_Design):
Handle `FT_FACE_FLAG_VARIATION'.

* src/type1/t1load.c (T1_Set_MM_Blend, T1_Set_MM_Design): Handle
`FT_FACE_FLAG_VARIATION'.
2017-10-07 12:12:49 +02:00
Werner Lemberg b19cdc9c81 [truetype] Fix `mmvar' array pointers, part 2.
The previous commit was incomplete.

* src/truetype/ttgxvar.c: Properly initialize sub-array offsets for
`master' also.
2017-09-21 11:02:35 +02:00
Werner Lemberg 3b3cb32dd2 [truetype] Fix `mmvar' array pointers.
Without this change, clang's AddressSanitizer reports many runtime
errors due to misaligned addresses.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Use multiples of pointer
size for sub-array offsets into `mmvar'.
2017-09-21 09:03:20 +02:00
Werner Lemberg f43b3094ef [base, truetype] New function `FT_Get_Var_Axis_Flags'.
The reserved `flags' field got a value in OpenType version 1.8.2;
unfortunately, the public `FT_Var_Axis' structure misses the
corresponding element.  Since we can't add a new field, we add an
access function.

* src/base/ftmm.c (FT_Get_Var_Axis_Flags): New function.

* include/freetype/ftmm.h (FT_VAR_AXIS_FLAG_HIDDEN): New macro.
Updated.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Increase allocated memory
of `mmvar' to hold axis flags.
Fill the axis flags array.

* docs/CHANGES: Updated.
2017-08-05 18:22:17 +02:00
Werner Lemberg 7e50824288 * src/truetype/ttgxvar.c (TT_Get_MM_Var): Fix thinko. 2017-08-01 12:44:35 +02:00
Behdad Esfahbod 55bbb98f5c [truetype] Fix loading of named instances.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): Preserve file position
while loading the `avar' table.
2017-08-01 09:17:02 +02:00
Werner Lemberg 4261e497d8 * src/truetype/ttgxvar.c (FT_Stream_SeekSet): Fix warning (#51395). 2017-07-05 23:00:23 +02:00
Werner Lemberg 1c85479d2d [truetype] Prevent address overflow (#51365).
* src/truetype/ttgxvar.c (FT_Stream_SeekSet): Add guard.
2017-07-04 08:08:54 +02:00
Werner Lemberg 5f2a72cbc7 [truetype] Fix TT_Set_Var_Design.
Reported by Nikolaus Waxweiler <madigens@gmail.com>.

* src/truetype/ttgxvar.c (TT_Set_Var_Design): Correctly handle the
case where we have less input coordinates than axes.
2017-06-10 11:29:24 +02:00
Werner Lemberg a9331c0f4d [truetype] Fix handling of design coordinates (#51127).
* src/truetype/ttgxvar.c (tt_set_mm_blend): Compute all design
coordinates if we have to create the `blends->coord' array.
(TT_Get_MM_Blend, TT_Get_Var_Design): Select default instance
coordinates if no instance is selected yet.
2017-05-27 15:50:25 +02:00
Behdad Esfahbod 60bf264ee2 [truetype] Make `IUP' gvar deltas do the same as Apple (#50832).
When points are not touched by gvar interpolation deltas, FreeType
gave a slightly different result than Apple's CoreText.

The OpenType working group will update the specification to document
the following behaviour: If the two points with deltas to the `left'
and `right' of the untouched point have the same coordinate, then
the inferred delta for the untouched point should be zero.

* src/truetype/ttgxvar.c (tt_delta_interpolate): Implement new
behaviour.
2017-05-02 14:38:54 +02:00
Werner Lemberg da38be831d [truetype] Fix HVAR and VVAR handling (#50678).
* src/truetype/ttgxvar.c (tt_hvadvance_adjust): Handle
glyph indices larger than `mapCount' as described in the
specification.
2017-03-30 13:24:03 +02:00
Werner Lemberg 1ede3674cb [truetype] Fix thinko related to PS name of default named instance.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `strid' and `psid' are
name ID values, not indices into the array of name entries.
2017-03-30 00:26:31 +02:00
Werner Lemberg 9931175dcc 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
Werner Lemberg d9ff6f20ad * src/truetype/ttgxvar.c (tt_done_blend): Free `vvar_table'.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=883
2017-03-16 20:20:51 +01:00
Werner Lemberg 981c23b75e Remove clang compiler warnings (#50548).
* include/freetype/internal/tttypes.h (TT_FaceRec): Make
`var_postscript_prefix_len' unsigned.

* src/autofit/afwarp.c (af_warper_compute_line_best): Remove
redundant assignment.

* src/cff/cffload.c (cff_subfont_load): Add casts.

* src/cff/cffparse.c (cff_parse_blend): Remove redundant assignment.

* src/sfnt/sfdriver.c (fmix32, murmur_hash_3_128): Add `static'
keyword.
Add casts.
(fixed2float): Add cast.
(sfnt_get_var_ps_name): Make `p' always initialized.
Add casts.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Add casts.
2017-03-15 11:35:26 +01:00