Commit Graph

1147 Commits

Author SHA1 Message Date
Werner Lemberg 029c9b2391 [truetype] Round offsets of glyph components only if hinting is on.
* src/truetype/ttgload.c (TT_Process_Composite_Component): Implement
it.
2018-01-03 19:05:20 +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 068a7a03aa * src/*/*: Only use `ft_' and `FT_' variants of stdc library stuff. 2017-12-18 20:34:05 +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 d062c54ce7 [truetype] Fix previous commit.
* src/truetype/ttgload.c (TT_Process_Simple_Glyph): Correctly handle
unhinted phantom points, which must be properly scaled.
2017-12-18 09:41:17 +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 98ba0c4a37 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:41:49 +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 c18c391b68 [truetype] Improving tracing of composite glyphs.
* src/truetype/ttgload.c (TT_Load_Composite_Glyph)
[FT_DEBUG_LEVEL_TRACE]: Show composite glyph information.
2017-11-28 12:43:45 +01:00
Tor Andersson 2f1863cfb7 Silence unused function warnings.
Some static function declarations cause unused function warnings if
certain config options are turned off via `ftoption.h'.

* src/base/ftbase.h, src/base/ftrfork.c, src/sfnt/ttbdf.h,
src/truetype/ttgxvar.h: Add #ifdef guards around these sections.
2017-11-23 20:40:52 +01:00
suzuki toshiya 77b34e01ed [truetype] Add more tricky fonts.
See the report by Yang Yinsen.
https://lists.gnu.org/archive/html/freetype-devel/2017-11/msg00000.html

* src/truetype/ttobjs.c (trick_names): Add `DFGothic-EB',
`DFGyoSho-Lt', `DFHSGothic-W5', `DFHSMincho-W3' and `DFHSMincho-W7'.
(tt_check_trickyness_sfnt_ids): Add checksums for DFGothic-EB,
DFGyoSho-Lt, DFHSGothic-W5, DFHSMincho-W3 and DFHSMincho-W7.  Also
add checksums for DLCLiShu and DLCHayBold which their family names
were already listed but their checksums were previously unknown.
2017-11-03 16:14:27 +09: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 e23fe2adbc Add framework for setting named instance in MM service.
* include/freetype/internal/services/svmm.h (FT_Set_Instance_Func):
New function typedef.
(MultiMasters): Add `set_instance' member.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.

* src/cff/cffdrivr.c (cff_service_multi_masters),
src/truetype/ttdriver (tt_service_gx_multi_masters),
src/type1/t1driver.c (t1_service_multi_masters): Updated.
2017-10-07 11:25:04 +02:00
Ben Wagner c06b9cf56d [truetype] Really, really fix #52082.
* src/truetype/ttinterp.c (Ins_MDRP): Correct conditional.
2017-09-28 19:08:38 +02:00
Ben Wagner 63be40bccf [truetype] Really fix #52082.
* src/truetype/ttinterp.c (Ins_MDRP): Correct conditional.
2017-09-23 00:44:59 +02:00
Werner Lemberg 6d04bd991b [truetype] Integer overflow (#52082).
* src/truetype/ttinterp.c (Ins_MDRP): Avoid FT_ABS.
2017-09-21 21:22:51 +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 eaa9adf325 [truetype] Integer overflows.
Changes triggered by

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

* src/truetype/ttinterp.c (Ins_SHPIX, Ins_DELTAP): Use NEG_LONG.
(Ins_MIAP): Use SUB_LONG.
2017-09-20 08:00:05 +02:00
Werner Lemberg 39ce3ac499 * Version 2.8.1 released.
=========================

Tag sources with `VER-2-8-1'.

* docs/VERSION.TXT: Add entry for version 2.8.1.
* docs/CHANGES: Updated.

* 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.8/2.8.1/, s/28/281/.

* include/freetype/freetype.h (FREETYPE_PATCH): Set to 1.

* builds/unix/configure.raw (version_info): Set to 21:0:15.
* CMakeLists.txt (VERSION_PATCH): Set to 1.
2017-09-16 19:08:17 +02:00
suzuki toshiya 5c4e40d7fd [sfnt, truetype] Register the tags for marginal fonts.
The first 32bit of standard TrueType variants is 0x00010000,
`OTTO', `ttcf', `true' or `typ1'.  2 marginal dfonts on legacy Mac
OS X, Keyboard.dfont and LastResort.dfont, have the sfnt resources
starting 0xA5 followed by `kbd' or `lst'.  Considering the following
data could be parsed as conventional TrueType fonts, the header
checking is updated to allow these tags.  It seems that recent Mac
OS X has already switched to normal TTF for these fonts.

See the discussion at
http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3931.0

* include/freetype/tttags.h (TTAG_0xA5kbd, TTAG_0xA5lst): New header
tags for Keyboard.dfont and LastResort.dfont.
* src/sfnt/sfobjs.c (sfnt_open_font): Accept the sfnt resource
starts with TTAG_0xA5kbd or TTAG_0xA5lst.
* src/truetype/ttobjs.c (tt_face_init): Accept the face with the
format tag is TTAG_0xA5kbd or TTAG_0xA5lst.
2017-09-09 01:03:26 +09:00
Werner Lemberg 0aca17cf53 [truetype] Integer overflow.
Changes triggered by

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

* src/truetype/ttinterp.c (Ins_MDRP, Ins_MIRP, Ins_ALIGNPTS): Use
NEG_LONG.
2017-08-22 08:25:14 +02:00
Werner Lemberg b45043c440 [sfnt, truetype] Improve handling of missing sbits.
Requested by Behdad.

Modern bitmap-only SFNTs like `NotoColorEmoji.ttf' don't contain
entries in the bitmap strike(s) for empty glyphs.  Instead, they
rely that a space glyph gets created from the font's metrics data.
This commit makes FreeType behave accordingly.

* include/freetype/fterrdef.h (FT_Err_Missing_Bitmap): New error
code.

* src/sfnt/ttsbit.c (tt_sbit_decoder_load_image): Change error codes
to make a distinction between a missing bitmap in a composite and a
simple missing bitmap.

* src/truetype/ttgload.c (TT_Load_Glyph): For a missing bitmap (in a
bitmap-only font), synthesize an empty bitmap glyph if metrics are
available.
2017-08-11 09:34:20 +02:00
Werner Lemberg 17196b7c74 [truetype] Integer overflow.
Reported as

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

* src/truetype/ttinterp.c (Ins_ALIGNRP): Use NEG_LONG.
2017-08-05 18:58:34 +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
Nikolaus Waxweiler 24e256ab00 [truetype] Fix metrics of B/W hinting in v40 mode.
Phantom points are now saved outside v40 backwards compatibility
mode.  This fixes the jumping glyphs when switching between v35 and
v40 monochrome mode.

* src/truetype/ttgload.c (TT_Hint_Glyph): Fix inversed bool logic.
2017-08-04 08:25:31 +02:00
Nikolaus Waxweiler 7f44c2db24 [truetype] Do not set any ClearType flags in v40 monochrome mode.
This fixes weird behavior of instructions that resulted in rendering
differences between v35 and v40 in monochrome mode, e.g., in
`timesbi.ttf'.

* src/truetype/ttinterp.c (Ins_GETINFO)
[TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL]: Check
`subpixel_hinting_lean'.
2017-08-03 06:15:30 +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 ce367774d2 [sfnt, truetype] Minor adjustments for OpenType 1.8.2.
* src/sfnt/sfobjs.c (sfnt_load_face): The units per EM value has now
(tighter) limits.

* src/truetype/ttgload.c (load_truetype_glyph): The new OpenType
version explicitly allows all negative values for the number of
contours if we have a composite glyph (this is for better backwards
compatibility I guess), but it still recommends value -1.
2017-08-01 08:24:51 +02:00
Werner Lemberg 38bdf22bfe [truetype] Improve code comment. 2017-07-13 10:28:09 +02:00
Werner Lemberg 3d083fc213 * src/truetype/ttpload.c (tt_face_get_location): Off-by-one typo.
Also improve tracing message.

Problem reported as

  https://bugs.chromium.org/p/chromium/issues/detail?id=738919
2017-07-12 00:24:48 +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 ca799e9be5 [truetype] Integer overflow.
Reported as

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

* src/truetype/ttinterp.c (Ins_SCFS): Use SUB_LONG.
2017-07-03 06:27:52 +02:00
Werner Lemberg dde8f5abbe [truetype] Integer overflows.
Reported as

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

* src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round, FT_DivFix): Use
NEG_LONG.

* src/truetype/ttinterp.c (Ins_SxVTL): Use NEG_LONG.
2017-06-27 06:16:04 +02:00
Werner Lemberg b27cef27ff [truetype] Integer overflows.
Reported as

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

* src/truetype/ttinterp.c (Ins_ISECT): Use NEG_LONG.
2017-06-24 20:17:46 +02:00
Werner Lemberg 298e2ea5a6 [cff, truetype] Integer overflows.
Reported as

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

* src/cff/cf2blues.c (cf2_blues_capture): Use ADD_INT32 and
SUB_INT32.

* src/truetype/ttinterp.c (Ins_SDPVTL): Use SUB_LONG and NEG_LONG.
2017-06-22 11:52:43 +02:00
Werner Lemberg 8c763fb1be [cff, truetype] Integer overflows.
Reported as

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

* src/cff/cf2hints.c (cf2_hintmap_adjustHints): Use ADD_INT32.

* src/truetype/ttinterp.c (Ins_ABS): Avoid FT_ABS.
2017-06-20 07:49:52 +02:00
Werner Lemberg 4dc00cf5c0 [truetype] Integer overflows.
Reported as

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

* src/truetype/ttinterp.c (Ins_MDRP, _iup_worker_interpolate): Use
ADD_LONG and SUB_LONG.
2017-06-16 13:33:09 +02:00
Werner Lemberg 5c402d97af [cff, truetype] Integer overflows.
Reported as

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

* src/cff/cf2fixed.h (cf2_fixedAbs): Use NEG_INT32.

* src/truetype/ttinterp.c (Ins_IP): Use SUB_LONG.
2017-06-13 06:56:48 +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 9038837ee2 [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
Werner Lemberg dcd8de272f */*: Remove `OVERFLOW_' prefix.
This increases readability.
2017-06-09 11:21:58 +02:00
Werner Lemberg 7bffeacd7e [cff, truetype] Integer overflows.
Reported as

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

* src/cff/cf2hints.c (cf2_hint_init): Use OVERFLOW_SUB_INT32.

* src/truetype/ttinterp.c (PROJECT, DUALPROJ): Use
OVERFLOW_SUB_LONG.
2017-06-07 17:08:01 +02:00
Werner Lemberg 9fa8a2997f [cff, truetype] Integer overflows.
Reported as

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

* src/cff/cf2font.c (cf2_font_setup): Use OVERFLOW_MUL_INT32.

* src/truetype/ttinterp.c (Ins_ISECT): Use OVERFLOW_MUL_LONG,
OVERFLOW_ADD_LONG, and OVERFLOW_SUB_LONG.
2017-06-04 20:43:08 +02:00
Werner Lemberg addb2dddb6 [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
Werner Lemberg 1ea343228d [cff, truetype] Integer overflows.
Reported as

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

* src/cff/cf2hints.c (cf2_hintmap_map): Use OVERFLOW_SUB_INT32.

* src/truetype/ttinterp.c (Ins_ADD): Use OVERFLOW_ADD_LONG.
(Ins_SUB): Use OVERFLOW_SUB_LONG.
(Ins_NEG): Use NEG_LONG.
2017-06-03 06:52:13 +02:00
Werner Lemberg 8d435c463d * src/truetype/ttinterp.c (TT_RunIns): Adjust loop counter again.
Problem reported by Marek Kašík <mkasik@redhat.com>.

The problematic font that exceeds the old limit is Padauk-Bold,
version 3.002, containing bytecode generated by a buggy version of
ttfautohint.
2017-06-01 07:09:44 +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
Nikolaus Waxweiler a0455468fd [truetype] Always use interpreter v35 for B/W rendering (#51051).
* src/truetype/ttgload.c (tt_loader_init)
[TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL]: Adjust
`subpixel_hinting_lean', `grayscale_cleartype', and
`vertical_lcd_lean' accordingly.

* src/truetype/ttinterp.c (Ins_GETINFO): Updated.
(TT_RunIns): Update `backward_compatibility' flag.
2017-05-20 07:28:46 +02:00
Werner Lemberg 6e5445a232 [truetype] Fix error handling for embedded bitmaps.
Problem reported by Hin-Tak Leung <htl10@users.sourceforge.net>.

