Commit Graph

5199 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov fd7f92b6f0 * builds/unix/configure.raw [mmap]: Restore default path.
Fixes #1023.
2021-02-03 14:44:14 -05:00
Werner Lemberg 0636dc8af1 [psaux] Fix integer overflow.
Reported as

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

* src/psaux/psblues.c (cf2_blues_capture): Use `SUB_INT32`.
2021-02-03 19:16:02 +01:00
Alexei Podtelezhnikov d3befe1c72 * builds/unix/configure.raw [mmap support]: Explicitly handle Windows.
Fixes #1024.
2021-02-02 23:02:54 -05:00
Werner Lemberg 5635d5edc4 * builds/unix/configure.raw [mmap support]: Correctly handle Windows.
Fixes #1024.
2021-02-02 10:33:53 +01:00
Werner Lemberg 4554c6da42 * builds/windows/ftdebug.c: Synchronize with `src/base/ftdebug.c`. 2021-01-31 17:17:40 +01:00
Werner Lemberg 324612ceb2 Always provide logging API.
It's easier to have stubs if FT_DEBUG_LOGGING is undefined than to
modify `ftexport.sym` conditionally.

Problem reported by Alexei.

* src/base/ftdebug.c: Include `ftlogging.h`.

(FT_Trace_Set_Level, FT_Trace_Set_Default_Level, FT_Set_Log_Handler,
FT_Set_Default_Log_Handler) [!FT_DEBUG_LOGGING]: Provide stubs.
2021-01-31 14:28:44 +01:00
Werner Lemberg 939e844468 * builds/unix/configure.raw: Fix typo.
Bug introduced in Vincent's last commit bb33f03.

