summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* [smooth] Fix compilation for x86_32.x86 ABIfix-x86_32.x86-compilationDavid Turner2021-07-161-0/+10
| | | | | | | | | | | | The code assumed that if __SSE2__ is defined, then 64-bit integer types are available. This is not the case apparently for certain multilib compiler targets like x86_32.x86 used by Gentoo. This patch fixes the issue by disabling the special code path when 64-bit integer types are not available. https://gitlab.freedesktop.org/freetype/freetype/-/issues/1071
* docs/CHANGES: Mention slight rendering changes.Werner Lemberg2021-07-161-1/+4
| | | | Suggested by Ben.
* * tests/issue-1063/main.c (main): Fix uninitialized variable.Alex Richardson2021-07-162-3/+11
| | | | | | | I tried running `meson test` but the test just crashed and gdb reported that the face argument to `FT_Get_Char_Index` was nonsense. With this change the test prints 'Could not open file: ' as it should.
* [smooth] Minor fixes.Werner Lemberg2021-07-162-31/+61
| | | | | | | | * src/smooth/ftgrays.c (gray_render_conic): Move variable and structure declarations to beginning of function. Inspite of C99 compliance we still do this for the sake of backward compatibility. This also avoids a shadowing declaration of `count`. (gray_convert_glyph_inner): Fix typo.
* Formatting and ChangeLog additions for previous commits.Werner Lemberg2021-07-163-98/+181
|
* Guard inclusion of emmintrin.hBen Wagner2021-07-151-0/+2
| | | | | | | | Guard inclusion of emmintrin.h with "#ifdef __SSE2__". The gcc version of this header, xmmintrin.h, and mmintrin.h check that the appropriate defines are set before defining anything (are internally guarded). However the clang versions of these includes are not internally guarded. As a result of this, externally guard the inclusion of these headers.
* [smooth] Implement Bezier quadratic arc flattenning with DDADavid Turner2021-07-152-1/+202
| | | | | | | | | | | | | | | | | | | Benchmarking shows that this provides a very slighty performance boost when rendering fonts with lots of quadratic bezier arcs, compared to the recursive arc splitting, but only when SSE2 is available, or on 64-bit CPUs. On a 2017 Core i5-7300U CPU on Linux/x86_64: ./ftbench -p -s10 -t5 -cb .../DroidSansFallbackFull.ttf Before: 4.033 us/op (best of 5 runs for all numbers) After: 3.876 us/op ./ftbench -p -s60 -t5 -cb .../DroidSansFallbackFull.ttf Before: 13.467 us/op After: 13.385 us/op
* [smooth] Minor speedup to smooth rasterizerDavid Turner2021-07-152-30/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This speeds up the smooth rasterizer by avoiding a conditional branches in the hot path. Namely: - Define a fixed "null cell" which will be pointed to whenever the current cell is outside of the current target region. This avoids a "ras.cell != NULL" check in the FT_INTEGRATE() macro. - Also use the null cell as a sentinel at the end of all ycells[] linked-lists, by setting its x coordinate to INT_MAX. This avoids a 'if (!cell)' check in gray_set_cell() as well. - Slightly change the worker struct fields to perform a little less operations during rendering. Example results (on a 2013 Corei5-3337U CPU) out/ftbench -p -s10 -t5 -bc /usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf Before: 5.472 us/op After: 5.275 us/op out/ftbench -p -s60 -t5 -bc /usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf Before: 17.988 us/op After: 17.389 us/op
* tests/scripts/download-test-fonts.sh rewrite in Python3David Turner2021-07-154-67/+306
| | | | | | | | | Replaces download-test-fonts.sh with download-test-fonts.py which does the same work, and also avoids downloading anything if the files are already installed with the right content. Now uses the first 8 byte of each file's sha256 hash for the digest.
* Support architectures where `long` is smaller than pointers.Alex Richardson2021-07-152-3/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I am currently trying to compile FreeType for CHERI-extended ISAs (CHERI-RISC-V and Arm's Morello), but I am getting compiler warnings from the `FT_UINT_TO_POINTER` macro. When compiling with the CHERI Clang compiler, not using `uinptr_t` for casts between integers an pointers results in the following `-Werror` build failures: ``` In file included from .../src/truetype/truetype.c:22: .../src/truetype/ttgload.c:1925:22: error: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Werror,-Wcheri-capability-misuse] node->data = FT_UINT_TO_POINTER( glyph_index ); ^ .../include/freetype/internal/compiler-macros.h:79:34: note: expanded from macro 'FT_UINT_TO_POINTER' ``` * include/freetype/internal/compiler-macros.h (FT_UINT_TO_POINTER): The ISO C standard compliant fix for this would be to use `uintptr_t` from `stdint.h`, but I am not sure if this is supported by the minimum compiler version. Therefore, use the compiler-defined `__UINTPTR_TYPE__` macro (supported in GCC 4.6+ and Clang since about 3.0) before checking for `_WIN64` and falling back to `unsigned long`.
* [base] Fix `FT_Open_Face`'s handling of user-supplied streams.Oleg Oshmyan2021-07-133-13/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was already true (though undocumented) most of the time, but not if `FT_NEW` inside `FT_Stream_New` failed or if the `FT_OPEN_XXX` flags were bad. Normally, `FT_Open_Face` calls `FT_Stream_New`, which returns the user-supplied stream unchanged, and in case of any subsequent error in `FT_Open_Face`, the stream is closed via `FT_Stream_Free`. Up to now, however, `FT_Stream_New` allocates a new stream even if it is already given one by the user. If this allocation fails, the user-supplied stream is not returned to `FT_Open_Face` and never closed. Moreover, the user cannot detect this situation: all they see is that `FT_Open_Face` returns `FT_Err_Out_Of_Memory`, but that can also happen after a different allocation fails within the main body of `FT_Open_Face`, when the user's stream has already been closed by `FT_Open_Face`. It is plausible that the user stream's `close` method frees memory allocated for the stream object itself, so the user cannot defensively free it upon `FT_Open_Face` failure lest it ends up doubly freed. All in all, this ends up leaking the memory/resources used by user's stream. Furthermore, `FT_Stream_New` simply returns an error if the `FT_OPEN_XXX` flags are unsupported, which can mean either an invalid combination of flags or a perfectly innocent `FT_OPEN_STREAM` on a FreeType build that lacks stream support. With this patch, the user-supplied stream is closed even in these cases, so the user can be sure that if `FT_Open_Face` failed, the stream is definitely closed. * src/base/ftobjs.c (FT_Stream_New): Don't allocate a buffer unnecessarily. Move error-handling code to make the control flow more obvious. Close user-supplied stream if the flags are unsupported. `FT_Stream_Open` always sets `pathname.pointer`, so remove the redundant (re)assignment. None of the `FT_Stream_Open...` functions uses `stream->memory`, so keep just one assignment at the end, shared among all possible control flow paths. ('Unsupported flags' that may need a stream closure can be either an invalid combination of multiple `FT_OPEN_XXX` mode flags or a clean `FT_OPEN_STREAM` flag on a FreeType build that lacks stream support.)
* [base] Reject combinations of incompatible `FT_OPEN_XXX` flags.Oleg Oshmyan2021-07-133-5/+32
| | | | | | | | | | | | | | | | | | | | The three modes are mutually exclusive, and the documentation of the `FT_OPEN_XXX` constants notes this. However, there was no check to validate this in the code, and the documentation on `FT_Open_Args` claimed that the corresponding bits were checked in a well-defined order, implying it was valid (if useless) to specify more than one. Ironically, this documented order did not agree with the actual code, so it could not be relied upon; hopefully, nobody did this and nobody will be hurt by the new validation. Even if multiple mode bits were allowed, they could cause memory leaks: if both `FT_OPEN_STREAM` and `stream` are set along with either `FT_OPEN_MEMORY` or `FT_OPEN_PATHNAME`, then `FT_Stream_New` allocated a new stream but `FT_Open_Face` marked it as an 'external' stream, so the stream object was never released. * src/base/ftobjs.c (FT_Stream_New): Reject incompatible `FT_OPEN_XXX` flags.
* [sdf] Improve documentation.Anuj Verma2021-07-132-8/+9
|
* * meson.build: Fix build for other UNIX systems (e.g., FreeBSD).Alex Richardson2021-07-122-1/+22
| | | | | | | | | | | | | | | | | Without this change the build of `unix/ftsystem.c` fails because the `ftconfig.h` header that defines macros such as `HAVE_UNISTD_H` and `HAVE_FCNTL_H` is only being generated for Linux, macOS, and Cygwin systems: ``` .../builds/unix/ftsystem.c:258:32: error: use of undeclared identifier 'O_RDONLY' file = open( filepathname, O_RDONLY ); ``` Instead of hardcoding a list of operating systems for this check, update the logic that decides whether to build the file and set a boolean flag that can be checked instead.
* [autofit] More clean-ups.Werner Lemberg2021-07-124-8/+12
| | | | | | | | * src/autofit/afhints.h (AF_GlyphHintsRec): Remove the no longer needed fields `xmin_delta` and `xmax_delta`. * src/autofit/afhints.c (af_glyph_hints_reload), src/autofit/afloader.c (af_loader_load_glyph): Updated.
* Small clean-ups for the last few commits.Werner Lemberg2021-07-127-38/+52
| | | | * include/freetype/fttrace.h (afwarp): Removed.
* Remove obsolete AF_Angle type and related sources.David Turner2021-07-127-352/+109
| | | | | | Move the af_sort_xxx() functions from afangles.c to afhints.c in order to get rid of the obsolete angle-related types, macros and function definitions.
* Remove experimental auto-hinting 'warp' mode.David Turner2021-07-1216-676/+18
| | | | | | | This feature was always experimental, and probably nevery worked properly. This patch completely removes it from the source code, except for a documentation block describing it for historical purpose.
* Remove experimental "Latin2" writing system (FT_OPTION_AUTOFIT2)David Turner2021-07-128-2498/+15
| | | | | | This code has always been experimental and was never compiled anyway (FT_OPTION_AUTOFIT2 does not appear in ftoption.h or even any of our build files).
* Update 'dlg' subproject.Werner Lemberg2021-07-121-0/+0
|
* meson.build: Minor doc fix.Werner Lemberg2021-07-051-2/+3
|
* * src/base/ftlcdfil.c (FT_Library_SetLcdGeometry): Fix argument.Werner Lemberg2021-07-052-1/+7
| | | | Reported by Hin-Tak.
* README.git: Revised.Werner Lemberg2021-07-031-15/+24
|
* meson.build: Minor doc improvements.Werner Lemberg2021-07-031-10/+17
|
* * meson_options.txt: Sort alphabetically; no final full stops.Werner Lemberg2021-07-032-17/+23
|
* * src/truetype/ttgxvar.c (tt_set_mm_blend): Test `coords`.Ben Wagner2021-07-012-3/+13
| | | | | | | It is undefined behavior to pass `NULL` to `memcpy`. `coords' is passed to `memcpy` but `TT_Get_MM_Blend` and `TT_Get_Var_Design` explictly call `tt_set_mm_blend` with `coords` as `NULL`. In addition, `TT_Set_MM_Blend` has a similar possible issue.
* [sfnt] Support PaintScale in 'COLR' v1 parsing.Dominik Röttsches2021-07-013-10/+138
| | | | | | | | | | * include/freetype/ftcolor.h (FT_PaintFormat): Renumber values, add `FT_COLR_PAINTFORMAT_SCALE`. (FT_PaintScale): New structure to represent 'PaintScale*' tables. (FT_COLR_Paint): Updated. * src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration. (read_paint): Parse 'PaintScale' and friends.
* [sfnt] Handle fonts without layer list in 'COLR' v1.Dominik Röttsches2021-07-012-13/+39
| | | | | | | | | | | | | 'COLR' v1 fonts do not necessarily need to have a layer list; for this reason, 'fontTools' recently started generating fonts in a way that drops the layer list if there are no layers in it. This results in the layer list offset becoming zero, which FreeType treated as an invalid table. Fix that and handle the case for layer list offset being 0. This slightly changes how we need to calculate the starting offset for paints. * src/sfnt/ttcolr.c (tt_face_load_colr): Handle case of layer list offset being zero without outright rejecting table.
* * src/raster/ftraster.c (Render_Single_Pass): Simplify `band_stack'.Alexei Podtelezhnikov2021-06-302-21/+9
|
* Update `CHANGES` file; other minor doc fixes.Werner Lemberg2021-06-305-12/+35
|
* [raster] Do not skip the second pass without dropout control.Alexei Podtelezhnikov2021-06-292-11/+12
| | | | | | | The second pass also fixes horizontal lines through the pixel centers. * src/raster/ftraster.c (black_TWorker): Do not use `second_pass'. (Render_Glyph): Skip the second pass only with the appropriate flag.
* [raster] Handle sub-band stack locally.Alexei Podtelezhnikov2021-06-292-30/+38
| | | | | | * src/raster/ftraster.c (black_TWorker): Move `band_stack' from here.. (Render_Single_Pass): ... to here and accept limit arguments. (Render_Glyph): Updated.
* [CI] Introduce linux CI and refactor job namesAnurag Thakur2021-06-292-6/+101
| | | | * .gitlab-ci.yml: Added jobs for building freetype on linux.
* ftcolor.h: Minor grammar fix.Werner Lemberg2021-06-291-27/+27
|
* [raster] Handle Bézier stack locally.Alexei Podtelezhnikov2021-06-282-46/+58
| | | | | | * src/raster/ftraster.c (black_TWorker): Move `arcs' from here... (Conic_To, Cubic_To): ... to here to tighten their scope. (Bezier_Up, Bezier_Down): ... Take the current `arc' argument.
* [sfnt] Improve paint limit checksDominik Röttsches2021-06-282-8/+43
| | | | | | | | | | | | | | | | Paint tables can appear before the `base_glyphs_v1` offset if the font is produced with the layer list before the base glyph list. In this case paint tables can occur after the layer list but before the base glyph list. Checks in the 'COLR' v1 code were rejecting fonts with this layout. Improve these checks by calculating a minimum offset after which paint tables can occur and use that in safety checks. * src/sfnt/ttcolr.c (Colr, tt_face_load_colr): Declare `paint_start_v1` and calculate that as the minimum of the end of layer list and base glyph list. (get_child_table_pointer, read_paint, tt_face_get_paint_layers): Use that in safety checks.
* [raster] Clean up vertical sweep.Alexei Podtelezhnikov2021-06-282-19/+23
| | | | | | | * src/raster/ftraster.c (black_TWorker): Replace the current line offset with the pointer and drop the increment. (Function_Sweep_Init): Take values as arguments instead of pointers. (Vertical_Sweep_*, Horizontal_Sweep_Init, Draw_Sweep): Updated.
* [raster] Make `band_top' local variable.Alexei Podtelezhnikov2021-06-262-18/+20
| | | | | | * src/raster/ftraster.c (black_TWorker): Move `band_top' from here... (Render_Single_Pass): ... to here, and refactor. (Render_Glyph): Updated.
* [raster] Adjust sub-band bisecting limits.Alexei Podtelezhnikov2021-06-252-5/+16
| | | | | | | | We can bisect a band until it is just a single scan line. This might be slow and cause time-outs but if we need to impose limits it should be elsewhere. * src/raster/ftraster.c (Render_Single_Pass): Tweak sub-banding.
* * src/raster/ftraster.c (Render_Single_Pass): Remove dead code.Alexei Podtelezhnikov2021-06-252-11/+5
|
* [base] Add trace level to logging output.Werner Lemberg2021-06-254-6/+37
| | | | | | | | | | | | | | | | | | | | | | | Some practical debugging work has shown that displaying level X of an `FT_TRACEX` macro in the output of `FT2_DEBUG="... -v"` would be very helpful to find out which trace level should be selected. As an example, we now get output like ``` [ttobjs:2] TTF driver [ttobjs:2] SFNT driver [sfobjs:2] not a font using the SFNT container format [t1objs:2] Type 1 driver [stream:7] FT_Stream_EnterFrame: 14 bytes ``` * include/freetype/internal/ftdebug.h (FT_LOGGING_TAGX): New macro. (FT_LOG): Use it to add the trace level to the logging tag. * include/freetype/internal/fttrace.h (FT_MAX_TRACE_LEVEL_LENGTH): Adjust. * docs/DEBUG: Updated.
* [smooth, raster] Fix up and align error codes.Alexei Podtelezhnikov2021-06-243-14/+32
| | | | | | | | | | | | | | | FT_Render_Glyph picked up FAILURE or 1 returned from the raster function, which became a confusing error code. Instead, return Raster_Overflow in the unlikely event that banding does not help or another meaningful error. * src/smooth/ftgrays.c (gray_convert_glyph_inner, gray_convert_glyph): Use Raster_Overflow when the rendering pool is exhausted and return it if banding does not help. (gray_raster_render): Use Smooth_Err_Ok. * src/raster/ftraster.c (Render_Single_Pass): Return Raster_Overflow if banding does not help or another error code.
* [smooth, raster] Remove synonymous error macros.Alexei Podtelezhnikov2021-06-233-59/+59
| | | | | | | | | | * src/smooth/ftgays.c [STANDALONE_]: s/ErrRaster_/Smooth_Err_/. (gray_convert_glyph_inner): Updated accordingly. * src/raster/ftraster.c [STANDALONE_]: Do not abbreviate error macros. (New_Profile, End_Profile, Insert_Y_Turn, Line_Up, Bezier_Up, Decompose_Curve, Draw_Sweep, Render_Single_Pass, ft_black_render): Updated accordingly.
* fterrors.h: Fix documentation extraction of `FT_Error_String`.Werner Lemberg2021-06-231-0/+2
|
* [sfnt] s/PaintTransformed/PaintTransform/, s/transformed/transform/.Dominik Röttsches2021-06-223-29/+39
| | | | | | | | * include/freetype/ftcolor.h (FT_PaintTransformed, FT_PaintFormat, FT_COLR_Paint): Do it to make it harmonize with other names such as 'PaintTranslate'. * src/sfnt/ttcolr.c (read_paint, tt_face_get_paint): Ditto.
* Move 'COLR' API to `ftcolor.h`.Dominik Röttsches2021-06-223-1238/+1247
| | | | | | | * include/freetype/freetype.h: Cut section layer managament containing 'COLR' v0 and v1 API and move it to `ftcolor.h` as requested by Werner on freetype-devel. * include/freetype/ftcolor.h: Paste that section.
* freetype.h: Mark 'COLR' v1 API as experimental.Werner Lemberg2021-06-202-29/+56
|
* ftver.rc: Update copyright year.Werner Lemberg2021-06-191-1/+1
|
* [truetype] Fix integer overflow.Werner Lemberg2021-06-192-1/+11
| | | | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35312 * src/truetype/ttinterp.c (Ins_JMPR): Use `ADD_LONG`.
* Prevent hinting if there are too many segments.Werner Lemberg2021-06-192-0/+38
| | | | | | | | | | | This speeds up handling of broken glyphs. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35309 * src/autofit/aflatin.c (af_latin_hints_compute_segments): Implement it.