* src/truetype/ttgload.c (TT_Load_Glyph)
[TT_CONFIG_OPTION_EMBEDDED_BITMAPS]: Handle error if font is not
scalable.
2017-05-15 21:24:04 +02:00
Werner Lemberg ec4cb04b31 [truetype] Add tricky font `DFGirl-W6-WIN-BF' (from Dynalab).
Reported by Roy Tam <roytam@gmail.com>.

* src/truetype/ttobjs.c (tt_check_trickyness_family): Implement it.
2017-05-07 13:06:36 +02:00
Roy Tam 0ed9fef032 [truetype] More tricky fonts (mainly from Dynalab).
* src/truetype/ttobjs.c (tt_check_trickyness_family,
tt_check_trickyness_sfnt_ids): Add them.
2017-05-07 08:32:58 +02:00
Werner Lemberg f784a5653a [truetype] Add tricky font `DLCHayMedium' (from Dynalab).
Reported by Roy Tam <roytam@gmail.com>.

* src/truetype/ttobjs.c (tt_check_trickyness_family): Implement it.
2017-05-07 00:45:05 +02:00
Werner Lemberg 8cd31eb7b0 */*: s/backwards compatibility/backward compatibility/. 2017-05-03 23:54:29 +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 ba40054c2d [autofit] Remove `slight' auto-hint mode again.
A poll on freetype-devel favoured changes directly applied to
`light'.

* include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT,
FT_RENDER_MODE_SLIGHT): Removed.

* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
(af_latin_hints_init), src/autofit/aflatin2.c
(af_latin2_hints_init): Revert change from 2017-04-22.

* src/autofit/afloader.c (af_loader_load_glyph) Remove references to
FT_RENDER_MODE_SLIGHT.
[AF_CONFIG_OPTION_TT_SIZE_METRICS]: Enable TrueType-like metrics
unconditionally.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Revert change from
2017-04-22.

* src/base/ftobjs.c (FT_Load_Glyph): Revert change from 2017-04-22.

* src/pshinter/pshalgo.c (ps_hints_apply): Revert change from
2017-04-22.

* src/smooth/ftsmooth.c (ft_smooth_render): Revert change from
2017-04-22.

* docs/CHANGES: Updated.
2017-05-02 12:32:19 +02:00
Werner Lemberg 785833d96e * src/truetype/ttdriver.c (tt_size_request): Properly check `error'.
Reported by Earnestly <zibeon@googlemail.com> in

  http://lists.nongnu.org/archive/html/freetype/2017-04/msg00031.html
2017-04-29 06:47:14 +02:00
Werner Lemberg 5f18d867c0 [truetype] Do linear scaling for FT_LOAD_NO_HINTING (#50470).
* src/truetype/ttobs.h (TT_SizeRec): Add field `hinted_metrics' to
hold hinted metrics.
Make `metrics' a pointer so that `tt_glyph_load' can easily switch
between metrics.

* src/truetype/ttdriver.c (tt_size_request): Updated.
(tt_glyph_load): Use top-level metrics if FT_LOAD_NO_HINTING is
used.

* src/truetype/ttgload.c (TT_Hint_Glyph, TT_Process_Simple_Glyph,
TT_Process_Composite_Component, load_truetype_glyph,
compute_glyph_metrics, TT_Load_Glyph): Updated.

* src/truetype/ttinterp.c (TT_Load_Context): Updated.

* src/truetype/ttobjs.c (tt_size_reset): Updated.

* src/truetype/ttsubpix.c (sph_set_tweaks): Updated.
2017-04-26 11:40:28 +02:00
Werner Lemberg 093c182058 [truetype] Avoid reexecution of `fpgm' and `prep' in case of error.
Reported as

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

* include/freetype/fterrdef.h (FT_Err_DEF_In_Glyf_Bytecode): New
error code.

* src/truetype/ttinterp.c (Ins_FDEF, Ins_IDEF): Prohibit execution
of these two opcodes in `glyf' bytecode.
(TT_RunIns): Don't enforce reexecution of `fpgm' and `prep' bytecode
in case of error since function tables can no longer be modified
(due to the changes in `Ins_FDEF' and `Ins_IDEF').  This change can
enormously speed up handling of broken fonts.
2017-04-03 11:37:33 +02:00
Werner Lemberg bb6c037bae * src/truetype/ttgload.c: Include FT_CONFIG_CONFIG_H.
Otherwise FT_UINT_TO_POINTER might not be defined.

Problem reported by Alexei.
2017-04-01 09:49:11 +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 bcc74f4daf [truetype] Allow linear scaling for unhinted rendering (#50470).
* src/truetype/ttdriver.c (tt_size_request): Revert change from
2011-07-16; the intended metrics fix seems now to be implemented in
a different way, making the patch unnecessary.  Note that this
change was usually patched out by all major GNU/Linux distributions
due to heavy side effects.

* src/truetype/ttgload.c (compute_glyph_metrics, TT_Load_Glyph):
Refer to the metrics of the `TT_Size' object.
2017-03-30 13:14:43 +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 208e712de0 [cid, truetype] Don't use `index' as a variable name.
At least on FreeBSD there is a global declaration of `index' in file
`/usr/include/strings.h'.

* src/cff/cf2intrp.c, src/truetype/ttgload.c: s/index/idx/ where
appropriate.
2017-03-27 20:56:23 +02:00
Werner Lemberg 683e3ad936 [truetype] Some variable renamings.
Too much local variables holding different structures were called
`metrics'.

* src/truetype/ttdriver.c (tt_size_select): s/metrics/size_metrics/.

* src/truetype/ttgload.c (tt_get_metrics_incr_overrids,
compute_glyph_metrics): s/metrics/incr_metrics/.
(load_sbit_image): s/metrics/sbit_metrics/.

* src/truetype/ttobjs.c (tt_size_run_fpgm): s/metrics/size_metrics/.
(tt_size_init_bytecode): s/metrics/tt_metrics/.
(tt_size_reset): s/metrics/size_metrics/.
2017-03-21 19:49:11 +01:00
Werner Lemberg 7aeee3c50f Introduce FT_UINT_TO_POINTER macro (#50560).
We have to make a separate case for Windows 64's LLP64 data model.

* builds/unix/ftconfig.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h (FT_UINT_TO_POINTER): New macro.

* src/truetype/ttgload.c (load_truetype_glyph): Use it.
2017-03-18 17:30:42 +01:00
Werner Lemberg 3e79254ae7 * src/truetype/ttinterp.c (TT_RunIns): Adjust loop counter (#50573).
The problematic font that exceeds the old limit is Lato-Regular,
version 2.007, containing bytecode generated by a buggy version of
ttfautohint.
2017-03-18 10:06:15 +01:00
Werner Lemberg 13fa85a246 [truetype] Another limitation for bytecode loop count maximum.
Reported as

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

* src/truetype/ttinterp.c (TT_RunIns): Limit `loopcall_counter_max'
by number of glyphs also.
2017-03-18 09:42:58 +01: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 d5bfa053f5 Fixes for conditional compilation.
* src/autofit/afcjk.c, src/autofit/afindic.c: Include `afcjk.h'
earlier.

* src/sfnt/sfobjs.c (sfnt_init_face): Put `memory' variable into
TT_CONFIG_OPTION_GX_VAR_SUPPORT block.
(sfnt_done_face): Protect some code with
TT_CONFIG_OPTION_GX_VAR_SUPPORT.

* src/sfnt/ttsbit.c (tt_face_load_sbix_image): Remove compiler
warning.

* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Put `tmp' variable
into TT_USE_BYTECODE_INTERPRETER block.

(tt_loader_init): Put `error' variable into
TT_USE_BYTECODE_INTERPRETER block.
2017-03-17 21:47:54 +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
Werner Lemberg 34010f7c47 [sfnt] Implement PS names for font instances [3/3].
Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.

* include/freetype/internal/tttypes.h (TT_FaceRec): New fields
`var_postscript_prefix' and `var_postscript_prefix_len'.

* src/sfnt/sfdriver.c: Include FT_TRUETYPE_IDS_H.
(sfnt_is_alphanumeric): New wrapperfunction for `ft_isalnum'.
(get_win_string, get_apple_string): Remove `const' from return
value.
(MAX_VALUE_DESCRIPTOR_LEN, MAX_PS_NAME_LEN): New macros.
(hexdigits): New array.
(sfnt_get_var_ps_name): New function, implementing Adobe TechNote
5902 to construct a PS name for a variation font instance.
(sfnt_get_ps_name): Call `sfnt_get_var_ps_name' for font instances.

* src/sfnt/sfobjs.c (sfnt_done_face): Updated.

* src/truetype/ttgxvar.c (tt_set_mm_blend): Reset
`face->postscript_name' to trigger recalculation for new instance
parameters.
2017-03-14 21:50:22 +01:00
Werner Lemberg 447a0b6263 [truetype] Ignore invalid MVAR tags.
Reported as

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

* src/truetype/ttgxvar.c (ft_var_load_mvar): Ignore value and emit
warning for invalid tags.
(tt_apply_mvar): Ignore invalid tags.
2017-03-13 07:42:34 +01:00
Werner Lemberg 5eb0fd5e97 [truetype] Store and use design coordinates also.
* include/freetype/internal/services/svmm.h (FT_Get_Var_Blend_Func):
Add `normalizedcoords' argument.

* src/truetype/ttgxvar.h (GX_BlendRec): Add `coords' field to store
the design coordinates of the current instance.
Updated.

* src/truetype/ttgxvar.c (TT_Set_MM_Blend): Move functionality to...
(tt_set_mm_blend): ... New function.
Convert data in `normalizedcoords' array to `coords' array on
demand.
(TT_Set_Var_Design): Store argument data in `coords' array.
(TT_Get_Var_Design): Get data from `coords' array.
(tt_get_var_blend): Updated.
(tt_done_blend): Updated.

* src/cff/cffload.c, src/cff/cffload.h (cff_get_var_blend): Updated.

* src/cff/cf2ft.c (cf2_getNormalizedVector): Updated.

* src/cff/cffobjs.c (cff_face_init): Updated.
2017-03-12 20:46:56 +01:00
Werner Lemberg 8dd9e9675d Document `GX_BlendRec'. 2017-03-12 10:47:20 +01:00
Werner Lemberg 4a62922bf8 src/truetype/ttgxvar.[ch]: s/avar_checked/avar_loaded/. 2017-03-12 10:19:53 +01:00
Werner Lemberg 27fee7f8c6 [sfnt, truetype] Always provide default instance.
As documented in the OpenType specification, an entry for the
default instance may be omitted in the named instance table.  In
particular this means that even if there is no named instance table
in the font we actually do have a named instance, namely the default
instance.

For consistency, we always want the default instance in our list of
named instances.  If it is missing, we try to synthesize it.

* src/sfnt/sfobjs.c (sfnt_init_face): Check whether the default
instance is in the table of named instances.  Otherwise adjust
number of instances.

* src/truetype/ttgxvar.c: Include FT_TRUETYPE_IDS_H.
(TT_Get_MM_Var): Use `face->root.style_flags' as the number of named
instances.
Sythesize a named instance entry if necessary.
(tt_done_blend): Free `normalized_stylecoords'.
2017-03-06 20:45:44 +01:00
Werner Lemberg 588e38e070 [truetype] Make `TT_Set_MM_Blend' set named instance index.
* src/truetype/ttgxvar.h (GX_Blend): New array
`normalized_stylecoords'.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Allocate and fill
`normalized_stylecoords'.
(TT_Set_MM_Blend): Check instance tuple and adjust `face_index'
accordingly.
2017-03-04 11:04:24 +01:00
Werner Lemberg 4717696c12 [truetype] Split off designer/normalized conversion routines.
* src/truetype/ttgxvar.c (TT_Set_Var_Design): Split off conversion
code designer->normalized coordinates to...
(ft_var_to_normalized): ... New function.
(TT_Get_Var_Design): Split off conversion code normalized->designer
coordinates to...
(ft_var_to_design): ... New function.
2017-03-02 21:42:14 +01:00
Werner Lemberg 01f315f076 [truetype] Minor improvement.
* src/truetype/ttgload.c (TT_Process_Simple_Glyph,
load_truetype_glyph): Remove unnecessary tests.
2017-02-28 15:27:43 +01:00
Werner Lemberg f0cee1a22c * include/freetype/internal/tttypes.h (TT_Face): s/isCFF2/is_cff2/.
For orthogonality with other structure field names.

Update all users.
2017-02-23 08:23:39 +01:00
Werner Lemberg faa3c88254 [truetype] Implement `VVAR' table support.
* src/truetype/ttgxvar.h (GX_HVarTable): Renamed to...
(GX_HVVarTable): ...This.
(GX_Blend): Add fields for `VVAR' table handling.
Other minor updates.

* src/truetype/ttgxvar.c (ft_var_load_hvar): Renamed to...
(ft_var_load_hvvar): ...This.
Handle VVAR loading also (controlled by an additional parameter).
(tt_hadvance_adjust): Renamed to...
(tt_hvadvance_adjust): ...This.
Handle application of advance height also (controlled by an
additional parameter).
(tt_hadvance_adjust, tt_vadvance_adjust): Wrappers for
`tt_hvadvance_adjust'.

* src/truetype/ttdriver.c (tt_service_metrics_variations): Updated.
2017-02-06 13:13:02 +01:00
Werner Lemberg e6699596af [truetype] Fix MVAR post-action handling.
Reported as

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

* src/truetype/ttobjs.c (tt_size_reset): Do nothing for CFF2.  This
is important to make `tt_size_reset_iterator' (called in
`tt_apply_mvar') always work.
2017-02-02 11:38:04 +01:00
Werner Lemberg e80e4d811a [truetype] Fix sanity check for `gvar' table (#50184).
* src/truetype/ttgxvar.c (ft_var_load_gvar): There might be missing
variation data for some glyphs.
2017-01-31 08:32:07 +01:00
Werner Lemberg 9db55ad1af Typo. 2017-01-30 07:35:06 +01:00
Werner Lemberg f502092bcd [truetype] Minor updates for OpenType 1.8.1.
* src/truetype/ttgxvar.h (GX_MVarTable): `axisCount' has been
removed frem the specification; it is now reserved.

* src/truetype/ttgxvar.c (ft_var_load_mvar): Updated.
(GX_FVar_Head): Remove `countSizePairs'; the corresponding data
field in the `MVAR' table is now reserved.
(fvar_fields): Updated.
2017-01-23 11:47:40 +01:00
Werner Lemberg 79d52b9a8d [truetype] Avoid segfault for invalid variation data.
* src/truetype/ttgxvar.c (ft_var_load_item_variation_store): Assure
`itemCount' is not zero.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=441
2017-01-23 07:43:56 +01:00
Werner Lemberg 43061d6a93 * src/truetype/ttinterp.c (TT_RunIns): Adjust loop detector limits. 2017-01-20 10:16:38 +01:00
Alexei Podtelezhnikov 236bbdbef9 Typos. 2017-01-18 23:12:31 -05:00
Werner Lemberg 322b3be514 * src/truetype/ttgxvar.c (tt_apply_var): Handle underline parameters
also.
2017-01-15 13:57:25 +01:00
Werner Lemberg 723aafb5e3 [truetype] Actually use metrics variation service.
* src/base/ftmm.c: Include FT_SERVICE_METRICS_VARIATIONS_H.
(ft_face_get_mvar_service): New auxiliary function to look up
metrics variation service.
(FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates,
FT_Set_Var_Blend_Coordinates): Call metrics variation service.

* src/truetype/ttobjs.c (tt_face_init): Use metrics variations for
named instances.
2017-01-11 14:21:26 +01:00
Werner Lemberg d718ac4ead [truetype] Provide metrics variation service.
* include/freetype/internal/services/svmetric.h
(FT_Metrics_Adjust_Func): Reduce number of necessary parameters.

* src/truetype/ttgxvar.c: Include FT_LIST_H.
(tt_size_reset_iterator): New auxiliary function for...
(tt_apply_var): New function.

* src/truetype/ttgxvar.h: Updated.

* src/truetype/ttdriver.c (tt_service_metrics_variations): Add
`tt_apply_mvar'.

* include/freetype/internal/ftserv.h (FT_ServiceCache): Add metrics
variation service.
2017-01-11 14:12:34 +01:00
Werner Lemberg 07ee1d250c [truetype] Parse `MVAR' table.
* src/truetype/ttgxvar.h (MVAR_TAG_XXX): New macros for MVAR tags.
(GX_Value, GX_MVarTable): New structures.
(GX_Blend): Add it.

* src/truetype/ttgxvar.c (GX_VALUE_SIZE, GX_VALUE_CASE,
GX_GASP_CASE): New macros.
(ft_var_get_value_pointer): New auxiliary function to get a pointer
to a value from various SFNT tables already stored in `TT_Face'.
(ft_var_load_mvar): New function.
(TT_Get_MM_Var): Call it.
(tt_done_blend): Updated.
2017-01-11 12:50:51 +01:00
Werner Lemberg 8ab08cff63 [truetype] More preparations for MVAR support.
* src/truetype/ttobjs.c (tt_size_reset): Add argument to make
function only recompute ascender, descender, and height.

* src/truetype/ttobjs.h: Updated.

* src/truetype/ttdriver.c (tt_size_select, tt_size_request):
Updated.
2017-01-11 10:05:27 +01:00
Werner Lemberg 469ced7f7f [truetype] Again some GX code shuffling.
We need this later on for MVAR also.

* src/truetype/ttgxvar.c (tt_hadvance_adjust): Split off computing
an item store variation delta into...
(ft_var_get_item_delta): ...new function.
2017-01-08 09:28:34 +01:00
Werner Lemberg 0291913491 [truetype] More GX code shuffling.
We need this later on for MVAR also.

* src/truetype/ttgxvar.c (tt_done_blend): Split off handling of item
variation store into...
(ft_var_done_item_variation_store): ...new function.
2017-01-07 07:45:28 +01:00
Werner Lemberg fb90f00cbd [truetype] More generalization of GX stuff.
We need this later on for MVAR also.

* src/truetype/ttgxvar.c (ft_var_load_delta_set_index_mapping): Add
parameters for delta-set index mapping and item variation store.
(ft_var_load_item_variation_store): Add parameter for item variation
store.
s/hvarData/varData/.
Move allocation of `hvar_table' to...
(ft_var_load_hvar): ...this function.
Updated.
2017-01-06 22:23:52 +01:00
Werner Lemberg 0bd0112f4e [truetype] Some GX structure renames for generalization.
We need this later on for MVAR also.

* src/truetype/ttgxvar.h (GX_HVarData): Renamed to...
(GX_ItemVarData): ...this.
(GX_HVarRegion): Renamed to...
(GX_VarRegion): ...this.
(GX_HVStore): Renamed to...
(GX_ItemVarStore): ...this.
(GX_WidthMap): Renamed to...
(GX_DeltaSetIdxMap): ...this.

(GX_HVarTable): Updated.

* src/truetype/ttgxvar.c: Updated.
2017-01-06 21:32:49 +01:00
Werner Lemberg 9c814704c0 [truetype] Code shuffling.
* src/truetype/ttgxvar.c (): Split off loading of item variation
store and delta set index mapping into...
(ft_var_load_item_variation_store,
ft_var_load_delta_set_index_mapping): ... new functions.
2017-01-06 21:13:36 +01:00
Werner Lemberg 7e1cce58b5 [truetype] Add HVAR access without advance width map.
* src/truetype/ttgxvar.c (ft_var_load_hvar): Handle case where
`offsetToAdvanceWidthMapping' is zero.
(tt_hadvance_adjust): Implement direct deltaSet access by glyph
index.
2017-01-06 20:31:22 +01:00
Werner Lemberg 348d39c68a Comment. 2017-01-05 12:29:55 +01:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 025226ae14 [cff, truetype] Minor tracing improvement.
* src/cff/cffobjs.c (cff_face_init), src/truetype/ttobjs.c
(tt_face_init): Indent first tracing message from SFNT driver.
2017-01-04 07:45:44 +01:00
Werner Lemberg 8982405f0c [truetype] Various minor fixes.
* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Check instruction
size only if we do native hinting.
(TT_Load_Glyph): Trace returned error code.

* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Trace
returned error code.
(tt_size_ready_bytecode): Don't run `prep' table if `fpgm' table is
invalid.
2017-01-03 09:46:19 +01:00
Werner Lemberg 248eaa4f60 Various fixes for clang's undefined behaviour sanitizer.
* src/cff/cffload.c (FT_fdot14ToFixed): Fix casting.
(cff_blend_doBlend): Don't left-shift negative numbers.
Handle 5-byte numbers byte by byte to avoid alignment issues.

* src/cff/cffparse.c (cff_parse): Handle 5-byte numbers byte by byte
to avoid alignment issues.

* src/cid/cidload (cid_read_subrs): Do nothing if we don't have any
subrs.

* src/psaux/t1decode.c (t1_decode_parse_charstring): Fix tracing.

* src/tools/glnames.py (main): Put `DEFINE_PSTABLES' guard around
definition of `ft_get_adobe_glyph_index'.

* src/psnames/pstables.h: Regenerated.

* src/psnames/psmodule.c: Inlude `pstables.h' twice to get both
declaration and definition.

* src/truetype/ttgxvar.c (FT_fdot14ToFixed, FT_intToFixed): Fix
casting.
2017-01-03 00:27:07 +01:00
Werner Lemberg e9a154e700 [truetype] Check axis count in HVAR table.
Reported as

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

* src/truetype/ttgxvar.c (ft_var_load_hvar): Check axis count.
(ft_var_load_avar): Fix tracing message.
2016-12-31 21:41:08 +01:00
Werner Lemberg 7591bf11d1 [truetype] Variation font API stability issues.
Make some functions work before a call to `TT_Set_MM_Blend'.

* src/truetype/ttgxvar.c (tt_hadvance_adjust): Exit immediately if
we don't blend.
(TT_Get_MM_Blend, TT_Get_Var_Design): Return default values if we
don't blend.
2016-12-29 21:39:06 +01:00
Werner Lemberg 91fc3bd7c9 * src/truetype/ttgxvar.c (TT_Get_MM_Var): Check axis data.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=348
2016-12-29 21:34:46 +01:00
Werner Lemberg 180185109b [truetype] Tracing fixes.
* src/truetype/ttgxvar.c (tt_hadvance_adjust): Emit correct
information.
(TT_Set_Var_Design): Fix typo.
(TT_Get_Var_Design): Fix typos.
2016-12-29 21:30:06 +01:00
Werner Lemberg 84b0d9927b */*: Use `0.5f' for tracing 16.16 numbers. 2016-12-29 10:38:51 +01:00
Werner Lemberg e5e3556fa2 [truetype, type1] Implement `FT_Get_Var_Design_Coordinates'.
* src/truetype/ttgxvar.c (TT_Get_Var_Design): Implement.
(TT_Set_Var_Design): Fix tracing.

