summaryrefslogtreecommitdiff
path: root/src/cff
Commit message (Collapse)AuthorAgeFilesLines
* Add new load flag `FT_LOAD_NO_SVG`.Werner Lemberg2023-05-151-2/+4
| | | | | | | | | | | | | | Modern color fonts often contain both an 'SVG' and 'COLR' table. FreeType always preferred 'SVG' over 'COLR' (this was a design decision), however, this might not be the right choice for the user. The new flags makes FreeType ignore the 'SVG' table while loading a glyph. Fixes #1229. * include/freetype/freetype.h (FT_LOAD_NO_SVG): New macro. * src/base/ftobjs.c (FT_Load_Glyph), src/cff/cffgload.c (cff_slot_load), src/truetype/ttgload.c (TT_Load_Glyph): Use it.
* * src/cff/cffdrivr.c (cff_glyph_load): Fix guard for `size`.Werner Lemberg2023-05-081-1/+1
| | | | | | | | This was forgotten to change in commit 2b54eba36b (in May 2004). Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=58739
* Minor compiler warning fixes.Werner Lemberg2023-05-081-3/+3
| | | | | | | * src/autofit/afcjk.c (af_cjk_get_standard_widths), src/autofit/aflatin.c (af_latin_get_standard_widths): Use `FT_CALLBACK_DEF`. * src/cff/cffparse.c (cff_parser_run): Initialize and fix allocation of `q`.
* * src/cff/cffcmap.c: Signature fixes.Werner Lemberg2023-05-071-35/+46
|
* * src/cff/*: Clean up interface.Werner Lemberg2023-05-074-155/+173
| | | | | | | Ensure that all driver functions use the signature of the service or driver. This avoids pointer mismatches, which are technically undefined behaviour. Recent compilers are more picky in catching them as part of Control Flow Integrity tests.
* [truetype] Fix PostScript name handling for variation fonts.Werner Lemberg2023-05-061-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A variation font's PostScript name of a named instance is usually different from the PostScript name of an unnamed instance. However, if a change between a named instance and an unnamed instance with exactly the same design axis values happened, it was possible that the PostScript name wasn't correctly updated. This commit reorganizes the code to handle this issue within the top-level API functions, using a new service to trigger recomputation of the PostScript name. * include/freetype/internal/services/svmm.h (FT_Construct_PS_Name_Func): New typedef. (FT_Service_MultiMasters): New field `construct_ps_name`. (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated. * src/base/ftmm.c (FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates): Call `mm->construct_ps_name` to handle `postscript_name`. (FT_Set_Named_Instance): Call `mm->construct_ps_name` to handle `postscript_name`. Use shortcut. * src/cff/cffdrivr.c (cff_construct_ps_name): New function. (cff_service_multi_masters): Updated. * src/truetype/ttgxvar.c (tt_set_mm_blend): Don't handle `postscript_name`. (TT_Set_MM_Blend): Simplify. (TT_Set_Named_Instance): Return -1 if axis values haven't changed. Don't set `face_index`. (tt_construct_ps_name): New function. * src/truetype/ttgxvar.h: Updated. * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated. * src/type1/t1driver.c (t1_service_multi_masters): Updated. * src/type1/t1load.c (T1_Set_MM_Blend): Simplify.
* [truetype] Fix deactivation of variation font handling.Werner Lemberg2023-05-061-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the documentation, the functions `FT_Set_Named_Instance`, `FT_Set_MM_Design_Coordinates`, `FT_Set_Var_Design_Coordinates`, and `FT_Set_Var_Blend_Coordinates` can unset the `FT_FACE_FLAG_VARIATION` flag. (The same is true for `FT_Set_MM_WeightVector` but this information was accidentally omitted from the documentation.) However, if a call of these functions didn't change the axis values this could fail because internal shortcuts exited too early. This commit reorganizes the code to handle `FT_FACE_FLAG_VARIATION` in the top-level API functions, also taking care of the issue at hand. * src/base/ftmm.c (FT_Set_MM_Design_Coordinates, FT_Set_MM_WeightVector, FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates): Handle `FT_FACE_FLAG_VARIATION`. * src/truetype/ttgxvar.c (TT_Set_MM_Blend, TT_Set_Var_Design, TT_Set_Named_Instance) Don't handle `FT_FACE_FLAG_VARIATION`. * src/type1/t1load.c (T1_Set_MM_Blend, T1_Set_MM_WeightVector, T1_Set_MM_Design): Ditto. * src/cff/cffobjs.c (cff_face_init): Use `FT_Set_Named_Instance` instead of low-level functions. * src/truetype/ttobjs.c (tt_face_init): Ditto.
* s/set_instance/set_named_instance/Werner Lemberg2023-05-062-5/+7
| | | | | | | | | | | | | | | | | | | * include/freetype/internal/services/svmm.h (FT_Set_Instance_Func): Renamed to... (FT_Set_Named_Instance_Func): ...this. (FT_Service_MultiMasters): Rename `set_instance` to `set_named_instance`. (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated. * src/base/ftmm.c (FT_Set_Named_Instance): Updated. * src/cff/cffdrivr.c (cff_set_instance): Renamed to... (cff_set_named_instance): ...this. (cff_service_multi_masters): Updated. * src/cff/cffobjs.c (cff_face_init): Updated. * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated. * src/type1/t1driver.c (t1_service_multi_masters): Updated.
* New Variation Font function `FT_Get_Default_Named_Instance`.Werner Lemberg2023-05-061-17/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/freetype/ftmm.h, src/base/ftmm.c (FT_Get_Default_Named_Instance): New function. * include/freetype/internal/services/svmm.h (FT_Get_Default_Named_Instance_Func): New typedef. (FT_Service_MultiMasters): New field `get_default_named_instance`. (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated. * include/freetype/internal/tttypes.h (TT_Face): New field `var_default_named_instance`. * src/sfnt/sfobjc.s (sfnt_init_face): Initialize `var_default_named_instance`. * src/cff/cffdrivr.c (cff_get_default_named_instance): New function. (cff_service_multi_masters): Updated. * src/truetype/ttgxvar.c (TT_Get_MM_Var): Initialize `var_default_named_instance`. (TT_Get_Default_Named_Instance): New function. * src/truetype/ttgxvar.h: Updated. * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated. * src/type1/t1driver.c (t1_service_multi_masters): Updated. * docs/CHANGES: Updated.
* * src/cff/cffdrivr/c (cff_get_ps_name): Avoid unnecessary crash.Werner Lemberg2023-04-281-1/+1
| | | | | | | | | The situation can happen if `FT_New_Face` (or one of its siblings) is called with a negative index to get the number of contained faces, followed immediately by a call to `FT_Get_Postscript_Name`. While this is not a valid use of the FreeType library there is no need for a crash. Fixes #1219.
* * src/cff/cffdrivr.c (cff_ps_get_font_info): Reject 'CFF2' format.Werner Lemberg2023-04-281-0/+6
|
* * src/ttgxvar.c: Minor changes.Werner Lemberg2023-04-271-1/+1
| | | | | (TT_Get_MM_Var): Improve tracing messages. (tt_set_mm_blend): Minor speed-up.
* s/this is,/that is,/Werner Lemberg2023-04-272-2/+2
|
* [sfnt, truetype] Add `size_reset` to `MetricsVariations`.Ben Wagner2023-04-112-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a generalization of commit ``` commit e6699596af5c5d6f0ae0ea06e19df87dce088df8 Author: Werner Lemberg <wl@gnu.org> Date: Thu Feb 2 11:38:04 2017 +0100 [truetype] Fix MVAR post-action handling. ``` It is also possible for plain `CFF ` style fonts to contain an `fvar` and `MVAR` table and use `cff_metrics_adjust`. `tt_size_reset` should only be called with `TT_Size` and never with `CFF_Size`. Allow the "metrics-variations" service to specify the correct function (if any) to reset `FT_Size`s after adjusting metrics. * src/truetype/ttobjs.c (tt_size_reset): Split off some functionality into... (tt_size_reset_height): ... this new function. * src/truetype/ttdriver.c (tt_service_metrics_variations): Add `size_reset`. (tt_size_select, tt_size_request): Updated. * src/truetype/ttobjs.h: Updated. * include/freetype/internal/services/svmetric.h (MetricsVariations): Add `size_reset`. (FT_DEFINE_SERVICE_METRICSVARIATIONSREC): Updated. * include/freetype/internal/tttypes.h (TT_FaceRec_): Rename `var` to `tt_var` and add `face_var`. * src/cff/cffdrivr.c (cff_service_metrics_variations): Add `size_reset`. (cff_hadvance_adjust, cff_metrics_adjust): Updated. * src/cff/cffobjs.c (cff_face_init): Use `face_var`. * src/sfnt/sfobjs.c (sfnt_init_face): Initialize `face_var`. * src/sfnt/ttmtx.c (tt_face_get_metrics): Use `tt_var`. * src/truetype/ttgxvar.c (tt_size_reset_iterator): Renamed to... (ft_size_reset_iterator): ... this new function. Call `size_reset`. (tt_apply_mvar): Pass `size_reset` to `ft_size_reset_iterator`. Fixes #1211
* * src/cff/cffcmap.c (cff_cmap_encoding_char_next): Abbreviate.Alexei Podtelezhnikov2023-04-101-18/+6
|
* Align `char_next` return types.Alexei Podtelezhnikov2023-04-101-2/+2
| | | | | | | This is mostly cosmetic because FT_UInt and FT_UInt32 are likely identical. * src/sfnt/ttcmap.c, src/cff/cffcmap.c, src/psaux/t1cmap.c, src/psnames/psmodule.c, include/freetype/internal/service/svpcsmap.h, src/pfr/pfrcmap.c, src/winfonts/winfnt.c (*_char_next): return FT_UInt.
* [cff] Simplify `t2_strings` management in the old engine.Alexei Podtelezhnikov2023-03-202-58/+7
| | | | | | | * src/cff/cffparse.c (cff_parser_run): Allocate the charstring buffers and the list nodes together so that they can be freed at once. (finalize_t2_strings): Removed as no longer needed. (cff_parser_done): Updated.
* [cff] Rework the stream limit checks.Alexei Podtelezhnikov2023-03-191-63/+22
| | | | | | | | | | | | | The old stream limit checks, before 6986ddac1ece, were good but pointless for the crafted t2_strings. Checking limits there is not necessary as they are created to hold all data. By using two conditions, we can detect the actual crossing of the stream boundary as appropriate for the stream pointer only. The t2_strings parsing will not be triggering these checks. * src/cff/cffparse.c (cff_parser_within_limits): Removed. (cff_parse_real, cff_parse_integer): Redesign the stream limit check. (cff_parse_num, do fixed, cff_parse_fixed_dynamic): Update callers.
* * src/cff/cffparse.c (cff_parser_run): Thinko.Alexei Podtelezhnikov2023-03-051-2/+2
|
* [cff] Clean up CharString number encoding.Alexei Podtelezhnikov2023-03-041-49/+18
| | | | * src/cff/cffparser.c (cff_parser_run): Work with signed numbers.
* * src/cff/cffparse.c (cff_parser_run): Fix variable type.Alexei Podtelezhnikov2023-03-041-1/+1
|
* [cff] Clean up memory management in the old engine.Alexei Podtelezhnikov2023-03-041-25/+13
| | | | | | | * src/cff/cffparse.c (finalize_t2_strings): Fix NULL-dereferencing in the out-of-memory situation, use `FT_FREE`. (cff_parser_run): Use FreeType memory allocation macros and avoid uninitialized pointers.
* * src/cff/cffobjs.c (cff_size_init): Synonymous change.Alexei Podtelezhnikov2023-03-041-4/+2
|
* * src/cff/cffobjs.c (cff_size_get_globals_funcs): Shorten de-referencing.Alexei Podtelezhnikov2023-03-031-2/+2
|
* [cff,cid,type1] Shorten de-referencing.Alexei Podtelezhnikov2023-03-031-2/+1
| | | | | * src/cff/cffobjs.c (cff_clot_init): Use immediate library reference. * src/cid/cidobjs.c (cid_slot_init): Ditto. * src/type1/t1objs.c (T1_GlyphSlot_Init): Ditto.
* * src/cff/cffload.c (cff_subfont_load): Synonymous update.Alexei Podtelezhnikov2023-03-021-1/+1
|
* * src/cff/cffload.c (cff_encoding_load): Optimize array zeroing.Alexei Podtelezhnikov2023-02-251-7/+4
| | | | | | This is unnecessary for predefined standard and expert encodings. Even for custom encodings the arrays might be already zeroed when CFF_FontRec is created but we keep it just in case.
* For debugging, avoid implicit conversion from integer to double.Werner Lemberg2023-02-081-6/+6
| | | | | | | | | | 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.
* * src/cff/cffgload.c (cff_slot_load): Avoid memory leak.Werner Lemberg2023-02-021-4/+5
| | | | Fixes issue #1204.
* Update all copyright notices.Werner Lemberg2023-01-1717-17/+17
|
* [cff, truetype] Simplify SVG metrics scaling.Alexei Podtelezhnikov2022-10-211-18/+12
| | | | | | | | Use pre-calculated scaling factors. Also, the advance widths used to be rounded, which was incorrect. * src/cff/cffgload.c (cff_slot_load): Use `x_scale` and `y_scale`. * src/truetype/ttgload.c (TT_Load_Glyph): Ditto.
* [cff] Remove `FT_CONFIG_OPTION_NO_GLYPH_NAMES`.Werner Lemberg2022-10-102-31/+2
| | | | | | | | | This ancient option stayed completely undocumented. Given that the 'cff' driver requires the 'psnames' module, it makes no sense today to have this macro. * src/cff/cffdrivr.c (cff_services), src/cff/cffobjs.c (cff_face_init): Remove corresponding conditional code.
* s/fixed point/fixed-point/Werner Lemberg2022-06-212-4/+4
|
* [svg] Set linear advances when loading SVG glyphsBen Wagner2022-06-061-0/+3
| | | | | | | | * 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
* [truetype, snft] Add service methods for `DeltaSetIdxMap` and `VarStore`.Dominik Röttsches2022-05-191-14/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * src/cff/cffgload.c (cff_slot_load) [FT_CONFIG_OPTION_SVG]: Fix segfault.Georg Brandl2022-04-161-2/+2
| | | | | | This can happen if the function is called with `size` being `NULL`. Fixes #1147.
* Whitespace.Werner Lemberg2022-04-012-3/+3
|
* [cff] Synchronize `cff_slot_load` with `TT_Load_Glyph`.Werner Lemberg2022-03-191-2/+10
| | | | | * src/cff/cffgload.c (IS_DEFAULT_INSTANCE): New macro. (cff_slot_load): Use it.
* Minor clean-ups.Alexei Podtelezhnikov2022-01-271-3/+1
| | | | | | | | * src/base/ftrfork.c (raccess_make_file_name): Do not set error. * src/sfnt/sfdriver.c (get_win_string, get_apple_string): Ditto. * src/cff/cffobjs.c (cff_strcpy): Do not confuse about error. * src/psaux/psobjs.c (ps_table_done): Ditto. * src/truetype/ttgxvar.c (ft_var_readpacked*, ft_var_load_avar): Ditto.
* [truetype, cff] Add code to load SVG document.Moazin Khatti2022-01-201-0/+70
| | | | | * src/cff/cffgload.c (cff_slot_load): Add code to load SVG doc. * src/truetype/ttgload.c (TT_Load_Glyph): Add code to load SVG doc.
* Update all copyright notices.Werner Lemberg2022-01-1117-17/+17
|
* Fix clang++ warnings.Werner Lemberg2021-11-161-6/+6
| | | | * src/*: Initialize some variables to NULL.
* Formatting.Werner Lemberg2021-10-261-2/+2
|
* [cff] Commit vstore data and regions on allocation.Ben Wagner2021-10-211-8/+18
| | | | | | | | | | | | | | | The vstore->regionCount and vstore->dataCount were read directly from the data. However, vstore->varRegionList and vstore->varData would still contain uninitialized entries with uninitialized pointers in the event of an error, leading to issues when attempting to clean up. Reportd as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40104 * src/cff/cffload.c (cff_vstore_load): Read the region and data counts into locals and update the vstore counts immediately after each entry becomes free-able.
* Signedness revisions.Alexei Podtelezhnikov2021-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | | This eliminates explicit casting by switching to unsigned fields. The revisions mostly impact the handling of CID fonts. * include/freetype/fttypes.h (FT_Data): Change to unsigned `length`. * include/freetype/t1tables.h (CID_FaceDictRec): Ditto for `sd_bytes`. (CID_FaceInfoRec): Ditto for `gd_bytes` and `gd_bytes`. * include/freetype/internal/tttypes.h (TT_LoaderRec): Ditto for `byte_len`. * src/cid/cidgload.c (cid_load_glyph): Updated. * src/cid/cidload.h (cid_get_offset): Update argument. * src/cid/cidload.c (cid_get_offset, cid_read_subrs, cid_face_open): Updated. * src/cff/cffgload.c (cff_get_glyph_data, cff_free_glyph_data): Updated. * src/psaux/psft.c (cf2_getT1SeacComponent): Updated. * src/truetype/ttgload.c (TT_Process_Composite_Glyph, load_truetype_glyph): Updated.
* Use NULL for pointers only.Alexei Podtelezhnikov2021-09-232-3/+3
| | | | | | | * src/bdf/bdflib.c (*): Code changes. * include/freetype/freetype.h: Comments only. * src/cff/cffload.c, src/cff/cffobjs.c: Ditto. * src/winfonts/winfnt.c: Ditto.
* * src/cff/cffdrivr.c (cff_ps_get_font_{info,extra}): Use FT_QNEW.Alexei Podtelezhnikov2021-09-201-9/+9
|
* [cff] Explicitly set StandardEncoding or ExpertEncoding offsets.Edwin Steiner2021-09-161-1/+2
| | | | | | Fixes #1097. * src/cff/cffload.c (cff_encoding_load): Set special offset values.
* * src/cff/cffload.c (cff_fd_select_get): Remove casting.Alexei Podtelezhnikov2021-09-161-2/+1
|
* Minor type adjustments.Alexei Podtelezhnikov2021-09-141-4/+4
| | | | | | * src/cff/cffobjs.c (cff_face_init): Reduce casting. * src/truetype/ttobjs.c (tt_size_ready_bytecode): Ditto. * src/type1/t1load.c (T1_Set_MM_Design): Ditto.