Commit Graph

158 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov 47574f7ea4 Update all copyright notices. 2024-01-27 11:11:22 -05:00
Alexei Podtelezhnikov 78464d1b0c * src/base/ftoutln.c (FT_Outline_Check): Fix C4701 warning. 2023-02-20 22:31:21 -05:00
Alexei Podtelezhnikov 34ed28d0fb [base] Clean up contour indexing.
* src/base/ftoutln.c (FT_Outline_Reverse, FT_Outline_EmboldenXY,
FT_Outline_Get_Orientation): Set the first and last indexes together.
(FT_Outline_Decompose): Ditto and check them more stringently.
* src/smooth/ftgrays.c (FT_Outline_Decompose)[STANDALONE_]: Ditto.
2023-02-20 16:33:45 +00:00
Alexei Podtelezhnikov 713580f41d * src/base/ftoutln.c (FT_Outline_Check): Update error code, clean up. 2023-02-20 15:58:04 +00:00
Alex Ringlein 74ea5454cc * src/base/ftoutln.c (FT_Outline_Reverse): Anchor first contour points.
A cubic contour has to always start from an on-point. Therefore, we
should not swap the first with the last point, which might be off, and
obtain an invalid contour. This does not matter for conic contours.
If anything, it also saves one swap there. Fixes #1207.
2023-02-16 22:38:35 -05:00
Werner Lemberg be724c8142 For debugging, avoid implicit conversion from integer to double.
Otherwise we get zillions of clang 15 warnings.