* src/type1/t1load.c (T1_Get_Var_Design): Implement.
2016-12-27 06:49:37 +01:00
Werner Lemberg f80c4473b6 Replace `++foo' and `--foo' with `foo++' and `foo--', resp. 2016-12-26 23:57:45 +01:00
Werner Lemberg 4441f7b246 Replace `foo == NULL' and `foo != NULL' with `!foo' and `foo', resp.
Other minor formatting.
2016-12-26 17:08:17 +01:00
Werner Lemberg 37c72f66a5 Minor formatting. 2016-12-25 22:55:25 +01:00
Werner Lemberg a300c1c3af * src/truetype/ttpload.c (tt_face_load_hdmx): Ignore `version'.
Problem reported by 張俊芝 <418092625@qq.com>.
2016-12-24 09:27:15 +01:00
Werner Lemberg fde0b78cce * src/truetype/ttpload.c (tt_face_load_loca): Sanitize table length.
This trivial fix allows us to accept more fonts.

Problem reported by 張俊芝 <418092625@qq.com>.
2016-12-24 08:17:19 +01:00
Werner Lemberg 7209110345 * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Thinko.
I should really stop coding late in the evening...

Thanks again to Ben for checking.
2016-12-21 23:46:29 +01:00
Werner Lemberg d44daf9e9b * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Thinko.
Don't apply deltas twice for non-phantom points.

Spotted by Ben Wagner.
2016-12-21 23:03:48 +01:00
Werner Lemberg e6a429e2c7 [cff, truetype] Another try for #49829.
* src/cff/cffdrivr.c: Don't include
`FT_SERVICE_METRICS_VARIATIONS_H'.
(cff_get_advances): Use `ttface->variation_support'.

* src/truetype/ttdriver.c (tt_get_advances): Use
`ttface->variation_support'.