Fixes issue #1021.
2021-01-30 06:32:38 +01:00
Alexei Podtelezhnikov 7ae5609dbe * src/base/ftstroke.c (FT_Stroker_EndSubPath): Ignore tiny gaps.
Fixes bug #1020.
2021-01-27 16:08:08 -05:00
Alexei Podtelezhnikov 4c3bd2ab93 [stroker] Minor clean-up.
* src/base/ftstroke.c (FT_Stroker_{ConicTo,CubicTo}): Reset the last
line length.
(FT_Stroker_EndSubPath): Call `ft_stroker_process_corner'.
2021-01-27 15:54:34 -05:00
Werner Lemberg 601c5a611e Improve ChangeLog entry for last commit. 2021-01-27 13:04:55 +01:00
Vincent Torri bb33f03a71 * builds/windows/ftsystem.c: Add shared memory support on Windows. 2021-01-27 06:43:41 -05:00
Werner Lemberg c7cc947c0f Minor documentation fixes. 2021-01-23 15:45:10 +01:00
Werner Lemberg 209e9841f2 Require HarfBuzz 2.0.0.
This is needed to make commit f1f9705f9 work.

* CMakeLists.txt (HARFBUZZ_MIN_VERSION), builds/unix/configure.raw
(harfbuzz_pkg), meson.build (harfbuzz_dep): Updated.
2021-01-23 14:15:29 +01:00
Alexei Podtelezhnikov 8dc311320c * autogen.sh: Absorb `version.sed'.
* version.sed: Removed.
2021-01-22 20:27:15 -05:00
Alexei Podtelezhnikov b594cd90bd * srd/base/ftlcdfil.c (FT_Library_SetLcdGeometry): Fix return value. 2021-01-19 07:35:38 -05:00
Nikolaus Waxweiler f1f9705f93 [afshaper] Fix hb_ot_tags_from_script deprecation warning.
* autofit/afshaper.c (af_shaper_get_coverage): Copy the source code
of the function as suggested in
https://github.com/harfbuzz/harfbuzz/issues/2737 and adjust to handle
at most three tags.
2021-01-17 17:33:50 +00:00
Werner Lemberg d35c7f7cba * src/tools/update-copyright-year: Fix single-year entry handling. 2021-01-17 08:44:00 +01:00
Werner Lemberg b6e8a71266 Update all copyright notices. 2021-01-17 07:18:48 +01:00
Alexei Podtelezhnikov 4e7a01840d * builds/unix/unixddef.mk: Remove the second DEVEL_DIR definition. 2021-01-16 12:04:35 -05:00
Werner Lemberg ba1a6acf28 [sfnt] Additional checks for 'colr' table presence.
* sfnt/ttcolr.c (tt_face_get_colr_glyph_paint,
tt_face_get_colorline_stops, tt_face_get_paint): Additional checks
for whether colr table is present.  Prevents crashes when these
methods are called on non-COLR fonts.
2021-01-15 10:09:00 +01:00
Dominik Röttsches 53fea87745 Add config option to test for 'COLR' v1 support in headers.
* include/freetype/config/ftoption.h (TT_SUPPORT_COLRV1): New macro
so that clients can test whether the FreeType checkout that they are
building against supports the 'COLR' v1 API.  This is intended to be
a temporary solution until 'COLR' v1 support is released in a
FreeType version and such a check can be made by using the version
number instead.
2021-01-14 16:06:03 +01:00
Dominik Röttsches 4b58cf47cc [base] Fill 'COLR' v1 API templates to make them work (#59703).
* src/base/ftobjs.c (FT_Get_Color_Glyph_Paint, FT_Get_Paint_Layers,
FT_Get_Paint, FT_Get_Colorline_Stops): Add basic sanity checks,
check for existence of `FT_Face`, check arguments and delegate calls
for the respective 'COLR' v1 API to the SFNT driver.
2021-01-14 15:56:04 +01:00
Dominik Röttsches d3e95d97a0 [sfnt] Register 'COLR' v1 API in driver (#59703).
* include/freetype/internal/sfnt.h (TT_Get_Color_Glyph_Paint_Func,
TT_Get_Paint_Layers_Func, TT_Get_Colorline_Stops_Func,
TT_Get_Paint_Func): New function pointer types.
(SFNT_Interface): Add them.
(FT_DEFINE_SFNT_INTERFACE): Updated.

* src/sfnt/sfdriver.c (PUT_COLOR_LAYERS_V1): New macro.
(sfnt_interface): Add new function pointers.
2021-01-14 15:56:04 +01:00
Dominik Röttsches 6260b4901c [sfnt] Add 'COLR' v1 API to retrieve color layers (#59703).
* src/sfnt/ttcolr.c (tt_face_get_paint_layers): New function to get
the layers of a `PaintColrLayers` table in the font, using an
`FT_LayerIterator` from an `FT_PaintColrLayers` object retrieved via
`tt_face_get_paint`.

* src/sfnt/ttcolr.h: Updated.
2021-01-14 15:56:04 +01:00
Dominik Röttsches be06a9d002 [sfnt] Add 'COLR' v1 API to iterate color stops (#59703).
* src/sfnt/ttcolr.c (tt_face_get_colorline_stops): New function to
return the current `FT_ColorStop` object from `FT_ColorStopIterator`.
Also increment the iterator.

* src/sfnt/ttcolr.h: Updated.
2021-01-14 15:56:04 +01:00
Dominik Röttsches cdad4db424 [sfnt] Add API to get actual paint from `FT_OpaquePaint` (#59703).
* src/sfnt/ttcolr.c (tt_face_get_paint): New function to resolve an
`FT_OpaquePaint` paint reference into an `FT_COLR_Paint` object of a
certain format, which contains the detailed information stored in a
paint of the respective format.
(read_paint): New function to provide the format specific parsing
and to populate the data members of each specific `FT_COLR_Paint`
subtype.
(read_color_line): New function to parse retrieved color line
information into an `FT_ColorLine` object, which has information
about the color line extend mode as well as an
`FT_ColorStopIterator` object.

* src/sfnt/ttcolr.h: Updated.
2021-01-14 15:56:04 +01:00
Dominik Röttsches 9e422b67c8 [sfnt] Add API to retrieve 'COLR' v1 root paint (#59703).
* src/sfnt/ttcolr.c (BaseGlyphV1Record): New structure.
(tt_face_load_colr): Handle version 1 table header.
(find_base_glyph_v1_record): New auxiliary function.
(tt_face_get_colr_glyph_paint): New function to find the root
`FT_OpaquePaint` object for a given glyph ID.

* src/sfnt/ttcolr.h: Updated.
2021-01-14 15:56:03 +01:00
Dominik Röttsches 08dba4dc35 Add new methods required for 'COLR' v1 to public API (#59703).
* include/freetype/freetype.h (FT_Get_Color_Glyph_Paint): New method
for retrieving the root paint object for a color glyph by specifying
a glyph ID.
(FT_Get_Paint_Layers): New method for retrieving the layers of a
`PaintColorGlyph`.
(FT_Get_ColorLine_Stops): New method for retrieving the stops of a
color.
(FT_Get_Paint): New method for resolving an `FT_OpaquePaint` into an
`FT_COLR_Paint` object.
2021-01-14 15:50:37 +01:00
Dominik Röttsches f57c24db63 Add types required for 'COLR' v1 to public API (#59703).
* include/freetype/freetype.h (FT_PaintFormat, FT_ColorStopIterator,
FT_ColorIndex, FT_ColorStop, FT_PaintExtend, FT_ColorLine,
FT_Affine23, FT_CompositeMode, FT_OpaquePaint, FT_PaintColrLayers,
FT_PaintSolid, FT_PaintLinearGradient, FT_PaintRadialGradient,
FT_PaintGlyph, FT_PaintColrGlyph, FT_PaintTransformed,
FT_PaintTranslate, FT_PaintRotate, FT_PaintSkew, FT_PaintComposite,
FT_COLR_Paint): Adding structs and enum to represent paint format,
color stop information, gradient extend information, structs to
reference paint offsets, and to define transforms and compositions.
Adding a union type to represent the union of the structs,
distinguished by `FT_PaintFormat`.
2021-01-14 15:47:34 +01:00
Werner Lemberg 03ceda9701 * builds/*: s/BUILD_DIR/PLATFORM_DIR/.
The old variable name caused confusion.
2021-01-10 15:34:46 +01:00
Alexei Podtelezhnikov 3431553836 [builds] Revert `FTMODULE_H' changes.
* builds/toplevel.mk, builds/freetype.mk: Revert changes.
2021-01-08 13:22:34 -05:00
Alexei Podtelezhnikov 6f24bab68c [builds/windows] Fix up DLG build with VC++.
* builds/windows/vc2010/script.bat: Copy headers to include/.
* builds/windows/vc2010/freetype.vcxproj: Remove DLG paths.
2021-01-07 16:57:13 -05:00
Alexei Podtelezhnikov 576403f22b [builds] Relocate `FTMODULE_H'.
* builds/toplevel.mk: Place `FTMODULE_H' in include/.
* builds/freetype.mk: Simplify included path.
2021-01-07 16:02:32 -05:00
Werner Lemberg cbc14b10e6 Fix ABI incompatibility.
* include/freetype/ftimage.h (FT_Pixel_Mode): Don't insert
`FT_PIXEL_MODE_GRAY16' but append it.

* src/base/ftobjs.c (pixel_modes): Updated.
2021-01-07 10:13:15 +01:00
Werner Lemberg 8afc185433 Fix typos from last commit. 2021-01-07 10:04:24 +01:00
Alexei Podtelezhnikov 6369058eee [dlg] Move the headers to include/dlg to simplify their use.
* autogen.sh, builds/toplevel.mk: Copy headers to incluide/dlg.
* builds/freetype.mk, builds/windows/vc2010/freetype.vcxproj:
Simplify included path.
* include/freetype/internal/ftdebug.h: Simplify #include.
* src/dlg/rules.mk, .gitignore: Updated.
2021-01-07 00:13:23 -05:00
Werner Lemberg f88c00e45a * meson.build: Add summary.
Based on a patch from Vincent Torri <vincent.torri@gmail.com>.
2021-01-06 19:19:29 +01:00
Torsten Hilbrich c6345ca36d * meson.build: Fix 'png' build option (#59458).
Without this patch, 'png' is always required.
2021-01-06 08:55:16 +01:00
Alexei Podtelezhnikov 74f1b6be4a [builds/windows] Add SDF to VC2010 project.
* builds/windows/vc2010/freetype.vcxproj: Updated;
AfterBuild conveniences.
2021-01-04 23:35:01 -05:00
Werner Lemberg c6ff2556c8 [sdf] Use 'counter-clockwise', not 'anti-clockwise'.
We prefer US nomenclature.

* src/sdf/ftsdf.c (SDF_Contour_Orientation):
s/SDF_ORIENTATION-ACW/SDF_ORIENTATION_CCW/.
Update all users.
2020-12-26 10:50:21 +01:00
Werner Lemberg b6c8542dfc * src/base/ftobjs.c (pixel_modes): Updated. 2020-12-26 08:51:46 +01:00
Anuj Verma 10a5dfec7f [sdf] Remove custom memory tracker.
The internal FreeType memory tracker is sufficient.

* src/sdf/ftsdf.c (FT_DEBUG_INNER, FT_ASSIGNP_INNER, SDF_MemoryUser,
sdf_alloc, sdf_free, SDF_ALLOC, SDF_FREE,
SDF_MEMORY_TRACKER_DECLARE, SDF_MEMORY_TRACKER_SETUP,
SDF_MEMORY_TRACKER_DONE): Removed.

s/SDF_ALLOC/FT_ALLOC/.
s/SDF_FREE/FT_FREE/.

Other updates.
2020-12-26 08:34:38 +01:00
Werner Lemberg 3c983eb84a [sdf] Fix `make multi`.
* src/sdf/ftsdf.c: Include `ftoutln.h`.
2020-12-24 08:36:09 +01:00
Werner Lemberg aa1b5362d3 [sdf] Fix tracing.
* include/freetype/internal.fttrace.h: Add 'bsdf' component.

* src/sdf/ftbsdf.c, src/sdf/ftsdf.c (FT_COMPONENT): Define.
2020-12-24 08:32:04 +01:00
Anuj Verma b298a64464 [sdf] Add debugging function.
* src/sdf/ftsdf.c (sdf_shape_dump): New function.
2020-12-24 07:23:48 +01:00
Anuj Verma 6cd6df55c9 [sdf] Add 'bsdf' renderer to 'sdf' module.
* src/sdf/ftsdfrend.c (ft_bsdf_render): New function.

(ft_bitmap_sdf_renderer_class): New structure.
2020-12-24 07:23:48 +01:00
Anuj Verma d27d107f15 [sdf] Add interface functions for the 'bsdf' rasterizer.
* src/sdf/ftsdf.c (bsdf_raster_new, bsdf_raster_reset,
bsdf_raster_set_mode, bsdf_raster_render, bsdf_raster_done): New
functions.

(ft_bitmap_sdf_raster): New variable.

* src/sdf/ftsdf.h: Updated.
2020-12-24 07:23:48 +01:00
Anuj Verma a21134751c [sdf] Add function to copy SDF data into output bitmap.
* src/sdf/ftbsdf.c (finalize_sdf): New function.
2020-12-24 07:23:48 +01:00
Anuj Verma e2ae96b978 [sdf] Add '8-point sequential Euclidean distance mapping' algorithm.
* src/sdf/ftbsdf.c (compare_neighbor, first_pass, second_pass,
edt8): New functions.
2020-12-24 07:23:48 +01:00
Anuj Verma 6b9a8044be [sdf] Add function to copy source bitmap to distance map.
* src/sdf/ftbsdf.c (bsdf_init_distance_map): New function.
2020-12-24 07:23:48 +01:00
Anuj Verma 0f644f38e9 [sdf] Add functions to compute pixel edge distances.
* src/sdf/ftbsdf.c (compute_edge_distance, bsdf_approximate_edge):
New functions.
2020-12-24 07:23:48 +01:00
Anuj Verma c576176461 [sdf] Add function to find edge pixels in a grid of alpha values.
* src/sdf/ftbsdf.c (bsdf_is_edge): New function.
2020-12-24 07:23:48 +01:00
Anuj Verma 9bbb3611b3 [sdf] Add essential structures for the 'bsdf' rasterizer.
* src/sdf/ftbsdf.c (ONE): New macro.
(BSDF_TRaster, ED, BSDF_Worker): New structures.
(zero_ed): New constant.
2020-12-24 07:23:48 +01:00
Anuj Verma c6f394bf7d [sdf] Add 'sdf' module to non-gnumake build systems.
* include/freetype/config/ftmodule.h: Add both the 'sfd' and 'bsfd'
renderers to the list of modules.

* CMakeLists.txt (BASE_SRCS): Add 'sdf' single-object module.
2020-12-24 07:23:48 +01:00
Anuj Verma 05f6088df3 [sdf] Added basic overlapping contour support.
* src/sdf/ftsdf.c (sdf_generate_with_overlaps): New function.
(sdf_raster_render): Enable it.
2020-12-24 07:23:48 +01:00
Anuj Verma 879ca87f0b [sdf] Add build infrastructure.
* src/sdf/module.mk, src/sfd/rules.mk: New files.

* src/sdf/ftsdf.h (ft_sdf_raster): New forward declaration.

* include/freetype/ftmoderr.h (FT_MODERRDEF): Add error definition
for the 'sdf' module.

* include/freetype/internal/fttrace.h (FT_TRACE_DEF): Add trace
definition for the `sdf' module.

* modules.cfg (RASTER_MODULES): Add the `sdf' module to the list of
rasterizers.
2020-12-24 07:23:48 +01:00
Anuj Verma 665ac96792 [sdf] Add interface functions for the 'sdf' rasterizer.
* src/sdf/ftsdf.c (sdf_raster_new, sdf_raster_reset,
sdf_raster_set_mode, sdf_raster_render, sdf_raster_done): New
functions.
(ft_sdf_raster): New structure.
2020-12-24 07:23:48 +01:00
Anuj Verma 1010f2c39c [sdf] Add subdivision and bounding box optimization.
* src/sdf/ftsdf.c (sdf_generate_bounding_box): New function, which
is an optimized version of `sdf_generate`.
(sdf_generate_subdivision): New function.
2020-12-24 07:23:48 +01:00
Anuj Verma 986d3108ac [sdf] Add function to generate SDF.
* src/sdf/ftsdf.c (sdf_generate): New function, currently disabled.
This is a proof-of-concept implementation: It doesn't use any
optimization, it simply checks all grid points against all contours.
2020-12-24 07:23:48 +01:00
Anuj Verma 0d52f4ae0a [sdf] Add functions to get shortest distance from any edge/contour.
* src/sdf/ftsdf.c (sdf_edge_get_min_distance): New function.
(sdf_contour_get_min_distance): New function, currently disabled.
2020-12-24 07:23:48 +01:00
Anuj Verma 81e32986ca [sdf] Add shortest distance finding functions.
* src/sdf/ftsdf.c (get_min_distance_line, get_min_distance_conic,
get_min_distance_cubic): New functions.  Note that
`get_min_distance_conic` comes with two implementations (using an
analytical and an iterative method, to be controlled with the
`USE_NEWTON_FOR_CONIC` macro).
2020-12-24 07:23:48 +01:00
Anuj Verma c918b54f25 [sdf] Add function to resolve corner distances.
* src/sdf/ftsdf.c (resolve_corner): New function.
2020-12-24 07:23:48 +01:00
Anuj Verma a255125fe4 [sdf] Add essential math functions.
* src/sdf/ftsdf.c (cube_root, arc_cos) [!USE_NEWTON_FOR_CONIC]: New
auxiliary functions.

* src/sdf/ftsdf.c (solve_quadratic_equation, solve_cubic_equation)
[!USE_NEWTON_FOR_CONIC]: New functions.
2020-12-24 07:23:48 +01:00
Anuj Verma cd4138458a [sdf] Add utility functions for contours.
* src/sdf/ftsdf.c (get_control_box, get_contour_orientation): New
functions.
(split_conic, split_cubic, split_sdf_conic, split_sdf_cubic,
split_sdf_shape): New functions.
2020-12-24 07:23:47 +01:00
Anuj Verma 2de1b5630d [sdf] Add functions to decompose `FT_Outline`.
* src/sdf/ftsdf.c (sdf_move_to, sdf_line_to, sdf_conic_to,
sdf_cubic_to): New auxiliary decomposition functions.
(sdf_compose_funcs): New structure.
(sdf_outline_decompose): New function.
2020-12-24 07:23:47 +01:00
Anuj Verma cf0464d855 [sdf] Structs, enums, macros, and functions for 'sdf' rasterizer.
* src/sdf/ftsdf.c (FT_DEBUG_INNER, FT_ASSIGNP_INNER)
[FT_DEBUG_LEVEL_TRACE && FT_DEBUG_MEMORY]: New macros.
(SDF_MemoryUser) [FT_DEBUG_LEVEL_TRACE && FT_DEBUG_MEMORY]: New
struct for memory usage tracing.
(sdf_alloc, sdf_free) [FT_DEBUG_LEVEL_TRACE && FT_DEBUG_MEMORY]: New
functions for memory usage tracing.

(SDF_ALLOC, SDF_FREE): New macros for memory management.
(SDF_MEMORY_TRACKER_DECLARE, SDF_MEMORY_TRACKER_SETUP,
SDF_MEMORY_TRACKER_DONE): New macros to set up memory usage tracing.

(USE_NEWTON_FOR_CONIC, MAX_NEWTON_DIVISIONS, MAX_NEWTON_STEPS,
CORNER_CHECK_EPSILON, CG_DIMEN): New configuration macros for
controlling the process of finding the shortest distance.

(MUL_26D6, VEC_26D6_DOT): New auxiliary macros.

(SDF_TRaster, SDF_Edge, SDF_Contour, SDF_Shape, SDF_Signed_Distance,
SDF_Params): New structs for setting up SDF data.
(SDF_Edge_Type, SDF_Contour_Orientation): New enums for SDF data.

(zero_vector, null_edge, null_contour, null_shape, max_sdf): Useful
constants.

(sdf_edge_new, sdf_edge_done, sdf_contour_new, sdf_contour_done,
sdf_shape_new, sdf_shape_done): New constructors and destructors.
2020-12-24 07:23:47 +01:00
Anuj Verma c6ec87ec48 [sdf] Add raster parameters structure.
* src/sdf/ftsdf.h (SDF_Raster_Params): New structure.

* src/sdf/sdf.c: Include source files in order to make a single
object of the module.
2020-12-24 07:23:47 +01:00
Anuj Verma 56d27d32c4 [sdf] Add 'sdf' renderer.
* src/sdf/ftsdf.c: Add 'sdf' renderer along with its interface
functions.
Also add functions to set and get properties.
2020-12-24 07:23:47 +01:00
Anuj Verma 216270327d [sdf] Add common elements for 'sdf' and 'bsdf' renderers.
* src/sdf/ftsdfrend.h (SDF_Rendere_Module, ft_sdf_renderer_class,
ft_bitmap_sdf_renderer_class): New structures.

* src/sdf/ftsdfcommon.h (DEFAULT_SPREAD, MIN_SPREAD_MAX_SPREAD,
USE_SQUARED_DISTANCES): New macros.
(FT_INT_26D6, FT_INT_16D16, FT_26D6_16D16): New macros.
(FT_CALL, VECTOR_LENGTH_16D16): New macros.
(FT_26D6_Vec, FT_16D16_Vec, FT_16D16, FT_26D6, FT_6D10, FT_CBox):
New typedefs.
(square_root): New macro.

* src/sdf/ftsdferrs.h: Add module error setup.
2020-12-24 07:23:47 +01:00
Anuj Verma cd6ff28a17 [sdf] Add files for new 'sdf' module.
Here is a breakdown of what the files will contain.

* src/sdf/ftsdfrend.c, src/sdf/ftsdfrend.h: The 'sdf' and 'bsdf'
renderers.

* src/sdf/ftsdf.c, src/sdf/ftsdf.h: The rasterizer for the 'sdf'
renderer.
* src/sdf/ftbsdf.c, src/sdf/ftbsdf.h: The rasterizer for the 'bsdf'
renderer.

* src/sdf/ftsdfcommon.h: Commmon properties and functions for both
rasterizers.
* src/sdf/ftsdferrs.h: Common error defines.

* src/sdf/sdf.c: For building a single object of the entire module.
2020-12-24 07:23:47 +01:00
Anuj Verma 5a1b9d014b [base] Allow renderers of different formats.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): Do not return if the
glyph's slot format is `FT_GLYPH_FORMAT_BITMAP`.  The forthcoming
'bsdf' renderer will require bitmaps for processing.

* src/base/ftobjs.c (ft_add_renderer, ft_remove_renderer): Remove
renderer's glyph format check before adding and removing them.  The
'bsdf' renderer will have a format `FT_GLYPH_FORMAT_BITMAP`.
2020-12-24 07:23:47 +01:00
Anuj Verma ec9b6c314d Add data types required for the forthcoming 'sdf' module.
* include/freetype/freetype.h (FT_Render_Mode): Add new render mode
`FT_RENDER_MODE_SDF`, which will be used to generate SDF.

* include/freetype/ftimage.h (FT_Pixel_Mode): Add new pixel mode
`FT_PIXEL_MODE_GRAY16`, which will be the output of the 'sdf'
module.
(FT_RASTER_FLAG_SDF): New raster flag to be used internally by the
'sdf' module.

* include/freetype/fttypes.h (FT_F6Dot10): New data type.
2020-12-24 07:23:47 +01:00
Anuj Verma 3b9196c467 [base] Allow renderers of different formats.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): Do not return if the
glyph's slot format is `FT_GLYPH_FORMAT_BITMAP`.  The forthcoming
'bsdf' renderer will require bitmaps for processing.

* src/base/ftobjs.c (ft_add_renderer, ft_remove_renderer): Remove
renderer's glyph format check before adding and removing them.  The
'bsdf' renderer will have a format `FT_GLYPH_FORMAT_BITMAP`.
2020-12-24 07:23:47 +01:00
Werner Lemberg 2373074a2c * builds/windows/detect.mk (COPY): Make it work with `shell`.
Without this patch, we get the error

  builds/toplevel.mk:127: *** missing separator.  Stop.

Reported by Anuj, with a solution from Alexei.
2020-12-23 22:02:48 +01:00
Ignacio Casal Quinteiro 768022b98e meson.build (ft2_defines): Fix builds on Windows. 2020-12-23 11:30:19 +01:00
Tatsuyuki Ishi 0d5f1dd37c [autofit] Fix double division in stem darkening.
The old code used to divide the darkening amount by em_ratio twice,
leading to unnecessarily bold stems on certain fonts with higher
units per em (e.g. Inter). This patch fixes it.

The return value of af_loader_compute_darkening was also changed to
use 16.16 fixed point to get rid of a redundant truncation operation.
This should slightly improve the precision, although it's still
bottlenecked by the emboldening function, which uses 26.6 fixed point.

* src/autofit/afloader.[ch]
(af_loader_compute_darkening): Return FT_Fixed.
(af_loader_embolden_glyph_in_slot): Revise calculations.
2020-12-18 22:10:30 -05:00
Alexei Podtelezhnikov c948df52e4 * include/freetype/ftmodapi.h (FT_FACE_DRIVER_NAME): New public macro.
The driver name is needed for `FT_Property_Set' and `FT_Property_Get'.
2020-12-17 15:53:51 -05:00
Chris Liddell f6be92767d [truetype] Fix incremental metrics (#59503).
* src/truetype/ttgload.c (tt_get_metrics, load_truetype_glyph):
Previously, the code would populate the phantom points before
calling the `get_glyph_metrics` callback.  For formats like PCL XL
format 1, class 2 downloaded fonts (where metrics are removed from
the TTF header), this causes problems when the hinting program uses
the phantom points (misplaced and distorted glyphs) due to the
metrics being unset (all zeros).
(tt_get_metrics_incr_overrides): Renamed to...
(tt_get_metrics_incremental): ... this.  Updated caller

* include/freetype/ftincrem.h: Update the documentation to make it
clearer that `get_glyph_metrics` is to retrieve metrics from a
non-standard source, but *not* for the purpose of imposing custom
metrics.
2020-12-16 06:08:54 +01:00
Werner Lemberg a3edbfa983 [type42] Pacify static analysis tools (#59682).
* src/type42/t42objs.c (T42_Size_Init, T42_GlyphSlot_Init): Avoid
warnings about uninitialized variables.
2020-12-14 16:11:06 +01:00
Werner Lemberg 505943a6a4 * builds/unix/configure.raw: Don't set `FT_DEBUG_LOGGING`.
All debug options are handled exclusively in `ftoption.h`.
2020-12-07 17:08:37 +01:00
Werner Lemberg 272ae5ee2a * src/*: More fixes for using a '\n' in `FT_TRACE` and `FT_ERROR`. 2020-12-07 10:29:24 +01:00
Werner Lemberg 015a9b8d8f */*: s/FT_LOGGING/FT_DEBUG_LOGGING/. 2020-12-07 10:27:42 +01:00
Werner Lemberg 7d3ab6a7db * builds/toplevel.mk (do-dist): Remove `submodules` directory. 2020-12-05 09:43:45 +01:00
Werner Lemberg a6adb25626 * src/*: Don't use more than one '\n' in `FT_TRACE` and `FT_ERROR`.
This ensures good logging output, with all lines having a proper
prefix (if requested).
2020-12-05 09:43:45 +01:00
Werner Lemberg 74822f64b0 [base] Don't close 'stderr' after logging.
* src/base/ftdebug.c, builds/windows/ftdebug.c (ft_logging_deinit):
Fix it.
2020-12-05 09:43:45 +01:00
Werner Lemberg c764686bc9 * submodules/dlg: Updated to commit 9f0c8b22. 2020-12-05 09:43:45 +01:00
Werner Lemberg 92db149e9c * src/bdf/bdflib.c: Fix `-Wformat` warning. 2020-12-05 09:43:45 +01:00
Werner Lemberg f6b0fd7b79 Improve setup for 'dlg' library.
* autogen.sh (copy_submodule_file), builds/toplevel.mk: Redirect
stderr to `/dev/null`.

* builds/toplevel.mk: Move code block to handle 'dlg' stuff into
`check_platform` conditional.
Also fix wildcard expressions for guarding `git submodule` commands.
Also make file copying work with non-Unix platforms (untested).
2020-12-05 09:43:45 +01:00
Werner Lemberg fcdab61ed1 [build] Use gcc (and clang) in C99 mode.
Other compilers are unchanged.

* builds/compiler/gcc-dev.mk, builds/compiler/gcc.mk (ANSIFLAGS):
s/-ansi/-std=c99/.

* builds/freetype.mk (FT_CFLAGS): Remove `-std=c99`.

* builds/unix/configure.raw: Handle C99.
Remove no longer needed test for gcc 4.6 and earlier.
2020-12-05 09:43:42 +01:00
Werner Lemberg 1c229af2d2 [dlg] Fix compiler warnings.
* src/dlg/dlgwrap.c: Duplicate some feature test macros from
`dlg.c`, which must come first before loading standard headers.  For
example, `freetype.h` loads `stdio.h` if compiled in debug mode.
2020-12-04 16:19:42 +01:00
Werner Lemberg 7691588098 * src/type42/t42parse.c: Fix `-Wformat` warnings. 2020-12-04 16:19:42 +01:00
Priyesh Kumar 33bd25ca07 [builds/unix] Check for 'pthread' library.
* builds/unix/ax_pthread.m4: New file, taken from 'autoconf-archive'
git repository.

* builds/unix/configure.raw: Check for 'pthread'; also check whether
it works.
2020-12-04 16:19:42 +01:00
Werner Lemberg ce43d808dc [base] Implement vertical alignment of log printing.
Based on a patch by Priyesh.

* include/freetype/internal/fttrace.h (FT_MAX_TRACE_LEVEL_LENGTH):
New macro.

* src/base/ftdebug.c, builds/windows/ftdebug.c (ft_log_handler):
Print logs after a fixed width to handle different lengths of
`FT_COMPONENT` entries.
Use `ft_strrchr` to check for final newline character.
2020-12-04 16:19:42 +01:00
Priyesh Kumar ab0ea068ee Update logging related documentation.
* docs/DEBUG: Updates related to `FT_LOGGING`.

* README.git: Updates related to logging.
2020-12-04 16:19:42 +01:00
Priyesh Kumar 6d9e6b21e5 * src/*: Fix `-Wformat` warnings. 2020-12-04 16:19:42 +01:00
Priyesh Kumar 2a5d8e8ff8 [builds/windows] Changes to build 'dlg' with FreeType on Windows.
We only support Visual C++ 2010 and newer.

* builds/windows/vc2010/script.bat: New windows batch file to copy
necessary 'dlg' files from `submodules/dlg` to `src/dlg`.  This file
is used as a pre-built event in Visual C++.

* builds/windows/ftdebug.c: Synchronize with `src/base/ftdebug.c`.

* builds/windows/vc2010/freetype.vcxproj.filters: Add
`src/dlgwrap.c`.

* builds/windows/vc2010/freetype.vcxproj
(AdditionalIncludeDirectories): Add include files of dlg for 'Debug'
and 'Debug Static' configurations on both 'x64' and 'win32'
platforms.
(PreprocessorDefinitions): Add `FT_LOGGING` for 'Debug' and 'Debug
Static' configurations on both 'x64' and 'win32' platforms.
Add `DLG_STATIC' for 'Debug' configuration on 'x64' and 'win32'
platforms.
(DisableLanguageExtensions): We need to disable the `/Za` option
when building 'dlg' with FreeType as 'dlg' strictly follows the C99
standard.  Visual C++ produces behaves unexpectedly when
compiling a C99 file with `/Za` option enabled.
2020-12-04 16:19:42 +01:00
Priyesh Kumar 2a46d1f04e [base] Add public API to change log handling function.
* include/freetype/ftlogging.h (FT_Custom_Log_Handler): New function
typedef to store the custom callback logging function.
(FT_Set_Log_Handler, FT_Set_Default_Log_Handler): New functions to
set and reset custom log handler.

* include/freetype/internal/ftdebug.h (custom_output_handler): New
variable to support a custom callback logging function.
(FT_Logging_Callback): A new function typedef to print log using
custom callback logging function, which is set using
`FT_Set_Log_Handler`.
(FT_Log): Use it.

* src/base/ftdebug.c (FT_Set_Log_Handler,
FT_Set_Default_Log_Handler, FT_Logging_Callback): Add function
definitions.
2020-12-04 16:19:36 +01:00
Priyesh Kumar 5fea76cf0f [base] Add public API to change the levels of tracing components.
* include/freetype/ftlogging.h: New header file.

* include/freetype/internal/ftdebug.h [FT_LOGGING]: Include
`ftlogging.h`.

* src/base/ftdebug.c (ft_custom_trace_level): New variable.
(ft_debug_init): Update to support change of levels of tracing
components of FreeType at run-time.
(FT_Trace_Set_Level): New function to change the levels of tracing
components at run-time.
(FT_Trace_Set_Default_Level): New function to reset the levels of
tracing components back to default.
2020-12-01 09:25:53 +01:00
Priyesh Kumar d00cbc3f90 [base] Updates to print timestamp and name of `FT_COMPONENT` in logs.
* include/freetype/internal/ftdebug.h (FT_LOGGING_TAG,
FT_LOGGING_TAG_): New macros to resolve the value of `FT_COMPONENT'
into a string.
(ft_add_tag, ft_remove_tag): New functions to add and remove dlg tags.

* src/base/ftdebug.c: Add new variables to control the logging of
timestamp and name of `FT_COMPONENT` along with actual logs.
(ft_add_tag, ft_remove_tag): Add function definitions.
(ft_log_handler): Updates to print timestamp and name of
`FT_COMPONENT`.
(ft_debug_init) [FT_LOGGING]: Users can now control the logging of
timestamp and name of `FT_COMPONENT` by adding tags in the
`FT2_DEBUG` environment variable.
2020-12-01 09:25:53 +01:00
Priyesh Kumar d46bada285 [base] Add functions and variables to print logs to a file.
* include/freetype/internal/ftdebug.h: Added dlg's header files.
(FT_LOG): New macro to redirect trace logs to dlg's API's whenever
`FT_LOGGING' is defined.
(ft_logging_init, ft_logging_deinit): New functions to handle
initialization and uninitialization of logging related variables.
(ft_log_handler): New function to handle logs of FreeType.

* src/base/ftdebug.c: Add necessary logging related variables.
(ft_logging_init, ft_logging_deinit, ft_log_handler): Add function
definitions.

* src/base/ftinit.c (FT_Init_FreeType) [FT_LOGGING]: Call
`ft_logging_init`.
(FT_Done_FreeType) [FT_LOGGING]: Call `ft_logging_deinit`.

* src/base/ftobjs.c (FT_New_Library): Call `ft_debug_init` only if
`FT_LOGGING` is not defined.
2020-12-01 09:25:39 +01:00
Priyesh Kumar 34b1c897c1 [builds] Necessary changes to make 'dlg' compile.
* autogen.sh (copy_submodule_files): New script to copy all the
necessary source and include files from `submodules/dlg` to
`src/dlg`.

* src/dlg/dlgwrap.c: New wrapper file for `src/dlg.c`.  It enables
the build of 'dlg' if the `FT_LOGGING` macro is defined.

* src/dlg/rules.mk: New sub-Makefile.

* builds/freetype.mk (DLG_DIR): New variable to include the
header files of the 'dlg' library.
(INCLUDES): Add `DLG_DIR`.
(FT_CFLAGS): Add `-std=c99' flag.
Include `src/dlg/rules.mk` file to build 'dlg' library.
(OBJ_S, OBJ_M): Add `DLG_OBJS_M` and `DLG_OBJS_S`.

* builds/toplevel.mk: For builds directly from the git repository
we need to copy files from `submodule/dlg` to `src/dlg`.

* include/freetype/config/ftoption.h, devel/ftoption.h (FT_LOGGING):
New macro to enable or disable the logging facility in FreeType.
2020-12-01 09:20:32 +01:00
Priyesh Kumar 8da4b437b4 * .gitmodules: Add 'dlg' library's git repository as submodule. 2020-12-01 09:20:32 +01:00
Werner Lemberg 8cc4d0dc32 * src/tools/chktrcmp.py (trace_use_pat): Update to current use. 2020-12-01 08:48:28 +01:00
Alexei Podtelezhnikov 5abd252a0a [cff,cid,type1] Demote old engine for lack of CFF2.
* src/cff/cffobjs.c (cff_iriver_init): Always default to Adobe engine.
* src/cid/cidobjs.c (cid_driver_init): Ditto.
* src/type1/t1objs.c (T1_Driver_Init): Ditto.
2020-11-20 15:24:42 -05:00
Werner Lemberg 32b14552d6 * src/type42/t42parse.c (t42_parse_sfnts): More tracing messages. 2020-11-09 21:00:45 +01:00
Werner Lemberg 26e2a89598 * meson.build: Fix .pc file generation.
For backwards compatibility we need the libtool version, not the .so
number.

Reported by Nikolaus.
2020-11-04 21:00:22 +01:00
Werner Lemberg 804e625def [truetype] Minor update to forthcoming OpenType 1.8.4 standard.
* src/truetype/ttgxvar.c (ft_var_load_item_variation_store): Limit
size of `regionCount`.
2020-10-28 13:34:52 +01:00
Werner Lemberg 40c5681ab9 * meson.build: Fix 'harfbuzz' and 'brotli' build options (#59347).
Without this patch, 'harfbuzz' and 'brotli' are always required.

Patch submitted anonymously in Savannah bug report.
2020-10-26 18:09:56 +01:00
Ben Wagner 007c109b45 * src/sfnt/pngshim.c (Load_SBit_Png): Fix memory leak (#59322).
The issue is that `rows` is allocated but will not be freed in the
event that the call to `png_read_image` fails and calls `longjmp`.
2020-10-23 08:32:30 +02:00
Werner Lemberg 6a2b3e4007 * Version 2.10.4 released.
==========================

Tag sources with `VER-2-10-4'.

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

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/index.html, docs/freetype-config.1:
s/2.10.3/2.10.4/, s/2103/2104/.

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

* builds/unix/configure.raw (version_info): Set to 23:4:17.
* CMakeLists.txt (VERSION_PATCH): Set to 4.
2020-10-20 07:13:33 +02:00
Werner Lemberg a3bab162b2 [sfnt] Fix heap buffer overflow (#59308).
This is CVE-2020-15999.

* src/sfnt/pngshim.c (Load_SBit_Png): Test bitmap size earlier.
2020-10-19 23:45:28 +02:00
Alexei Podtelezhnikov 840ce58f94 * src/sfnt/tt{colr,cpal}.c: Fix signedness warnings from VC++. 2020-10-18 07:36:57 -04:00
Alexei Podtelezhnikov a93f50b611 * src/sfnt/sfwoff2.c (Read255UShort): Tweak types to please VC++. 2020-10-17 21:58:50 -04:00
Werner Lemberg 337670af0a * Version 2.10.3 released.
==========================

Tag sources with `VER-2-10-3'.

* docs/VERSION.TXT: Add entry for version 2.10.3.

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/index.html, docs/freetype-config.1:
s/2.10.2/2.10.3/, s/2102/2103/.

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

* builds/unix/configure.raw (version_info): Set to 23:3:17.
* CMakeLists.txt (VERSION_PATCH): Set to 3.
2020-10-10 18:14:57 +02:00
Werner Lemberg 40479fad93 [autofit] Synchronize with ttfautohint.
This corresponds to the following commits in the ttfautohint git
repository:

  bb6842bd3bd437b7b4a7921b0376c860f5e73d18  Typo, formatting.
  d5c91ddb1cb310257a3dfe9a8e20e1fc51335faa  Add Medefaidrin script.

* src/autofit/afblue.dat: Add blue zone data for Medefaidrin.
* src/autofit/afblue.c, src/autofit/afblue.h: Regenerated.

* src/autofit/afscript.h: Add Medefaidrin standard characters.

* src/autofit/afranges.c, src/autofit/afstyles.h: Add Medefaidrin
data.
2020-09-25 17:44:00 +02:00
Werner Lemberg e8ee98e669 Move `scripts/make_distribution_archives.py` to `src/tools`.
* scr/tools/scripts/make_distribution_archives.py: (_TOP_DIR,
_SCRIPT_DIR): Updated to new location.
(main): s/shutils.copyfile/shutils.copy/ to preserve file
permissions.
(main): Prefix source file paths with `git_dir` while copying files
to allow calls of the script from other places than the top-level
directory.
2020-09-25 08:07:43 +02:00
Werner Lemberg 4f13a43ab3 * src/cff/cffgload.c (cff_slot_load): Scale `vertBearingY`.
Towards the end of the the function there is a call to
`FT_Outline_Get_CBox` that retrieves the glyph bbox in scaled units.
That sets `horiBearing{X,Y}` and `vertBearingX` but `vertBearingY`
is left alone, and is not scaled.

Patch from Eric Muller <emuller@amazon.com>.
2020-09-24 09:35:24 +02:00
Werner Lemberg bed960d948 * src/base/ftobjs.c (FT_Load_Glyph): Trace glyph metrics. 2020-09-24 09:31:56 +02:00
Werner Lemberg 3ce0df52e2 [meson] Move auxiliary scripts to `builds/meson`.
Suggested by Alexei.

* scripts/*.py: Move meson scripts to...
* builds/meson/*.py: ... this new location.

* meson.build: Updated.
2020-09-22 20:05:37 +02:00
David Turner d686f2ff9c Add python script for building tarballs.
* scripts/make_distribution_archives.py: New file.

This standalone Python script should be equivalent to running `make
dist` with the Make-based build system, with the following minor
differences:

- Since `make distclean` doesn't always clean up `objs/` properly,
  `make dist` archives may contain some stale binaries like
  `objs/.libs/libfreetype.so.6` or others.

- `config.guess` and `config.sub` are not updated unless option
  `--gnu-config-dir=DIR` is used to specify the location of these
  files.

- Some bits of the auto-generated reference documentation may
  appear in slightly different order, probably due to issues related
  to mkdocs and docwriter.

As an example, the call

  scripts/make_distribution_archives.py /tmp/freetype2-dist

creates the following files under `/tmp/freetype2-dist`:

  freetype-<version>.tar.gz
  freetype-<version>.tar.xz
  ft<winversion>.zip
2020-09-21 09:27:51 +02:00
Werner Lemberg 46417607e6 * scripts/extract_freetype_version.py: Fix regex typos. 2020-09-21 09:21:46 +02:00
David Turner 66978a5887 Add Meson build project file.
Example usage:

  # Configure Meson build in directory `build-meson` to generate
  # release binaries comparable to to the ones from the
  # autotools/make build system.
  meson setup build-meson \
        --prefix=/usr/local \
        --buildtype=debugoptimized \
        --strip \
        -Db_ndebug=true

  # After configuring the Meson build with the above command,
  # compile and install to `/usr/local/`; this includes a pkg-config
  # file.
  ninja -C build-meson install

  # Alternatively, compile and install to `/tmp/aa/usr/local/...`
  # for packaging.
  DESTDIR=/tmp/aa ninja -C build-meson install

  # Generate documentation under `build-meson/docs`.
  ninja -C build-meson docs

Library size comparison for stripped `libfreetype.so` generated by
all three build systems:

  - Default build (autotools + libtool): 712 KiB
  - CMake build (RelWithDebInfo):        712 KiB
  - Meson build:                         712 KiB

* meson.build: New top-level Meson build file for the library.

* meson_options.txt: New file.  It holds user-selectable options for
the build, which can be printed with `meson configure`, and selected
at `meson setup` or `meson --reconfigure` time with
`-D<option>=<value>`.

* scripts/parse_modules_cfg.py: A script invoked by `meson.build` to
parse `modules.cfg` and extract important information out of it
(i.e., the list of modules).

* scripts/process_ftoption_h.py: New script invoked by `meson.build`
to process the original `ftoption.h` file.  It enables or disables
configuration macro variables based on the available dependencies.
This is similar to what other build systems are using (i.e., Meson's
`configure_file()` command is not used here).

* scripts/extract_freetype_version.py: New script invoked by
`meson.build` to extract the FreeType version number from
`<freetype/freetype.h>`.

* scripts/extract_libtool_version.py: New script invoked by
`meson.build` to extract the libtool `revision_info` data from
`builds/unix/configure.raw`, and to generate the corresponding
shared library suffix.

* scripts/generate_reference_docs.py: New script invoked by
`meson.build` to generate the FreeType 2 reference documentation
(using the `docwriter` and `mkdocs` packages, which must be already
installed).
2020-09-21 07:53:02 +02:00
Alexei Podtelezhnikov 20186d1be6 [raster] Improve the second pass (#58373).
Besides dropout control the second horizontal sweep is supposed to
clean up straight horizontal edges that are mishandled by the first
vertical sweep when a line passes through pixel centers.  This line
would present as perfectly aligned span edges in the second sweep.

* src/raster/ftraster.c (Horizontal_Sweep_Span): Replace the old
implementation with a better one focusing on aligned span edges only.
2020-09-11 23:47:54 -04:00
Alexei Podtelezhnikov c3721642f1 [raster] Tune SMART macro (#58352).
Windows seems to perform smart dropout control at 26.6 precision.
To mimick Windows independent of increased precision, we need to tweak
the macro so that some close calls break down rather than up.

* src/raster/ftraster.c (SMART): Tweak the macro.
2020-09-11 23:13:02 -04:00
Alexei Podtelezhnikov cb47331369 [raster] Introduce SMART macro.
* src/raster/ftraster.c (SMART): New macro for smart dropout rounding.
(Verstical_Sweep_Drop, Horizontal_Sweep_Drop): Use it.
2020-09-08 22:41:53 -04:00
Nikolaus Waxweiler fa82803f46 * ChangeLog: Add entry for last commit. 2020-09-03 11:11:41 +01:00
Alexei Podtelezhnikov 600d59e343 [truetype] Reduce Infinality footprint (cont'd).
* src/truetype/ttinterp.c (Ins_DELTAP): Shrink variable scope.
(Ins_SHPIX, Ins_MIRP): Revise if-logic.
2020-09-02 15:48:03 -04:00
Alexei Podtelezhnikov 51a5e3389c [truetype] Reduce Infinality footprint.
* src/truetype/ttinterp.c (Ins_SHPIX, Ins_MSIRP, Ins_MIAP, Ins_MDRP,
Ins_MIRP): Shrink variable scopes and consolidate ifdefs.
2020-09-02 00:02:28 -04:00
Alexei Podtelezhnikov e6c7e4b42b [truetype] Refactor compensation color.
* src/truetype/ttinterp.h (TT_Round_Func): Change the last argument.
* src/truetype/ttinterp.c (Ins_ROUND, Ins_NROUND, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Move compensation retrieval from here...
(Round_*): ... to here.
* src/truetype/ttobjs.c (tt_size_init_bytecode): Reserve zero
compensation at color index 3.
2020-09-01 21:49:52 -04:00
Alexei Podtelezhnikov 16ee2a22ab [smooth] Don't set target in direct mode.
* src/smooth/ftsmooth.c (ft_smooth_raster_overlap): Remove assignment.
(ft_smooth_raster_lcd) [!FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Ditto.
2020-08-28 23:08:42 -04:00
Alexei Podtelezhnikov 6730854c39 * src/smooth/ftsmooth.c (ft_smooth_raster_overlap): Limit width.
Segmentation fault reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24729
2020-08-25 23:16:27 -04:00
Werner Lemberg cdc009c24a * src/truetype/ttgload.c (TT_Get_VMetrics): Add tracing message. 2020-08-22 13:30:11 +02:00
Alexei Podtelezhnikov f9f6adb625 [truetype] Retain OVERLAP_SIMPLE and OVERLAP_COMPOUND.
For glyphs with OVERLAP_SIMPLE or OVERLAP_COMPOUND, set
FT_OUTLINE_OVERLAP to render them with direct oversampling, which
mitigates artifacts (see 3bb512bc9f).

* include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): Redefine to rhyme
with OVERLAP_SIMPLE.
* src/base/ftgloadr.c (FT_GlyphLoader_Rewind): Reset outline flags.
* src/truetype/ttgload.c
(TT_Load_Simple_Glyph): Retain OVERLAP_SIMPLE.
(load_truetype_glyph): Retain OVERLAP_COMPOUND.
2020-08-05 08:24:15 -04:00
Alexei Podtelezhnikov 3a1f4b7aaa * src/truetype/ttgload.c (TT_Load_Glyph): More tracing. 2020-08-04 22:17:05 -04:00
Werner Lemberg 8b3601324f Minor typos, formatting. 2020-08-04 10:48:42 +02:00
Alexei Podtelezhnikov f76f7fdecd Hide internal functions with SunPro.
* include/freetype/internal/compiler-macros.h
(FT_INTERNAL_FUNCTION_ATTRIBUTE) <__SUNPRO_C>: Define as __hidden.
2020-07-28 23:13:51 -04:00
Anuj Verma 3273521f40 Fix static compilation with Visual C.
* include/freetype/internal/compiler-macros.h
(FT_INTERNAL_FUNCTION_ATTRIBUTE) <_WIN32>: Define as empty.
2020-07-28 18:34:37 +02:00
Priyesh Kumar 53be1753de Fix `-Wformat' compiler warnings.
* src/*: Fix format specifiers.

* builds/unix/ftsystem.c (FT_Stream_Open): Ditto.
2020-07-28 07:33:40 +02:00
Werner Lemberg 8cfc41ae95 Fix `-Wformat' compiler warnings.
Problem reported by Priyesh kumar <priyeshkkumar@gmail.com>

* src/base/ftoutln.c (FT_Outline_Decompose): Fix number of arguments
to tracing macro.

* src/bdf/bdfdrivr.c (bdf_cmap_char_next, bdf_get_bdf_property):
Ditto.

* src/cache/ftcbasic.c (ftc_basic_family_get_count): Ditto.
Reformulate message.

* src/pcf/pcfdrivr.c (pcf_get_bdf_property): Ditto.

* src/sfnt/sfwoff2.c (woff2_open_font): Ditto.
Trace table offset, too.

* src/truetype/ttgxvar.c (ft_var_apply_tuple): Ditto.
2020-07-25 12:23:22 +02:00
Werner Lemberg b6183ea369 * src/sfnt/sfwoff2.c (woff2_decompress): Fix compiler warning.
Reported by Hin-Tak.
2020-07-23 13:03:22 +02:00
Werner Lemberg c922ffa5d2 * builds/unix/configure.raw: Fix inclusion of `ftoption.h'. 2020-07-12 07:52:55 +02:00
Werner Lemberg 96fb73efd5 Fix clang warnings.
* include/freetype/internal/autohint.h
(FT_DECLARE_AUTOHINTER_INTERFACE): New macro.
* src/autofit/afmodule.h: Use it to declare
`af_autofitter_interface'.

* include/freetype/internal/ftobjs.h (FT_DECLARE_GLYPH): New macro.
* src/base/ftbase.h: Use it to declare `ft_bitmap_glyph_class' and
`ft_outline_glyph_class'.

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

* src/cff/cffparse.c (cff_parser_run): Fix type of `t2_size'.

* src/pcf/pcfdrivr.c (pcf_cmap_char_next): Fix type of `result'.

* src/psaux/psauxmod.c (psaux_module_class): Use `FT_DEFINE_MODULE'.
* src/psaux/psauxmod.h: Declare `afm_parser_funcs',
`t1_cmap_classes', `cff_decoder_funcs', and `psaux_module_class'.

* src/pshinter/pshmod.c: Include `pshmod.h'.

* src/sfnt/sfwoff2.c (ROUND4, WRITE_SHORT): Fix implicit sign
conversion.
(compute_ULong_sum): Fix return type.
Fix implicit sign conversion.
(store_points): Fix type of `last_flag', `repeat_count', and `flag'.
Use casts to avoid warnings.
(reconstruct_glyf): Fix implicit sign conversion.
Use cast to avoid warning.
(get_x_mins): Fix implicit sign conversion.
* src/sfnt/ttcmap.c: Undef `TTCMAPCITEM'.
* src/sfnt/ttcmap.h: Define `TTCMAPCITEM' and include `ttcmapc.h' to
declare cmap classes.

* src/smooth/ftsmooth.c (ft_smooth_overlap_spans): Use cast.

* src/truetype/ttinterp.c (Ins_MIAP): Fix typo.
2020-07-07 16:58:14 +02:00
David Turner 0f35b042e0 [build] Really fix multi and C++ builds.
The following builds were still failing due to previous changes:

  make multi
  make multi CC="c++"
  make CC="c++"

This patch fixes the issues, which were missing includes to get the
right macro definitions in multi-build mode.

Also, `FT_UNUSED' is actually used by third-party code, so move it
back to `public-macros.h' to avoid breaking it.

* include/freetype/config/public-macros.h (FT_EXPORT): Remove
special definition for C++.
(FT_UNUSED): Define here instead of...
* include/freetype/config/compiler-macros.h: ... here.
(FT_FUNCTION_DECLARATION): Remove special definition for C++.
(FT_LOCAL_ARRAY_DEF): Fix definition.

* src/cache/ftccback.h, src/lzw/ftzopen.h, src/gxvalid/gxvmort.h,
src/gxvalid/gxvmorx.h: Add `FT_BEGIN_HEADER' and `FT_END_HEADER'.
2020-07-07 06:51:09 +02:00
David Turner cb4a943bc4 [build] Fix multi and C++ builds.
The following builds were failing due to previous changes:

  make multi
  make multi CC="c++"

* include/freetype/config/ftconfig.h: Remove `FT_END_HEADER'.

* include/freetype/config/ftheader.h (FT_BEGIN_HEADER,
FT_END_HEADER): Protect against redefinition.

* src/cache/ftccache.h, src/cache/ftcmru.h, src/pcf/pcfutil.h,
src/psaux/pserror.h, src/psaux/psft.h, src/psaux/psstack.h,
src/sfnt/woff2tags.h: Include `compiler-macros.h'.

* src/sfnt/woff2tags.c: Include `woff2tags.h'.
2020-07-06 11:49:00 +02:00
Werner Lemberg 2eb8f88626 [psaux] Improve `t1_decoder_parse_metrics' (#58646).
* src/psaux/t1decode.c (t1_decoder_parse_metrics): Copy
corresponding code from old engine's `t1_decoder_parse_charstrings'
function to handle `op_callsubr' and `op_return'.
2020-07-06 09:21:03 +02:00
David Turner b0667d2d36 [build] Improve visibility support of library function names.
* include/freetype/config/public-macros.h
(FT_PUBLIC_FUNCTION_ATTRIBUTE): New macro to tag functions as
public (and thus exportable).
(FT_EXPORT): Use it.

* include/freetype/config/compiler-macros.h
(FT_INTERNAL_FUNCTION_ATTRIBUTE): New macro to tag functions as
internal to the library (and thus hidden).  Note that on ELF
systems, all internal functions have hidden visibility, which avoids
the need to enforce this when invoking the compiler (e.g., with an
option like `-fvisibility=hidden').

(FT_FUNCTION_DECLARATION, FT_FUNCTION_DEFINITION): New base macros
to deal with C and C++ linkage issues at the same time.

(FT_LOCAL, FT_LOCAL_DEF, FT_LOCAL_ARRAY, FT_LOCAL_ARRAY_DEF,
FT_BASE, FT_BASE_DEF, FT_EXPORT_VAR, FT_BASE_CALLBACK,
FT_BASE_CALLBACK_DEF): Redefined using new macros.
2020-07-05 11:03:23 +02:00
David Turner bb66c8d8cf [build] Split off more stuff from `ftconfig.h'.
* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off macro definitions
required by the FreeType API headers to...
* include/freetype/config/public-macros.h: ...this new file.

* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off macro definitions used
by the library but not to be exposed to clients to...
* include/freetype/config/compiler-macros.h: ...this new file.

* include/freetype/internal/*.h, src/raster/ftraster.h: Include
`compiler-macros.h' where needed.
2020-07-05 10:42:23 +02:00
David Turner 0322efb5e5 [build] Move mac support code to `mac-support.h'.
* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off mac-specific stuff
to...
* include/freetype/config/mac-support.h: ...this new file.

* CMakeLists.txt, builds/unix/configure.raw: Remove `/undef ->
#undef' string replacement; the affected code is no longer part of
the `ftconfig.h' template.
2020-07-05 09:59:29 +02:00
David Turner bd7251ac97 [build] Put integer type definitions into `integer-types.h'.
Refactor some of the `ftconfig.h' headers and template to move the
definition of the FreeType integer types (e.g., `FT_Int16') to a
common header file `freetype/config/integer-types.h'.

* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off integer type
definition stuff to...
* include/freetype/config/integer-types.h: ...this new file.

* builds/unix/ftconfig.h.in: Control the definition of
`FT_SIZEOF_INT' and `FT_SIZEOF_LONG' with macro
`FT_USE_AUTOCONF_SIZEOF_TYPES'.  If these are not defined, auto
detection happens in `integer-types.h' as usual based on `INTXX_MAX'
values.  Otherwise the autoconf-detected values are used.

* builds/unix/configure.raw (CPPFLAGS): Don't include path to
`config' directory.  Instead, ...
(FT_CONFIG_STANDARD_LIBRARY_H): Use complete path.
2020-07-05 09:52:23 +02:00
David Turner a4d9206754 [build] Rename `build/unix/ftconfig.in' to `ftconfig.h.in'.
Since we are no longer limited to 8.3 file names, it is simpler to
follow the usual conventions for template files.

* builds/unix/ftconfig.in: Renamed to...
* builds/unix/ftconfig.h.in: ...this.

* CMakeLists.txt, builds/unix/configure.raw: Updated.
2020-07-05 09:51:38 +02:00
Alexei Podtelezhnikov 3bb512bc9f [smooth] Introduce direct oversampling for overlaps.
This implements oversampling to metigate artifacts in pixels partially
covered by overlapping contours.  It turns out that the 4x4
oversampling is sufficient but, at least, quadruples the rendering
time.  The outline has to set FT_OUTLINE_OVERLAP to use this method.

* include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): New flag.
* src/smooth/ftsmooth.c (ft_smooth_render): Check it to...
(ft_smooth_raster_overlap): ... inflate outline and set up direct
rendering for oversampling with...
(ft_smooth_overlap_spans): ... new span function that integrates them.
2020-07-03 22:29:34 -04:00
Alexei Podtelezhnikov 19d39f43d2 [smooth] Use direct rendering mode in Harmony.
Instead of rendering 3 bitmaps side by side and reshuffling, we use
direct rendering to deliver the bitmaps on each third byte.

* src/smooth/ftsmooth.c (ft_smooth_raster_lcd)
[!FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Set up direct mode with...
(ft_smooth_lcd_spans): ... new span function.
2020-07-03 09:17:22 -04:00
Alexei Podtelezhnikov 2d67511a14 [smooth] Separate LCD paths from gray rendering.
This makes `ft_smooth_render' a lot smaller and easier to follow. It
also cleanly separates Harmony and ClearType-style LCD rendering
algorithms. Now I only wish to move LCD filtering and geometry from
FT_Library to FT_Renderer.

* src/smooth/ftsmooth.c (ft_smooth_render): Move LCD code from here...
(ft_smooth_raster_lcd, ft_smooth_raster_lcdv): ... to here.
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Reorganize #ifdef's.
2020-07-03 09:02:09 -04:00
Sebastian Rasmussen a443474755 [cff] Fix handling of `style_name == NULL' (#58630).
* src/cff/cffobjs.c (cff_face_init): If a call to `cff_strcpy' fails
by returning NULL in `cff_face_init', `remove_style' is still
called.  This means that the NULL pointer is dereferenced, causing a
crash.
2020-06-20 05:31:34 +02:00
Sebastian Rasmussen f594ffdc35 [cff] Fix another two memory leaks (#58629).
* src/cff/cffobjs.c (cff_size_init): If a call to `funcs->create'
fails to allocate one of the `internal->subfont' variables, make
sure to free `internal->topfont' and any successfully allocated
subfonts.
2020-06-19 18:55:49 +02:00
Sebastian Rasmussen 2e2f3cb5ba [psaux] Fix memory leak (#58626).
* src/psaux/psstack.c (cf2_stack_init): If `cf2_stack_init' fails to
allocate the stack, return error early.
2020-06-19 18:51:33 +02:00
Sebastian Rasmussen 09b98060d3 Fix memory leak (#58624).
* src/base/ftobjs.c (FT_New_Size): Avoid trying to free
  `size->internal`, unless `size' has been allocated. This
  mistake appeared in the fix for 58611.
2020-06-19 18:49:36 +02:00
Alexei Podtelezhnikov 6e722f2eaa [base] Rework d1180b5f95 until further notice.
* src/base/ftoutln.c (FT_Outline_Get_Orientation): Reject large
outlines.
2020-06-19 08:39:23 -04:00
Sebastian Rasmussen 8ed5a2477e [cff, cid] Fix segfaults in case of error (#58621).
* src/cff/cffobjs.c (cff_slot_done), src/cid/cidobjs.c
(cid_slot_done): If `ft_glyphslot_init' fails to allocate
`internal', then the class' `done_slot' callback (called by
`ft_glyphslot_done') must not dereference the pointer to `internal'.
2020-06-19 10:37:50 +02:00
Werner Lemberg d1180b5f95 [base] Fix UBSAN error.
Reported as

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

* src/base/ftoutln.c (FT_Outline_Get_Orientation): Avoid values
larger than 32 bits.
2020-06-19 08:18:26 +02:00
Werner Lemberg 4d364b6821 [woff2] Fix segfault.
Reported as

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

* src/sfnt/sfwoff2.c (get_x_mins): Check whether `loca' table
exists.
2020-06-19 05:41:37 +02:00
Stephen McDowell d924c5cf7e [sfnt] Support Intel compilers.
* src/sfnt/pngshim.c (premultiply_data): Intel compilers do not
currently support `__builtin_shuffle'.
2020-06-19 04:14:39 +02:00
Sebastian Rasmussen a4429959b0 [base] Fix memory leak (#58611).
* src/base/ftobjs.c (FT_New_Size): When the call to `clazz->init_size'
fails, make sure to free `size->internal'.
2020-06-19 03:57:21 +02:00
Sebastian Rasmussen 575b78d9e3 [cff] Fix memory leak (#58610).
* src/cff/cffobjs.c (cff_size_init): When the call to
`funcs->create' fails, make sure to free `internal'.
2020-06-19 03:53:27 +02:00
Werner Lemberg 74cebeae12 * src/cff/cffload.c (cff_index_get_pointers): Rename `t' to `tbl'. 2020-06-19 03:41:12 +02:00
Sebastian Rasmussen c8cd139c30 [cff] Free table upon error allocating other data (#58609).
* src/cff/cffload.c (cff_index_get_pointers): When new_bytes fails
to allocate, make sure to free the table.  Do the same for both
allocations if there is a later error.
2020-06-19 03:37:32 +02:00
Werner Lemberg 1658685967 Remove redundant inclusion of `ft2build.h'.
* */*: Remove `#include <ft2build.h>' where possible.

* include/freetype/freetype.h: Remove cpp error about missing
inclusion of `ft2build.h'.
2020-06-13 21:15:45 +02:00
David Turner e13391333f Make macros for header file names optional.
We no longer have to take care of the 8.3 file name limit; this
allows us (a) to introduce longer, meaningful file names, and (b) to
avoid macro names in `#include' lines altogether since some
compilers (most notably Visual C++) doesn't support this properly.

*/*: Replace

   #include FOO_H

with

   #include <freetype/foo.h>

or something similar.  Also update the documentation.
2020-06-08 13:31:55 +02:00
Werner Lemberg 9e6e903cc4 * src/sfnt/ttcmap.c (tt_face_build_cmaps): Trace number of cmaps. 2020-06-02 17:14:54 +02:00
David Turner 62fea391fa Remove obsolete HAVE_STDINT_H probing macro.
This macro was updated by the unix configure script and the
`CMakeLists.txt' one, but is never used in the source tree (nor is
<stdint.h> included anywhere).

* CMakeLists.txt, builds/unix/ftconfig.in: Don't handle
`HAVE_STDINT_H'.
2020-05-18 18:42:57 +02:00
David Turner 4eee13404d Remove Jamfile files from the tree.
These have not been used in a very, very long time, so better remove
them.  A corresponding patch will be submitted to the
`freetype2-demos' repository.

* src/Jamfile, src/*/Jamfile, Jamrules: Delete.
2020-05-18 17:56:06 +02:00
Alexei Podtelezhnikov 3f70e6d20c [smooth] Turn on LCD filtering during FreeType initialization.
* src/smooth/ftsmooth.c (ft_smooth_init): Enable LCD filtering.

* include/freetype/ftlcdfil.h: Document it, remove patent warnings.
* include/freetype/freetype.h (FT_Render_Mode): Updated.
* include/freetype/config/ftoption.h, devel/ftoption.h
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Do not mention patents.
2020-05-12 00:38:46 -04:00
Alexei Podtelezhnikov 652f886319 [smooth] Stop using dedicated LCD modules and classes.
The LCD modules were never truly independent. They mostly served as
a way to disable patented LCD rendering, which is no longer necessary.
The `smooth' module now handles LCD modes as well.

* src/smooth/ftsmooth.c (ft_smooth_lcd_renderer_class.
ft_smooth_lcdv_renderer_class): Deleted.
(ft_render_smooth): Reworked from `ft_render_smooth_generic'.
* src/smooth/ftsmooth.h: Remove dedicated LCD classes.
* src/smooth/module.mk: Remove dedicated LCD modules.
* include/freetype/config/ftmodule.h: Ditto.
* builds/amiga/include/config/ftmodule.h: Ditto.
* include/freetype/ftmodapi.h: Do not mention LCD modules.
2020-05-11 23:30:37 -04:00
Werner Lemberg 132f19b779 * Version 2.10.2 released. ==========================
Tag sources with `VER-2-10-2'.

* docs/VERSION.TXT: Add entry for version 2.10.2.

* README, Jamfile (RefDoc), src/base/ftver.rc,
builds/windows/vc2010/index.html, builds/windows/visualc/index.html,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/index.html, docs/freetype-config.1:
s/2.10.1/2.10.2/, s/2101/2102/.

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

* builds/unix/configure.raw (version_info): Set to 23:2:17.
* CMakeLists.txt (VERSION_PATCH): Set to 2.

* docs/CHANGES: Updated.
2020-05-09 07:09:40 +02:00
Jakub Alba a45da25349 * src/truetype/ttinterp.c (TT_RunIns): Adjust loop counter (#58319).
The font that exceeds the old limit is Icono Regular, version
1.00000.
2020-05-08 10:59:37 +02:00
Alexei Podtelezhnikov de60e7d3f8 * builds/freetype.mk: Refactor for readability. 2020-05-03 17:11:20 -04:00
Alexei Podtelezhnikov 49967cb610 [builds] Clean up Windows CE project files.
Remove version from filenames that caused a lot of polution in the
release process. Use VERSIONINFO resource instead.

* builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2008-ce/freetype.vcproj,
builds/windows/visualce/freetype.vcproj,
builds/windows/visualce/freetype.dsp: s/2101//g, but add `ftver.rc'.
* builds/wince/vc2008-ce/index.html,
builds/wince/vc2005-ce/index.html,
builds/windows/visualce/index.html: s/2101//g.
2020-05-02 13:50:33 -04:00
Alexei Podtelezhnikov a612da0e8b * devel/ft2build.h: Override FT_CONFIG_MODULES_H here as well. 2020-05-01 22:52:52 -04:00
Alexei Podtelezhnikov 9c850f5611 [builds/unix] Consolidate marco overrides (for the demos to see them).
* builds/unix/unix-cc.in (FT_CONFIG_MODULES_H, FT_CONFIG_OPTIONS_H):
Override them here...
* builds/freetype.mk: ... instead of here.
2020-05-01 22:30:15 -04:00
Werner Lemberg 11beee855e Allow setting `CC' in Unix build (#58051).
* builds/unix/unix-cc.in (CC): Use `override'.  The command line
  value of `CC' (if any) is stored already in `CCraw'.
2020-04-08 09:05:32 +02:00
Nikhil Ramakrishnan 7a019a63ed [woff2] Return if single stream operation fails.
* src/sfnt/sfwoff2.c (get_x_mins): Do it.

* src/sfnt/woff2tags.c: Remove unused include.
2020-04-04 14:06:37 +05:30
Nikhil Ramakrishnan 13c0df80dc [docs] Fix building docs if `srcdir' != `builddir'.
`docs/reference/*' was moved one directory up in commit 237fed6.

* builds/unix/unix-def.in (PIP): Remove variable.

* configure: Create `docs' directory and copy assets from
`docs/markdown'.

* docs/README: Output directory is `reference'.
2020-03-22 23:29:51 +05:30
Nikhil Ramakrishnan 1fd3148713 [docwriter] Drop support for Python < 3.5.
Python versions < 3.5 have reached end-of-life and as such, no
security or bug fixes will be provided for those versions.  See

  https://devguide.python.org/#status-of-python-branches

for more information.

* Jamfile (RefDoc): Add `site' parameter.

* builds/detect.mk (std_setup): Update Python version requirement.

* builds/freetype.mk (refdoc-venv): Use pip as `python -m pip'.

* builds/unix/ax_compare_version.m4,
builds/unix/ax_prog_python_version.m4: Macros to detect Python
version.  New files.

* builds/unix/configure.raw: Check for Python >= 3.5 and remove
check for `pip'.

* docs/CHANGES, docs/INSTALL.GNU, docs/README: Updated.
2020-03-21 20:17:17 +05:30
Moazin Khatti 6a431038c9 [gzip] Support `gzip' encoded header conditionally.
In order to support `gzip' encoded header the call to
`inflateInit2' was modified in commit 6a92b1fadd.
However, this code breaks with the outdated internal version
of zlib.  This is a temporary fix to conditionally support
`gzip' encoded header whenever a system installation of zlib
is being used.

Problem report in

  https://lists.nongnu.org/archive/html/freetype-devel/2020-02/msg00023.html

* src/gzip/ftgzip.c (FT_Gzip_Uncompress): Change the the call to
`inflateInit2' depending on whether the system installation is
being used or the internal copy.
2020-03-02 18:21:27 +05:00
Ben Wagner 11975fe9f6 Fix state of `FT_Face' for buggy `gvar' tables (#57923).
By resetting the blend as implemented with this commit fonts with
invalid `gvar' tables may keep calling into `ft_var_load_gvar' from
`tt_set_mm_blend' and failing, but the font was invalid anyway and
we want to keep seeing the failure in `tt_set_mm_blend'.

* src/truetype/ttgxvar.c (ft_var_load_gvar): Calculate length of
offset array once.
Allocate arrays after `FT_FRAME_ENTER' (extra check before
allocating and avoid needing to free array later if error entering
frame).
Always call `FT_FRAME_EXIT'.
Consistently set counts immediately after array initialized.
Reset the blend (particularly `blend->glyphoffsets') on failure.
2020-02-29 20:29:14 +01:00
Werner Lemberg 149b9055e6 ChangeLog entry for last commit. 2020-02-29 20:28:03 +01:00
Ben Wagner 216e077600 [truetype] Add better checks for loading `gvar' table (#57905).
* src/truetype/ttgxvar.c (ft_var_load_gvar): Delay settings of any
`blend->xxxcount' values until the corresponding data has been
checked.
Also do some sanitizing to avoid a too early exit.

(TT_Vary_Apply_Glyph_Deltas): Improve tracing message.
2020-02-28 07:43:00 +01:00
Werner Lemberg 141da02816 Make `FT_HAS_*' and `FT_IS_*' really return true (#57906).
* include/freetype/freetype.h (FT_HAS_*, FT_IS_*): Implement it.
2020-02-27 09:49:06 +01:00
Dominik Röttsches 5b1a37af56 Fix for CFF space glyph regression (#57541).
* src/psaux/psft.c (cf2_decoder_parse_substrings): Replace early-out
  with FT_OFFSET.
2020-02-25 11:02:28 +01:00
Werner Lemberg fa147af4a5 [woff2] Fix font table access.
Reported as

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

* src/sfnt/sfwoff2.c (get_x_mins): Explicitly check for presence of
`head' table, which might not have been processed yet.
2020-02-22 18:30:46 +01:00
Werner Lemberg 6e49dff005 [psaux] Make `t1_decoder_parse_metrics' handle `op_div' (#57519).
* src/psaux/t1decode.c (t1_decoder_parse_metrics): Copy
corresponding code from old engine's `t1_decoder_parse_charstrings'
function.
2020-02-21 21:00:04 +01:00
Nikolaus Waxweiler 49f3394d7a [autofit] Add support for Hanifi Rohingya script.
* src/autofit/afblue.dat: Add blue zone data for Hanifi Rohingya.
* src/autofit/afblue.c, src/autofit/afblue.h: Regenerated.

* src/autofit/afscript.h: Add Hanifi Rohingya standard character.

* src/autofit/afranges.c, src/autofit/afstyles.h: Add Hanifi
  Rohingya data.
2020-02-19 20:04:31 +01:00
Werner Lemberg 84d56589f0 Require HarfBuzz 1.8.
* builds/unix/configure.raw, CMakeLists.txt: Request HarfBuzz 1.8.0
or newer.

We are going to add auto-hinter support for Hanifi Rohingya, which
was introduced in Unicode 11.0.
2020-02-19 19:22:49 +01:00
Werner Lemberg 8930cc9618 * src/sfnt/ttcmap.c (tt_face_build_cmaps): Ignore version (#57708). 2020-02-12 18:25:03 +01:00
Werner Lemberg 4a19a53d5a * src/truetype/ttinterp.c (TT_RunIns): Adjust loop counter (#57732).
The font that exceeds the old limit is Constantine, version 1.001.
2020-02-04 13:37:19 +01:00
Werner Lemberg e5038be704 Update all copyright notices. 2020-01-19 17:05:19 +01:00
Werner Lemberg fd03cf8816 [base] Fix `FREETYPE_PROPERTIES=type1:hinting-engine=adobe`.
* src/base/ftpsprop.c (ps_property_set) [hinting-engine]: Avoid an
incorrect return value that caused a warning.  The function did the
right thing, though.
2020-01-04 19:28:36 +01:00
Werner Lemberg 50b013871c Add reference to another oss-fuzz bug report. 2020-01-04 18:42:27 +01:00
Werner Lemberg a99a8e2863 [woff2] Fix memory leaks and a runtime warning.
Reported as

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

* src/sfnt/sfwoff2.c (compute_ULong_sum): Add missing cast.
(reconstruct_hmtx): Add missing deallocation calls.
2020-01-03 18:09:12 +01:00
Dominik Röttsches 10d8de7541 [truetype] Fix UBSan warning on offset to nullptr (#57501).
* src/truetype/ttinterp.c (Ins_CALL): Fail if `exc->FDefs' is null.
2020-01-02 11:14:01 +01:00