summaryrefslogtreecommitdiff
path: root/src/truetype/ttgload.c
Commit message (Collapse)AuthorAgeFilesLines
* * src/truetype/ttgload.c (TT_Process_Composite_Glyph): Fix leak too.Alexei Podtelezhnikov2023-03-061-0/+2
|
* * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Triage memory leak.Alexei Podtelezhnikov2023-03-061-0/+2
| | | | | | This leak has been introduced in the previous commit and immediately detected: https://chromium-review.googlesource.com/c/chromium/src/+/4313202
* [truetype] Simplify memory management.Alexei Podtelezhnikov2023-03-061-57/+40
| | | | | | | | | | | | Instead of using `Update_Max`, switch to regular FreeType memory allocation macros, stop pre-allocating the glyph instruction arrays. * src/truetype/ttgload.c (TT_Load_Simple_Glyph, TT_Process_Composite_Glyph): Switch to regular memory allocation. * src/truetype/ttinterp.c (Update_Max): Removed. (TT_Load_Context): Reallocate stack and free old instructions. (Modify_CVT_Check, Ins_WS): Switch to regular memory allocation. * src/truetype/ttinterp.h (Update_Max): Removed.
* For debugging, avoid implicit conversion from integer to double.Werner Lemberg2023-02-081-7/+7
| | | | | | | | | | 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.
* Whitespace.Werner Lemberg2023-01-281-4/+4
|
* Update all copyright notices.Werner Lemberg2023-01-171-1/+1
|
* * src/truetype/ttgload.c: Cosmetic changes.Alexei Podtelezhnikov2022-10-211-24/+11
|
* [cff, truetype] Simplify SVG metrics scaling.Alexei Podtelezhnikov2022-10-211-17/+11
| | | | | | | | 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.
* * ttgload.c (TT_Process_Composite_Glyph): Fix a signedness warning.Alexei Podtelezhnikov2022-06-211-1/+1
|
* [truetype] Clean up phantom point accounting.Alexei Podtelezhnikov2022-06-181-71/+25
| | | | | | | | | | | | | | 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-181-20/+0
| | | | | | | | | 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.
* [truetype/GX] Clean up advance adjustment (Brrr). Alexei Podtelezhnikov2022-06-161-11/+0
| | | * src/truetype/ttgload.c (load_truetype_glyph): Remove remaining code.
* [truetype/GX] Clean up advance adjustment.Alexei Podtelezhnikov2022-06-151-28/+3
| | | | | | | | | * 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.
* [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
* * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Integer overflow.Werner Lemberg2022-04-191-2/+2
| | | | | | Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=46792
* Whitespace.Werner Lemberg2022-04-011-3/+3
|
* [truetype] Use SUB_LONG for component offset.Ben Wagner2022-04-011-2/+2
| | | | | | * src/truetype/ttgload.c (TT_Process_Composite_Component): do it. Bug: https://crbug.com/1309429
* [truetype] Fix 'sbix' table handling.Werner Lemberg2022-03-251-1/+34
| | | | | | | | | | | | | | | | | * src/sfnt/ttsbit.c (tt_face_load_sbix_image): Correct calculation of 'metrics->horiBearingY'. Set vertical metrics. * src/sfnt/sfobjs.c (sfnt_load_face): Adjust setting of `FT_FACE_FLAG_SBIX`. Handle metrics of fonts with 'sbix' table. * src/truetype/ttgload.c (TT_Load_Glyph): For 'sbix' embedded bitmaps, apply bbox offset and bearing values of the corresponding glyph in the 'glyf' table if it exists and has a contour. * src/truetype/ttobjs.c (tt_face_init): Handle font with 'sbix' table. Fixes issue #998.
* Various minor doc fixes.Werner Lemberg2022-02-061-1/+2
|
* [truetype, cff] Add code to load SVG document.Moazin Khatti2022-01-201-1/+63
| | | | | * 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-111-1/+1
|
* [truetype] Upstream the hdmx binary search.Alexei Podtelezhnikov2021-12-131-3/+1
| | | | | | | | | * src/truetype/ttobjs.h (TT_SizeRec): Add `widthp` for the hdmx widths. * src/truetype/ttobjs.c (tt_size_reset): Initialize `widthp` even though it might never be used by the interpreter. * src/truetype/ttgload.c (tt_loader_init): Avoid repeated searches in the hdmx table.
* [truetype] Reset the IUP-called flags for each subglyph.Alexei Podtelezhnikov2021-12-121-5/+0
| | | | | | | | | This fixes fall-out from 7809007a5b88b15, where the composite accents were no longer hinted. * src/truetype/ttgload.c (ttloader_init): Move the IUP-called flag initialization from here... * src/truetype/ttinterp.c (TT_Run_Context): ... to here.
* [truetype] Honor FT_LOAD_ADVANCE_ONLY if `hdmx` is usable.Alexei Podtelezhnikov2021-12-111-0/+10
| | | | | | | | | This simply shortcuts the glyph loading if FT_LOAD_ADVANCE_ONLY is specified by FT_Get_Advances and the `hdmx` data are located. Particularly, the classic v35 interpreter or "verified" ClearType fonts might see 100x speed up in retrieving the hdmx cache. * src/truetype/ttgload.c (TT_Load_Glyph): Insert the shortcut.
* [truetype] Initialize the loader with `hdmx` data.Alexei Podtelezhnikov2021-12-111-35/+30
| | | | | | | | | The `hdmx` matching can be done before the glyph is loaded. * include/freetype/internal/tttypes.h (TT_LoaderRec): Add a field. * src/truetype/ttgload.c (compute_glyph_metrics): Relocate the `hdmx` code from here... (tt_loader_init): ... to here, before the glyph is loaded.
* [truetype] Relocate subpixel flag setting.Alexei Podtelezhnikov2021-12-111-2/+29
| | | | | | | | | | `TT_RunIns` is too busy to deal with subpixel flags. It is better to set them in `tt_loader_init`, which is executed before each glyph program. * src/truetype/ttinterp.c (TT_RunIns): Move the flag setting from here... * src/truetype/ttgload.c (tt_loader_init): ... to here.
* [truetype] Reduce Infinality footprint again.Alexei Podtelezhnikov2021-12-071-28/+12
| | | | | * src/truetype/ttgload.c (compute_glyph_metrics): Streamline and prioritize the Infinality checks to use `hdmx`.
* * src/truetype/ttgload.c (load_truetype_glyph): Fix MSVC warning C4312.Alexei Podtelezhnikov2021-10-291-1/+1
|
* [truetype] Reload context after re-executing `prep`.Ben Wagner2021-10-151-0/+3
| | | | | | | | | | When a different hinting mode from the current is selected, the `prep` table must be re-executed with the new mode. After this happens the context must be re-loaded in preparation for the glyph program to be run. Fixes #1104. * truetype/ttgload.c (tt_loader_init): Add call to `TT_Load_Context`.
* Signedness revisions.Alexei Podtelezhnikov2021-10-071-9/+8
| | | | | | | | | | | | | | | | | | | | | 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.
* [truetype] Avoid some memory zeroing.Alexei Podtelezhnikov2021-09-121-1/+1
| | | | | | * src/truetype/ttgload.c (load_truetype_glyph): Use Q-macro. * src/truetype/ttinterp.c (Update_Max): Ditto. * src/truetype/ttpload.c (src/truetype/ttpload.c): Ditto.
* [truetype] Prevent glyph program state from persisting.Ben Wagner2021-04-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `FDEF` instructions are specified as allowed only in 'prep' or 'fpgm'. FreeType has attempted to prevent their use in the glyph program, but they were still allowed in glyph programs if defined in a function defined in 'prep' or 'fpgm' and called from the glyph program. Similarly, `IDEF` instructions are specified not to be able to modify any existing instruction. FreeType has attempted to prevent their use in the glyph program, but they can still be used like `FDEF`. This change stores the initial bytecode range type and disallows the use of `FDEF` and `IDEF` while running the glyph program. Most other state is copied from the `TT_Size` into the execution context. However, it is possible for a glyph program to use `WS` to write to the storage area or `WCVTP`, `WCVTF`, and `DELTAC[123]` to write to the control value table. Allowing any change to the global state from the glyph program is problematic as the outlines of any given glyph may change based on the order the glyphs are loaded or even how many times they are loaded. There exist fonts that write to the storage area or the control value table in the glyph program, so their use should not be an error. Possible solutions to using these in the glyph program are * ignore the writes; * value-level copy on write, discard modified values when finished; * array-level copy on write, discard the copy when finished; * array-level copy up-front. Ignoring the writes may break otherwise good uses. A full copy up-front was implemented, but was quite heavy as even well behaved fonts required a full copy and the memory management that goes along with it. Value-level copy on write could use less memory but requires a great deal more record keeping and complexity. This change implements array-level copy on write. If any attempt is made to write to the control value table or the storage area when the initial bytecode range was in a glyph program, the relevant array will be copied to a designated storage area and the copy used for the rest of the glyph program's execution. * src/truetype/ttinterp.h (TT_ExecContextRec): New fields `iniRange`, `glyfCvtSize`, `glyfCvt`, `origCvt`, `glyfStoreSize`, `glyfStorage`, and `origStorage`. * src/truetype/ttinterp.c (Modify_CVT_Check): New function to handle `exc->glyfCvt`. (Write_CVT, Write_CVT_Stretched, Move_CVT, Move_CVT_Stretched): Use it. (Ins_WS): Handle `exc->glyfStorage`. (Ins_FDEF, Ins_IDEF): Updated. (TT_RunIns): Updated. (TT_Done_Context): Free 'glyf' CVT working and storage area. (TT_Load_Context): Fix/add casts. * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Fix cast.
* Update all copyright notices.Werner Lemberg2021-01-171-1/+1
|
* [truetype] Fix incremental metrics (#59503).Chris Liddell2020-12-161-15/+18
| | | | | | | | | | | | | | | | | * src/truetype/ttgload.c (tt_get_metrics, load_truetype_glyph): Previously, the code would populate the phantom points before calling the `get_glyph_metrics` callback. For formats like PCL XL format 1, class 2 downloaded fonts (where metrics are removed from the TTF header), this causes problems when the hinting program uses the phantom points (misplaced and distorted glyphs) due to the metrics being unset (all zeros). (tt_get_metrics_incr_overrides): Renamed to... (tt_get_metrics_incremental): ... this. Updated caller * include/freetype/ftincrem.h: Update the documentation to make it clearer that `get_glyph_metrics` is to retrieve metrics from a non-standard source, but *not* for the purpose of imposing custom metrics.
* * src/*: Don't use more than one '\n' in `FT_TRACE` and `FT_ERROR`.Werner Lemberg2020-12-051-3/+5
| | | | | This ensures good logging output, with all lines having a proper prefix (if requested).
* * src/truetype/ttgload.c (TT_Get_VMetrics): Add tracing message.Werner Lemberg2020-08-221-0/+5
|
* [truetype] Retain OVERLAP_SIMPLE and OVERLAP_COMPOUND.Alexei Podtelezhnikov2020-08-051-2/+11
| | | | | | | | | | | | | For glyphs with OVERLAP_SIMPLE or OVERLAP_COMPOUND, set FT_OUTLINE_OVERLAP to render them with direct oversampling, which mitigates artifacts (see 3bb512bc9f62). * include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): Redefine to rhyme with OVERLAP_SIMPLE. * src/base/ftgloadr.c (FT_GlyphLoader_Rewind): Reset outline flags. * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Retain OVERLAP_SIMPLE. (load_truetype_glyph): Retain OVERLAP_COMPOUND.
* * src/truetype/ttgload.c (TT_Load_Glyph): More tracing.Alexei Podtelezhnikov2020-08-041-2/+9
|
* Fix `-Wformat' compiler warnings.Priyesh Kumar2020-07-281-2/+2
| | | | | | * src/*: Fix format specifiers. * builds/unix/ftsystem.c (FT_Stream_Open): Ditto.
* Make macros for header file names optional.David Turner2020-06-081-8/+8
| | | | | | | | | | | | | | | | | 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.
* Update all copyright notices.Werner Lemberg2020-01-191-1/+1
|
* [truetype] Fix integer overflow (#57287).Armin Hasitzka2019-11-231-2/+3
| | | | * src/truetype/ttgload.c (compute_glyph_metrics): Use `SUB_LONG'.
* Properly handle phantom points for variation fonts (#56601).Ben Wagner2019-07-121-6/+21
| | | | | * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Scale phantom points if HVAR and/or VVAR is present.
* [truetype] Fix copy-and-paste error (#56409).Ben Wagner2019-05-291-4/+6
| | | | | * src/truetype/ttgload.c (load_truetype_glyph): Use correct indices into `unrounded' array for phantom points.
* * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Improve accuracy.Ben Wagner2019-05-261-5/+2
|
* * src/truetype/ttgload.c (load_truetype_glyph): Init `unrounded'.Werner Lemberg2019-05-161-1/+1
| | | | | This fixes linear advance width values for spacing glyphs. Bug introduced 2019-05-09.
* [truetype] Avoid code duplication.Werner Lemberg2019-05-161-5/+0
| | | | | | | * src/truetype/ttobjs.c (tt_size_run_prep): Scale CVT values in this function. (tt_size_ready_bytecode): Updated. * src/truetype/ttgload.c (tt_loader_init): Updated.
* [truetype] Doh. Fix last commit to make it work.Werner Lemberg2019-05-131-25/+64
| | | | | | | | | | | | | | | | | | | | | | | | Very embarassing :-) Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14701 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14705 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14710 * src/truetype/ttgload.c (IS_DEFAULT_INSTANCE): Move up and add argument; update all callers. (TT_Process_Simple_Glyph): Use it. The `unrounded' array is active for variation fonts only, thus also enclose related code with `#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT ... #endif' where necessary. Revert commit a113e5d from 2019-05-09, and don't use `extra_points2' but allocate a temporary array. Speed up the scaling of the `unrounded' array. * src/truetype/ttgxvar.c (FT_fixedToInt, FT_FixedToFdot6): Fix type conversions and rounding. The unsigned type must have more or equal bits to the signed type.
* [truetype] Increase precision of font variation (#54371).Werner Lemberg2019-05-111-18/+44
| | | | | | | | | | | | | | | | This patch make FreeType use font units in 26.6 format internally instead of integers. * src/truetype/ttgxvar.c (FT_fixedToFdot6): New macro. (TT_Vary_Apply_Glyph_Deltas): Add argument to output unrounded font coordinates. * src/truetype/ttgxvar.h: Updated. * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Use `extra_points2' array to temporarily hold unrounded point coordinates; use them to compute scaled coordinates and linear advance width and height. (load_truetype_code): Adjust similarly.
* * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Minor.Werner Lemberg2019-05-091-8/+5
|