summaryrefslogtreecommitdiff
path: root/src/sfnt
Commit message (Collapse)AuthorAgeFilesLines
* Fix clang warnings.Werner Lemberg2020-07-073-23/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* [build] Fix multi and C++ builds.David Turner2020-07-062-1/+2
| | | | | | | | | | | | | | | | | | 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'.
* [woff2] Fix segfault.Werner Lemberg2020-06-191-0/+6
| | | | | | | | | 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.
* [sfnt] Support Intel compilers.Stephen McDowell2020-06-191-1/+6
| | | | | * src/sfnt/pngshim.c (premultiply_data): Intel compilers do not currently support `__builtin_shuffle'.
* woff2tags.h: Fix copyright year.Werner Lemberg2020-06-171-1/+1
|
* Remove redundant inclusion of `ft2build.h'.Werner Lemberg2020-06-1330-30/+0
| | | | | | | * */*: Remove `#include <ft2build.h>' where possible. * include/freetype/freetype.h: Remove cpp error about missing inclusion of `ft2build.h'.
* Make macros for header file names optional.David Turner2020-06-0827-85/+85
| | | | | | | | | | | | | | | | | 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.
* * src/sfnt/ttcmap.c (tt_face_build_cmaps): Trace number of cmaps.Werner Lemberg2020-06-021-1/+2
|
* Remove Jamfile files from the tree.David Turner2020-05-181-42/+0
| | | | | | | | 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.
* [woff2] Return if single stream operation fails.Nikhil Ramakrishnan2020-04-042-4/+3
| | | | | | * src/sfnt/sfwoff2.c (get_x_mins): Do it. * src/sfnt/woff2tags.c: Remove unused include.
* [woff2] Fix font table access.Werner Lemberg2020-02-221-3/+13
| | | | | | | | | 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.
* * src/sfnt/ttcmap.c (tt_face_build_cmaps): Ignore version (#57708).Werner Lemberg2020-02-121-8/+10
|
* Update all copyright notices.Werner Lemberg2020-01-1936-36/+36
|
* [woff2] Fix memory leaks and a runtime warning.Werner Lemberg2020-01-031-1/+9
| | | | | | | | | 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.
* [woff2] Allow bitmap-only fonts (#57394).Nikhil Ramakrishnan2019-12-311-2/+2
| | | | | * src/sfnt/sfwoff2.c (reconstruct_font): Fix test for `glyf' and `loca' tables.
* Avoid more nullptr offset UBSan warnings (#57316).Dominik Röttsches2019-11-291-1/+1
| | | | | | | | * 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'.
* [sfnt] Avoid sanitizer warning (#57286).Ben Wagner2019-11-231-4/+5
| | | | | | * src/sfnt/ttcmap.c (tt_face_build_cmaps): Avoid possible `NULL + offset' computation. Tag `table' as `const'.
* [sfnt] Ensure OTTO fonts have tables (#57285).Ben Wagner2019-11-231-0/+8
| | | | * src/sfnt/ttload.c (tt_face_load_font_dir): Add test.
* * src/sfnt/sfwoff2.c (woff2_open_font): Check `num_fonts' for TTCs.Werner Lemberg2019-10-251-0/+6
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18494
* * src/sfnt/sfwoff2.c (woff2_open_font): Avoid undefined shift.Werner Lemberg2019-10-221-6/+14
| | | | | | | | Also improve tracing. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18390
* * src/sfnt/pngshim.c (premultiply_data): Optimize for __SSE__ only.Alexei Podtelezhnikov2019-10-101-0/+1
|
* * src/sfnt/sfwoff2.c (reconstruct_glyf): Check `triplet_size'.Werner Lemberg2019-10-101-0/+5
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18108
* [woff2] Fix SFNT table checks.Werner Lemberg2019-10-081-41/+34
| | | | | | | | | | | | | | | | | | | | Also reduce number of SFNT table lookups. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18065 * include/freetype/internal/wofftypes.h (WOFF2_InfoRec): Add fields `glyf_table', `loca_table', and `head_table'. * src/sfnt/sfwoff2.c (reconstruct_glyf): Update signature. Use table pointers in `info' parameter. (get_x_mins): Check `maxp_table' Use table pointers in `info' parameter. (reconstruct_font): Use and set table pointers in `info' parameter. Fix check for `glyf' and `loca' tables. Update call to `reconstruct_glyf'. (woff2_open_font): Updated.
* * src/sfnt/sfwoff2 (reconstruct_glyf): Fix reallocation.Werner Lemberg2019-10-061-0/+3
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18046
* * src/sfnt/sfwoff2 (reconstruct_font): Fix reallocation.Werner Lemberg2019-10-031-0/+3
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17966
* * src/sfnt/sfwoff2 (woff2_open_font): Initialize `woff2.ttc_fonts'.Werner Lemberg2019-10-011-0/+2
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17804
* * src/sfnt/sfwoff2.c (reconstruct_font): Fix memory leak.Werner Lemberg2019-09-301-10/+10
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17812
* [woff2] Reject fonts without `head' table.Werner Lemberg2019-09-301-8/+8
| | | | | | | | | | | | | Also fix memory deallocation in case of error. `head' problem reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17820 * src/sfnt/sfwoff2.c (reconstruct_glyf): Don't use `stream_close'. Abort if `head_table' is NULL. Don't free `transformed_buf' in case of error. (woff2_open_font): Don't set `uncompressed_buf' to NULL.
* [woff2] Fix compiler warnings.Werner Lemberg2019-09-291-4/+3
| | | | | | | | Problem reported by Alexei. * src/sfnt/sfwoff2.c (reconstruct_glyf): Initialize `x_min'. (reconstruct_font): Initialize `num_hmetrics'. (woff2_open_font): Initialize `info'.
* * src/sfnt/sfwoff2.c (woff2_open_font): Fix sanity check.Werner Lemberg2019-09-281-4/+7
| | | | Correct thinkos in patch from 2019-09-01.
* [woff2] Fix memory leaks.Werner Lemberg2019-09-281-1/+19
| | | | | | | | | | | One of them reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17766 * src/sfnt/sfwoff2.c (woff2_open_font): Free `info->x_mins' and `woff2->ttc_fonts'. (reconstruct_glyf): Initialize `info->x_mins'.
* * src/sfnt/sfwoff2.c (woff2_open_font): Check (sum of) table sizes.Werner Lemberg2019-09-251-0/+7
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17684
* [woff2] Fix memory leaks.Nikhil Ramakrishnan2019-09-201-2/+8
| | | | | | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16896 * src/sfnt/sfwoff2.c (woff2_open_font): Fix error handling. Free `uncompressed_buf'. (reconstruct_font): Free `transformed_buf'.
* * src/sfnt/sfwoff2.c (woff2_open_font): Check table index.Werner Lemberg2019-09-171-0/+7
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17100
* * src/sfnt/sfwoff2.c (compute_ULong_sum): Fix undefined shift.Werner Lemberg2019-09-031-4/+4
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16933
* * src/sfnt/sfwoff2.c (woff2_open_font): Add sanity check.Werner Lemberg2019-09-011-1/+16
| | | | | | | | Don't trust `totalSfntSize' unconditionally. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16893
* [woff2] Don't use `FT_UInt64' (#56815).Dominik Röttsches2019-08-271-1/+1
| | | | | | * src/sfnt/sfwoff2.c (woff2_open_font): Use `FT_UInt32' for `file_offset'. This fixes builds on platforms where `FT_LONG64' is not defined while still being sufficient to store a file offset.
* [woff2] Fix compiler warnings.Werner Lemberg2019-08-272-11/+8
| | | | | | | | | | | | | | * src/sfnt/sfwoff2.c (read_num_hmetrics): Remove unused argument `table_len'. Update caller. (triplet_decode, compute_bbox, store_loca, reconstruct_glyf): Make `i' variable unsigned. (reconstruct_glyph): Remove condition which is always false. (reconstruct_html): Removed unused argument `transformed_size'. Update caller. * src/sfnt/woff2tags.c (woff2_known_tags): Remove condition which is always false.
* [woff2] Formatting; some comments.Werner Lemberg2019-08-274-173/+275
|
* [woff2] Check whether known tag is in array bounds.Nikhil Ramakrishnan2019-08-272-2/+13
| | | | | | | | | If table tag is not 0x3f, we expect a value between 0 and 62. If this is not the case, exit with errors. * src/sfnt/sfwoff2/c: Check whether table tag makes sense. * src/sfnt/woff2tags.c: Return 0 if tag is out of bounds.
* [woff2] More formatting and documentation.Nikhil Ramakrishnan2019-08-271-47/+86
| | | | | | | * include/freetype/internal/wofftypes.h, src/sfnt/sfwoff2.c: Implement formatting changes suggested as https://lists.nongnu.org/archive/html/freetype-devel/2019-08/msg00052.html
* * src/sfnt/sfwoff2.c: Improve trace comments.Nikhil Ramakrishnan2019-08-271-101/+54
| | | | Adjust tracing levels for comments, and more formatting.
* [woff2] Formatting.Nikhil Ramakrishnan2019-08-272-191/+194
| | | | * src/sfnt/sfobjs.c, src/sfnt/sfwoff2.c: Better formatting.
* [woff2] Support `hmtx' reconstruction when `glyf' is untransformed.Nikhil Ramakrishnan2019-08-271-4/+89
| | | | | | | | | `reconstruct_hmtx' requires `info->x_mins' and `info->num_glyphs' to reconstruct the hmtx table. In case glyf is not transformed, we call `get_x_mins' which does the necessary work. * src/sfnt/sfwoff2.c (get_x_mins): New function. (reconstruct_font): Call get_x_mins.
* [sfnt] Support `face->num_faces' for WOFF2 fonts.Nikhil Ramakrishnan2019-08-273-11/+46
| | | | | | | | | | | | | | | | | | | | | | Set correct value of `face->num_faces' for WOFF2 fonts. This is being handled separately because we only load the tables for the requested font face in `woff2_open_font' and create a single-face sfnt stream. The full discussion is at: https://lists.gnu.org/archive/html/freetype-devel/2019-08/msg00000.html * src/sfnt/sfobjs.c (sfnt_open_font): Add parameter `woff2_num_faces'. (sfnt_init_face): Introduce variable `woff2_num_faces', and change `face->root.num_faces' if `woff2_num_faces' is set. * src/sfnt/sfwoff2.c (woff2_open_font): Validate requested face index and handle negative face indices. * src/sfnt/sfwoff2.h (woff2_open_font): Add parameter `num_faces' to declaration.
* [woff2] Improve memory and error handling.Nikhil Ramakrishnan2019-08-271-23/+61
| | | | | | | Free up memory after use, and improve error handling. * src/sfnt/sfwoff2.c (reconstruct_font, woff2_open_font): Implement changes.
* [woff2] Avoid too many calls to `FT_REALLOC'.Nikhil Ramakrishnan2019-08-271-35/+62
| | | | | | | | | | | | | | | | | | | | | | | We do this by using `totalSfntSize' as an initial reference, and extending the buffer when required. This reduces rendering time considerably. * include/freetype/internal/wofftypes.h (WOFF2_HeaderRec): Add `totalSfntSize', rename `total_sfnt_size' to `actual_sfnt_size'. * src/sfnt/sfwoff2.c (write_buf): Add parameter `dst_size' to keep track of and update total size of stream. (WRITE_SFNT_BUF, WRITE_SFNT_BUF_AT): Modify macros accordingly. (pad4, store_loca, reconstruct_glyf, reconstruct_hmtx, reconstruct_font): Update parameters to accept `sfnt_size'. (woff2_open_font): Add variable `sfnt_size'. Use WOFF2 header field `totalSfntSize' as initial reference (if value makes sense) and allocate `totalSfntSize' bytes for the sfnt stream. `write_buf' handles reallocation if and when required. Also resize the stream to `actual_sfnt_size' after reconstruction.
* [woff2] Reconstruct `loca', `hmtx', and swap out stream.Nikhil Ramakrishnan2019-08-273-73/+373
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add necessary functions to reconstruct loca and hmtx tables (the two remaining tables that can have a transform). `woff2_open_font' is now capable of loading a woff2 font face. This code may still need more refining and better memory management. * include/freetype/internal/wofftypes.h (WOFF2_HeaderRec): Add total (final) size of sfnt stream. (WOFF2_InfoRec): Add header checksum value. * src/sfnt/sfobjs.c (sfnt_open_font): Change `face_instance_index' parameter to its pointer so its value can be modified by `woff2_open_font'. * src/sfnt/sfwoff2.c: (WRITE_SFNT_BUF_AT): New macro to write into sfnt buffer at given position. (write_buf): Add parameter `extend_buf' which allows caller to specify whether buffer should be reallocated before copying data. (WRITE_SFNT_BUF): Updated. (pad4, store_loca, reconstruct_htmx): New functions. (reconstruct_glyf): Calculate loca values and store them. (reconstruct_font): Call `reconstruct_hmtx', write table record entries, and calculate table checksums. Also calculate font checksum and update `checksumAdjustment' entry in head table. (woff2_open_font): Open stream for sfnt buffer, swap out input stream and return. * src/sfnt/sfwoff2.h (woff2_open_font): Modify parameter to accept pointer to `face_index'.
* [woff2] Reconstruct transformed `glyf' table.Nikhil Ramakrishnan2019-08-273-48/+831
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reconstruct `glyf' table if it is transformed in the uncompressed table stream. Also add necessary structures, macros and functions. * include/freetype/internal/wofftypes.h (WOFF2_InfoRec, WOFF2_SubstreamRec, WOFF2_PointRec): New structures. (WOFF2_TableRec): s/OrigLength/dst_length/. * src/sfnt/sfwoff2.c (READ_255USHORT, READ_BASE128): Use `FT_SET_ERROR' to set implicit `error' variable. (WRITE_SHORT): New macro. (N_CONTOUR_STREAM, N_POINTS_STREAM, FLAG_STREAM, GLYPH_STREAM, COMPOSITE_STREAM, BBOX_STREAM, INSTRUCTION_STREAM): New macros to refer to substreams of the transformed `glyf' tables. (Read255UShort, ReadBase128): Return errors set by `FT_READ_XXX' macros. (with_sign, safe_int_addition): New functions to add sign to values based on a flag and perform safe addition respectively. (triplet_decode): Decode variable-length (flag, xCoordinate, yCoordinate) triplet for a simple glyph. See https://www.w3.org/TR/WOFF2/#triplet_decoding (store_points, compute_bbox, composteGlyph_size, reconstruct_glyf): New functions. (reconstruct_font): Call `reconstruct_glyf'. * src/sfnt/sfwoff2.h: Add required constants. * src/sfnt/woff2tags.h: Move out constants to `sfwoff2.h'.
* [woff2] Copy un-transformed tables to sfnt stream.Nikhil Ramakrishnan2019-08-272-7/+96
| | | | | | | | | | | | | | | | | Copy un-transformed tables to the sfnt stream. * src/sfnt/sfwoff2.c: (WRITE_SFNT_BUF): New macro. (write_buf): New function. Extend memory of `dst' buffer and copy bytes from `src'. (compute_ULong_sum): New function. Calculate checksum of table. (reconstruct_font): Change `FT_Byte* sfnt' to `FT_Byte** sfnt_bytes'. This has been done because we reallocate memory to `sfnt' multiple times, which may change the pointer value of `sfnt'. This new pointer must be propogated back to the caller. Same reason for using a double pointer in `write_buf'. * src/sfnt/woff2tags.h (WOFF2_DEFAULT_MAX_SIZE): New macro used for overflow checking.