summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* [sfnt] Fix typo in clip box computation.Dominik Röttsches2022-07-301-2/+3
| | | | | * src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Use appropriate scale factor for `yMin` and `yMax`.
* [autofit] Use unsigned accounting for hints.Alexei Podtelezhnikov2022-07-294-16/+16
| | | | | | | | | | * src/autofit/afhints.h (AF_AxisHintsRec): Use unsigned types. * src/autofit/afhints.c (af_axis_hints_new_{segment,edge}, af_glyph_hints_get_num_segments, af_glyph_hints_get_segment_offset): Updated accordingly. * src/autofit/aflatin.c (af_cjk_hints_compute_edges): Ditto. * src/autofit/afcjk.c (af_cjk_hints_compute_edges): Ditto.
* * src/autofit/afhints.h: Remove dead code.Alexei Podtelezhnikov2022-07-291-5/+0
|
* * src/base/ftglyph.c (FT_Get_Glyph): Set `*aglyph` to NULL in case of error.Werner Lemberg2022-07-291-0/+3
|
* Fix compilation if `TT_CONFIG_OPTION_GX_VAR_SUPPORT` is not set.Werner Lemberg2022-07-291-14/+32
| | | | | * src/sfnt/ttcolr.c: Protect relevant code with `TT_CONFIG_OPTION_GX_VAR_SUPPORT`.
* Fix clang14 compiler warnings.Werner Lemberg2022-07-291-5/+2
| | | | | | | | | * include/freetype/internal/ftstream.h (FT_GET_SHORT_LE, FT_GET_USHORT_LE): Fix type. * src/sfnt/ttcolr.c (get_deltas_for_var_index_base): Always return boolean value. (tt_face_get_colorline_stops): Fix type of `var_index_base`.
* [pfr] Fortify the kerning code.Alexei Podtelezhnikov2022-07-261-8/+7
| | | | | | | | | | | | Any array index must be strictly less then the array size. Therefore, we must reject indexes that are equal to the array size. Alternatively, we should move the bounds check before the index decrement but that would be confusing. In addition, it is ok to decrement zero (.notdef) and get UINT_MAX, which is then automatically rejected in the bounds check. * src/pfr/pfrobjs.c (pfr_face_get_kerning): Fix the bounds checking.
* [pfr] Add some safety guards.Werner Lemberg2022-07-261-0/+15
| | | | | | | * src/pfr/pfrload.c (pfr_phy_font_load): Check resolutions and number of characters. Fixes #1174.
* * src/pfr/*.c: Trivial improvements and formatting.Werner Lemberg2022-07-264-21/+14
|
* [base] Build outlines in amortized constant time.Ben Wagner2022-07-231-5/+15
| | | | | | | | | | | | | | | When resizing the loader's points and contours, resize them to at least 1.5 times their current size. The code currently only reserves as much space as is currently required, leading to O(n^2) runtime when adding points one at a time. This change does not attempt to ever shrink the loader's point and contour storage since this was not attempted previously either. The 1.5 multiple was chosen as a trade-off between potentially unused space and the runtime. * src/base/ftgloader.c (FT_GlyphLoader_CheckPoints): Implement it. Fixes #1173.
* [sfnt] Support variable 'COLR' v1 `PaintVarSkew*`.Dominik Röttsches2022-07-091-4/+49
| | | | | | | | * src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration values `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW`, `FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER`, and `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW_CENTER`. (read_paint): Handle new enumeration values.
* [sfnt] Support variable 'COLR' v1 `PaintVarRotate*`.Dominik Röttsches2022-07-091-3/+47
| | | | | | | * src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration values `FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE` and `FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE_CENTER`. (read_paint): Handle new enumeration values.
* [sfnt] Support 'COLR' v1 variable `PaintVarScale*`.Dominik Röttsches2022-07-091-24/+95
| | | | | | | | | * src/sfnt/ttcolr.c: (FT_PaintFormatInternal): New enumeration values `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE`, `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_CENTER`, `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM`, and `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM_CENTER`. (read_paint): Handle new enumeration values.
* [sfnt] Support for 'COLR' v1 variable translate.Dominik Röttsches2022-07-091-1/+22
| | | | | | * src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration value `FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSLATE`. (read_paint): Handle new enumeration value.
* [sfnt] Support for 'COLR' v1 variable transforms.Dominik Röttsches2022-07-091-1/+26
| | | | | | * src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration value `FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSFORM`. (read_paint): Handle new enumeration value.
* [sfnt] Deltas for 'COLR' v1 gradient coordinates.Dominik Röttsches2022-07-091-0/+59
| | | | | | * src/sfnt/ttcolr.c (read_paint) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Read and apply deltas to radial, linear, and sweep gradient coordinates such as 'p0', 'p1', 'p2', 'center', 'radii', and 'angles'.
* [sfnt] Support variable 'COLR' v1 color lines.Dominik Röttsches2022-07-081-8/+56
| | | | | | | | | | | | * include/freetype/ftcolor.h (FT_ColorStopIterator): Add field `read_variable` to indicate whether a variation index base should be read. * src/sfnt/ttcolr.c: (FT_PaintFormat_Internal): New enumerations `FT_COLR_PAINTFORMAT_INTERNAL_VAR_LINEAR_GRADIENT` `FT_COLR_PAINTFORMAT_INTERNAL_VAR_RADIAL_GRADIENT`, and `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SWEEP_GRADIENT`. (read_color_line): New parameter `read_variable`; update callers. (read_paint): Handle new enumerations.
* [sfnt] Apply variation deltas to `PaintVarSolid`.Dominik Röttsches2022-07-071-5/+92
| | | | | | | | | | | | * src/sfnt/ttcolr.c (FT_PaintFormat_Internal_): New enumeration `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SOLID`. (get_deltas_for_var_index_base) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: New function to retrieve an array of delta values, which will be used for most of 'COLR' v1 variation formats (in follow-up commits). (read_paint): Add `face` parameter; update caller. Handle `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SOLID`.
* [sfnt] Check safety of cast to `TT_Driver` before accessing member.Dominik Röttsches2022-07-071-4/+8
| | | | | * src/sfnt/ttcolr.c (VARIABLE_COLRV1_ENABLED): Access `enable_variable_colrv1` only if driver class matches.
* [sfnt] Load variation store for 'COLR' v1.Dominik Röttsches2022-07-041-0/+100
| | | | | | | | | | * src/sfnt/ttcolr.c: Include `ttobjs.h` temporarily. (VARIABLE_COLRV1_ENABLED): New temporary macro to detect whether variable COLRv1 is enabled. (Colr): New fields `var_store` and `delta_set_idx_map`. (tt_face_load_colr, tt_face_free_colr) [VARIABLE_COLRV1_ENABLED]: Load and free variation store data using the functions from the Multiple Masters service.
* [base] Improve error handling in `FT_GlyphLoader_CheckPoints`.Chris Liddell2022-07-031-4/+10
| | | | | | | | | | If `FT_GlyphLoader_CreateExtra` returns an error (and a couple of other places), `FT_GlyphLoader_CheckPoints` would propagate the error immediately, rather than cleaning up the partially set up `FT_GlyphLoader`. As a consequence, a subsequent attempt to create a glyph could result in a crash. * src/base/ftgloadr.c (FT_GlyphLoader_CheckPoints): Ensure all the error conditions exits are consistent, eventually calling `FT_GlyphLoader_Reset`.
* [base] Round values in `FT_MulAdd_Fix`.Dominik Röttsches2022-07-011-4/+11
| | | | | | | | | | | This avoids regressing Blink layout tests and makes `FT_MulAdd_Fix` delta retrieval implementation consistent with the previous implementation, which used `FT_fixedToInt` and included rounding. * src/base/ftcalc.c (FT_MulAdd_Fix): Implement it. Also fix remaining `temp` initialization compilation issue. Fixes #1169.
* Minor formatting.Werner Lemberg2022-07-013-3/+6
|
* Fix initialisation of temp variable in new FT_MulAddFixDominik Röttsches2022-06-301-1/+1
| | | | src/truetype/ttgxvar.c (FT_MulAddFix): Initialise `temp`.
* [truetype] Perform variation store delta computation with 64-bit precision.Dominik Röttsches2022-06-292-13/+35
| | | | | | | | | | | | * include/freetype/internal/ftmmtypes.h (FT_ItemVarDelta): Make type explicitly 32-bit. * include/freetype/internal/services/svmm.h (FT_Var_Get_Item_Delta_Func): Change return type to `FT_ItemVarDelta` * truetype/ttgxvar.h (tt_var_get_item_delta): Change return type to `FT_ItemVarDelta`. * truetype/ttgxvar.c (tt_var_get_item_delta): Store scalars and deltas to intermediate array, perform computation using new method `FT_MulAddFix`.
* New function `FT_MulAddFix` to compute the sum of fixed-point products.Dominik Röttsches2022-06-291-0/+60
| | | | | | | | This function, based on the code of `FT_MulFix`, uses 64-bit precision internally for intermediate computations. * include/freetype/internal/ftcalc.h, base/ftcalc.c (FT_MulAddFix): Implement it.
* [sfnt] Upgrade stop_offset to FT_Fixed from FT_F2Dot14Dominik Röttsches2022-06-221-1/+1
|
* * ttgload.c (TT_Process_Composite_Glyph): Fix a signedness warning.Alexei Podtelezhnikov2022-06-211-1/+1
|
* s/fixed point/fixed-point/Werner Lemberg2022-06-218-18/+18
|
* Proposal: Feature control for variable COLRv1Dominik Röttsches2022-06-212-0/+19
| | | | | | | | * include/freetype/ftdriver.h (variable-color-v1 property): Add documentation for variable-colr-v1 property. * src/truetype/ttdriver.c (tt_property_set): Ingest variable-control property when called, set to enable_variable_colrv1 driver flag. * src/truetype/ttobjs.h (TT_DriverRec): Add enable_variable_colrv1 flag.
* [truetype] Clean up phantom point accounting.Alexei Podtelezhnikov2022-06-183-80/+28
| | | | | | | | | | | | | | This formalizes that the phantom points appended in the outline do not increase its point count, nor are they tagged or included in any additional contours. Only their coordinates are stored. They are counted in the glyph zone, however. * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Infer `n_points` from the outline size plus four phantom points. * src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Remove this argument. * src/truetype/ttgload.c (tt_prepare_zone): Add phantom four. (TT_Process_Simple_Glyph, load_truetype_glyph): Update all callers.
* [truetype/GX] Clean up phantom point adjustment.Alexei Podtelezhnikov2022-06-182-82/+33
| | | | | | | | | This moves phantom point and advance variation adjustment next to calculations. The logic stays the same, HVAR and VVAR take priority. * src/truetype/ttgload.c (load_truetype_glyph): Move it from here... * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): ... to here and check for HVAR and VVAR presence outside the main loop.
* [stream] Fix reading s32 when long is s64Ben Wagner2022-06-181-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `FT_READ_LONG`, `FT_GET_LONG`, and related macros did not return negative values when `long` is more than 32 bits. `FT_Stream_ReadULong` would read four bytes into the LSB of an `FT_ULong` and return that. Since this can never set the MSb of the `FT_ULong` when `FT_ULong` is more than 32 bits the cast to `FT_Long` never resulted in a negative value. Fix this by modifying `FT_Stream_Read*` to return a type of the same size as the bytes it is reading and changing the `FT_READ_*` and `FT_GET_*` macros to cast to the same type returned by `FT_Stream_Read*` but with the correctly signed type (instead of casting to what is assumed to be the type of `var` which will happen automatically anyway). There exist a few cases like with the `OFF3` variants where there isn't generally a type with the correct size. `FT_PEEK_OFF3` works around this loading the bytes into the three most significant bits and then doing a signed shift down. `FT_NEXT_OFF3` also already worked correctly by casting this signed value to another signed type. `FT_Stream_GetUOffset` works correctly but one must be careful not to attempt to cast the returned value to a signed type. Fortunately there is only `FT_GET_UOFF3` and no `FT_GET_OFF3`. All of these cases are handled correctly when reading values through `FT_Stream_ReadFields` since it generically computes the signed value through an `FT_Int32`. This change is essentially doing the same for these macros. * include/freetype/internal/ftstream.h (FT_NEXT_*, FT_GET_*, FT_READ*): Update macros and return types to use fixed size types for fixed size values. * src/base/ftstream.c (FT_StreamGet*, FT_StreamRead*): Dito. Issue: #1161
* [truetype/GX] Fix an old typo.Alexei Podtelezhnikov2022-06-161-2/+2
| | | | | * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Vertical advance is measured along y-coordinate.
* [truetype/GX] Clean up advance adjustment (Brrr). Alexei Podtelezhnikov2022-06-161-11/+0
| | | * src/truetype/ttgload.c (load_truetype_glyph): Remove remaining code.
* [type1] Directly search for eexec in private dictBen Wagner2022-06-161-46/+9
| | | | | | | | | | | | | | | | | | | | | This code originally just searched for `eexec`. This was later modified to check that the `eexec` found is valid (not in a string or comment). This was done by searching for `eexec` as before and then, for each `eexec` found, searching from the beginning using the correct parsing to see if the `eexec` was still found. If the private dictionary is large and contains many copies of `eexec` which are not valid, the initial part of the private dictionary is scanned once for each, potentially leading to n^2 parsing time. Instead of finding an initial `eexec` and then re-parsing to discover if it is valid, drop the initial search for `eexec` and just parse to find a valid `eexec`. This is strictly faster since the validation must happen anyway and avoids restarting from the beginning each time an `eexec` is found in the data. * src/type1/t1parse.c (T1_Get_Private_Dict): avoid n^2 parsing Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1328883
* [truetype/GX] Clean up advance adjustment.Alexei Podtelezhnikov2022-06-153-44/+25
| | | | | | | | | * src/truetype/ttgload.c (TT_Process_Simple_Glyph, load_truetype_glyph): Move the advance adjustment from here... * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): ... to here and simplify arguments. * src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Update prototype with fewer arguments.
* [gzip] Handle inflate returning Z_NEED_DICTBen Wagner2022-06-141-0/+3
| | | | | | | | | | | | | When `inflate` returns `Z_NEED_DICT` this is currently not reported as an error and callers may assume that the decompression succeeded when it did not. In particular, a compressed table in a woff file may not actually be decompressed and written as expected, leaving the backing memory for the expanded table uninitialized. * src/gzlip/ftgzip.c (FT_Gzip_Uncompress): treat `Z_NEED_DICT` as indicating invalid data since there is no means to provide a dictionary. Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335712
* [woff] Don't allocate table entries until neededBen Wagner2022-06-131-5/+2
| | | | | * src/sfnt/sfwoff.c (woff_open_font): delay allocating space for the table entries until they are actually written out with the data.
* * src/sfnt/sfwoff2.c (woff2_open_font): Partial revert.Alexei Podtelezhnikov2022-06-121-1/+2
| | | | Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47981.
* * src/lzw/ftzopen.c (ft_lzwstate_stack_grow): Cosmetic macro change.Alexei Podtelezhnikov2022-06-111-1/+1
|
* [woff, woff2] Avoid buffer zeroing.Alexei Podtelezhnikov2022-06-112-41/+35
| | | | | | * src/sfnt/sfwoff.c (woff_open_font): Use Q-macros. * src/sfnt/sfwoff2.c: Ditto. (reconstruct_font): Allocate table_entry on stack.
* [smooth] Fix GCC LTO crashes on Windows.Alexei Podtelezhnikov2022-06-101-1/+1
| | | | | | | | Fixes #1164 by using a volatile variable around `setjmp`. It is hard to say how this fixes crashes related to certain link-time optimizations. This does not decrease the rendering performance. * src/smooth/ftgrays.c (gray_convert_glyph_inner): Use volatile `error`.
* * src/smooth/ftgrays.c [FT_STATIC_RASTER]: Fix compilation.bruvzg2022-06-091-2/+2
|
* [svg] Set linear advances when loading SVG glyphsBen Wagner2022-06-062-0/+6
| | | | | | | | * include/freetype/freetype.h (FT_GlyphSlotRec_): update doc * src/cff/cffgload.c (cff_slot_load): do it * src/truetype/ttgload.c (TT_Load_Glyph): do it Fixes: #1156
* [svg] Clear correct flags for doc ownershipBen Wagner2022-06-011-1/+1
| | | | | | | | | | | | | This issue was discovered with an SVG based font with some documents compressed and other uncompressed. After loading the first compressed document the ownership flag on the glyph slot was set to true but never set to false. As a result after loading a compressed document a glyph from an uncompressed document would load fine, but when this glyph slot was cleared it would try to free its document resulting in a wild free. * src/base/ftobjs.c (ft_glyphslot_clear): clear correct flags Fixes: #1162
* * src/sfnt/ttmtx.c (tt_face_get_metrics): Apply variations unconditionally.Behdad Esfahbod (بهداد اسفهبد)2022-05-251-1/+1
| | | | This causes a speed-up of approx. 20% for getting advance widths.
* [truetype] Support reading 32bit/16bit VarStore deltasDominik Röttsches2022-05-231-34/+15
| | | | | | | | * include/freetype/internal/ftmmtypes.h (FT_ItemVarDelta): Define type to be used for delta arrays, upgrade to FT_long. * src/truetype/ttgxvar.c: Adhere to long_words bit and read either Short/Byte pairs or Long/Short pairs, as defined by spec. For better readability, define macro for repetitive read code.
* [truetype] Handle 0xFFFF special value inside delta retrieval functionDominik Röttsches2022-05-201-21/+10
| | | | | | | | * truetype/ttgxvar.c (tt_hvadvance_adjust, tt_apply_mvar, tt_var_get_item_delta): Remove special 0xFFFF handling in favor of less redundant handling inside the tt_var_get_item_delta function, as it is equivalent to returning a 0 delta. Avoids code-duplication checking for special value 0xFFFF.
* [truetype, snft] Add service methods for `DeltaSetIdxMap` and `VarStore`.Dominik Röttsches2022-05-195-116/+200
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will be needed for 'COLR' v1 variation support. * src/truetype/ttgxvar.h (GX_ItemVarData, GX_AxisCoords, GX_VarRegion, GX_VarItemStore, GX_DeltaSetIdxMap): Move structures to... * include/freetype/internal/ftmmtypes.h: ... this new file. * include/freetype/internal/service/svmm.h (MultiMasters): Include `ftmmtypes.h`. (FT_Var_Load_Delta_Set_Idx_Map_Func, FT_Var_Load_Item_Var_Store_Func, FT_Var_Get_Item_Delta_Func, FT_Var_Done_Item_Var_Store_Func, FT_Var_Done_Delta_Set_Idx_Map_Func): New function typedefs. (MultiMasters): Add them. (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated. * src/cff/cffdrivr.c (cff_load_item_variation_store, cff_load_delta_set_index_mapping, cff_get_item_delta, cff_done_item_variation_store, cff_done_delta_set_index_map): New wrapper methods calling into mm service. (cff_service_multi_masters): Updated. * src/truetype/ttgxvar.c (ft_var_load_item_variation_store, ft_var_load_delta_set_index_mapping, ft_var_get_item_delta, ft_var_done_item_variation_store, ft_var_done_delta_set_index_map): Renamed to ... (tt_var_load_item_variation_store, tt_var_load_delta_set_index_mapping, tt_var_get_item_delta, tt_var_done_item_variation_store, tt_var_done_delta_set_index_map): ... this for consistency. Mark them as non-static. * src/truetype/ttgxvar.h: Add corresponding prototypes. * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated. * src/type1/t1driver.c (t1_service_multi_masters): Updated.