* src/truetype/ttgload.c (TT_Process_Simple_Glyph,
load_truetype_glyph): Use `ttface->variation_support'.
2016-12-21 20:27:48 +01:00
Werner Lemberg 64a91137f1 [truetype, sfnt] Introduce font variation flags to `TT_Face'.
* include/freetype/internal/tttypes.h (TT_FACE_FLAG_VAR_XXX):
New macros describing available functionality of various OpenType
tables related to font variation.
(TT_Face): New fields `variation_support' and `mvar_support',
replacing and extending `use_fvar'.

* src/sfnt/sfobjs.c (sfnt_init_face, sfnt_load_face): Use
`variation_support'.

* src/truetype/ttgxvar.c (ft_var_load_hvar): Set `variation_support'
field.
(TT_Vary_Apply_Glyph_Deltas): Updated.
2016-12-21 19:30:33 +01:00
Werner Lemberg 70704b34ac [truetype] Improve logic for getting fast advance widths.
* src/cff/cffdrivr.c (cff_get_advances), src/truetype/ttdriver.c
(tt_get_advances): Use `is_default_instance' for test; this gets
recomputed after changing blend coordinates.
2016-12-20 12:27:22 +01:00
Ben Wagner cc576f8002 [truetype] Fix linear metrics of GX variation fonts.
When asking for an unhinted non-default variations,
`linearVertAdvance' is currently the value from the `hmtx' table
instead of the actual value after applying the variation.  `HVAR'
support fixes this, but fonts will exist without that table and will
need sane fallback.

* src/truetype/ttgload.c (TT_Process_Simple_Glyph,
load_truetype_glyph): Implement linear advance adjustments if `HVAR'
or `VVAR' tables are missing.
2016-12-20 11:37:42 +01:00
Werner Lemberg a1e85f11c8 [cff, truetype] Fast advance width retrieval for fonts with HVAR.
Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Don't handle MM.

* src/cff/cffdrivr.c: Include FT_SERVICE_METRICS_VARIATIONS_H.
(cff_get_advances): Test for HVAR and VVAR.

* src/truetype/ttdriver.c (tt_get_advances): Test for HVAR and VVAR.
2016-12-20 10:52:26 +01:00
Werner Lemberg a8652c59da [truetype, cff] Extend `get_var_blend' function of MM service.
In particular, we need access to named instance data.