* src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/base/ftobjs.c, src/base/ftoutln.c, src/cff/cffparse.c,
src/raster/ftraster.c, src/sfnt/pngshim.c, src/truetype/ttgload.c,
src/truetype/ttgxvar.c, src/truetype/ttobjs.c, src/type1/t1gload.c: Use
`double` cast in debugging and tracing macros.
2023-02-08 21:09:32 +01:00
Werner Lemberg 65f8523706 Update all copyright notices. 2023-01-17 09:18:25 +01:00
Werner Lemberg d0cfb4e1b2 Update all copyright notices. 2022-01-11 10:54:10 +01:00
Werner Lemberg b6e8a71266 Update all copyright notices. 2021-01-17 07:18:48 +01: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
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
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 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 e5038be704 Update all copyright notices. 2020-01-19 17:05:19 +01:00
Dominik Röttsches 4270e9f324 Avoid more nullptr offset UBSan warnings (#57316).
* src/base/ftoutln.c (FT_Outline_Transform): Bail on empty points.
* src/cff/cffload.c (cff_subfont_load): Use `FT_OFFSET'.
* src/psaux/psft.c (cf2_decoder_parse_substrings): Early out if
`charstring_base' or `charstring_len' are null.
* src/sfnt/ttload.c (tt_face_load_name): Use `FT_OFFSET'.
2019-11-29 06:26:18 +01:00
Alexei Podtelezhnikov 300458eb94 Miscellaneous macro updates.
* src/base/ftoutln.c (SCALED): Updated.
* src/smooth/ftgrays.c (SCALED): Ditto.
(FLOOR, ROUND, CEILING): Removed.
* src/psaux/psfixed.h (cf2_fracToFixed): Updated.
2019-05-03 23:16:42 -04:00
Alexei Podtelezhnikov 1f271751a3 [smooth] Fix segfault in direct mode (#56092).
* src/base/ftoutln.c (FT_Outline_Render): Set missing clip_box for
direct mode.
* src/smooth/ftgrays.c (gray_raster_render): Use it.
2019-04-11 23:48:21 -04:00
Werner Lemberg 7585997024 Update all copyright notices. 2019-02-23 10:07:09 +01:00
Werner Lemberg f686ad46a3 Update copyright years. 2019-01-22 20:31:44 +01:00
Werner Lemberg c13635ee4b [base] Fix numeric overflow.
Reported as

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

* src/base/ftoutln.c (FT_Outline_Get_Orientation): Use `MUL_LONG'.
2018-10-29 21:25:10 +01:00
Werner Lemberg 9be656bb0c Remove `FT_Outline_{New,Done}_Internal'.
These public API functions(!) were always undocumented and have
escaped all clean-up efforts until now.

* include/freetype/ftoutln.h (FT_Outline_New_Internal,
FT_Outline_Done_Internal): Removed.

* src/base/ftoutln.h (FT_Outline_New_Internal,
FT_Outline_Done_Internal): Merge into...
(FT_Outline_New, FT_Outline_Done): ... these functions.

* docs/README: Updated.
2018-09-01 11:04:58 +02:00
Werner Lemberg a0dd16fb3d Don't use `trace_' prefix for FT_COMPONENT arguments.
* include/freetype/internal/ftdebug.h (FT_TRACE_COMP,
FT_TRACE_COMP_): New auxiliary macros to add `trace_' prefix.
(FT_TRACE): Use `FT_TRACE_COMP'.

*/* (FT_COMPONENT): Updated.
2018-08-15 18:13:17 +02:00
Alexei Podtelezhnikov e16bfbec4c [raster, smooth] Reinstate bitmap size limits.
This again moves outline and bitmap size checks one level up.

* src/base/ftoutln.c (FT_Outline_Render): Explicitly reject enormous
outlines.
* src/raster/ftrend1.c (ft_raster1_render): Reject enormous bitmaps
and, therefore, outlines that require them.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Ditto.

* src/raster/ftraster.c (ft_black_render): Remove outline size checks.
* src/smooth/ftgrays.c (gray_raster_render): Ditto.
[STANDALONE]: Remove `FT_Outline_Get_CBox' copy.
2018-08-09 22:18:00 -04:00
Werner Lemberg 799d27b0b6 Fix clang warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Fix type of
`orientation'.

* src/gxvalid/gxvcommn.c (gx_lookup_value_read): Fix signature.

* src/pcf/pcfread.c (pcf_get_encodings): Fix type of some variables.
Add cast.

* src/type1/t1load.c (parse_weight_vector): Fix cast.
2018-08-04 06:39:11 +02:00
Werner Lemberg 9f15370e56 * src/base/ftoutln.c (FT_Outline_Get_Orientation): Init `cbox'.
Taken from patch #9667, written by Steve Langasek
<vorlon@debian.org>.

This fixes a build failure (most probably a bug in gcc) on ppc64el
when building with -O3.
2018-07-12 07:31:26 +02:00
Werner Lemberg 9ac9060df0 [GSoC] src/*.*: Convert block comments to `light' style.
This monster commit was created by applying Nikhil's scripts
`docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.

No change in functionality, of course.

I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
2018-06-03 09:08:41 +02:00
Werner Lemberg 67697d0076 * src/base/ftoutln.c (FT_Outline_Decompose): Improve error tracing. 2018-04-22 21:15:10 +02:00
Werner Lemberg 0a0c22569d Update copyright year. 2018-01-02 09:33:57 +01:00
Werner Lemberg 6498551921 * src/base/ftoutln.c (FT_Outline_Translate): Fix integer overflow.
Reported as

  https://bugs.chromium.org/p/chromium/issues/detail?id=772775
2017-10-09 07:45:03 +02:00
Werner Lemberg dcd8de272f */*: Remove `OVERFLOW_' prefix.
This increases readability.
2017-06-09 11:21:58 +02:00
Werner Lemberg fbe2fe4c75 Handle some integer overflow run-time errors (#46149, #48979).
This commit (mainly for 32bit CPUs) is the first of a series of
similar commits to handle known integer overflows.  Basically, all
of them are harmless, since they affect rendering of glyphs only,
not posing security threats.  It is expected that fuzzying will show
up more overflows, to be fixed in due course.

The idea is to mark places where overflows can occur, using macros
that simply cast to unsigned integers, because overflow arithmetic
is well defined in this case.  Doing so suppresses run-time errors
of sanitizers without adding computational overhead.

* include/freetype/internal/ftcalc.h (OVERFLOW_ADD_INT,
OVERFLOW_SUB_INT, OVERFLOW_MUL_INT, OVERFLOW_ADD_LONG,
OVERFLOW_SUB_LONG, OVERFLOW_MUL_LONG): New macros.

* src/base/ftcalc.c (FT_RoundFix, FT_CeilFix, FT_Matrix_Multiply,
FT_Matrix_Multiply_Scaled, FT_Vector_Transform_Scaled,
ft_corner_orientation): Use new macros.

* src/base/ftoutln.c (FT_Outline_Get_Orientation): Use new macros.
2017-05-29 13:29:28 +02:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 24be60b5f1 */*: Use hex numbers for errors in tracing messages. 2017-01-01 08:20:38 +01: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
Werner Lemberg 31f2dc1946 [raster, smooth] Directly test outline size (#47500).
This improves stand-alone compilation.

* src/base/ftoutln.c (FT_Outline_Render): Move cbox size test to...

* src/raster/ftraster.c (ft_black_render), src/smooth/ftgrays.c
(gray_raster_render): ...these functions.
2016-03-23 07:31:59 +01:00
Alexei Podtelezhnikov 495de6cc72 [base] Refuse to render enormous outlines (#47114).
The goal is to avoid integer overflows in the rendering algorithms.
The limit is chosen arbitrarily at some 2^18 pixels, which should be
enough for modern devices including printers.

* src/base/ftoutln.c (FT_Outline_Render): Check CBox and reject
enormous outlines.
2016-03-06 23:54:34 -05:00
Werner Lemberg 0d053bac84 Fix runtime errors found by clang's sanitizer (#47082).
* src/base/ftobjs.c (FT_Render_Glyph_Internal), src/base/ftoutln.c
(FT_Outline_Copy), src/cache/ftcsbits.c (ftc_sbit_copy_bitmap):
Properly handle empty input buffer.
2016-02-07 19:25:56 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg e484d36b2b [base] Pacify compiler (#46266).
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Initialize `in' and
`anchor'.
2015-10-21 20:48:27 +02:00
Alexei Podtelezhnikov c14ae9c5fd * src/base/ftoutln.c (FT_Outline_Get_Orientation): Fix overflow (#46149). 2015-10-10 22:28:26 -04: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
Alexei Podtelezhnikov 6ec0434ec9 Minor refactoring. 2015-08-30 22:50:48 -04:00
Werner Lemberg 340e59da3a Minor formatting. 2015-08-18 05:56:51 +02:00
Alexei Podtelezhnikov a0172d10e8 [base] Improve emboldener (#45596).
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Correct displacement
of zero-lenght segments.
2015-08-17 22:58:59 -04:00
Alexei Podtelezhnikov 815c32469b Minor. 2015-08-17 21:48:46 -04: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 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 9ef02bd41a [base] Speed up emboldening.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Use `FT_Vector_NormLen'.
2015-06-29 22:39:10 -04:00
Alexei Podtelezhnikov b6c511d9d0 * src/base/ftoutln.c: Minor. 2015-04-24 00:10:40 -04:00