* include/freetype/internal/services/svmm.h (FT_Get_Var_Blend_Func):
Add argument for `FT_MM_Var'.

* src/cff/cffload.c (cff_get_var_blend): Updated.
* src/cff/cffload.h: Updated.

* src/cff/cf2ft.c (cf2_getNormalizedVector): Updated.

* src/truetype/ttgxvar.c (tt_get_var_blend): Updated.
Accept value `NULL' for arguments.
* src/truetype/ttgxvar.h: Updated.
2016-12-18 18:12:03 +01:00
Werner Lemberg 25f3ac2b9e [sfnt] Handle `fvar' with zero axes as a non-MM font.
This is better behaviour than exiting with an error.

* include/freetype/internal/tttypes.h (TT_Face): Add `use_fvar'
field.

* src/sfnt/sfobjs.c (sfnt_init_face): Compute `use_fvar', also
updating the validation code.
Use `use_fvar' to compute FT_FACE_FLAG_MULTIPLE_MASTERS.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Remove `fvar' validation
code.
2016-12-18 15:50:18 +01:00
Werner Lemberg eb6d02087b Minor GX code shuffling.
* include/freetype/internal/tttypes.h (TT_Face): Move
`is_default_instance' into TT_CONFIG_OPTION_GX_VAR_SUPPORT
block.

* src/sfnt/sfobjs.c (sfnt_init_face): Updated.
* src/truetype/ttgload.c (IS_DEFAULT_INSTANCE): New macro.
(TT_Load_Glyph): Use it.
2016-12-18 09:29:58 +01:00
Werner Lemberg 5d664b6d51 Use FT_SET_ERROR where useful. Other minor code formatting. 2016-12-17 20:47:42 +01:00
Werner Lemberg db17ceb4c0 * src/truetype/ttobjs.c (tt_face_init): Simplify conditional code. 2016-12-17 13:39:31 +01:00
Werner Lemberg 7c75b166c8 [sfnt, truetype] Various sanitizing fixes.
* src/sfnt/sfobjs.c (sfnt_init_face): If the axis count in `fvar' is
zero, set `num_instances' to zero.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Handle `fvar' table with
zero axes as invalid.

* src/truetype/ttobjs.c (tt_face_init): Improve logic of loading
`loca', `cvt', `fpgm', and `prep' table.
2016-12-17 13:28:24 +01:00
Werner Lemberg df2cf43e94 [truetype] Fix `cvar' sanity test.
Reported by Dave Arnold.

* src/truetype/ttgxvar.c (tt_face_vary_cvt): Use tuple count mask.
2016-12-16 11:38:20 +01:00
Werner Lemberg 6862024854 [cff, truetype] Remove compiler warnings; fix `make multi'.
* src/cff/cf2font.h: Include `cffload.h'.

* src/cff/cffload.c: Include FT_MULTIPLE_MASTERS_H and
FT_SERVICE_MULTIPLE_MASTERS_H.
(cff_vstore_load): Eliminate `vsSize'.
(cff_load_private_dict): Tag as `FT_LOCAL_DEF'.

* src/cff/cffload.h: Include `cffobjs.h'.
Provide declaration for `cff_load_private_dict'.

* src/truetype/ttgxvar.c (ft_var_load_hvar): Eliminate
`minorVersion' and `map_offset'.
2016-12-16 11:15:17 +01:00
Dave Arnold edf4014854 [cff] Implement CFF2 support (2/2).
The font variation code.  All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).

* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.

* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.

* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.

* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.

* src/cff/cffobjs.c (cff_face_done): Updated.

* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.

* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.

* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
Werner Lemberg 3bd79cc257 [truetype] Provide HVAR advance width variation as a service.
Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.

* src/truetype/ttdriver.c (tt_service_metrics_variations): Updated.

* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Prevent
double adjustment of advance width.

* src/sfnt/ttmtx.c: Include FT_SERVICE_METRICS_VARIATIONS_H.
(tt_face_get_metrics): Apply metrics variations.
2016-12-15 14:34:57 +01:00
Dave Arnold aa0c4b4f55 [truetype] Provide function to apply `HVAR' advance width variation.
* src/truetype/ttgxvar.c (tt_hadvance_adjust): New function.
* src/truetype/ttgxvar.h: Updated.
2016-12-15 14:04:51 +01:00
Dave Arnold 097cd874ee [truetype] Add `HVAR' table parsing.
Note that this is not complete yet; it only handles advance width
variation.

Activation of the code follows in another commit.

* include/freetype/ftmm.h (FT_Var_Named_Style): Add `psid' member.

* src/truetype/ttgxvar.h (GX_HVarData, GX_AxisCoords, GX_HVarRegion,
GX_HVStore, GX_WidthMap): New auxiliary structures for...
(GX_HVarTable): ... HVAR main structure.
(GX_BlendRec): Add data for HVAR loading.

* src/truetype/ttgxvar.c (FT_FIXED_ONE, FT_fdot14ToFixed,
FT_intToFixed, FT_fixedToInt): New macros.
(ft_var_load_hvar): New function.
(TT_Get_MM_Var): Updated.
(tt_done_blend): Deallocate HVAR data.
2016-12-15 12:58:26 +01:00
Werner Lemberg 0918325e3f [sfnt, truetype] Add framework for Metrics Variations service.
No effect yet; service functions will be implemented later on.

Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.

* include/freetype/internal/services/svmetric.h: New file.

* include/freetype/internal/ftserv.h
(FT_SERVICE_METRICS_VARIATIONS_H): New macro.

* include/freetype/internal/tttypes.h (TT_Face): New field `var'.

* src/sfnt/sfobjs.c: Include FT_SERVICE_METRICS_VARIATIONS_H.
(sfnt_init_face): Initialize `face->var'.

* src/truetype/ttdriver.c: Include FT_SERVICE_METRICS_VARIATIONS_H.
(tt_service_metrics_variations): New service.
(tt_services): Updated.

* src/truetype/ttpic.h: Updated.
2016-12-14 20:44:11 +01:00
Werner Lemberg ab22b43bac * src/truetype/ttgxvar.c (tt_get_var_blend): Fix compiler warning. 2016-12-14 18:34:55 +01:00
Werner Lemberg 8b174b4b96 [truetype, type1] Add `get_var_blend' to MM service.
For internal use; we want to share code between the forthcoming CFF2
support and TrueType.

* include/freetype/internal/services/svmm.h (FT_Get_Var_Blend_Func):
New typedef.
(MultiMasters): Add `get_var_blend'.
(FT_Service_MultiMasters): Updated.

* src/truetype/ttgxvar.c (tt_get_var_blend): New function.
* src/truetype/ttgxvar.h: Updated.

* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
* src/type1/t1driver.c (t1_service_multi_masters): Updated.
2016-12-11 09:16:52 +01:00
Werner Lemberg 27bdb36cbe [truetype, type1] Add `done_blend' to MM service.
For internal use; we want to share code between the forthcoming CFF2
support and TrueType.

* include/freetype/internal/services/svmm.h (FT_Done_Blend_Func):
New typedef.
(MultiMasters): Add `done_blend'.
(FT_Service_MultiMasters): Updated.

* src/truetype/ttgxvar.c (tt_done_blend): Use `TT_Face' as argument.
* src/truetype/ttgxvar.h: Updated.

* src/truetype/ttobjs.c (TT_Face_Done): Updated.

* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
* src/type1/t1driver.c (t1_service_multi_masters): Updated.
2016-12-10 09:56:03 +01:00
Dave Arnold bcae657482 Add `FT_Get_Var_Design_Coordinates' function.
Note that the low-level functions aren't implemented yet.

* include/freetype/ftmm.h: Declare.

* include/freetype/internal/services/svmm.h
(FT_Get_Var_Design_Func): New typedef.
(MultiMasters): New MM service function `get_var_design'.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
Update all callers.

* src/base/ftmm.c (FT_Get_Var_Design_Coordinates): Implement.

* src/truetype/ttdriver.c: Updated.

* src/truetype/ttgxvar.c (TT_Get_Var_Design): New dummy function to
handle `get_var_design' service.
* src/truetype/ttgxvar.h: Updated.

* src/type1/t1driver.c: Updated.

* src/type1/t1load.c (T1_Get_Var_Design): New dummp function to
handle `get_var_design' service.
* src/type1/t1load.h: Updated.
2016-12-06 11:49:15 +01:00
Behdad Esfahbod b72858c992 [truetype] Clamp variation requests to valid range.
This is required by OpenType 1.8; it also avoids rounding surprises.

* src/truetype/ttgxvar.c (TT_Set_Var_Design): Clamp design coordinates
outside of the allowed range to always stay within the range instead
of producing an error.
2016-11-03 06:41:00 +01:00
Werner Lemberg 328d68449d [truetype] Remove clang warnings.
* src/truetype/ttinterp.h (TT_ExecContextRec): Using `FT_ULong' for
loop counter handling.

* src/truetype/ttinterp.c: Updated.
(Ins_SCANTYPE): Use signed constant.
(TT_RunIns): Ensure `num_twilight_points' is 16bit.
2016-10-29 00:18:56 +02:00
Werner Lemberg ddf3872699 [truetype] Fix commit from 2014-11-24.
Problem reported by Hin-Tak Leung  <htl10@users.sourceforge.net>.

* src/truetype/ttpload.c (tt_face_load_hdmx): Fix file checking
logic.
2016-10-27 07:27:27 +02:00
Werner Lemberg 9c45ac3966 Add `FT_Get_{MM,Var}_Blend_Coordinates' functions.
* include/freetype/ftmm.h: Declare.

* include/freetype/internal/services/svmm.h (FT_Get_MM_Blend_Func):
New typedef.
(MultiMasters): New MM service function `get_mm_blend'.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
Update all callers.

* src/base/ftmm.c (FT_Get_MM_Blend_Coordinates,
FT_Get_Var_Blend_Coordinates): Implement.

* src/truetype/ttdriver.c: Updated.

* src/truetype/ttgxvar.c (TT_Get_MM_Blend): New function to handle
`get_mm_blend' service.
* src/truetype/ttgxvar.h: Updated.

* src/type1/t1driver.c: Updated.

* src/type1/t1load.c (T1_Get_MM_Blend): New function to handle
`get_mm_blend' service.
* src/type1/t1load.h: Updated.

* docs/CHANGES: Document.
2016-10-26 16:00:00 +02:00
Werner Lemberg 5081674c5f [truetype] Fix SCANTYPE instruction (#49394).
* src/truetype/ttinterp.c (Ins_SCANTYPE): Only use lower 16bits.
2016-10-22 19:16:08 +02:00
Werner Lemberg 7eeaf986b5 [truetype] Fix handling of `cvar' table data.
Reported as

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

* src/truetype/ttgxvar.c (tt_face_vary_cvt): Ignore invalid CVT
indices.
2016-10-14 08:58:17 +02:00
Werner Lemberg 922812281c * src/truetype/ttgxvar.c (tt_done_blend): Fix deallocation. 2016-10-11 07:12:12 +02:00
Werner Lemberg 2067c6985a [truetype] Disallow bitmap strokes for non-default instances.
Also speed up access of default instances if GX variations are
active.

* include/freetype/internal/tttypes.h (TT_FaceRec): Add
`is_default_instance' member.

* src/sfnt/sfobjs.c (sfnt_init_face): Initialize
`is_default_instance'.

* src/truetype/ttgload.c (TT_Process_Simple_Glyph,
load_truetype_glyph): Add test for default instance.
(TT_Load_Glyph): Load embedded bitmaps for default instance only.

* src/truetype/ttgxvar.c (TT_Set_MM_Blend): Compute
`is_default_instance'.
2016-09-29 19:49:07 +02:00
Werner Lemberg 2ecf89b481 */*: s/FT_MEM_ZERO/FT_ZERO/ where appropriate. 2016-09-28 19:06:21 +02:00
Werner Lemberg a3e2c83234 [truetype] Trace number of executed opcodes.
* src/truetype/ttinterp.c (TT_RunIns): Implement it.
2016-09-27 21:42:02 +02:00
Werner Lemberg e27b8a5598 [truetype] Speed up `TT_Load_Glyph'.
This avoids additional calls to `tt_face_lookup_table' for the
`glyf' table, which can be expensive.

* include/freetype/internal/tttypes.h (TT_LoaderRec): Move
`glyf_offset' field to ...
(TT_FaceRec): ... this structure.
* src/truetype/ttgload.c (load_truetype_glyph): Updated.
(tt_loader_init): Move initialization of `glyf_offset' to ...
* src/truetype/ttpload.c (tt_face_load_loca): .. this function.
2016-09-27 21:21:01 +02:00
Werner Lemberg 0d94592942 [truetype] Introduce dynamic limits for some bytecode opcodes.
This speeds up FreeType's handling of malformed fonts.

* src/truetype/ttinterp.c (TT_RunIns): Set up limits for the number
of twilight points, the total number of negative jumps, and the
total number of loops in LOOPCALL opcodes.  The values are based on
the number of points and entries in the CVT table.
(Ins_JMPR): Test negative jump counter.
(Ins_LOOPCALL): Test loopcall counter.

* src/truetype/ttinterp.h (TT_ExecContext): Updated.

* docs/CHANGES: Updated.
2016-09-27 08:44:31 +02:00
Werner Lemberg a764963f26 [truetype] Sanitize only last entry of `loca' table.
Without this patch, a loca sequence like `0 100000 0 100000 ...',
where value 100000 is larger than the `glyf' table size, makes
FreeType handle the whole `glyf' table as a single glyph again and
again, which is certainly invalid (and can be very slow, too).

* src/truetype/ttpload.c (tt_face_get_location): Implement.
Improve tracing messages.
2016-09-25 16:29:05 +02:00
Werner Lemberg c95b7652d8 s/0/NULL/ for function pointers; comments, formatting. 2016-09-17 17:12:50 +02:00
Werner Lemberg e421a0bffc [sfnt] Fix previous commit.
Problems reported as

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

We now map the strike index right before accessing the physical
data, not earlier.

* src/sfnt/sfobjs.c (sfnt_load_face): Set `face->sbit_strike_map'
after creating the map so that...

* src/sfnt/ttsbit.c (tt_face_load_strike_metrics): ... this function
can be used before and after setting up `sbit_strike_map'.
(tt_face_set_sbit_strike): Revert change.
(tt_sbit_decoder_init, tt_face_load_sbix_image): Map strike index.

* src/truetype/ttdriver.c (tt_size_select): Revert change.
2016-09-10 08:02:30 +02:00
Werner Lemberg d609b7c158 [sfnt] Don't provide (completely) broken strike data.
FreeType tries to sanitize strike header data; we now reject
completely broken ones.

* include/freetype/internal/tttypes.h (TT_FaceRec): New
`sbit_strike_map' array pointer.

* src/base/ftobjs.c (FT_Match_Size): Reject matches where either
width or height would be zero.
Add tracing message in case of error.

* src/sfnt/sfobjs.c (sfnt_load_face): Populate `sbit_strike_map',
only using (more or less) valid strike header data for
FT_Face's `available_sizes' array.
(sfnt_done_face): Updated.

* src/sfnt/ttsbit.c (tt_face_set_sbit_strike): Use
`sbit_strike_map'.
(tt_face_load_strike_metrics): Improve tracing.

* src/truetype/ttdriver.c (tt_size_select): Use `sbit_strike_map'.
2016-09-09 22:11:07 +02:00
Werner Lemberg b1e7b68efe * src/truetype/ttinterp.c: Include `ttgxvar.h'.
This fixes the `multi' build.
2016-09-08 08:56:34 +02:00
Werner Lemberg 4e659d7ead [truetype] More fixes for handling of GX deltas.
Problems reported by Bob Taylor <Bob.Taylor@monotype.com>.

* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Fix rough
sanity test for glyph variation array header size.
Always set stream position before reading packed x and y deltas.
Fix thinko w.r.t. `localpoints' array.
2016-09-03 18:14:00 +02:00
Werner Lemberg a4c2a31138 [truetype] Fix `MPS' instruction.
According to Greg Hitchcock, MPS in DWrite really returns the point
size.

* src/truetype/ttobjs.h (TT_SizeRec): Add `point_size' member.

* src/truetype/ttdriver.c (tt_size_request): Set `point_size'.

* src/truetype/ttinterp.h (TT_ExecContextRec): Add `pointSize'
member.

* src/truetype/ttinterp.c (TT_Load_Context): Updated.
(Ins_MPS): Fix instruction.
2016-08-22 19:32:34 +02:00
Werner Lemberg cf4224adb9 [truetype] Fix compiler warning.
* src/truetype/ttgload.c (load_truetype_glyph): Add cast.
2016-08-16 06:44:23 +02:00
Alexei Podtelezhnikov 125f2b63a5 * src/truetype/ttinterp.c (Pop_Push_Count): Revert changes. 2016-08-11 23:40:05 -04:00
Alexei Podtelezhnikov 49d474f6f6 * src/truetype/ttinterp.c (TT_RunIns): Minor and formatting. 2016-08-11 23:03:09 -04:00
Alexei Podtelezhnikov dce554b1bd * src/truetype/ttinterp.c (Pop_Push_Count): Fix some entries. 2016-08-11 07:29:19 +02:00
Behdad Esfahbod 8183eeb18d [truetype] Fix GX variation handling of composites.
* src/truetype/ttgload.c (load_truetype_glyph)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Check `ARGS_ARE_XY_VALUES' flag.
2016-08-06 23:12:55 +02:00
Werner Lemberg 053943a757 [truetype] Comment. 2016-07-30 00:27:48 +02:00
Werner Lemberg fae4ec0525 [sfnt, truetype] Don't abort on invalid `maxComponentDepth'.
Since 2016-05-16 we detect infinite recursion directly.

* src/sfnt/ttload.c (tt_face_load_maxp): Don't adjust
`maxComponentDepth'.
* src/truetype/ttgload.c (load_truetype_glyph): Don't abort if
`maxComponentDepth' is not valid.  Instead, simply adjust its value
and emit a tracing message.
2016-07-29 06:43:32 +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 7f63105c07 [truetype] Sanitizer fix, second try.
* src/truetype/ttgxvar.c (ft_var_readpackedpoints): Fix boundary
tests and use only one slot more.
2016-07-19 21:35:58 +02:00
Werner Lemberg 9f6426eb16 Thinko; fix previous commit. 2016-07-19 07:23:38 +02:00
Werner Lemberg e69f34b1e2 [truetype] Sanitizer fix.
* src/truetype/ttgxvar.c (ft_var_readpackedpoints): Increase array
to fix nested loops.
2016-07-19 07:06:19 +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
Behdad Esfahbod 69446ddcce [truetype] Make all glyphs in `Zycon' GX font work.
* src/truetype/ttgxvar.c (ft_var_readpackedpoints): Fix boundary
tests.
2016-07-16 10:52:38 +02:00
Werner Lemberg a3b61253a7 [truetype] Fix GX delta tracing.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Trace
relative point movements.
2016-07-16 08:16:16 +02:00
Werner Lemberg f147fb2881 [truetype] More fixes for GX.
This finally fixes the rendering of the cyclist and the lizard in
the `Zycon' font.

* src/truetype/ttgxvar.c (ft_var_readpackedpoints): `first' point
index is always cumulative.

(tt_handle_deltas): Rename to...
(tt_interpolate_deltas): ... This.
Add new parameter for output point array.
Update caller.

(TT_Vary_Apply_Glyph_Deltas): Add `points_out' array; it now holds
the intermediate results of `tt_interpolate_deltas' that are to be
added to `outline->points'.
2016-07-16 07:06:21 +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 631e218147 * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Fix tracing. 2016-07-14 06:25:05 +02:00
Behdad Esfahbod 0f9ddf20c8 [truetype] Fix gxvar delta interpolation.
The coordinates of the base font should be used for interpolation
purposes, NOT the current points (i.e., the result of accumulation
of previous deltas).

* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Initialize
`points_org' before looping over all tuples.
2016-07-14 06:08:39 +02:00
Werner Lemberg 605946af6d Conditionally compile environment support.
* include/freetype/internal/ftobjs.h, src/autofit/afmodule.c,
src/base/ftobjs.c, src/cff/cffdrivr.c, src/truetype/ttdriver.c:
Decorate with `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES' where
necessary.
2016-07-11 16:14:36 +02:00
Werner Lemberg 8f8ae8c52d Handle properties in `FREETYPE_PROPERTIES' environment variable.
This commit covers the most important one.

* src/autofit/afmodule.c (af_property_set): Handle `warping',
`darkening-parameters', and `no-stem-darkening'.

* src/cff/cffdrivr.c (cff_property_set): Handle
`darkening-parameters', `hinting-engine', and `no-stem-darkening'.

* src/truetype/ttdriver.c (tt_property_set): Handle
`interpreter-version'.
2016-07-11 15:11:38 +02:00
Werner Lemberg c3beb30a21 Add function `ft_property_string_set'.
This is a preparation for handling an `FREETYPE_PROPERTIES'
environment variable to control (some) driver properties.

No change in functionality.

* src/base/ftobjs.c (ft_property_do): Add `value_is_string'
parameter.
(ft_property_string_set): New function.
(FT_Property_Set, FT_Property_Get): Updated.

* include/freetype/internal/ftobjs.h: Updated.

* include/freetype/internal/services/svprop.h
(FT_Properties_SetFunc): Add `value_is_string' parameter.

* src/autofit/afmodule.c (af_property_set), src/cff/cffdrivr.c
(cff_property_set), src/truetype/ttdriver.c (tt_property_set):
Updated, emitting an error currently if `value_is_string' is set.
2016-07-10 07:11:45 +02:00
Werner Lemberg 474682ff87 * src/truetype/ttinterp.c (TInstruction_Function): Removed, unused. 2016-07-06 08:54:35 +02:00
Werner Lemberg 8ba407a7fe [truetype] Really fix deallocation in case of error (#47726).
* src/truetype/ttgload.c (load_truetype_glyph): Thinko; initialize
`outline.points' also.
2016-06-25 18:09:22 +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 01de37e54f [truetype] Make TT_LOADER_SET_PP support subpixel hinting [3/3].
* src/truetype/ttgload.c (TT_LOADER_SET_PP): Replace macro with...
(tt_loader_set_pp): ... this new function.
Update all callers.
2016-05-18 07:07:44 +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
Nikolaus Waxweiler 596157365a [truetype] New implementation of v38 bytecode interpreter [1/3].
This patch prepares data structures and the like.

See added comments in `ttinterp.h' for more information on this and
the following commits in the series.

* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): Assign values to differentiate
between subpixel versions.
(TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY,
TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL): New macros.

* include/freetype/ftttdrv.h (TT_INTERPRETER_VERSION_40): New macro.

* include/freetype/internal/tttypes.h (TT_FaceRec): Updated.

* src/truetype/ttinterp.h (TT_ExecContextRec): Define new fields
`subpixel_hinting_lean', `vertical_lcd_lean',
`backwards_compatibility', `iupx_called', iupy_called', and
`grayscale_cleartype' for new hinting mode.

* src/truetype/ttdriver.c (tt_property_set): Handle v38 and v40
interpreters conditionally.

* src/truetype/ttgload.c (TT_Hint_Glyph): Save phantom points unless
in v38 backwards compatibility mode.
Updated.
(compute_glyph_metrics): Add v38 backwards compatibility mode
constraint for adjusting advance widths.
Updated.
(tt_loader_init): Handle new flags `subpixel_hinting_lean',
`grayscale_cleartype', and `vertical_lcd_lean'.
Updated.
(tt_get_metrics, TT_Process_Simple_Glyph, TT_LOADER_SET_PP):
Updated.

* src/truetype/ttobjs.c (tt_driver_init): Conditionally set
default interpreter version number.

* src/truetype/ttsubpix.c, src/truetype/ttsubpix.h: Updated.
2016-05-18 06:57:59 +02:00
Werner Lemberg 533887a947 Whitespace, formatting. 2016-05-16 20:38:41 +02:00
suzuki toshiya a7d8bdbcfe [truetype] Improve the recursive reference detector.
The previous fix for #46372 misunderstood a composite glyph referring
same component twice as a recursive reference.  See the discussion

http://lists.gnu.org/archive/html/freetype/2016-05/msg00000.html

Thanks to Khaled Hosny for finding this issue.

* src/truetype/ttgload.c (ft_list_get_node_at): A function to get
the i-th node from FT_List.  (load_truetype_glyph): In the traversal
scan of the reference tree in the composite glyph, we clear the
nodes filled by previous sibling chain.
2016-05-16 21:57:26 +09:00
Werner Lemberg 0b3cb8a8af [cff, truetype] Fix logic for `FT_Property_Set'.
Otherwise some properties could be set to arbitrary values, which is
harmless, but querying could give wrong positive results.

* src/cff/cffdrivr.c (cff_property_set) [hinting-engine],
* src/truetype/ttdriver.c (tt_property_set) [interpreter-version]:
Only allow defined values.
2016-05-05 12:28:48 +02:00
Werner Lemberg 432e00db2e [truetype] Fix deallocation in case of error (#47726).
* src/truetype/ttgload.c (load_truetype_glyph): Initialize fields in
`outline' that are going to be deallocated in case of error.
2016-04-24 08:14:07 +02:00
Behdad Esfahbod 99eff67824 [truetype] Another fix for non-intermediate GX tuples.
* src/truetype/ttgxvar.c (ft_var_apply_tuple): Add some missing
cases.
2016-04-16 07:32:23 +02:00
Alexei Podtelezhnikov e85422606d Typos. 2016-04-08 23:21:34 -04:00
Werner Lemberg b663307320 * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Minor.
This fixes an AddressSanitizer issue:

  ttgload.c:430:7: runtime error: null pointer passed as argument 1,
                   which is declared to never be null
2016-03-22 08:26:55 +01:00
Behdad Esfahbod 74c0a72d52 [truetype] Fix handling of non-intermediate GX tuples.
We probably did not notice this as all fonts we tested had only
tuple_coords[i] be +1 or -1 for non-intermediate tuples.

* src/truetype/ttgxvar.c (ft_var_apply_tuple): Implement it.
2016-03-09 20:35:27 +01:00
Werner Lemberg 3295039107 Whitespace. 2016-02-15 12:54:40 +01:00
Werner Lemberg 9cc2d46785 Minor. 2016-02-05 11:52:50 +01:00
Nikolaus Waxweiler 1d8d0b4ef9 Remove unpatented hinter (3/3).
* include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_UNPATENTED_HINTING): Remove.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
`ignore_unpatented_hinter' field.
Update users.
(FT_DEBUG_HOOK_UNPATENTED_HINTING): Remove.
Update users.

* include/freetype/internal/tttypes.h (TT_FaceRec): Remove
`unpatented_hinting' field.
Update users.

* src/base/ftpatent.c (_tt_check_patents_in_range,
_tt_check_patents_in_table, _tt_face_check_patents): Remove.
(FT_Face_CheckTrueTypePatents, FT_Face_SetUnpatentedHinting):
Replace code with dummies.

* src/truetype/ttobjs.c (tt_face_init): Remove now defunct code.
* src/truetype/ttobjs.h (TT_GraphicsState): Remove `both_x_axis'
field.
2016-01-28 14:11:14 +01: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
Derek B. Noonburg 4cdfefd4bd [truetype] Add another tricky font.
* src/truetype/ttobjs.c (TRICK_SFNT_IDS_NUM_FACES): Increase.
(sfnt_id): Add variant of `DFKaiShu'.
2016-01-19 07:12:44 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg 37412ff9f4 Don't use macro names that contain `__' [1/2].
Such macro names are reserved for both C and C++.

*/*: Replace macros of the form `__XXX_H__' with `XXX_H_'.
2016-01-12 21:37:13 +01:00
Werner Lemberg 4679bf83a6 Fix C++ compilation.
* src/autofit/afloader.c: Include FT_INTERNAL_CALC_H.

* src/truetype/ttgload.c (load_truetype_glyph): Pacify compiler.
2015-11-28 19:05:36 +01:00
Werner Lemberg 837285e407 [truetype] Remove integer to pointer conversion compiler warning.
Problem reported by Alexei.

* src/truetype/ttgload.c (load_truetype_glyph): Use a solution found
in the glib library to fix the issue.
2015-11-09 09:20:08 +01:00
Werner Lemberg 758d55e522 [truetype] Catch infinite recursion in subglyphs (#46372).
* include/freetype/internal/tttypes.h (TT_LoaderRec): New field
`composites'.

* src/truetype/ttgload.c: Include FT_LIST_H.
(load_truetype_glyph): Add composite subglyph index to a list;
abort if index is already in list.
(tt_loader_init): Updated.
(tt_loader_done): New function.
(TT_Load_Glyph): Call `tt_loader_done'.
2015-11-04 11:44:47 +01:00
Werner Lemberg 040edaf5fb [truetype] Better tracing of composite glyphs.
* src/truetype/ttgload.c (TT_Load_Composite_Glyph,
load_truetype_glyph): Implement it.
2015-11-04 07:35:51 +01:00
Werner Lemberg 4188deacf3 Comments. 2015-10-30 08:07:56 +01:00
Werner Lemberg 6a19a7d332 [truetype] Fix sanitizing logic for `loca' (#46223).
* src/truetype/ttpload.c (tt_face_load_loca): A thinko caused an
incorrect adjustment of the number of glyphs, most often using far
too large values.
2015-10-26 15:40:22 +01:00
Werner Lemberg 5179c89f61 Comments. 2015-10-19 08:49:25 +02:00
Werner Lemberg dcfc4d9c21 [truetype] Better protection against malformed `fpgm' (#46223).
* src/truetype/ttobjs.c (tt_size_init_bytecode): Don't execute a
malformed `fpgm' table more than once.
2015-10-18 16:47:06 +02: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
Werner Lemberg 6de2a355ff Minor. 2015-10-15 08:40:12 +02:00
Werner Lemberg 43a96eb26f [truetype] Refine some GX sanity tests.
Use the `gvar' table size instead of the remaining bytes in the
stream.

* src/truetype/ttgxvar.h (GX_BlendRec): New field `gvar_size'.

* src/truetype/ttgxvar.c (ft_var_load_gvar): Set `gvar_size'.
(ft_var_readpackedpoints, ft_var_readpackeddeltas: New argument
`size'.
(tt_face_vary_cvt, TT_Vary_Apply_Glyph_Deltas): Updated.
2015-10-13 11:18:55 +02:00
Werner Lemberg 052f6c5649 [truetype] Another GX sanity test.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Check
`tupleCount'.
Add tracing message.
2015-10-13 08:24:32 +02:00
Werner Lemberg 7ef0d8661a [truetype] Fix memory leak for broken GX fonts (#46188).
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Fix scope of
deallocation.
2015-10-13 08:14:20 +02:00
Werner Lemberg f96094eef0 [truetype] Fix commit from 2015-10-10.
* src/truetype/ttgxvar.c (ft_var_load_gvar): Add missing error
handling body to condition.
2015-10-13 07:13:56 +02:00
Werner Lemberg da34673e54 [truetype] More sanity tests for GX handling.
These tests should mainly help avoid unnecessarily large memory
allocations in case of malformed fonts.

* src/truetype/ttgxvar.c (ft_var_readpackedpoints,
ft_var_readpackeddeltas): Check number of points against stream
size.
(ft_var_load_avar): Check `pairCount' against table length.
(ft_var_load_gvar): Check `globalCoordCount' and `glyphCount'
against table length.
(tt_face_vary_cvt): Check `tupleCount' and `offsetToData'.
Fix trace.
(TT_Vary_Apply_Glyph_Deltas): Fix trace.
Free `sharedpoints' to avoid memory leak.
2015-10-10 10:21:27 +02:00
Werner Lemberg c220d8b498 [truetype] Better protection against malformed GX data (#46166).
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Correctly
handle empty `localpoints' array.
2015-10-10 08:13:04 +02:00
Werner Lemberg 8651f37ad5 [truetype] Adjust number of glyphs for malformed `loca' tables.
* src/truetype/ttpload.c (tt_face_load_loca): Implement it.
2015-09-30 10:26:10 +02:00
Hin-Tak Leung 265ade8e80 Add new FT_LOAD_COMPUTE_METRICS load flag.
* include/freetype/freetype.h (FT_LOAD_COMPUTE_METRICS): New macro.
* src/truetype/ttgload.c (compute_glyph_metrics): Usage.
2015-09-26 14:51:30 +02:00
Werner Lemberg bd0438a461 Minor fixes for some clang warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Cast, possible missing
initialization.

* src/truetype/ttgload.c (TT_Process_Composite_Component): Cast.
2015-09-16 18:05:43 +02:00
Werner Lemberg 7f0f40116d [truetype] Fix integer type (#45965).
* src/truetype/ttobjs.c (tt_synth_sfnt_checksum): Implement it.
2015-09-15 07:23:53 +02:00
Alexei Podtelezhnikov 0963526435 Minor. 2015-08-31 23:14:46 -04:00
Alexei Podtelezhnikov ae258aa088 [truetype] Clean up.
* src/truetype/ttgload.c (TT_Process_Composite_Component): Use
`FT_Outline_Transform' and `FT_Outline_Translate'.
(translate_array): Dropped.
2015-08-14 23:23:18 -04:00
Werner Lemberg 14d6b5d748 [truetype] Introduce named instance access to GX fonts.
For functions querying a face, bits 16-30 of the face index can hold
the named instance index if we have a GX font.  The indices start
with value 1; value 0 indicates font access without GX variation
data.

* include/freetype/freetype.h (FT_FaceRec): Update documentation.
* include/freetype/internal/sfnt.h: Ditto.

* src/sfnt/sfobjs.c (sfnt_init_face)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Get number of named instances and
do argument checks.
(sfnt_load_face): Updated.

* src/truetype/ttobjs.c (tt_face_init)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Use named instance, overwriting
the style name.

* src/base/ftobjs.c (open_face_from_buffer,
open_face_PS_from_sfnt_stream): Updated.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Updated.
* src/cff/cffload.c (cff_font_load): Updated.

* src/cff/cffobjs.c (cff_face_init): Make function exit early for
pure CFF fonts if `font_index < 0'.
Updated.

* src/cid/cidobjs.c (cid_face_init): Updated.
* src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
* src/pfr/pfrobjs.c (pfr_face_init): Updated.
* src/type1/t1objs.c (T1_Face_Init): Updated.
* src/type42/t42objs.c (T42_Face_Init): Updated.
* src/winfonts/winfnt.c (fnt_face_get_dll_font, FNT_Face_Init):
Updated.

* docs/CHANGES: Updated.
2015-08-13 15:22:17 +02:00
Alexei Podtelezhnikov 98e8e99986 [truetype] Clean up types.
* src/truetype/ttobjs.c (TT_Size): Move declaration from here.
* include/freetype/internal/tttypes.h (TT_Size): ... to here.
(TT_LoaderRec): Switch to appropriate types for `face' and `size'.
* src/truetype/ttgload.c: Remove corresponding type casts.
* src/truetype/ttsubpix.c: Ditto.
2015-08-06 00:06:14 -04:00
Werner Lemberg 8dfc760161 * src/truetype/ttgload.c (load_truetype_glyph)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Fix crash for composite glyphs
having a depth greater than 1.
2015-08-03 12:23:30 +02:00
Werner Lemberg 70e9d81577 Fix more invalid left-shifts.
* src/pfr/pfrgload.c (pfr_glyph_load_compound): Use multiplication,
not left-shift.

* src/truetype/ttgxvar.c (ft_var_load_avar, ft_var_load_gvar,
tt_face_vary_cvt, TT_Vary_Apply_Glyph_Deltas): Use multiplication,
not left-shift.
2015-08-02 09:42:12 +02:00
Werner Lemberg 6343ba22a3 Fix some bugs found by clang's `-fsanitize=undefined' (#45661).
* src/base/ftrfork.c (FT_Raccess_Get_HeaderInfo): Only accept
positive values from header.
Check overflow.

* src/base/ftoutln.c (SCALED): Correctly handle left-shift of
negative values.

* src/bdf/bdf.h (_bdf_glyph_modified, _bdf_set_glyph_modified,
_bdf_clear_glyph_modified): Use unsigned long constant.

* src/bdf/bdfdrivr.c (BDF_Size_Select, BDF_Glyph_Load): Don't
left-shift values that can be negative.

* src/pcf/pcfdrivr.c (PCF_Size_Select, PCF_Glyph_Load): Don't
left-shift values that can be negative.

* src/raster/ftraster.c (SCALED): Correctly handle left-shift of
negative values.

* src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Don't left-shift
values that can be negative.

* src/truetype/ttgload.c (TT_Load_Composite_Glyph,
compute_glyph_metrics, load_sbit_image): Don't left-shift values
that can be negative.
2015-08-01 07:53:48 +02:00
Werner Lemberg f9be567f5f Better support of user-supplied C++ namespaces.
See

  http://lists.nongnu.org/archive/html/freetype-devel/2015-07/msg00008.html

for a rationale.

* src/autofit/afpic.h, src/base/basepic.h, src/cff/cffpic.h,
src/pshinter/pshpic.h, src/psnames/pspic.h, src/raster/rastpic.h,
src/sfnt/sfntpic.h, src/smooth/ftspic.h, src/truetype/ttpic.h
(FT_BEGIN_HEADER, FT_END_HEADER): Move macro calls to not enclose
header files that contain FT_{BEGIN,END}_HEADER macros by
themselves.

* src/autofit/aftypes.h [FT_DEBUG_AUTOFIT]: Include
FT_CONFIG_STANDARD_LIBRARY_H earlier.

* src/truetype/ttpic.h: Include FT_INTERNL_PIC_H.
2015-07-09 15:10:31 +02:00
Werner Lemberg 6f91896980 Minor documentation issue. 2015-07-04 11:35:28 +02: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 31d97df99f Make Jam support work again.
This is just very basic stuff and just a little bit tested on
GNU/Linux only.  I won't delve into this since I'm not a Jam user.

* Jamfile: Call `HDRMACRO' for `ftserv.h' also.
(DEFINES): Replace with...
(CCFLAGS): ... this.

* src/Jamfile: Don't call `HDRMACRO' for `internal.h'; this is
already handled in the top-level Jamfile.

* src/autofit/Jamfile (DEFINES): Replace with...
(CCFLAGS): ... this.
(_sources): Add missing files.

* src/cache/Jamfile: Don't call `HDRMACRO' for `ftcache.h'; it no
longer contains macro header definitions.

* src/base/Jamfile, src/cff/Jamfile, src/sfnt/Jamfile,
src/truetype/Jamfile (_sources): Add missing files.
2015-06-21 19:12:12 +02: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