Compare commits

...

668 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov 68399b4244 * include/freetype/ftmm.h: Include `freetype.h`.
Reported by Ben Wagner, see !326.
2024-05-13 16:57:35 +00:00
Alexei Podtelezhnikov b8db819768 [type1/MM] Safer handle arrays of different types.
* src/type1/t1load.c (parse_blend_design_map): Separately allocate...
(T1_Done_Blend): ... and free `design_points` and `blend_points`.
2024-05-12 22:38:38 -04:00
Alexei Podtelezhnikov 5b1cde804d * src/type1/t1load.c (parse_blend_design_map): Add risky cast. 2024-05-11 23:27:34 -04:00
Alexei Podtelezhnikov e834786b34 * docs/CHANGES: Mention the last commit. 2024-05-11 23:25:37 -04:00
Alexei Podtelezhnikov 4a85db7e31 [type1/MM] Tighten headers.
* include/freetype/internal/t1types.h: Host PS_DesignMap and PS_Blend.
* include/freetype/ftmm.h: Host and document TT_MAX_MM_XXX.
* include/freetype/t1tables.h: Remove them from here.
2024-05-11 22:19:25 -04:00
Alexei Podtelezhnikov b875924a6f * src/pshinter/pshrec.c (ps_hints_stem): Correct argument. 2024-05-10 23:01:23 -04:00
Ben Wagner a46424228f [psaux] Fix location and type order in initializer
`T1_FIELD_ZERO` is used to zero initialize a `T1_FieldRec`.
`T1_FIELD_ZERO` is currently initilizing `T1_FieldRec::location` with a
`T1_FieldType` and `T1_FieldRec::type` with a `T1_FieldLocation`. This
was detected with `-Wenum-conversion`.

* include/freetype/internal/psaux.h (T1_FIELD_ZERO): correct order of
initalizers
2024-05-08 11:36:18 -04:00
Alexei Podtelezhnikov 1264b84c08 * include/freetype/internal/psaux.h: Fix g++ warning.
Reported by Hin-Tak Leung.
2024-05-07 23:35:59 -04:00
Ben Wagner 5858fa16ca [colr] Avoid overflow in range checks
In 32 bit builds `FT_ULong` is 32 bits and can silently overflow when a
large number is read into one and then it is summed or multiplied with
another number.  Checks for range overflow must be written so that they
themselves do not overflow.  Also ensure that the table_size is always the
first part of the range check and consistently use `<` or `<=`.

* src/sfnt/ttcolr.c (tt_face_load_colr): Avoid overflow.
(find_base_glyph_v1_record): Remove old work-around.

Bug: https://issues.chromium.org/issues/41495455
Bug: https://issues.chromium.org/issues/40945818
2024-05-08 05:01:16 +02:00
Werner Lemberg 2240e21cf5 .mailmap: Fix entry for Ben Wagner. 2024-05-06 21:53:24 +02:00
Alexei Podtelezhnikov d0e3239f32 [sdf, bsdf] Use shared FT_SqrtFixed.
FT_SqrtFixed (95b0fe2a6d) is faster and does not overflow.

* src/sdf/ftsdfcommin.h (square_root): Replace with a macro.
* src/sdf/ftsdfcommin.c (square_root): Remove function.
2024-05-06 13:39:06 +00:00
Alexei Podtelezhnikov 2edfd7e168 * src/autofit/aflatin.c (af_latin_metrics_scale_dim): Remove FT_ABS.
See
    https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68679
2024-05-04 16:42:47 -04:00
Alexei Podtelezhnikov 7bd887f177 * src/sfnt/sfwoff2.c (woff2_open_font): Fix copy-paste typo. 2024-05-03 16:04:35 +00:00
Alexei Podtelezhnikov 3f28a6b6af [woff,woff2] Limit the number of tables and use FT_MSB.
The upper limit of 4095 is implied by the SFNT header format
where the multiplication by 16 would overflow without it.

* src/sfnt/sfwoff.c (woff_open_font): Updated.
* src/sfnt/sfwoff2.c (woff2_open_font): Ditto.
2024-05-03 15:44:57 +00:00
Ben Wanger 13d1180f45 [woff2] Disallow zero table font entries
The existing code already disallows zero table woff2 overall, but still
allows for individual CollectionFontEntry to create font instances with
zero tables. Such fonts are not useful so error early.

This also fixes an MSAN discovered issue where if a CollectionFontEntry
numTables is zero then the sfnt_header was not fully initialized.

* src/sfnt/sfwoff2.c (woff2_open_font): error on zero tables, always
initalize sfnt_header

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68384
2024-05-02 15:00:27 -04:00
Alexei Podtelezhnikov 4d50468478 [sfnt] Use faster macros in checksums.
* src/truetype/ttobjs.c (tt_synth_sfnt_checksum): Use FT_NEXT_XXX.
* src/sfnt/sfwoff2.c (compute_ULong_sum): Use macros.
2024-05-01 23:19:31 -04:00
Alexei Podtelezhnikov 13da904267 * src/sfnt/sfwoff2.c (compute_ULong_sum): Clean up. 2024-05-01 00:34:21 -04:00
Alexei Podtelezhnikov 2c9691e7c1 * docs/CHANGES: Updated. 2024-04-30 12:59:52 +00:00
Alexei Podtelezhnikov 5962d3c1b9 * src/cache/ftccache.c (FTC_Cache_RemoveFaceID): Remove nodes instantly. 2024-04-29 22:34:09 -04:00
Alexei Podtelezhnikov a209e1adcd [cache] Remove unused `node_reset`.
* src/cache/ftcmru.h (FTC_MruListClassRec): Remove `node_reset` field.
* src/cache/ftcbasic.c (ftc_basic_{image,sbit}_family_class): Ditto.
* src/cache/ftcmanag.c (ftc_face_list_class): Ditto.
(ftc_size_node_reset): Remove function.
* src/cache/ftcglyph.h: Fix comment.
2024-04-29 17:54:30 -04:00
Alexei Podtelezhnikov f8f0d1a1d9 * src/cache/ftcmru.c (FTC_MruList_New): Do not reset nodes.
Resetting of the size nodes can crash, if a parent face purge happens
simultaneously and destroys the node. It is safer to create a new node.
Fixes #1270, reopened with a separate issue.
2024-04-29 16:58:59 -04:00
Alexei Podtelezhnikov 1168b1b5b0 * src/cache/ftcimage.c (ftc_inode_weight): Formatting. 2024-04-27 20:44:01 -04:00
Alexei Podtelezhnikov 4e079f6357 Document the SDF spread further. 2024-04-27 20:07:36 -04:00
Alexei Podtelezhnikov e2bcca40ca * include/freetype/ftdriver.h: s/truncated/clamped/. 2024-04-22 22:43:41 -04:00
Alexei Podtelezhnikov ec46a50dac Improve SDF documentation. 2024-04-22 21:21:12 -04:00
Alexei Podtelezhnikov 982bc83849 [cache] Minor tweaks.
* src/cache/ftcimage.c (ftc_inode_free): Remove unnecessary check.
* src/cache/ftcmanag.c (FTC_Manager_Done): Do not zero before freeing.
2024-04-21 15:53:05 -04:00
Alexei Podtelezhnikov 5a3bfa92d9 * src/cache/ftcbasic.c: Cosmetic harmonization. 2024-04-20 23:28:17 -04:00
Alexei Podtelezhnikov 23e1d64556 [cache] Reduce type mismatches.
* src/cache/ftcbasic.c (FTC_BasicAttrRec): Match type of `load_flags`
to its main purpose in `FT_Load_Glyph`.
(FTC_ImageCache_Lookup{,Scaler},FTC_SBitCache_Lookup{,Scaler}): Updated.
2024-04-20 12:01:58 -04:00
Alexei Podtelezhnikov 9a2d6d97b2 * src/cache/{ftcbasic.c,ftccmap.c}: Use FTC_INLINE. 2024-04-19 14:45:39 -04:00
Alexei Podtelezhnikov dbdcd75889 [cache] Tweak headers.
* src/cache/ftccback.h: Include less and move `ftc_node_destroy`...
* src/cache/ftccache.h: ... to here.
* src/cache/ftcmanag.c: Include less.
2024-04-19 14:02:43 -04:00
Alexei Podtelezhnikov db83e9c0ec * src/cache/ftcglyph.c [!FTC_INLINE]: Fix compilation. 2024-04-18 23:23:13 -04:00
Alexei Podtelezhnikov 12adfc212b [cache] Improve MRU list management.
* src/cache/ftcmru.c (FTC_MruList_Remove): Cosmetic.
(FTC_MruList_New): Accept only valid changes.
* src/cache/ftcmanag.c (ftc_size_node_done):  Simplify.
2024-04-17 15:07:23 +00:00
Alexei Podtelezhnikov d091bca546 [cache] Fix error handling.
Manipulate the cache after a face is requested or a size is looked up
successfully. Fixes #1270.

* src/cache/ftcmanag.c (ftc_size_node_init, ftc_size_node_reset,
ftc_face_node_init): Check for errors before accepting a change.
* src/cache/ftcmru.c (FTC_MruList_New): Do nothing if reset fails.
2024-04-17 00:33:14 -04:00
Alexei Podtelezhnikov b3a6a20a80 [smooth] Switch to vertical bisections.
With horizontal bisections, the smallest section is a whole single
scanline. Almost horizontal lines or other complex scanlines can
easily overflow the rendering pool. Switching to vertical bisections
splits the scanlines and should rule out the overflows.  Fixes #1269.

* src/smooth/ftgrays.c (gray_convert_glyph): Bisect vertically.
2024-04-14 15:37:57 -04:00
Alexei Podtelezhnikov fff58f5424 * src/smooth/ftgrays.c (gray_convert_glyph): Refactor for convenience. 2024-04-14 15:12:31 -04:00
Alexei Podtelezhnikov 674d629b5e [smooth] Store persistent clipping box.
* src/smooth/ftgrays.c (gray_TWorker, gray_raster_render): Add and set
the new structure field.
(gray_convert_glyph): Use it.
2024-04-14 13:06:01 -04:00
Ben Wanger f42ce25563 [colr] Ensure enough bytes for PaintColrLayers
* src/sfnt/ttcolr.c (read_paint): check that there are five additional
bytes to be read when reading PaintColrLayers.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66566
2024-03-08 14:55:12 -05:00
Ben Wagner 17545d4bf7 Avoid n^2 scanning for binary data.
When creating a CID parser the location of the 'StartData' or '/sfnts'
tokens needs to be known.  However, the token parser requires that the
entire document be in memory and flattening the entire stream into memory is
to be avoided.

To avoid forcing the entire stream into memory, previously this code would
scan through the stream looking for 'StartData' or '/sfnts' as strings.
However, these strings could have been in a comment or string token, so the
stream would be read into memory up to that point and the parser run to
check that these strings were actually tokens.  This forced a parser restart
from the beginning each time; as a result, data with many 'StartData'
non-tokens would take n^2 time to check.

* src/cid/cidparse.c (cid_parser_new): Change algorithm to make the initial
scan look for the last possible 'StartData' or '/sfnts' string in the
stream.  The stream is read forward instead of backward as a typical normal
CID font will have one 'StartData' toward the beginning of the data and it
it much faster to read the data from beginning to end instead of end to
beginning.  For memory-based fonts the limit is set to the end of the stream
since the stream is already in memory.  Then the parser is run once to look
for 'StartData' or '/sfnts' tokens.  If they are found the parser is re-set
to reflect this new information.

Reported as

  https://issues.chromium.org/issues/40201695
2024-03-08 17:47:43 +01:00
Alexei Podtelezhnikov 660a7017fa * CMakeLists.txt: Bump required version to 3.5.
Fixes #1267.
2024-03-06 20:08:04 +00:00
Jordan Williams 2cc589043e
meson: Use the standard dependency mechanism to find bzip2
This follows standard conventions in Meson by using the pkg-config file.
This change allows Conan to switch to the Meson build system.
2024-03-04 12:46:19 -06:00
Ben Wanger 2a790a9f49 [cff, truetype] Always set up default variable instance.
For default variable instances `cff_face_init` did not set the blend.  This
mostly worked as later use of the unset blend produced the default
variation.  However, if a user called `TT_Get_MM_Var` the blend would be
partially set up, but not fully.  In particular the number of axes, the axis
definitions, and the instance locations would be set up, but not the current
instance location (`coords` and `normalizedcoords`).  This could lead to the
default instances of CFF2 fonts erroring on any use of `blend`.

Ensure the default variable instance is fully set up by always calling
`FT_Set_Named_Instance` on a variable face.

* src/cff/cffobjs.c (cff_face_init): Call `FT_Set_Named_Instance` on
default instances.
* src/truetype/ttobjs.c (tt_face_init): Ditto.

Fixes #1268.
2024-02-29 07:06:46 +01:00
Werner Lemberg 546237e1bb * src/truetype/ttgxvar.c (ft_var_to_normalized): Integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66543
2024-02-23 11:55:53 +01:00
Alexei Podtelezhnikov 47574f7ea4 Update all copyright notices. 2024-01-27 11:11:22 -05:00
Alexei Podtelezhnikov 4f0256c13f * src/sfnt/ttgpos.c (tt_gpos_get_glyph_class): Fix warning C4018. 2024-01-27 10:47:10 -05:00
David Saltzman 8f286c86ef Add support for kerning from 'GPOS' tables.
This commit adds support for kerning from 'GPOS' tables, while maintaining
support for basic 'kern' tables.  `FT_HAS_KERNING` will be true for a font
with either available and `FT_Get_Kerning` will still use the basic 'kern'
table data if avilable, otherwise check the GPOS 'kern' feature.

This feature is disabled by default; it can be enabled with the
`TT_CONFIG_OPTION_GPOS_KERNING` flag.

Only basic kerning (pair positioning with just an x advance) is supported
from the GPOS layout features; support for that was added to make the
existing `FT_Get_Kerning` API more consistently functional.  FreeType does
not intend to extend itself to further GPOS functionality though; a
higher-level library like HarfBuzz can be used instead for that.

* include/freetype/config/ftoption.h, include/devel/ftoption.h
(TT_CONFIG_OPTION_GPOS_KERNING): New configuration option.

* include/freetype/internal/fttrace.h: Add `ttgpos` trace handler.

* include/freetype/internal/sfnt.h (SFNT_Interface): Add `load_gpos` and
`get_gpos_kerning` fields.
(FT_DEFINE_SFNT_INTERFACE): Updated.

* include/freetype/internal/tttypes.h: Include `fttypes.h`.
(TT_FaceRec) [TT_CONFIG_OPTION_GPOS_KERNING]: Add `gpos_table` and
`gpos_kerning_available` fields.

* src/sfnt/ttgpos.c, src/sfnt/ttgpos.h: New files.

* src/sfnt/sfdriver.c [TT_CONFIG_OPTION_GPOS_KERNING]: Include `ttgpos.h`.
(sfnt_interface): Updated.

* src/sfnt/sfnt.c: Include `ttgpos.c`.

* src/sfnt/sfobjs.c [TT_CONFIG_OPTION_GPOS_KERNING]: Include `ttgpos.h`.
(sfnt_load_face) [TT_CONFIG_OPTION_GPOS_KERNING]: Load and free GPOS kerning
data; check GPOS kerning availability.

* src/truetype/ttdriver.c (tt_get_kerning): Use GPOS kerning if there's no
'kern' table.
2024-01-27 10:55:04 +01:00
Alexei Podtelezhnikov 5761778246 [smooth] Remove SSE2.
As a result of 7b308a29dd, the regular 64-bit execution is now faster
than SSE2. The rendering speed of script fonts at 64 ppem or larger is
improved by about 3% without SSE2. See !314 for the testing results.   

* src/smooth/ftgrays.c (gray_render_conic)[FT_INT64]: Remove SSE2 code.
2024-01-14 13:03:51 +00:00
Alexei Podtelezhnikov 6d9147263b * CMakeLists.txt: Accommodate MingGW.
See https://github.com/StephanTLavavej/mingw-distro/issues/97.
2024-01-13 22:28:54 -05:00
Ozkan Sezer 7bac4d146a * src/sfnt/ttcolr.c (find_base_glyph_v1_record): Fix build in C90 mode. 2024-01-08 20:27:03 +01:00
Alexei Podtelezhnikov cc081d7cce [base] Fix up Mac resource forks and dfonts.
* src/base/ftobjs.c (IsMacResource): Assign `face_index`.
* src/base/ftmac.c (FT_New_Face_From_Suitcase): Ditto after rework.
2024-01-06 19:22:36 -05:00
Alexei Podtelezhnikov 4a85ff0b79 [sfnt] Restrict POST version 1.0.
A font has surfaced with `post` version 1.0 and fewer than 258 glyphs.
Its glyphs did not correspond to their names. We now reject such `post`
strictly following specifications.

* src/sfnt/ttpost.c (tt_face_get_ps_name): Check the number of glyphs
for version 1.0.
2024-01-04 21:38:51 -05:00
Alexei Podtelezhnikov a07ca46cd0 * .gitlab-ci.yml: Use detached CI pipelines.
See issue freedesktop/freedesktop#540.
2024-01-03 14:55:33 +00:00
Werner Lemberg 57c4252ab5 [sfnt] Guard access in 'COLR' v1 glyph binary search.
Reported as

  https://bugs.chromium.org/p/chromium/issues/detail?id=1505216

* src/sfnt/ttcolr.c (find_base_glyph_v1_record): Guard access of the search
pointer during binary search.  The pointer needs to be checked as we go as
the test that compares number of v1 glyphs with table size at the time of
loading the table is not sufficient on its own.

A scenario is possible in which the `BaseGlyphRecord` list extends into
non-`BaseGlyphRecord` parts of the 'COLR' v1 table (but passed the size
comparison check).  Then, at those locations, invalid glyph ID values are
read and may provoke an invalid read due to reassigning min and max values
during the binary search.
2024-01-02 17:55:33 +01:00
Alexei Podtelezhnikov ca76683b78 [ci] Add support for MSBuild on Windows.
This adds msbuild job for VS2019 (x64).

* .gitlab-ci.yml: Added "windows msbuild vs2019 amd64".
2023-12-18 17:45:05 +00:00
Skef Iterum 8eab511017 [CFF] Extract `BlueValues` as `Fixed` rather than `Int`.
This is a follow-up to commit 26a7f047,

  [cff] Make blend operator work with floats in private dicts.

which addressed the 'party baseline' bug.  However, the reporting user
indicated that the default location and some other points in design space
rendered OK, but other points in design space still had problems.  The most
obvious issue being that the x-heights of lower-case letters did not align;
see

  https://github.com/adobe-fonts/source-serif/issues/121#issuecomment-1773794136

After some analysis we determined that this was due to an interaction
between `BlueValue` rounding and the zone-based algorithm.  In short, for a
point to be considered in a zone it must fall within the bounds of the zone.
(There is a slop factor in some cases, but only a very small one.)  In the
Adobe-contributed side of the code, point values are not integer-rounded,
instead they're kept as (some form of) fixed.  Rounding just the `BlueValues`
means that points that need to be considered within a zone will fall outside
of it at some points in design space.

The majority of this patch changes the storage and parsing of `BlueValues`
to keep them as `FT_Fixed`.  No significant code changes were needed because
the values are converted to `Fixed` anyway when stored in `CF_BlueRec`.  No
attempt was made to address problems in the older pshinter code beyond
converting the values from `FT_Fixed` to `FT_Short` when copying the private
dictionary.  (However, as the point values are also rounded in that code,
the problem is much less likely to occur, although inconsistency between
rounding and truncation could cause an analogous problem.)

* include/freetype/internal/cfftypes.h (CFF_PrivateRec): Use `FT_Fixed` for
`blue_values`, `other_blues`, `family_blues`, and `family_other_blues`.

* src/cff/cffload.c (cff_blend_doBlend): Updated.

* src/cff/cffobjs.c (CFF_fixedToInt): New macro.
(cff_make_private_dict): Use it.

* src/cff/cffparse.h (cff_kind_delta_fixed): New enum value.

* src/cff/cffparse.c (do_fixed): Updated.
(CFF_FIELD_DELTA, CFF_FIELD_DELTA_FIXED, CFF_DELTA_KIND): New set of macros,
replacing `CFF_FIELD_DELTA`.
(cff_parser_run): Updated to handle fixed-float deltas.

* src/cff/cfftoken.h: Updated to use `CFF_FIELD_DELTA_FIXED` for blue
values.

* src/psaux/psblues.c (cf2_blueToFixed): Removed, no longer needed.
(cf2_blues_init): Updated.

* src/pxaux/psft.c, src/pxaux/psft.h (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Updated signatures.

* src/psaux/psobjs.c (t1_make_subfont): Updated.
2023-12-14 07:17:01 +01:00
Skef Iterum 6f2bf6a582 [psaux] Improve tracing.
* src/psaux/psintrp.c (cf2_doBlend, cf2_interpT2CharString [cf2_cmdBLEND]):
Show blended values.
2023-12-14 06:55:33 +01:00
Jouk Jansen af6d210537 * vms_make.com: Switch to `clang`.
Also add proper bzip2 support.
2023-12-14 06:21:52 +01:00
Werner Lemberg 9bf72966ed * src/truetype/ttgxvar.c (ft_var_to_normalized): Fix undefined left-shift.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63723
2023-12-14 06:14:43 +01:00
Alexei Podtelezhnikov 50740b37ba [msbuild] Streamline the process.
MSBuild.exe can now be fired from the root folder without options.

* builds/windows/vc2010/freetype.sln: Relocated to...
* MSBuild.sln: ... here with minor changes.
* MSBuild.rsp: New file with command line options.
* docs/INSTALL: Reference `MSBuild.sln`.
2023-12-06 23:33:32 -05:00
Alexei Podtelezhnikov 01f23c39e0 * src/raster/ftraster.c (Draw_Sweep): Swap stub conditions. 2023-12-01 23:13:28 -05:00
Alexei Podtelezhnikov 5999d47d68 * src/raster/ftmisc.h (FT_MulDiv): Remove unused copy. 2023-12-01 20:50:16 -05:00
Alexei Podtelezhnikov 8f255c89e1 [raster] Speed up Bézier arches with extrema.
While it is recommended to have an explicit point at each curve
extrema, they might be missing or outline could be rotated. This
leads to excessive bisections in raster to find them.  This change
helps to decrease the number of bisections.  The scanline
intersections remain monotonous, of course.

* src/raster/ftraster.c (Conic_To, Cubic_To): Check that control
points cross the scanlines to bisect.
2023-11-27 22:44:36 -05:00
Alexei Podtelezhnikov 1eb04c71eb * docs/*: Typos. 2023-11-25 09:00:11 -05:00
Alexei Podtelezhnikov efbae5476f [raster] Eliminate intensive flow checking.
* src/raster/ftraster.c (Draw_Sweep): Pass the flow increment.
(Increment): Accept the flow increment.
2023-11-24 10:23:36 -05:00
Alexei Podtelezhnikov 63d3a37eb7 * src/raster/ftraster.c: Comments, defines, includes, cleanups. 2023-11-23 17:50:04 -05:00
Alexei Podtelezhnikov df39b017d9 * src/raster/ftraster.c (FT_Outline_Get_CBox ) [STANDALONE_]: Removed. 2023-11-21 18:12:45 +00:00
Alexei Podtelezhnikov c62027d910 * src/raster/ftraster.c (Draw_Sweep): No-fault return.
(Render_Single_Pass): Updated.
2023-11-21 16:54:25 +00:00
Alexei Podtelezhnikov d77dd24b41 [raster] Sweep polishing.
* src/raster/ftraster.c (*_Sweep_Span): Polish.
(*_Sweep_Drop): Restore tracing, polish.
(Draw_Sweep): Simplify the dropout processing loop.
2023-11-21 15:16:56 +00:00
Alexei Podtelezhnikov da8e428977 [raster] Rearrange dropout control.
This reduces the code duplication.

* src/raster/ftraster.c (Function_Sweep_Span): Change signature.
(Vertical_Sweep_Drop, Horizontal_Sweep_Drop): Focus on pixel setting
and move duplicated the dropout control logic to...
(Draw_Sweep): ... this function and refactor.
(Vertical_Sweep_Span, Horizontal_Sweep_Span): Minor.
2023-11-21 00:53:50 -05:00
Alexei Podtelezhnikov d7c72ff919 [raster] Use bitwise dropout mode interpretation.
* src/raster/ftraster.c (Vertical_Sweep_Drop, Horizontal_Sweep_Drop,
Draw_Sweep, Render_GLyph): Interpret dropout mode using bit masks.
2023-11-20 22:46:36 -05:00
Alexei Podtelezhnikov e969289f88 * docs/CHANGES: Updated. 2023-11-16 20:02:08 +00:00
Alexei Podtelezhnikov 050a320764 [raster] Keep only bottom y-turns.
This results in noticeable performance improvement.

* src/raster/ftraster.c (Insert_Y_Turns): All bottom y-turns are still
sorted and stored; only the maximum top y-turn is recorded now. The
function is renamed.
(End_Profile): Updated accordingly.
(Convert_Glyph): Reserve space for the top value.
2023-11-15 23:41:56 -05:00
Alexei Podtelezhnikov fa59e0d64c * src/raster/ftraster.c (End_Profile): Reduce branching.
(InsNew): Tweak condition.
2023-11-15 16:55:57 +00:00
Alexei Podtelezhnikov c580926f35 * src/raster/ftraster.c (Draw_Sweep): Use more natural loop. 2023-11-15 15:17:50 +00:00
Alexei Podtelezhnikov b0265ccd33 [raster] Dissolve a loop.
* src/raster/ftraster.c (End_Profile): Set initial `X` here...
(Draw_Sweep): ... instead of here; delay the `start` decrement.
2023-11-14 23:32:06 -05:00
Alexei Podtelezhnikov 6dc2ecb757 * src/raster/ftraster.c: Comments. 2023-11-14 23:06:41 -05:00
Alexei Podtelezhnikov aec7e717fb [raster] Stylistic changes.
* src/raster/ftraster.c (Line_To): Code it similar to curves;
shortcut the flat lines here...
(Line_Up): ... instead of here.
2023-11-14 16:47:34 +00:00
Alexei Podtelezhnikov d1b3ef7704 [raster] Revise overshoot setting.
* src/raster/ftraster.c (New_Profile, End_Profile): Deal with overshoots
locally.
(Line_To, Conic_To, Cubic_To): Update callers.
2023-11-14 15:54:52 +00:00
Alexei Podtelezhnikov 667aad581a * src/raster/ftraster.c (Conic_To, Cubic_To): Fix recent regression. 2023-11-14 15:10:52 +00:00
Alexei Podtelezhnikov 0f98994ef6 * include/freetype/ftimage.h: Fix type and link. 2023-11-13 23:15:00 -05:00
Alexei Podtelezhnikov 6e7ef1687f * src/raster/ftraster.c (Increment): Minor tweak. 2023-11-13 22:07:42 -05:00
Alexei Podtelezhnikov e9359e29be [raster] Get rid of the fresh flag.
* src/raster/ftraster.c (black_TWorker): Remove the fresh flag.
(New_Profile): Set the starting scanline here based on the current
coordinate and initialize the joint crossing if necessary.
(Line_Up, Bezier_Up): Do not deal with fresh and joint starts at all.
(Line_Down, Bezier_Down): Simplify.
(Conic_To, Cubic_To): Update the current coordinate after each
subsection.
2023-11-12 23:01:49 -05:00
Alexei Podtelezhnikov d5e8686dd8 [raster] Get rid of the joint flag.
* src/raster/ftraster.c (Line_Up, Bezier_Up): Deal with the scanline
joints directly based on the initial y-coordinate.
(New_Profile, black_TWorker): Remove the boolean flag.
2023-11-11 21:10:29 -05:00
Alexei Podtelezhnikov 9cd403bc9f * src/raster/ftraster.c (Line_Up, Bezier_Up): Check "between" earlier. 2023-11-11 10:18:53 -05:00
Alexei Podtelezhnikov 028b0d5c1b * src/raster/ftraster.c (Line_Up): Updated and fixed up.
This largely synchronizes the entries into `Line_Up` and `Bezier_Up`.
Minor bugs in the remainder calculations and accumulations are fixed.
2023-11-10 23:25:26 -05:00
Alexei Podtelezhnikov d5973932d0 * src/raster/ftraster.c (End_Profile, Convert_Glyph): Clean up. 2023-11-09 22:52:14 -05:00
Alexei Podtelezhnikov e9a81e4dd8 * src/raster/ftraster.c (Bezier_Up): Improve joint and loop. 2023-11-09 22:31:36 -05:00
Alexei Podtelezhnikov 6338f2a681 [raster] Harmonize target bitmap navigation.
* src/raster/ftraster.c (black_TWorker): Store signed maximum indexes
in both directions instead of unsigned dimensions of the original bitmap.
(*_Sweep_*, Render_Glyph, ft_black_render): Updated all users.
2023-11-06 18:56:38 -05:00
Alexei Podtelezhnikov e920273774 * src/raster/ftraster.c (Bezier_Up): Improve flow. 2023-11-05 23:12:56 -05:00
Alexei Podtelezhnikov 8a2ca26b41 [raster] Reshuffle code for readability.
* src/raster/ftraster.c (Render_Glyph): Setup the rendering pool here.
(ft_black_render): Setup the target bitmap helpers here.
2023-11-05 22:34:16 -05:00
Alexei Podtelezhnikov 9e86fb806d [raster] Improve profile accounting during sweeping.
* src/raster/ftraster.c (TProfile): Get rid of `countL`.
(Draw_Sweep): Use `start` for countdown to activation.
(Horizontal_Sweep_Drop, Vertical_Sweep_Drop): Rely on `height` and
`offset` to verify profile ends for the stub detection.
2023-11-03 23:59:05 -04:00
Alexei Podtelezhnikov 32081d8123 [raster] Consolidate profile increment to the next line.
* src/raster/ftraster.c (s/Sort/Increment): Rename this function to
reflect its true purpose, delete exhausted profiles here...
(Draw_Sweep): ... instead of here.
2023-11-03 23:10:41 -04:00
Alexei Podtelezhnikov 046c4fc7be [raster] Instantly remove profiles from linked lists.
* src/raster/ftraster.c (DelOld): Remove loopy function.
(Draw_Sweep): Implement instant profile removal.
2023-11-03 22:34:37 -04:00
Alexei Podtelezhnikov (Алексей Подтележников) 6d6607b8b3 [raster] Modify the split condition.
While curving close to a pixel center, vertical and horizontal pass
might split the curve differently and cause a rare dropout.  This
makes the split condition invariant of the sweep direction and more
robust.

* src/raster/ftraster.c (Bezier_Up): Modify the split condition.
2023-11-03 03:09:54 +00:00
Alexei Podtelezhnikov (Алексей Подтележников) f2e76e8356 [raster] Remove the jitter exception.
The jitter exception used to be applied when two neighboring pixels
were barely inside the outline. One the left one was turned on then,
which contradicts the OpenType specifications.  Intended to remove
glitches, it caused disappearing lines and was softened by adding an
exception to the exception (#54589).

* src/raster/ftraster.c (Vertical_Sweep_Span): Drop the jitter exception.
2023-11-03 03:09:54 +00:00
Alexei Podtelezhnikov dc519d06ea [raster] Simplify dropout detection.
* src/raster/ftrater.c (Draw_Sweep): Use a single dropout condition.
2023-10-31 15:01:32 +00:00
Alexei Podtelezhnikov 4e2d1f040c [raster] Simplify sweeping entry and exit.
* src/raster/ftraster.c (Draw_Sweep): Use y-turns to set the range,
correctly set the initial position, directly loop through y_turns,
and remove a 5-gray remnant at exit.
2023-10-30 22:46:32 -04:00
Alexei Podtelezhnikov 55d0287cfc [raster] Switch to routine Int instead of Short.
This is mostly cosmetic and removes a few casts, plus Short is
promoted to Int in calculations anyway.

* src/raster/ftraster.c (Vertical_Sweep_Init, Vertical_Sweep_Span,
Vertical_Sweep_Drop, Horizontal_Sweep_Init, Horizontal_Sweep_Span,
Horizontal_Sweep_Drop, Draw_Sweep): Mostly s/Short/Int/ and remove
casting.
2023-10-25 23:23:30 -04:00
Alexei Podtelezhnikov 8c5ec8dd63 [raster] Increase the raster pool density.
This only helps to delay the pool overflow and bisections to larger
sizes and benefits only very intricate glyphs at reasonable sizes.

* src/raster/ftraster.c (TProfile): Use Int instead of Long or PLong
when it is sufficient.
(New_Profile, End_Profuile, Bezier_Up, Sort): Updated accordingly.
2023-10-23 22:48:34 -04:00
Alexei Podtelezhnikov a0e10a87f5 [raster] Slightly improve the pool design.
* src/raster/ftraster.c (TProfile): Include the variable array member
and repackage with pointers first.
(New_Profile): Advance the top using the variable array pointer.
2023-10-23 17:47:10 -04:00
Alexei Podtelezhnikov d1e894b1f1 [raster] Clean up sweeping.
* src/raster/ftraster.c (Draw_Sweep): Zero initialize the working
lists directly and remove unnecessary y-turn checks.
(Init_Linked): Removed.
2023-10-22 13:08:36 -04:00
Alexei Podtelezhnikov 09ae6eb677 * src/raster/ftraster.c (Insert_Y_Turn): Improve flow. 2023-10-22 08:13:35 -04:00
Alexei Podtelezhnikov fab53f7b1f * src/pcf/pcfutil.c (BSWAP16): Limit clang support.
These ancient builtins have been supported by clang since 2013. We
condition it somewhat stricter but still around 2017.  This is more
portable than `__has_builtin`. Fixes #1260.
2023-10-21 19:08:20 -04:00
Alexei Podtelezhnikov 4e61303a3b [raster] Small optimizations.
* src/raster/ftraster.c (New_Profile): Set important fields only and
delay setting `gProfile` until...
(End_Profile): ... it is checked to be valid here.
(Convert_Glyph): Updated.
2023-10-18 23:13:13 -04:00
Alexei Podtelezhnikov a35da2c093 * src/raster/ftraster.c (Convert_Glyph): Remove redundant check. 2023-10-18 18:44:00 +00:00
Alexei Podtelezhnikov 3fa5c84565 [raster] Fix linked profiles in contour loops.
This fixes a subtle bug when the last profile in a contour was not
properly short-circuited if it was still empty at `End_Profile`.
We finalize all linking in `Finalize_Profile_List` now and do nothing
else there.  The turns are added in `End_Profile`.

* src/raster/ftraster.c (Insert_Y_Turn): Moved up unchanged.
(End_Profile): Take care of turns but set only preliminary linking.
(Finalize_Profile_Table): Take care of linking and null-termination.
(Convert_Glyph): Adjusted accordingly.
2023-10-17 23:56:23 -04:00
Alexei Podtelezhnikov 749b8f9d34 * src/raster/ftraster.c: Improve tracing. 2023-10-14 22:28:06 -04:00
Alexei Podtelezhnikov 153c038e3c [raster] Improve profile accounting.
* src/raster/ftraster.c (End_Profile): Do not initiate next profile.
(New_Profile): Fully initiate new profile.
(Convert_Glyph): Clean up variables, initialize `fProfile` here.
2023-10-13 15:22:32 +00:00
Alexei Podtelezhnikov f09c5e58c2 * src/raster/ftraster.c (Convert_Glyph): Fix null-dereference. 2023-10-13 13:44:39 +00:00
Alexei Podtelezhnikov c7fa00bf4e [raster] Fix pool overflow checking.
* src/raster/ftraster.c (New_Profile, End_Profile): Check for overflow
immediately.
(Convert_Glyph, Render_Single_Pass): Fix boundaries.
2023-10-13 00:16:02 -04:00
Alexei Podtelezhnikov 14bcb2867a [raster] Miscellaneous clean-ups.
* src/raster/ftraster.c (New_Profile): Use NULL.
(End_Profile): Optimize variables.
(Convert_Glyph): Do not initialize `cProfile` yet.
(Render_Single_Pass): Tracing.
2023-10-12 22:44:46 -04:00
Alexei Podtelezhnikov 322e580bd0 * src/smooth/ftgrays.c: Move the sweep functions...
... out of the setjmp/longjmp scope for readability.
2023-10-09 22:22:24 -04:00
Alexei Podtelezhnikov 84cd2e9897 * src/raster/ftraster.c: Tracing updates. 2023-10-09 22:11:41 -04:00
Zachary Zollman 21435f07de fix typo in FT_Outline_Decompose note 2023-10-08 23:34:28 +00:00
Alexei Podtelezhnikov 7b308a29dd * src/smooth/ftgrays.c (gray_render_conic) [SSE2]: Improve flow. 2023-09-28 22:56:15 -04:00
Alexei Podtelezhnikov e0e5b838e5 * src/gxvalid/gxvcommn.h (GXV_USHORT_TO_SHORT): Removed. 2023-09-25 22:26:15 -04:00
Alexei Podtelezhnikov 49781ab72b Comment typos. 2023-09-24 20:09:17 -04:00
Alexei Podtelezhnikov 73490681a7 * src/base/ftcalc.c (FT_MOVE_SIGN): Enclose assignments. 2023-09-24 19:39:10 -04:00
Alexei Podtelezhnikov cc732ec6d1 * include/freetype/internal/ftcalc.h (FT_MSB): Define for Solaris 11. 2023-09-21 02:28:32 +00:00
Alexei Podtelezhnikov c4073d8251 [psaux] Use `FT_SqrtFixed`.
* src/psaux/cffdecode.c <cff_op_sqrt>: Call `FT_SqrtFixed`.
* src/psaux/psintrp.c <cf2_escSQRT>: Ditto.
2023-09-19 22:29:14 -04:00
Alexei Podtelezhnikov 95b0fe2a6d [base] Reintroduce `FT_SqrtFixed`.
The general square root calculations are not necessary in FreeType.
For vector normalization or length, FreeType uses special functions.
It is, however, required in the legacy CFF specifications.

* src/base/ftcalc.c (FT_SqrtFixed): New function that uses either
Babylonian or bit-wise algorithm, whichever is faster for the given
situation.
* include/freetype/internal/ftcalc.h (FT_SqrtFixed): Declare it.
2023-09-19 22:26:32 -04:00
Alexei Podtelezhnikov babe6af167 * src/base/ftcalc.c /* FT_SqrtFixed */: Fix defunct overflow. 2023-09-18 15:01:26 +00:00
Alexei Podtelezhnikov d7b63a966b * src/tools/apinames.c (read_header_file): Typos. 2023-09-14 13:00:07 +00:00
Alexei Podtelezhnikov 6eb5f2be40 Update 2 files
- /src/base/ftcalc.c
- /include/freetype/internal/ftcalc.h
2023-09-13 17:02:31 +00:00
Ben Wagner 16f311d725 [base] Fix typo to correct predicate for call
* src/base/ftobj.c (FT_Get_Color_Glyph_Paint): check
`get_colr_glyph_paint` before calling `get_colr_glyph_paint` and not
`get_colr_layer`
2023-09-12 18:35:01 -04:00
Alexei Podtelezhnikov 7d45cf2c8f * src/psaux/cffdecode.c (cff_op_sqrt): Correct upper limit. 2023-09-11 20:45:16 -04:00
Alexei Podtelezhnikov 18eb93556c * src/psaux/cffdecode.c (cff_op_sqrt): Improve initial guess. 2023-09-11 17:00:49 -04:00
Alexei Podtelezhnikov 30b0ce7303 src/psaux/psintrp.c (cf2_escSQRT): Improve initial guess.
The worst number of iterations decreased from 11 to 5.
2023-09-11 16:34:36 +00:00
Alexei Podtelezhnikov 17db21f3fc * src/type1/t1afm.c (t1_get_index): Restore `strlen` call.
This reverts commit 8ed6d97446
and fixes
   https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62246
2023-09-10 22:34:17 -04:00
Alexei Podtelezhnikov 446720a29e * src/cff/cffparse.c (CFF_Field_Handler): Some s/0/NULL/. 2023-09-09 23:01:13 -04:00
Alexei Podtelezhnikov 8d0897b37d [type1, cid, type42] Post-cleanup.
* include/freetype/internal/psaux.h (T1_FIELD_ZERO): Terminating macro.
* src/cid/cidload.c (cid_parse_dict): Use while-loop.
* src/type1/t1load.c (parse_dict): Ditto.
* src/type42/t42parse.c (t42_parse_dict): Ditto.
2023-09-09 22:20:00 -04:00
Alexei Podtelezhnikov 3302e2f60c Update forgotten array termini.
* src/cid/cidload.c (cid_field_records): Account for added `len`.
* src/type1/t1load.c (t1_keywords): Ditto.
* src/type42/t42parse.c (t42_keywords): Ditto.
2023-09-09 17:24:34 -04:00
Alexei Podtelezhnikov 7ad9d57c3b [type1, cid, type42] Streamline dictionary parsing.
When matching the keywords, we avoid calculating their lengths by
checking the stored values. This itself is a sufficient pre-check
before diving into `memcmp`. Therefore, we remove explicit check of
the first characters.

* include/freetype/internal/psaux.h (T1_FieldRec): Store length.
* src/cid/cidload.c (cid_parse_dict): Use `memcmp` and stored length.
* src/type1/t1load.c (parse_dict): Ditto.
* src/type42/t42parse.c (t42_parse_dict): Ditto.
2023-09-09 15:19:06 -04:00
Alexei Podtelezhnikov 8ed6d97446 * src/type1/t1afm.c (t1_get_index): Avoid `strlen` call.
Instead, we check the terminal zero.
2023-09-09 15:13:55 -04:00
Alexei Podtelezhnikov 68f1b93247 * src/type1/t1driver.c (t1_ps_get_font_value): Avoid redundant null. 2023-09-08 16:23:05 +00:00
Alexei Podtelezhnikov 9c51e21e53 [cff, truetype] Improve prefix and suffix removal.
* src/cff/cffobjs.c (remove_style): Rewrite using pointers.
(remove_subset_prefix): Unwrap loop and use `memmove`.
* src/truetype/ttobjs.c (tt_skip_pdffont_random_tag): Unwrap loop
and avoid `strlen`.
2023-09-07 23:50:35 -04:00
Alexei Podtelezhnikov 4904d1eb1b * src/sfnt/ttpost.c (load_format_20): Micro-optimize. 2023-09-06 22:58:46 -04:00
Werner Lemberg 45903920b9 [autofit] Fix synchronization mistake between FreeType and ttfautohint.
Found by Behdad.

* src/autofit/aflatin.c (af_latin_metrics_init_blues): Fix array size of
`blue_sorted`: FreeType doesn't have artificial blue zones.
2023-09-05 08:09:31 +02:00
Werner Lemberg ad20173942 [autofit] Fix typos.
This also reduces the used heap size by a large factor.

From Behdad.

* src/autofit/afcjk.h (AF_CJKAxisRec): Use `AF_BLUE_STRINGSET_MAX_LEN`.
* src/autofit/aflatin.h (AF_LatinAxisRec): Ditto.
2023-09-04 19:26:31 +02:00
Alexei Podtelezhnikov 000b26a30f * src/sfnt/ttpost.c (load_format_20): Rework tracing. 2023-08-30 23:03:02 -04:00
Alexei Podtelezhnikov dd1ced4ee3 [builds] Abbreviate the DLG submodule update.
* autogen.sh, builds/toplevel.mk: Revise the command options.
2023-08-30 02:28:48 +00:00
Alexei Podtelezhnikov 2f7abe4838 Comment added. 2023-08-29 19:18:43 +00:00
Alexei Podtelezhnikov c46c4b8e79 * src/sfnt/ttpost.c (load_format_20): Permit long names.
Fixes #1254.
2023-08-29 17:52:06 +00:00
Werner Lemberg 2d9fce53d4 [gzip] Update sources to zlib 1.13. 2023-08-27 09:47:24 +02:00
Werner Lemberg 4a0c5639f7 docs/release: Minor fixes. 2023-08-25 21:36:39 +02:00
Anurag Thakur a4f3e858ae docs/freetype-web.txt: New file. 2023-08-25 21:36:12 +02:00
Werner Lemberg 920c5502cc * Version 2.13.2 released.
==========================

Tag sources with `VER-2-13-2'.

* docs/VERSION.TXT: Add entry for version 2.13.2.
* docs/CHANGES: Updated.
* docs/release, docs/README, builds/macs/README: Updated.

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html, builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html, builds/wince/vc2008-ce/index.html,
docs/freetype-config.1: s/2.13.1/2.13.2/, s/2131/2132/.

* include/freetype/freetype.h (FREETYPE_PATCH): Set to 2.

* builds/unix/configure.raw (version_info): Set to 26:1:20.
* CMakeLists.txt (VERSION_PATCH): Set to 2.
2023-08-25 20:12:52 +02:00
Alexei Podtelezhnikov 0c817334b7 * src/base/ftcalc.c (FT_MulAddFix): Simplify 32-bit rounding. 2023-08-25 17:57:47 +00:00
Werner Lemberg d42679b93d Fix clang warnings.
* src/cffload.c (cff_blend_doBlend): Fix type of `sum`.
* src/truetype/ttgxvar.c (tt_var_load_item_variation_store): Fix type of
  `word_delta_count`.
2023-08-25 18:05:01 +02:00
Werner Lemberg aa5f001874 * subprojects/*.wrap: Updated. 2023-08-24 20:47:00 +02:00
Hugh McMaster e3ada2f70d builds/unix/configure.raw: Use variable to specify minimum Python version. 2023-08-24 20:47:00 +02:00
Alexei Podtelezhnikov 00b07598d9 * builds/toplevel.mk: Simplify version extraction. 2023-08-24 08:13:18 -04:00
Alexei Podtelezhnikov 97251fd5aa [base] Improve the matrix degeneracy check.
Also fixes #1251.

* src/base/ftcalc.c (FT_Matrix_Check): To avoid overflow, scale by shifting.
* include/freetype/internal/ftcalc.h (FT_Matrix_Check): Update description.
2023-08-22 11:01:16 +00:00
Werner Lemberg a3f44aadbc builds/toplevel.mk: Don't use `\#` in functions.
The behaviour changed in GNU make 4.3, where `#` (without the backslash)
would be necessary.  Using a variable instead the code works with both older
and newer GNU make versions.

Fixes #1252.
2023-08-22 12:27:10 +02:00
Hugh McMaster e907eef6b2 builds/freetype.mk: Invoke `mkdocs` as a Python module
FreeType's `refdoc` target currently allows users to override the
default Python path, which is useful for testing and development.

In contrast, `mkdocs` is invoked via the default Python path.

Invoking `mkdocs` via Python's module syntax allows for greater
flexibility, although there is no change for the default use case.
2023-08-19 22:02:14 +10:00
Ben Wagner a9793feace [base] Avoid UB with memcpy
`FT_NEW_ARRAY(p, 0)` sets `p` to `NULL`. `FT_Stream_ReadAt` with a
memory based stream uses `FT_MEM_COPY` which is `memcpy` which specifies
that it is undefined behavior for either the `src` or `dst` to be
`NULL`. Instead of forcing all callers work around calling
`FT_Stream_Read` when `buffer == NULL && count == 0` do the check in
`FT_StreamRead`. This allows any call with `count == 0` to succesfully
read zero bytes without UB.

* src/base/ftstream.c (FT_Stream_ReadAt): skip `FT_MEM_COPY` when
`count == 0`. (FT_Stream_TryRead): ditto

Fixes: #1250
2023-08-17 13:25:31 -04:00
Werner Lemberg a20de84e16 Fix warnings in tracing messages for 32bit compilation.
Since we now require C99, use `%td` for `ptrdiff_t` and `%zu` for `size_t`.
2023-08-12 11:47:41 +02:00
Ben Wagner 3829fdaae5 Avoid overflow in COLR bounds checks.
The values read into `base_glyphs_offset_v1` and `layer_offset_v1` may
be in the range 0xFFFFFFFD-0xFFFFFFFF. On systems where `unsigned long`
is 32 bits adding 4 to such values will wrap and pass bounds checks but
accessing values at such offsets will be out of bounds.

On the other hand `table_size` has already been tested to be at least
`COLRV1_HEADER_SIZE` (34) so it is safe to subtract 4 from it.

* src/sfnt/ttcolr.c (tt_face_load_colr): subtract 4 from `table_size`
instead of adding 4 to font data offsets in bounds checks

Fixes: https://crbug.com/1469348
2023-08-04 11:41:23 -04:00
Alexei Podtelezhnikov 95a872085e * src/base/ftobjs.c (open_face_from_buffer): Silence `maybe-uninitialized`.
We never call this function without a `driver_name` (#1245).
2023-08-01 22:48:31 -04:00
Alexei Podtelezhnikov b2584c738f [truetype] Reduce v40 footprint.
*  src/truetype/ttgload.c (TT_HInt_Glyph, tt_loader_set_pp,
tt_loader_init): Refactor code.
2023-07-28 22:35:58 -04:00
Alexei Podtelezhnikov 1ecfd21990 [truetype] Remove Infinality for good (remaining bits).
* src/truetype/ttobjs.h: Remove remaining fields.
* src/truetype/ttinterp.c: Do not initialize them.
* include/freetype/internal/tttypes.h: Remove descriptions.
2023-07-27 16:12:28 +00:00
Alexei Podtelezhnikov 5b7e45ac34 [truetype] Remove Infinality for good.
Remove everything `#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY`,
which was undefined for a while now.

* include/freetype/internal/tttypes.h: Ditto.
* src/truetype/truetype.c: Ditto.
* src/truetype/ttdriver.c: Ditto.
* src/truetype/ttgload.c: Ditto.
* src/truetype/ttinterp.c: Ditto.
* src/truetype/ttinterp.h: Ditto.
* src/truetype/ttobjs.c: Ditto.
* src/truetype/ttsubpix.[ch]: Remove files.
* src/truetype/rules.mk: Don't mention "ttsubpix.c".
2023-07-27 15:06:38 +00:00
Jouk Jansen 9e3c5d7e18 * vms_make.com: Provide separate library compiled with C++.
Some types on OpenVMS x86_64 (for example, `long') have different sizes
depending on whether compiled with either C or C++.  In particular,
X-Windows applications crash if linked with the C++ version.

This patch makes `vms_make.com` create a second version of the FreeType
library compiled with C++ if OpenVMS is running on the x86_64 platform.
2023-07-21 21:36:57 +02:00
Jouk Jansen f7ae7e88e9 * vms_make.com: Fix typos. 2023-07-21 21:33:20 +02:00
Jouk Jansen 7c542d02bf * src/smooth/ftgrays.c (FT_SSE2): Fix definition for VMS. 2023-07-21 21:31:28 +02:00
Jouk Jansen 5769f13a6b vms_make.com: Make use of additional libraries optional.
Check whether `.olb` files are present.

Also check for the HarfBuzz library.
2023-07-19 13:41:04 +02:00
Jouk Jansen e8aa5af936 vms_make.com: Add `/warn=noinfo` to `CFLAGS`.
This reduces enormously the informationals while compiling on x86_64 (i.e.,
which `.h` file is inluded form where).
2023-07-19 13:41:04 +02:00
Ben Wagner dd3c9c5fec [woff2] Clean up on large brotli expansion
* src/sfnt/sfwoff2.c (woff2_open_font): set error and goto cleanup

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60711
2023-07-18 13:34:09 -04:00
Werner Lemberg 336503dfd7 [woff2] Avoid allocation bomb.
This is a fix for commit 85167dbd5, reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60615

* src/sfnt/sfwoff2.c (MAX_SFNT_SIZE): New macro.
(woff2_open_font): Use it to limit the maximum size of an uncompressed WOFF2
font.
2023-07-16 07:40:32 +02:00
Werner Lemberg 3c92e7bfc2 [cff] Fix compiler warning.
* src/cff/cffparse.c, src/cff/cffparse.h: Make `cff_parse_fixed` a local
function.
2023-07-14 18:58:55 +02:00
Ben Wagner 85167dbd50 [woff2] Remove sfnt size guess check
In WOFF the `totalSfntSize` must be correct, however in WOFF2 this value
is now just a hint and a conforming implementation must not reject
otherwise valid data if the `totalSfntSize` turns out not to be exact.

* src/sfnt/sfwoff2.c (woff2_open_font): remove check that uncompressed
woff2 data would fit in the sfnt size guess.

Fixes: #1235
2023-07-14 14:52:20 +00:00
Skef Iterum 26a7f0478b [cff] Make blend operator work with floats in private dicts.
The CFF2 blend operator takes N default values and corresponding
sets of deltas and pushes N values specific to a designspace
location.  CFF has a floating point numeric type and the FreeType
blending code was not converting those into its internal 16.16
Fixed type format.

Fixes #1243.

* src/cff/cffparse.c (do_fixed): Handle floating point numbers.
Also fix scaling overflow check for integer-to-fixed conversion.

* src/cff/cffload.c (cff_blend_doBlend): Updated.
2023-07-14 11:28:24 +02:00
Hin-Tak Leung dec2743e6a * src/truetype/ttgload.c (TT_Hint_Glyph): More mostly cosmetic update.
This is a follow-up to commit 49c74ac02, which creates a new local variable
"exec = loader->exec", and shortening a lot of "loader->exec".  This commit
does two more such changes missed in that first commit.

Signed-off-by: Hin-Tak Leung <htl10@users.sourceforge.net>
2023-07-08 05:39:25 +02:00
Hugh McMaster 355e919746 [gzip] Don't compile internal zlib development files when using system zlib.
`src/gzip/rules.mk` compiles the internal zlib sources even when using the
zlib development files provided by a host system.  If the internal zlib
development files are not present, FreeType fails to build from source.

This patch ensures the internal zlib development files are only
prerequisites when not using zlib development files on a host system.

* src/gzip/rules.mk (GZIP_DRV_SRCS): Define conditionally.
2023-07-06 14:22:15 +02:00
Werner Lemberg e4586d960f * Version 2.13.1 released.
==========================

Tag sources with `VER-2-13-1'.

* docs/VERSION.TXT: Add entry for version 2.13.1.
* docs/CHANGES: Updated.
* docs/release, docs/README, builds/macs/README: Updated.

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html, builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html, builds/wince/vc2008-ce/index.html,
docs/freetype-config.1: s/2.13.0/2.13/1/, s/2130/2131/.

* include/freetype/freetype.h (FREETYPE_PATCH): Set to 1.

* builds/unix/configure.raw (version_info): Set to 26:0:20.
* CMakeLists.txt (VERSION_PATCH): Set to 1.

* subprojects/libpng.wrap, subprojects/zlib.wrap, subprojects/dlg: Updated.
2023-06-24 08:11:05 +02:00
suzuki toshiya 5c00a46805 Comment fixes. 2023-06-09 07:36:49 +02:00
Werner Lemberg 86d0ca245a [sdf] Correct handling of empty glyphs.
This is a refinement of commit 7b3ebb9.

* src/sdf/ftsdfrend.c (ft_sdf_render): Goto 'Exit' instead of directly
returning.
(fd_bsdf_render): Ditto, also taking care of setting `FT_GLYPH_OWN_BITMAP`
correctly.
2023-06-09 05:38:49 +02:00
Ben Wagner 4e1c0e8fba Mark FT_Renderer_Class::raster_class as pointer to const
The `FT_DEFINE_RASTER_FUNCS` macro declares a `const FT_Raster_Funcs`.
The address of the definition is taken and assigned to
`FT_Renderer_Class::raster_class` which is currently `FT_Raster_Funcs*`.
Until recently the `const` was cast away and with the removal of the
cast there are now warnings about dropping this `const`. Instead of
adding back the casts, make `FT_Renderer_Class::raster_class` a pointer
to const, as is done with pointers in other interfaces.

* include/freetype/ftrender.h (FT_Renderer_Class_): mark `raster_class`
as const.
2023-06-05 12:06:24 -04:00
Ben Wagner 7bed7a02f4 Fix some `FT_Fixed` vs. `FT_Long` confusion.
`FT_Fixed` and `FT_Long` are both typedef'ed to be `signed long`.  However,
`FT_Fixed` implies that the lower 16 bits are being used to express
fractional values and so these two types should not be confused.

* include/freetype/internal/services/svmm.h (FT_Set_MM_Blend_Func): Use
`FT_Fixed` for `coords`.  Users are passing `FT_Fixed` and implementations
are taking `FT_Fixed`.
(FT_Get_MM_Blend_Func): Ditto.

* src/autofit/afcjk.c (af_cjk_metrics_check_digits): Use `FT_Long` for
`advance` and `old_advance`.  `advance`'s address is passed as `FT_Long*` to
`af_shaper_get_elem`, which writes the advance in em units (not fixed).  The
exact value is not important here as it is only compared to check whether it
has changed.

* src/autofit/aflatin.c (af_latin_metrics_check_digits): Ditto.
2023-06-03 07:02:12 +02:00
Ben Wagner 2fb8eda5d6 */*: Remove many function pointer casts.
In C it is undefined behavior to call a function through a function pointer
of a different type.  This is now detected by the Control Flow Integrity
Sanitizer.  All known issues have already been fixed.  Prevent any
accidental re-introduction by removing function pointer casts when defining
services.  The services will call the service functions through the function
pointers on the service.  As a result the functions must have the same type
so there should be no need to cast.  Removing the casts allows compilers to
warn about assignment to an incompatible function pointer type.
2023-06-03 06:58:09 +02:00
Werner Lemberg b641b607be Minor formatting. 2023-06-03 06:09:30 +02:00
Werner Lemberg 80a507a6b8 Replace `sprintf` with `snprintf`.
Fixes #1233.

* include/freetype/config/ftstdlib.h (ft_sprintf): Replace with...
(ft_snprintf): This new macro.

* src/autofit/afhints.c (af_print_idx): Add argument to pass the buffer
size.
(af_glyph_hints_dump_points, af_glyph_hints_dump_segments,
af_glyph_hints_dump_edges): Updated.

* src/bdf/bdflib.c (BUFSIZE): New macro.
(bdf_parse_properties_, bdf_parse_start_): Use `ft_snprintf`.

* src/tools/ftrandom/ftrandom.c (do_test): Use `snprintf`.
2023-05-23 13:18:01 +02:00
Werner Lemberg 66cc4619d2 docs/DEBUG: Formatting. 2023-05-23 12:54:48 +02:00
suzuki toshiya 562f348192 [doc] Type1 GX (sfnt-wrapped Type1) is not supported.
* docs/formats.txt: Clarify the reference of Type1 GX,
and state that this format is not supported.  This
is because the content `TYP1' table is not exactly same
with the Type1 font format specification; no eexec
encryption is used.  For detail and concrete examples,
see the analysis on:

https://gitlab.freedesktop.org/freetype/freetype/-/issues/1231
2023-05-20 12:52:25 +00:00
Craig White 2342a03a9d Add missing end quote of a string in the example code of FT_Trace_Set_Level 2023-05-19 14:11:57 -04:00
Seigo Nonaka 115e927540 [truetype] Reduce heap allocation of `deltaSet` variation data.
`deltaSet` is an array of packed integers that can be 32 bits, 16 bits, or
8 bits.  Before this change, these values were unpacked to 32-bit integers.
However, this can cause big heap allocations, e.g., around 500 KByte for
'NotoSansCJK'.  To reduce this amount, store the packed integers and unpack
them just before passing to the calculation.  At calculation time, due to
the variable length of region indices, temporary heap allocations are
necessary.  This heap allocation is not negligible and visible in `ftbench`
results.  So, use stack-allocated arrays for short array calculations.

Fixes #1230.

* include/freetype/internal/ftmmtypes.h (GX_ItemVarDataRec): New fields
`wordDeltaCount` and `longWords`.

* src/truetype/ttgxvar.c (tt_var_load_item_variation_store): Load packed
data.
(tt_var_get_item_delta): Unpack data before applying.
2023-05-19 06:50:28 +02:00
Jouk Jansen 99dadd56a4 vms_make.com: Create shared executable for x86 version of OpenVMS. 2023-05-17 12:40:59 +02:00
Werner Lemberg 416d4c25f1 Add new load flag `FT_LOAD_NO_SVG`.
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.
2023-05-15 16:04:15 +02:00
Werner Lemberg 872a759b46 .mailmap: Updated. 2023-05-13 09:35:12 +02:00
Alexei Podtelezhnikov e1a4e081aa [cache] Merge functions.
* src/cache/ftccache.c (FTC_Cache_Init): Merge into...
(ftc_cache_done): ... this function, with unnecessary checks removed.
2023-05-12 22:27:08 -04:00
Alexei Podtelezhnikov 771ff8bd03 [cache] Minor casting and cosmetic updates.
* src/cache/ftcglyph.c (ftc_gcache_{init,done}): Remove casting.
(FTC_GCache_Lookup): Cosmetic variable renaming.
* src/cache/ftcsbits.c (ftc_snode_compare): Formatting.
2023-05-12 22:21:47 -04:00
Werner Lemberg 3af4772d68 * include/freetype/ftcache.h: Typo, punctuation. 2023-05-12 05:59:00 +02:00
Alexei Podtelezhnikov b07ab47b2a * include/freetype/ftcache.h: Formatted and updated. 2023-05-11 23:23:52 -04:00
suzuki toshiya 7132f5b0d1 * include/freetype/internal/t1types.h: Fix the indentation. 2023-05-12 09:49:58 +09:00
Alexei Podtelezhnikov ad708d70c9 [cache] Revise the dynamic hash table accounting.
Instead of counting entries relative to the middle of the hash table,
this switches to the absolute counter with the full index range mask.
As a result, some calculations become a bit simpler.  The cache resizing
logic stays largely the same.

* src/cache/ftccache.h (FTC_NODE_TOP_FOR_HASH): Revised with new counter.
* src/cache/ftccache.c (ftc_get_top_node_for_hash): Ditto.
(ftc_cache_resize): Simplify reallocations and stop their zeroing.
(ftc_cache_init): Stop over-allocating but keep zeroing initially.
(FTC_Cache_Clear, FTC_Cache_RemoveFaceID): Updated accordingly.
2023-05-11 21:44:31 +00:00
suzuki toshiya 6ca0a9356f [t1cid] Set FT_FACE_FLAG_CID_KEYED.
* cidobjs.c (cid_face_init): Set FT_FACE_FLAG_CID_KEYED.

* cidriver.c (cid_get_is_cid): Comment about the case that
is_cid cannot guarantee the glyph collection specification.
2023-05-11 14:31:23 +00:00
Jouk Jansen c3876354e5 * src/smooth/ftgrays.c (FT_SSE2): Don't define for VMS. 2023-05-09 07:15:53 +02:00
Werner Lemberg e02a40a4f8 * src/cff/cffdrivr.c (cff_glyph_load): Fix guard for `size`.
This was forgotten to change in commit 2b54eba36b (in May 2004).

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=58739
2023-05-08 20:12:26 +02:00
Werner Lemberg 5edd6d52b1 Minor compiler warning fixes.
* 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`.
2023-05-08 07:22:59 +02:00
Werner Lemberg bd37b84718 * src/psaux/t1cmap.c: Signature fixes. 2023-05-08 06:46:55 +02:00
Werner Lemberg 968fc281ac * src/bzip2/ftbzip2.c: Signature fixes. 2023-05-08 06:26:43 +02:00
Werner Lemberg d52166ae9d [cache] Signature fixes.
* src/cache/ftcglyph.c, src/cache/ftcglyph.h (FTC_GNode_Compare): Remove
redundant function.  It is equivalent to `ftc_gnode_compare` and becomes
completely meaningless with fixed signatures.
Update all callers.

* src/cache/ftcsbits.c, src/cache/ftcsbits.h (FTC_SNode_Compare): Remove
redundant function.  It is equivalent to `ftc_snode_compare` and becomes
completely meaningless with fixed signatures.
Update all callers.
2023-05-08 06:21:16 +02:00
Werner Lemberg c8ae37bab3 [sdf] Signature fixes. 2023-05-07 21:06:14 +02:00
Werner Lemberg 924329a9b0 * src/svg/ftsvg.c: Signature fixes. 2023-05-07 20:57:22 +02:00
Werner Lemberg 6e7b1b7650 [raster] Signature fixes. 2023-05-07 20:51:32 +02:00
Werner Lemberg 02283a6e99 [smooth] Signature fixes. 2023-05-07 20:44:20 +02:00
Werner Lemberg 669b7f7d6b [pshinter] Signature fixes.
* src/pshinter/pshrec.c (t1_hints_close, t1_hints_apply): New wrapper
functions.
(t1_hints_funcs_init): Use them.
(t2_hints_close, t2_hints_apply): New wrapper functions.
(t2_hints_funcs_init): Use them.
2023-05-07 20:26:12 +02:00
Werner Lemberg 274e0dd5b5 [autofit] Signature fixes. 2023-05-07 19:54:46 +02:00
Werner Lemberg 365eb10dd4 * src/sfnt/ttcmap: Signature fixes. 2023-05-07 19:16:38 +02:00
Werner Lemberg 60c11919e0 * src/pcf/pcfdrivr.c: Signature fix. 2023-05-07 16:42:01 +02:00
Werner Lemberg 5f7a26fd31 * src/winfonts/winfnt.c: Signature fixes. 2023-05-07 16:30:21 +02:00
Werner Lemberg 394c4de988 * src/type42/t42parse.c: Signature fixes. 2023-05-07 16:25:37 +02:00
Werner Lemberg 19aca9666e [pfr] Signature fixes. 2023-05-07 15:57:06 +02:00
Werner Lemberg 3297a7a9e0 * src/cid/cidload.c: Signature fixes. 2023-05-07 15:23:46 +02:00
Werner Lemberg 4a28ff3db8 * src/cff/cffcmap.c: Signature fixes. 2023-05-07 14:59:50 +02:00
Werner Lemberg 563f401127 * src/type1/t1load.c: Signature fixes. 2023-05-07 14:59:50 +02:00
Werner Lemberg 95d635eab1 [truetype] Signature fixes. 2023-05-07 14:59:50 +02:00
Werner Lemberg e05c056220 [base] Signature fixes. 2023-05-07 14:59:50 +02:00
Werner Lemberg ff0ef828c9 * src/type42/t42drivr.c: Clean up interface.
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.
2023-05-07 14:59:50 +02:00
Werner Lemberg 7cc5dfa297 * src/type1/*: Clean up interface.
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.
2023-05-07 14:59:50 +02:00
Werner Lemberg 3a85bf0b3f * src/truetype/*: Clean up interface.
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.
2023-05-07 14:59:50 +02:00
Werner Lemberg e245951c43 * src/sfnt/sfdriver.c, src/sfnt/ttbdf.c: Clean up interface.
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.

* src/sfnt/sfdriver.c (sfnt_load_table): New wrapper function.
(sfnt_service_sfnt_table): Use it.
2023-05-07 14:59:50 +02:00
Werner Lemberg ceba488cf8 * src/psnames/psmodule.c: Use `FT_CALLBACK_DEF`. 2023-05-07 14:59:50 +02:00
Werner Lemberg 4360e20e31 * src/pfr/pfrdrivr.c: face -> pfrface, pfrface -> face. 2023-05-07 14:59:50 +02:00
Werner Lemberg 0685b0ad36 * src/pcf/pcfdrivr.c: Clean up interface.
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.
2023-05-07 14:59:50 +02:00
Werner Lemberg b9ce8e33a7 * src/cid/cidriver.c: Clean up interface.
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.
2023-05-07 14:59:50 +02:00
Werner Lemberg bc7466ad45 * src/bdf/bdfdrivr.c: Clean up interface.
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.
2023-05-07 14:59:50 +02:00
Werner Lemberg c041411917 * src/cff/*: Clean up interface.
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.
2023-05-07 14:59:21 +02:00
Werner Lemberg 8fe50c2adc [truetype] Fix style name handling for variation fonts.
* include/freetype/internal/tttypes.h (TT_FaceRec): New field
`non_var_style_name`.

* src/sfnt/sfobjs.c (sfnt_load_face): Initialize `non_var_style_name`.
(sfnt_done_face): Free `non_var_style_name`.

* src/truetype/ttgxvar.c (TT_Set_Named_Instance): Restore non-VF style name
if switching back to non-VF mode.
2023-05-06 18:53:50 +02:00
Werner Lemberg c8a24209d3 [truetype] Fix PostScript name handling for variation fonts.
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.
2023-05-06 18:53:50 +02:00
Werner Lemberg 7af8fd0063 * include/freetype/internal/services/svmm.h: Minor changes. 2023-05-06 18:53:50 +02:00
Werner Lemberg 6713b1e41a [truetype] Fix deactivation of variation font handling.
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.
2023-05-06 18:53:50 +02:00
Werner Lemberg fdcb14a2ee s/set_instance/set_named_instance/
* 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.
2023-05-06 18:53:50 +02:00
Werner Lemberg fb982e78a7 New Variation Font function `FT_Get_Default_Named_Instance`.
* 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.
2023-05-06 18:53:50 +02:00
Werner Lemberg b5e57b041b [cid] Improve tracing messages; formatting. 2023-05-06 16:41:13 +02:00
Alexei Podtelezhnikov 9127c68f59 * src/cache/ftccache.c (ftc_node_hash_unlink): Minor. 2023-05-04 16:54:22 +00:00
Alexei Podtelezhnikov 345f88109b * src/cache/ftcmru.c (FTC_MruList_RemoveSelection): Purge backwards. 2023-05-03 23:33:32 -04:00
Alexei Podtelezhnikov f2f9754542 [cache] Revise list cleansing.
* src/cache/ftcmru.c (FTC_MruList_RemoveSelection): Use one loop to
do it.
* src/cache/ftcmanag.c (FTC_Manager_Compress, FTC_Manager_FlushN):
Streamline loops.
2023-05-03 23:02:04 -04:00
suzuki toshiya be15811c46 [t1cid] Improve cid_get_cid_from_glyph_index().
Update cid_get_cid_from_glyph_index() to
return an error and CID=0 in the case that
the specified glyph index points to an invalid
entry.

cidgload.h (cid_compute_fd_and_offsets):
Declare new helper function to set the
fd_select and 2 offsets to access the glyph
description data.

cidgload.c (cid_compute_fd_and_offsets):
Move the part loading fd_select and 2 offsets
from cid_load_glyph() to here.  If the loaded
parameters are broken, return the Invalid_Offset
error.  This function does not load the glyph
data, only fills these parameters.

(cid_load_glyph): Use new helper function in above.

cidriver.c (cid_get_cid_from_glyph_index):
Check whether the requested glyph index points
to a valid entry, by calling cid_compute_fd_and_offsets().
If it is valid, fill the cid by the glyph
index (=CID).  If it is invalid, return an
error and fill the cid by 0.
2023-05-03 01:31:37 +00:00
Werner Lemberg 77bbfc5960 API documentation: Re-organize chapters and sections
* Split the very long 'Base Interface' section into smaller sections.
* Split the 'Core API' chapter into two chapters.
* Remove single enumeration values from `@order` fields since they have no
  effect.
2023-04-30 14:42:11 +00:00
Alexei Podtelezhnikov 36a086b630 * src/sfnt/pngshim.c (Load_SBit_Png): Remove FALL_THROUGH warning. 2023-04-28 19:40:35 -04:00
Werner Lemberg 08268691aa * src/sfnt/ttload.c (tt_face_load_font_dir): Add another guard.
Reject 'OTTO' fonts with no valid tables.
2023-04-28 15:33:58 +02:00
Werner Lemberg 966ff5a55c * src/cff/cffdrivr/c (cff_get_ps_name): Avoid unnecessary crash.
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.
2023-04-28 15:25:20 +02:00
Werner Lemberg 17a0c5dfd5 * src/cff/cffdrivr.c (cff_ps_get_font_info): Reject 'CFF2' format. 2023-04-28 10:40:41 +02:00
Werner Lemberg 4908c1e84d * src/cid/cidgload.c (cid_load_glyph): Fix compiler warnings. 2023-04-28 06:54:25 +02:00
Werner Lemberg 13df1c7d29 Minor documentation updates. 2023-04-28 06:39:32 +02:00
Werner Lemberg 9a3d05d980 * src/ttgxvar.c: Minor changes.
(TT_Get_MM_Var): Improve tracing messages.
(tt_set_mm_blend): Minor speed-up.
2023-04-27 06:24:48 +02:00
Werner Lemberg cfe54d6ac3 s/this is,/that is,/ 2023-04-27 06:24:48 +02:00
Alexei Podtelezhnikov 7ab541a28b [bdf] Clean up the atom property parsing.
* src/bdflib.c (bdf_is_atom_): Refactor code with fewer checks.
(bdf_list_join_): Return NULL.
(bdf_add_comment_): Use const argument.
(bdf_get_property): Ditto, ditto, make the function static.
* src/bdf.h (bdf_get_property): Remove prototype.
2023-04-26 23:15:24 -04:00
Werner Lemberg 0a3836c97d Improve/add source comments and documentation. 2023-04-25 11:47:18 +02:00
Werner Lemberg 40676afc4c [sfnt] Fix handling of PS names for Variation Fonts.
* src/sfnt/sfdriver.c (get_win_string, get_apple_string): Continue
construction of string if an invalid character is encountered.

Fixes #1218.
2023-04-25 11:47:18 +02:00
suzuki toshiya f312b3402a [t1cid] Change the trace messages of the charstrings retrieval errors.
The t1cid driver catches 3 types of errors in
the charstrings retrieval;
A) The invalid FD number, there are 2 subtypes;
  A-1) FD number is the maximum number fitting to FDBytes.
  A-2) FD number is greater than num_dicts.
B) Declared length is overrunning.
C) Declared length is invalid (its end is before its head).

Considering that some widely distributed fonts
(e.g., "CJKV" book by O'Reilly) have A-1 errors
in the unimplemented glyphs, the trace level for
A-1 is calmed to level 1.

The errors A-2, B, and C would be irregular;
their trace levels are kept at level 0, but
the updated trace messages include the CID number.
2023-04-24 14:06:09 +09:00
suzuki toshiya 9806414c15 [truetype] Fix `make multi'.
* src/truetype/ttgxvar.c: Include freetype/internal/services/svmetric.h
for the FT_Service_MetricsVariations type definition.
2023-04-24 13:36:30 +09:00
Ben Wagner 8154d8e2be [services] FT_Size_Reset_Func to return FT_Error
The `MetricsVariations` `FT_Size_Reset_Func` is currently defined to
return `void`, but the implementations return `FT_Error`. Even though
the pointers passed will be the same at runtime, calling a function
through a pointer of a different type from the original function pointer
type is undefined behavior. This may be caught at runtime by Control
Flow Integrity with something like clang's `cfi-icall`.

Issue: https://crbug.com/1433651

* include/freetype/internal/services/svmetric.h (FT_Size_Reset_Func):
return `FT_Error` instead of `void`.
2023-04-19 13:48:59 -04:00
Ben Wagner c4fe77c3f0 [truetype] tt_size_reset_height to take FT_Size
The `MetricsVariations` `FT_Size_Reset_Func` is defined to take an
`FT_Size`. Because `tt_size_reset_height` is to be used as such a
function, it must also take an `FT_Size` instead of a `TT_Size`. Even
though the pointers passed will be the same at runtime, calling a
function through a pointer of a different type from the original
function pointer type is undefined behavior. This may be caught at
runtime by Control Flow Integrity with something like clang's
`cfi-icall`.

Issue: https://crbug.com/1433651

* src/truetype/ttobjs.h (tt_size_reset_height): take `FT_Size`

* src/truetype/ttobjs.c (tt_size_reset_height): take `FT_Size` and
update documentation
2023-04-17 12:32:04 -04:00
Werner Lemberg ea9fca0add * src/truetype/ttinterp.c: Remove outdated comments. 2023-04-13 06:34:32 +02:00
Ben Wagner e78e2d29a9 [sfnt, truetype] Add `size_reset` to `MetricsVariations`.
This is a generalization of commit

```
commit e6699596af
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
2023-04-11 10:20:58 +02:00
Alexei Podtelezhnikov e77d8ba87c * src/cff/cffcmap.c (cff_cmap_encoding_char_next): Abbreviate. 2023-04-10 15:17:17 -04:00
Alexei Podtelezhnikov 1a4c18f7cb Align `char_next` return types.
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.
2023-04-10 15:30:43 +00:00
Alexei Podtelezhnikov d25444333c [sfnt] Clean up CMAP{4,12,13} handling.
This moves the charcode overflow checks upstream and turns some
while-loops into the do-while ones to avoid the uninitialized warnings.
This should slightly reduce the number of checks and jumps.

* src/sfnt/ttcmap.c (tt_cmap{4,12,13}_next,
tt_cmap{4.12.13}_char_map_linear): Remove the charcode overflow check.
(tt_cmap{4,12,13}_char_map_binary): Ditto and use do-while.
(tt_cmap{12,13}_char_next): Add the overflow check.
2023-04-08 23:15:41 -04:00
Alexei Podtelezhnikov b0a4f99278 * src/sfnt/ttpost.c (load_format_25): Do not abort frame reading. 2023-04-02 22:45:48 -04:00
Alexei Podtelezhnikov 340767bf85 * src/sfnt/ttpost.c (load_format_*): Streamline frame reading. 2023-04-02 22:00:59 -04:00
Alexei Podtelezhnikov 311b78fa12 * src/sfnt/ttpost.c: Formatting and comments. 2023-04-02 09:24:16 -04:00
Alexei Podtelezhnikov 8f7b145524 [sfnt] Consolidate POST version 2.0 and 2.5 (pt 2).
* src/sfnt/ttpost.c (load_format_20, load_format_25): Update arguments
and move shared calls and checks upstream to...
(load_post_names): ... this function.
(tt_face_free_ps_names, tt_face_get_ps_name): Updated.
2023-04-01 23:37:51 -04:00
Alexei Podtelezhnikov 9597a62bac [sfnt] Consolidate POST version 2.0 and 2.5 (pt 1).
The deprecated POST version 2.5 can be handled using the data
structures of version 2.0.  The goal is to reduce the footprint.

* include/freetype/internal/tttypes.h (TT_Post_Names): Absorb and...
(TT_Post_20, TT_Post_25): ... remove these structures.
src/sfnt/ttpost.c (load_post_names, tt_face_get_ps_name,
tt_face_free_ps_names, load_format_20): Updated accordingly.
(load_format_25): ditto and convert offsets to glyph indices.
2023-04-01 22:34:30 -04:00
Alexei Podtelezhnikov 6d7b8b22c4 [sfnt] Miscellaneous POST clean-ups.
* src/sfnt/ttpost.c (load_format_20): Decrease casts.
(load_format_25): Check the table length and impose a theoretical
glyph number limit usable with 8-bit offset.  Decrease casts.
(load_post_names): Pass the mapping data length without 2 bytes.
2023-03-31 23:17:46 -04:00
Alexei Podtelezhnikov 0db6997026 * src/sfnt/ttpost.c (load_format_20): Simplify comutations. 2023-03-30 09:06:35 -04:00
Alexei Podtelezhnikov 4679fcb666 [sfnt] Streamline POST format 2.0 handing (cont'd).
* src/sfnt/ttpost.c (load_format_20): Co-allocate the string data and
their pointers, which makes it easier to handle and free them.
(tt_face_free_ps_names): Updated.
* include/freetype/internal/tttypes.h (TT_Post_20): Update type.
2023-03-29 00:21:00 -04:00
Alexei Podtelezhnikov 4d8db130ea [cff] Simplify `t2_strings` management in the old engine.
* 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.
2023-03-20 16:53:51 -04:00
Alexei Podtelezhnikov 4f0a55d15e [cff] Rework the stream limit checks.
The old stream limit checks, before 6986ddac1e, 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.
2023-03-19 10:13:52 -04:00
Alexei Podtelezhnikov 8fc6df1028 * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Use for-loop.
Even though we never call `TT_Load_Simple_Glyph` with zero contours,
out of abundance of precaution, let's handle this case properly.
2023-03-17 23:35:10 -04:00
Alexei Podtelezhnikov ef63669652 [truetype] Clean up zeroing and local variables.
* src/truetype/ttgload.c (TT_Process_Simple_Glyph): Avoid zeroing.
(load_truetype_glyph): Avoid zeroing and clean local variables.
2023-03-17 23:25:45 -04:00
Werner Lemberg 7be364c6a2 * include/freetype/ftsystem.h (FT_Stream_IoFunc): Improve documentation.
Fixes #1208.
2023-03-16 05:26:48 +01:00
Alexei Podtelezhnikov dd78d4a774 * src/base/ftsynth.c (FT_GlyphSlot_AdjustWeight): New API. 2023-03-16 03:28:59 +00:00
Alexei Podtelezhnikov 764bc8e41c [truetype] Clean up glyph loading.
* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Clean space checking.
(TT_Hint_Glyph): Don't copy the outline structure.
(TT_Process_Simple_Glyph): Cosmetic update.
2023-03-15 23:18:18 -04:00
Alexei Podtelezhnikov e71647621c * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Clean up. 2023-03-15 18:48:27 +00:00
Werner Lemberg d857bd535b builds/vms/apinames_vms.bash: Fix `unzip` artifact
The problem occured when unpacking a zip file created on OpenVMS on Linux.
While OpenVMS knows many different file formats, Unix only knows stream-LF
and binary.  In principle `zip` on Linux should have translated the file to
stream-LF but failed to do so.  That caused the file to incorrectly contain
only one line with control-characters.
2023-03-13 11:47:38 +01:00
Alexei Podtelezhnikov b9376065d6 [truetype] Fix recent fallout in memory management.
* src/truetype/ttgload.c (TT_Process_Composite_Glyph,
TT_Load_Simple_Glyph): Clean up old instructions regardless of
new ones, postpone setting `control_len` and `control_data` until...
(TT_Load_Glyph): ... the exit from this function.
2023-03-10 23:41:39 -05:00
Jouk Jansen 24d2523cdd Update VMS installation support. 2023-03-10 16:56:15 +01:00
Alexei Podtelezhnikov 49c74ac021 * src/truetype/ttgload.c (TT_Hint_Glyph): Mostly cosmetic update.
The number of instructions is now taken from the executed context.
Technically, this means that `control_len` and `control_data`
values are no longer _used_ internally but only expose them.
2023-03-09 22:37:03 -05:00
Werner Lemberg bd6208b712 apinames.c: Add comment. 2023-03-08 10:49:42 +01:00
Werner Lemberg d5c6b948ac [gzip] File `infback.c` is not needed.
* src/gzip/infback.c: Remove.
* src/gzip/rules.mk (GZIP_DRV_SRCS): Updated.
2023-03-07 08:55:58 +01:00
Werner Lemberg 092f9d9874 [apinames] Fix VMS handling of overly long function names.
Based on ideas from Jouk Jansen <joukj@hrem.nano.tudelft.nl>.

* src/tools/vms_shorten_symbol.c: New file, taken from

  https://sourceforge.net/p/vms-ports/vmsshortsym/ci/default/tree/vms_shorten_symbol.c

with some minor edits to allow compilation with C++ and being included in
another source code file.

* src/tools/apinames.c: Include `vms_shorten_symbol.c`.
(PROGRAM_VERSION): Set to '0.5'.
(names_dump) [OUTPUT_VMS_OPT]: Call `vms_shorten_symbol` to get unique function
identifiers not longer than 31 characters.
2023-03-07 07:28:32 +01:00
Werner Lemberg 72a8d65218 * src/tools/apinames.c (panic): Accept variable number of arguments. 2023-03-07 07:16:59 +01:00
Alexei Podtelezhnikov b3250f367a * src/truetype/ttgload.c (TT_Process_Composite_Glyph): Fix leak too. 2023-03-06 23:53:42 -05:00
Alexei Podtelezhnikov b36193d025 * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Triage memory leak.
This leak has been introduced in the previous commit and immediately
detected:
  https://chromium-review.googlesource.com/c/chromium/src/+/4313202
2023-03-06 22:48:21 -05:00
Alexei Podtelezhnikov de94e2cbfb [truetype] Simplify memory management.
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.
2023-03-06 16:23:14 -05:00
David PROVENT b2a9490623 Added information about the zlib version update in the changelog 2023-03-06 14:32:02 +01:00
Alexei Podtelezhnikov fc01e7dd67 Fix a couple of MSVC warnings.
* src/base/ftcalc.c (FT_MulAddFix): Add cast.
* src/sfnt/ttcolr.c (tt_face_get_colorline_stops, read_paint): Ditto.
2023-03-05 22:05:24 -05:00
Alexei Podtelezhnikov 70946f6dc6 * builds/windows/vc2010/freetype.vcxproj: Suppress C4267 on _WIN64.
This usually comes from `strlen` returning 64-bit `size_t`, which
we often assign to 32-bit `FT_ULong` on Windows-64 (LLP64).
2023-03-05 16:08:14 -05:00
Alexei Podtelezhnikov c4b5127b74 * src/cff/cffparse.c (cff_parser_run): Thinko. 2023-03-05 00:31:58 -05:00
Alexei Podtelezhnikov de6002203b [cff] Clean up CharString number encoding.
* src/cff/cffparser.c (cff_parser_run): Work with signed numbers.
2023-03-04 23:49:49 -05:00
Alexei Podtelezhnikov 51c1705477 * src/cff/cffparse.c (cff_parser_run): Fix variable type. 2023-03-04 23:32:50 -05:00
Alexei Podtelezhnikov a2b8937d47 [cff] Clean up memory management in the old engine.
* 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.
2023-03-04 14:00:52 -05:00
Alexei Podtelezhnikov 29578f75c3 * src/cff/cffobjs.c (cff_size_init): Synonymous change. 2023-03-04 13:39:27 +00:00
Alexei Podtelezhnikov 7ae20e55c9 * src/sfnt/sfobjs.c (sfnt_load_face): Shorten de-referencing. 2023-03-03 22:41:09 -05:00
Alexei Podtelezhnikov 49eac0da0c [pfr] Shorten de-referencing.
* src/pfr/pfrobjs.c (pfr_face_done, pfr_face_init): Use closer `memory`.
* src/pfr/pfrgload.c (pfr_glyph_load_compound): Remove `loader`.
2023-03-03 22:10:50 -05:00
Alexei Podtelezhnikov 2adef94f43 * src/cff/cffobjs.c (cff_size_get_globals_funcs): Shorten de-referencing. 2023-03-03 18:40:48 +00:00
Alexei Podtelezhnikov 5ac6276af1 [cff,cid,type1] Shorten de-referencing.
* 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.
2023-03-03 17:21:10 +00:00
Alexei Podtelezhnikov 5c37b64062 * configure: Use `sed` instead of `grep`.
This is more portable and consistent with `autogen.sh`.
2023-03-02 20:53:21 +00:00
Ben Wagner 09b326fa2b Avoid strtol on non-null-terminated data.
Technically, `strtol` can only be used with C strings terminated with
`\0`.  CID data is not generally null-terminated and often does not
contain a `\0` if it is hex-encoded.  AddressSanitizer with `ASAN_OPTIONS`
containing `strict_string_checks=1` verifies this by using an adversarial
`strtol` that always reads to the terminating `\0`.

To avoid undefined behavior from `strtol` in `cid_parser_new`, use the
parser to parse the tokens instead of attempting to parse them ad-hoc.
This will internally use `PS_Conv_Strtol` to parse the integer, which
respects the parser's limits and directly implements the PostScript
parsing rules for integers.

* src/cid/cidparse.c (cid_parser_new): Use the parser to parse the
tokens.

Fixes: https://bugs.chromium.org/p/chromium/issues/detail?id=1420329
2023-03-02 20:56:41 +01:00
Alexei Podtelezhnikov e95e623471 * src/cff/cffload.c (cff_subfont_load): Synonymous update. 2023-03-02 17:58:03 +00:00
ubawurinna e8931f8c56 * src/gzip/README.freetype: Update version. 2023-03-01 18:20:46 +00:00
ubawurinna 79c8bd9110 [gzip] Fix static linking.
Without this patch, static linking with MS Visual Studio causes linking
errors.

* src/gzip/ftgzip.c: Set `ZEXPORT` to nothing and `ZEXTERN` to static for
all compilers.
2023-03-01 18:09:56 +01:00
Werner Lemberg d874ffa96c * include/freetype/internal/compiler-macros.h (FALL_THROUGH): Update.
This follows

  https://lists.gnu.org/archive/html/bug-gnulib/2023-02/msg00200.html
2023-03-01 06:36:59 +01:00
Alexei Podtelezhnikov 638df2fe32 [truetype] Treat 38 as 40 without Infinality.
* include/freetype/ftdriver.h (TT_INTERPRETER_VERSION_38): Reinstate.
* src/truetype/ttdriver.c (tt_property_set): Fallback from 38 to 40.
2023-02-27 21:54:23 -05:00
Werner Lemberg 2257f9abf6 * include/freetype/internal/compiler-macros.h (FALL_THROUGH): Update.
This follows

  https://lists.gnu.org/archive/html/bug-gnulib/2023-02/msg00159.html
2023-02-26 20:23:43 +01:00
Werner Lemberg d399657f1b * src/*: Replace leading underscores with trailing ones in dummy variables.
This is to avoid clang warnings.
2023-02-26 20:18:54 +01:00
Karl Berry f19ab67327 * configure: Don't hardcode `grep -E`.
TeXLive still supports Solaris 5.10, where the system's `grep` doesn't
accept the `-E` option.  We thus introduce an `EGREP` variable that is set
to either `grep -E` or `-egrep`.
2023-02-26 07:31:49 +01:00
Alexei Podtelezhnikov 6423ddb8a0 * src/cff/cffload.c (cff_encoding_load): Optimize array zeroing.
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.
2023-02-25 21:54:21 -05:00
Alexei Podtelezhnikov 74c498a383 * src/type1/t1load.c (T1_Get_MM_Var): Optimize array zeroing. 2023-02-25 11:02:21 -05:00
Tamir Duberstein 3f2ac7d890 * src/base/ftsystem.c (ft_ansi_stream_io): Avoid undefined behaviour.
Also short-circuit on `offset` to avoid checking `count` a second time when
`ft_ansi_stream_io` is used for reading.

Per ISO/IEC 9899:

  If an argument to a function has an invalid value (such as a value outside
  the domain of the function, or a pointer outside the address space of the
  program, or a null pointer, or apointer to non-modifiable storage when the
  corresponding parameter is not const-qualified) or a type (after
  promotion) not expected by a function with variable number of arguments,
  the behavior is undefined.  If a function argument is described as being
  an array, the pointer actually passed to the function shall have a value
  such that all address computations and accesses to objects (that would be
  valid if the pointer did point to the first element of such an array) are
  in fact valid.

Per IEEE Std 1003.1:

  size_t fread(void *restrict ptr, size_t size, size_t nitems,
               FILE *restrict stream);

  The `fread` function shall read into the array pointed to by `ptr` up to
  `nitems` elements whose size is specified by `size` in bytes, from the
  stream pointed to by `stream`.

Since the first argument to `fread` is described as being an array, its
behavior is undefined when that argument is a null pointer.

Per the documentation on `ft_ansi_stream_io`:

  If `count' is zero (this is, the function is used for seeking), a non-zero
  return value indicates an error.

Thus the intent is clear, and the call to `fread` can be skipped, avoiding
undefined behaviour.
2023-02-25 05:20:57 +01:00
Alexei Podtelezhnikov 3f01161ff2 [raster] Clean up contour indexing.
* src/raster/ftraster.c (Decompose_Curve, Convert_Glyph): Use consistent
index types (Int) and compact iterations.
2023-02-21 16:17:07 +00:00
Alexei Podtelezhnikov 7f9499044e [autofit] Clean up contour indexing.
* src/autofit/aflatin.c (af_latin_metrics_init_blues): Refactor.
* src/autofit/afcjk.c (af_cjk_metrics_init_blues): Ditto.
2023-02-20 23:29:58 -05:00
Alexei Podtelezhnikov 78464d1b0c * src/base/ftoutln.c (FT_Outline_Check): Fix C4701 warning. 2023-02-20 22:31:21 -05:00
Alexei Podtelezhnikov f5f969a8fe * src/sdf/ftsdf.c (get_min_distance_cubic): Fix C4701, typos. 2023-02-20 22:29:18 -05:00
Alexei Podtelezhnikov fecd19b449 * src/base/ftstroke.c (FT_Stroker_ParseOutline): Clean up contour indexing. 2023-02-20 17:13:40 +00:00
Alexei Podtelezhnikov 34ed28d0fb [base] Clean up contour indexing.
* src/base/ftoutln.c (FT_Outline_Reverse, FT_Outline_EmboldenXY,
FT_Outline_Get_Orientation): Set the first and last indexes together.
(FT_Outline_Decompose): Ditto and check them more stringently.
* src/smooth/ftgrays.c (FT_Outline_Decompose)[STANDALONE_]: Ditto.
2023-02-20 16:33:45 +00:00
Alexei Podtelezhnikov 713580f41d * src/base/ftoutln.c (FT_Outline_Check): Update error code, clean up. 2023-02-20 15:58:04 +00:00
Alexei Podtelezhnikov bbfcd79eac [truetype] Hide Infinality.
Remove Infinality as an option before its complete extraction.

* include/freetype/ftoption.h: Remove the Infinality option.
* devel/ftoption.h: Ditto.
* include/freetype/ftdriver.h (TT_INTERPRETER_VERSION_38): Is 40 now.
2023-02-17 04:22:24 +00:00
Alex Ringlein 74ea5454cc * src/base/ftoutln.c (FT_Outline_Reverse): Anchor first contour points.
A cubic contour has to always start from an on-point. Therefore, we
should not swap the first with the last point, which might be off, and
obtain an invalid contour. This does not matter for conic contours.
If anything, it also saves one swap there. Fixes #1207.
2023-02-16 22:38:35 -05:00
Werner Lemberg 0eca6ead82 Documentation improvement for `FT_Bitmap`.
Fixes #1205.
2023-02-16 06:35:33 +01:00
Alexei Podtelezhnikov dacbb55433 [type1/MM] Round design coordinates.
The design coordinates for MM fonts were not rounded. For example,
`FT_Get_Var_Design_Coordinates` returned values with fractional part.

* src/type1/t1load.c (mm_axis_unmap): Refactor with rounding.

* include/freetype/ftmm.h (FT_Var_Axis, FT_Set_Var_Design_Coordinates,
FT_Get_Var_Design_Coordinates): Reword documentation.
2023-02-10 08:24:33 -05:00
Jan Alexander Steffens (heftig) 23e60caeef * builds/meson/parse_modules_cfg.py: Handle `gxvalid` and `otvalid`.
These need a name mapping similar to what was done for other modules,
or linking will fail.
2023-02-09 21:49:34 +01:00
Werner Lemberg 79a8201e6e * build/toplevel.mk (do_dist): Fix typo. 2023-02-09 07:32:05 +01:00
Werner Lemberg de8b92dd7e * Version 2.13 released.
==========================

Tag sources with `VER-2-13-0'.

* docs/VERSION.TXT: Add entry for version 2.13.
* docs/CHANGES: Updated.

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html, builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html, builds/wince/vc2008-ce/index.html,
docs/freetype-config.1: s/2.12.1/2.13/, s/2121/2130/.

* include/freetype/freetype.h (FREETYPE_MINOR): Set to 13.
(FREETYPE_PATCH): Set to 0.

* builds/unix/configure.raw (version_info): Set to 25:0:19.
* CMakeLists.txt (VERSION_MINOR): Set to 13.
(VERSION_PATCH): Set to 0.
2023-02-09 07:24:52 +01:00
Alexei Podtelezhnikov 4f8c4b0fc4 Comment on `FT_GlyphSlot_Slant'. 2023-02-09 03:59:30 +00:00
Werner Lemberg 995ccfaca5 [autofit] Fix 'multi' compilation.
* src/autofit/ft-hb.c: Decorate with `FT_LOCAL_DEF`.
Add ANSI boilerplate code for otherwise empty file.
* src/autofit/ft-hb.h: Include `compiler-macros.h` and `freetype.h`.
Use `FT_BEGIN_HEADER` and `FT_END_HEADER`.
Decorate with `FT_LOCAL`.

* src/autofit/rules.mk (AUTOF_DRV_SRC): Add `ft-hb.c`.
2023-02-08 21:53:30 +01:00
Werner Lemberg 663486a7ac Fix `FT_LOCAL` and `FT_LOCAL_DEF` tags. 2023-02-08 21:09:32 +01:00
Werner Lemberg ac5babe876 Fix 'fall-through' warning messages.
Modern compilers get more insistent on that...

* include/freetype/internal/compiler-macros.h (FALL_THROUGH): Define.
* src/*: Use it instead of `/* fall through */` comments.
2023-02-08 21:09:32 +01:00
Werner Lemberg be724c8142 For debugging, avoid implicit conversion from integer to double.
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.
2023-02-08 21:09:32 +01:00
Werner Lemberg 37bc7c2604 Avoid reserved identifiers that are globally defined.
This is mandated by the C99 standard, and clang 15 produces zillions of
warnings otherwise.

* devel/ftoption.h, include/freetype/config/ftoption.h,
include/freetype/internal/ftmemory.h, src/autofit/afhints.h,
src/autofit/afmodule.c, src/autofit/aftypes.h, src/base/ftadvanc.c,
src/base/ftdbgmem.c, src/base/ftstream.c, src/bdf/bdflib.c,
src/truetype/ttinterp.c: Replace identifiers of the form `_foo` with `foo_`.
2023-02-08 21:09:30 +01:00
Werner Lemberg da9eb9c719 Fix minor clang and clang++ warnings. 2023-02-08 19:57:22 +01:00
Alexei Podtelezhnikov 4c3916e901 [truetype, type1] Additional variation tags.
Sync with
  https://learn.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg#registered-axis-tags

* src/truetype/ttgxvar.h (TTAG_ital): New tag.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): Use it.
* src/type1/t1load.c (T1_Get_MM_Var): Handle 'slnt' and 'ital'.
2023-02-08 14:58:46 +00:00
Alexei Podtelezhnikov 27b2cd4101 * src/base/ftsynth.c (FT_GlyphSlot_Slant): Add vertical slant.
* include/freetype/ftsynth.h (FT_GlyphSlot_Slant): Update it.
2023-02-07 23:03:18 -05:00
anuj 515bdfef7e [sdf] Use 32-bit integers internally.
* src/sdf/ftsdfcommon.h (FT_16D16, FT_26D6): Use 32-bit integers
  instead of `FT_Fixed` for internal data types. `FT_Fixed` i.e.
  `signed long` is 64-bit on some architectures.
2023-02-07 23:03:23 +00:00
Werner Lemberg d3582e3f8d docs/CHANGES: Updated. 2023-02-07 05:56:12 +01:00
Alexei Podtelezhnikov beb2272949 Comment on optional ascender and descender. 2023-02-04 09:47:44 -05:00
Alexei Podtelezhnikov 1bbec9e993 * src/type1/t1afm.c (T1_Read_Metrics): Reaffirm ascender and descender. 2023-02-04 08:34:58 -05:00
Alexei Podtelezhnikov 82c131accb * src/type1/t1afm.c (T1_Read_Metrics): Validate ascender and descender.
The ascender and descender are optional in the AFM specifications.
They could be omitted or even set to zero, e.g., in the current release
of URW++ base 35 fonts.
2023-02-04 03:20:25 +00:00
Werner Lemberg 646cc8ef8d * src/cff/cffgload.c (cff_slot_load): Avoid memory leak.
Fixes issue #1204.
2023-02-02 10:51:39 +01:00
Werner Lemberg 9508811a3a * src/truetype/ttgxvar.c (tt_var_get_item_delta): Check `face->blend`.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=55581
2023-02-01 12:01:58 +01:00
Werner Lemberg aec87c0955 * docs/CHANGES: Add news for 'freetype-demos'. 2023-02-01 11:52:26 +01:00
Werner Lemberg 9c23b89d54 * subprojects/harfbuzz.wrap, subprojects/libpng.wrap: Updated. 2023-01-30 17:16:34 +01:00
Werner Lemberg e97544a739 Minor changes.
Comment fixes, typos, removing of unnecessary parentheses.
2023-01-28 17:04:38 +01:00
Werner Lemberg bacc48e616 Whitespace. 2023-01-28 17:04:11 +01:00
Behdad Esfahbod bea675cde6 [ttgxvar] Fix crash in COLRv1.
This is a stopgap until issue #1202 is properly fixed.

* src/truetype/ttxgvar.c (tt_var_get_item_delta): Check `normalizedcoords`.
2023-01-27 06:53:46 +01:00
Werner Lemberg 82ce172669 The 'COLR' v1 API will no longer be experimental in the next release. 2023-01-19 07:17:14 +01:00
Alexei Podtelezhnikov 0982d3ecc6 * docs/oldlogs/ChangeLog.210: Typos. 2023-01-18 18:31:27 +00:00
Ben Wagner d680908af2 [base] Fix typo.
* src/base/ftobjs.c (open_face_PS_from_sfnt_stream): Request module 't1cid',
not 'cid'.
2023-01-18 09:00:21 +01:00
Ben Wagner 188019eb70 [base] Return error if requested driver is not found.
In `open_face_from_buffer` it is possible that a driver is requested but
FreeType was built without the requested module.  Return an error in this
case to indicate that the request could not be satisfied, rather than trying
all existing driver modules.

* src/base/ftobjs.c (open_face_from_buffer): Return `FT_Err_Missing_Module`
if a driver is specified but not found.
2023-01-18 08:37:51 +01:00
Dominik Röttsches a297feab0e [sfnt] Avoid nullptr dereference in reading malformed 'COLR' v1 table.
Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=1408044.

* src/sfnt/ttcolr.c (tt_face_load_colr): When the 'COLR' v1 table header is
too small, don't deallocate delta set index map structures.
2023-01-18 08:22:53 +01:00
Werner Lemberg f80be4e959 * src/tools/update-copyright: Allow execution from other repositories.
We use this for `freetype-demos`.
2023-01-17 19:03:45 +01:00
Werner Lemberg 65f8523706 Update all copyright notices. 2023-01-17 09:18:25 +01:00
Werner Lemberg 6c1bd0f2b2 * src/tools/no-copyright: Updated. 2023-01-17 09:15:36 +01:00
Ben Wagner 29f83d1dd5 [base] 'close' callback may not use `stream->memory`.
The documentation for `FT_StreamRec::memory` states that it 'shouldn't be
touched by stream implementations'.  This is true even for internal
implementations of the 'close' callback, since it is not guaranteed that
`memory` will even be set when the 'close' callback occurs.

* src/base/ftobjs.c (new_memory_stream): stash current `memory` in
`stream->descriptor`.
(memory_stream_close): Use it.
2023-01-17 08:59:25 +01:00
Ben Wagner 0d4f887c79 [base] Always close user-provided stream.
The `FT_Open_Face` documentation states

> If `FT_OPEN_STREAM` is set in `args->flags`, the stream in `args->stream`
> is automatically closed before this function returns any error (including
> `FT_Err_Invalid_Argument`).

However, if the user provides a stream in `args.stream` with
`FT_OPEN_STREAM` set and a `close` function, but then for some reason passes
NULL for `aface` and a non-negative `face_index`, the error
`Invalid_Argument` is returned but the `close` callback will not be called
on the user-provided stream.  This may cause resource leaks if the caller is
depending on the `close` callback to free resources.

The difficulty is that a user may fill out a `FT_StreamRec` and pass its
address as `args.stream`, but the stream isn't really 'live' until
`FT_Stream_New` is called on it (and `memory` is set).  In particular, it
cannot really be cleaned up properly in `ft_open_face_internal` until the
stream pointer has been copied into the `stream` local variable.

* src/base/ftobj.c (ft_open_face_internal): Ensure that user-provided
`args.stream.close` is called even with early errors.
2023-01-17 08:54:11 +01:00
Ben Wagner 13983b058e [base] Fix leak of internal stream marked external.
`open_face_from_buffer` allocates a new `FT_Stream` to pass to
`ft_open_face_internal`.  Because this is an `FT_OPEN_STREAM`,
`ft_open_face_internal` will mark this as an 'external stream', which the
caller must free.  However, `open_face_from_buffer` cannot directly free it
because the stream must last as long as the face.  There is currently an
attempt at this by clearing the 'external stream' bit after
`open_face_from_buffer` returns successfully.  However, this is too late as
the original stream may have already been closed and the stream on the face
may not be the same stream as originally passed.

It is tempting to use `FT_OPEN_MEMORY` and let `ft_open_face_internal`
create the stream internally.  However, with this method there is no means
to pass through a 'close' function to the created stream to free the
underlying data, which must be owned by the stream.

A possibility is to check on success if the stream of the face is the same
as the original stream.  If it is then unset the external flag.  If not,
then free the original stream.  Unfortunately, while no current
implementation does so, it is possible that the face still has the original
stream somewhere other than as the `FT_FaceRec::stream`.  The stream needs
to remain available for the life of the face or until it is closed,
whichever comes earlier.

The approach taken here is to let the stream own itself.  When the stream is
closed it will free itself.

* src/base/ftobjs.c (memory_stream_close): Free `stream`.
(open_face_from_buffer): Simplify error handling, since
`ft_open_face_internal` always closes `args.stream` on any error.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54930
2023-01-17 08:48:33 +01:00
Werner Lemberg 6a179ff7d5 sr/*.c: Various minor fixes.
* src/autofit/ft-hb.c (_hb_ft_reference_table): Call `FT_UNUSED` after
variable declarations.

* src/gxvalid/gxvjust.c (gxv_just_widthDeltaClusters_validate): Eliminate
unused variable.

* src/gzip/ftgzip.c: Don't call GCC '-Wstrict-prototypes' pragma for C++
compiler.

* src/sfnt/ttcolr.c (ENSURE_READ_BYTES): Remove final semicolon to avoid
compiler warning.

* src/sfnt/ttsvg.c (tt_face_load_svg_doc): Fix signedness warning.
2023-01-16 16:38:56 +01:00
Dominik Röttsches 2692b3215b [sfnt] Remove temporary runtime flag for variable 'COLR' v1.
Fixes #1187.

* src/sfnt/ttcolr.c (top level, read_paint, tt_face_load_colr,
tt_face_free_colr, get_deltas_for_var_index_base,
tt_face_get_color_glyph_clipbox, tt_face_get_colorline_stops): Remove macro
definition `VARIABLE_COLRV1_ENABLED` and its usage.

* src/truetype/ttdriver.c (tt_property_set): Remove parsing of
'TEMPORARY-enable-variable-colrv1' property name.

* src/truetype/ttobjs.h (TT_DriverRec): Remove `enable_variable_colrv1`
flag.
2023-01-16 14:02:36 +01:00
Werner Lemberg b1c90733ee * src/autofit/ft-hb.c (_hb_ft_reference_table): Minor integration fixes. 2023-01-07 07:41:31 +01:00
Ben Wagner 3481b15443 [truetype] Reset cvt and storage in context load.
Currently the cvt and storage are saved and restored in `TT_RunIns`.
However, this is too granular as the cvt and storage area should be set to
the original cvt and storage area only when setting up the hinting context.
This allows for the cvt and storage area to be modified while parsing
multiple glyphs, as is the case with composite glyphs.

* src/truetype/ttinterp.h (TT_ExecContextRec): Remove `origCvt` and
`origStorage`.

* src/truetype/ttinterp.c (TT_RunIns): Don't save and restore the cvt and
storage area.
(Modify_CVT_Check, Ins_WS): Switch from "if in glyph and using original data
do copy on write" to "if in glyph and not using glyph specific data do copy
on write".
2023-01-07 07:28:04 +01:00
Matthias Clasen ebe7e9128c [autofit] Don't depend on 'hb-ft'.
The circular dependency is still there, but at least we no longer depend on
the HarfBuzz API that is only present if HarfBuzz has been built with
FreeType support, making the bootstrapping a bit easier.

* src/autofit/ft-hb.c, src/autofit/ft-hb.h: New files, providing
`_hb_ft_font_create`, which is more or less a verbatim copy of the
corresponding HarfBuzz code from file `hb-ft.cc`.

* src/autofit/afglobal.c (af_face_globals_new): Use it.
* src/autofit/afshaper.h: Don't include `hb-ft.h` but `ft-hb.h`.
* src/autofit/autofit.c: Include `ft-hb.c`.

* LICENSE.TXT: Updated.
2023-01-06 12:54:17 +01:00
Ben Wagner 262b47ac5a [truetype] Keep variation store consistent.
`tt_var_load_item_variation_store` fills out a `GX_ItemVarStore`.  While it
may return an error, the item store must be left in a consistent state so
that any use or destruction of the item store can properly use or free the
data in it.  Before this change the counts from the font data were read
directly into the item store before the actual allocation of the arrays to
which they referred.  There exist many opportunities between the time the
counts are read and the arrays are allocated to return early due to invalid
data.  When this happened the item store claimed to have entires it actually
did not, leading to crashes later when it was used.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54449

* src/truetype/ttgxvar.c (tt_var_load_item_variation_store): Read the counts
into local variables and store them in the item store only after the related
arrays are actually created on the item store.
2023-01-06 07:11:41 +01:00
Ben Wagner 15afb55458 [base] Report used stream's external status.
In `open_face` the initial stream is set on the face, along with the
information about if FreeType is the owner of the stream object itself.  The
loaders may in the course of their work replace this stream with a new
stream (as is the case for 'woff' and 'woff2'), which may have a different
ownership than the initial stream object (likely the original stream object
is owned by the user and is external, while the new stream object is created
internally to FreeType and is internal).  When the stream is replaced, the
face's flags are updated with the new ownership status.

However, `open_face` cannot itself free this stream as its caller
`ft_open_face_internal` is responsible for this.  In addition, in the case
of an error `open_face` cannot return an actual face with the new stream and
its ownership status to the caller.  As a result, it must pass this
information back to the caller as a sort of "failed face" so that the caller
can clean up.

`open_face` was already passing back the new stream but was not passing back
the stream ownership information.  As a result the stream may not have been
free'd when needed.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54700

* src/base/ftobjs.c (open_face): Pass back the ownership information as
well.
(ft_open_face_internal): Updated.
2023-01-05 22:05:02 +01:00
Noah Cabral c0b4f6a862 fix spelling err in LICENSE.txt 2023-01-05 14:58:51 +01:00
Dominik Röttsches 63f371367a [sfnt] Fix color stop bounds check calculation at table end.
Fixes https://bugs.chromium.org/p/skia/issues/detail?id=14021

* src/sfnt/ttcolr.c (VAR_IDX_BASE_SIZE): New macro.
(tt_face_get_colorline_stops): Fix off-by-one bounds check calculation, take
`VarColorStop` into account, and hopefully make it easier to read.
2023-01-05 09:35:32 +01:00
Alexei Podtelezhnikov 81a456b28f * src/base/ftobjs.c (FT_Request_Metrics): Avoid division by zero.
The division-by-zero might happen in broken fonts (see #1194).
Instead of returning a huge number from FT_DivFix and failing
to scale later, we now bail immediately.
2023-01-04 22:41:34 -05:00
Alexei Podtelezhnikov 0bcb664de8 [psaux] Delay the upem validity assertion.
Fixes #1194.

* src/psaux/psft.c (cf2_getUnitsPerEm): Remove the upem assert.
(cf2_checkTransform): Assert the upem validity after checking the scale.
2022-12-20 16:38:39 +00:00
David Vanderson ace97a02a4 [gzip] Make static compilation not leak global symbols.
* src/gzip/ftgzip.c (HAVE_HIDDEN): Do not define; it is no longer needed
because everything is static.
(HAVE_MEMCPY): Define.
(zcalloc, zcfree): Remove no longer needed definitions (because `Z_SOLO` is
active).

* src/gzip/patches/freetype-zlib.diff: Regenerated.

Fixes #1146.

Co-authored-by: Werner Lemberg <wl@gnu.org>
2022-12-14 10:44:03 +01:00
Werner Lemberg bc3aa767a7 * src/gzip/ftzconf.h: Updated to zlib 1.2.13.
I forgot to copy that file.
2022-12-14 10:32:53 +01:00
Werner Lemberg 30d4863781 * builds/unix/configure.raw: Don't check for `memcpy` and `memmove`.
We expect a C99 compiler, and both functions are part of this standard.
2022-12-14 09:19:26 +01:00
Werner Lemberg 26e9028f10 [sdf, sfnt] Handle minor compiler warnings.
* src/sdf/ftsdf.c (get_min_distance_conic): Initialize `nearest_point`.

* src/sfnt/ttsvg.c (find_doc): Initialize `mid_doc`.

Fixes #1195.
2022-12-13 09:53:26 +01:00
Werner Lemberg b405fc5c1d * subprojects/zlib.wrap: Micro-update from upstream. 2022-12-07 17:05:17 +01:00
Jiří Malák 34c1bb66e4 * include/freetype/internal/ftcalc.h (FT_MSB): Support Open Watcom 2.0.
Closes !232.
2022-12-06 10:21:53 -05:00
Luca Bacci aca4ec5907 * src/base/ftdbgmem.c (ft_mem_source_compare): Add FT_COMPARE_DEF.
Closes !230.
2022-11-22 22:34:41 -05:00
Alexei Podtelezhnikov 1c44de209c * src/autofit/afloader.c (af_loader_load_glyph): Remove `size` check.
This is done by `FT_Load_Glyph`.
2022-11-20 22:37:08 -05:00
Alexei Podtelezhnikov 4e6906cc5d Comments added. 2022-11-18 14:03:19 +00:00
Johan Matsson 0f43a0e7eb * src/autofit/afloader.c (af_loader_load_glyph): Fix dereference.
This must happen after the NULL check.

Taken from

  https://github.com/freetype/freetype/pull/2
2022-11-16 07:54:39 +01:00
Alexei Podtelezhnikov 47e61d02e6 * src/pcf/pcfutil.c ({Two,Four}ByteSwap): Use builtins or shifts.
We trust glibc which uses shifts or builtins to swap bytes.  This
must be more efficient.
2022-11-14 22:53:14 -05:00
Werner Lemberg e6fda039ad * src/truetype/ttgxvar.c (tt_hvadvance_adjust): Integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50462
2022-11-14 19:18:19 +01:00
Loïc Yhuel 63ccaef07a [meson] Use generated ftmodule.h
ftmodule.h is generated at the root of the build directory, but FT_CONFIG_MODULES_H
(freetype/config/ftmodule.h) is used instead.
This makes the build fail when disabling modules in modules.cfg.

* meson.build (harfbuzz_dep): Add '-DFT_CONFIG_MODULES_H=<ftmodule.h>'.
2022-11-14 14:43:04 +01:00
Loïc Yhuel b37b8d2a70 [meson] Fix generated ftmodule.h
The sdf module wasn't recognized, so the generated ftmodule.h had "None_renderer_class".

* builds/meson/parse_modules_cfg.py: Handle sdf in RASTER_MODULES.
2022-11-14 14:43:04 +01:00
Dominik Röttsches ba4bd5b994 Add `TT_CONFIG_OPTION_NO_BORING_EXPANSION` configuration macro.
This gives users a possibility to deactivate new features not (yet) in the
OpenType standard.

* include/freetype/config/ftoption.h, devel/ftoption.h
(TT_CONFIG_OPTION_NO_BORING_EXPANSION): New macro.

* src/truetype/ttgxvar.c (ft_var_load_avar): Use it to disable 'avar'
version 2.0 support.
2022-11-12 17:11:36 +01:00
Behdad Esfahbod e97cb9e8da [truetype] Improve bounds checks for `ItemVariationStore`.
* src/truetype/ttgxvar.c (tt_hvadvance_adjust): Move bounds check ...
(tt_var_get_item_delta): ...  to this function, because it is safer.  For
example, the 'avar' table 2.0 codepath was not performing a bounds check at
all.
2022-11-12 16:45:44 +01:00
Behdad Esfahbod 9be958ca39 [truetype] In `ItemVariationStore`, value 0xFFFF for `dataCount` is valid.
It corresponds to outer indices of 0 to 0xFFFE.

* src/truetype/ttgxvar.c (tt_var_load_item_variation_store): Remove invalid
code.
2022-11-12 16:41:20 +01:00
Alexei Podtelezhnikov 109179c70e [pcf] Improve CMap efficiency and readability.
* src/pcf/pcfdrivr.c (pcf_cmap_char_{index,next}): Check and walk
the encoding array indexes.
2022-11-10 23:25:48 -05:00
Sam James e82371bf6e Fix `-Wstrict-prototypes`.
* builds/unix/configure.raw: Fix `-Wstrict-prototypes`.
Clang 16 warns on these and they will be dropped in C23.

* builds/unix/freetype2.m4: Ditto.

Signed-off-by: Sam James <sam@gentoo.org>
2022-11-10 05:38:55 +01:00
Ben Wagner 9154707f6b [truetype] Check avar_segment before access
* src/truetype/ttgxvar.c (tt_done_blend): check `avar_segment` before
accessing to free its `correspondence`.

Reported as:

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53062
2022-11-09 19:15:26 +00:00
Ben Wagner d38407f79e [truetype] Restore behavior of ft_var_load_hvvar
* src/truetype/ttgcvar.c (ft_var_load_hvvar): restore previous behavior

In a previous change [0] the behavior of `ft_var_load_hvvar` was changed
to not load the item variation store if it was at offset 0, but not
return an error when this happened. This broke any users, like
`tt_hvadvance_adjust`, that rely on successful completion of
`ft_var_load_hvvar` to imply that returned table's `itemStore` had been
initialized. This lead such users to dereference NULL.

This change appears to have been unintentional and unrelated to the
actual avar2 changes. As a result, fix these NULL dereferences by
restoring the code to always attempt to initialize the `itemStore`.

[0] ae4eb996 "[truetype] Add support for `avar` table 2.0 format."

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53061
2022-11-09 19:02:22 +00:00
Werner Lemberg 978fdb292a docs/CHANGES: Updated. 2022-11-08 08:27:52 +01:00
suzuki toshiya bccf1cd6b4 [build] use AC_CHECK_PROG() macro for libpng-config detection
* builds/unix/configure.raw: use AC_CHECK_PROG() instead of `which` to find `libpng-config`.
2022-11-08 14:31:23 +09:00
suzuki toshiya 32cfab4be7 [build] fix for make multi
Fix "make multi" by MR !223

* include/freetype/internal/services/svmm.h: include ftmm.h to define FT_Get_MM_Func.
* src/truetype/ttgxvar.h: include ftmmtypes.h to use GX_AVarTable properly.
* src/base/ftmac.c: include ftdebug.h to use FT_THROW() properly.
2022-11-08 14:23:37 +09:00
Alexei Podtelezhnikov e00afdb35b * src/pfr/pfrsbit.c (pfr_lookup_bitmap_data): Accelerate the search.
This is mostly for consistency because PFR fonts with bitmap strikes
do not seem to exist.
2022-11-07 21:36:32 -05:00
Alexei Podtelezhnikov 6139f2b647 [bdf, pfr, psnames] Accelarate charmap searches.
The binary searches within charmaps can be accelerated because they
often contain dense continuous blocks of character codes. Within such
blocks, you can predict matches based on misses.  This method has been
deployed in `bdf` since 0f122fef34; we only refactor it there.  We now
use it in `pfr` and `psnames`, which speeds up the unicode charmap
access by about 50% in PFR and Type 1 fonts.

* src/bdf/bdfdrivr.c (bdf_cmap_char_{index,next}): Refactor.
* src/pfr/pfrcmap.c (pfr_cmap_char_{index,next}): Predict `mid` based
on the mismatch distance.
* src/psnames/psmodule.c (ps_unicodes_char_{index,next}): Ditto.
2022-11-06 13:12:47 -05:00
Behdad Esfahbod ae4eb996ab [truetype] Add support for `avar` table 2.0 format.
See

  https://github.com/harfbuzz/boring-expansion-spec/blob/main/avar2.md

for the specification.

Currently, this is implemented only in most recent OS versions on Apple
platforms and in the HarfBuzz library, but it is expected to be added to the
OpenType standard soon.

* src/truetype/ttgxvar.h (GX_AVarTableRec): New structure.
(GX_BlendRec): Use it to replace `avar_segment` with `avar_table`.

* src/truetype/ttgxvar.c (ft_var_load_avar): Load new table version.
(ft_var_to_normalized, tt_done_blend): Extend for new format.
(ft_var_load_hvvar, ft_var_to_design): Updated.
2022-11-04 19:44:36 +01:00
Werner Lemberg dea2e6358b Replace '1/64th' (and similar entries) with '1/64' in docs and comments. 2022-10-24 07:01:21 +02:00
Ivan Panchenko 05e1b37e3d * include/freetype/*: Fix documentation typos. 2022-10-24 06:52:06 +02:00
Alexei Podtelezhnikov ffbbf3df3e * src/truetype/ttgload.c: Cosmetic changes. 2022-10-21 15:55:30 +00:00
Alexei Podtelezhnikov 1bfaca0635 [cff, truetype] Simplify SVG metrics scaling.
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.
2022-10-21 12:14:52 +00:00
Werner Lemberg 0ec85f71a8 * subprojects/zlib.wrap: Update to zlib version 1.2.13. 2022-10-20 13:55:41 +02:00
Dominik Röttsches 0b62c1e43d [sfnt] Additional bounds checks for `COLR` v1 table handling.
* src/sfnt/ttcolr.c (read_paint): Add `colr` argument, necessary for...
... another use of `ENSURE_READ_BYTES`.
Update callers.
(tt_face_get_paint_layers): Ensure that the 4-byte paint table
offset can be read.

This is a follow-up to !124 and issue
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52404
2022-10-18 19:55:25 +02:00
Werner Lemberg af46fcc15a [gzip] Update sources to zlib 1.2.13. 2022-10-18 19:43:52 +02:00
Alexei Podtelezhnikov b8882a3ed6 * src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Simplify calculations. 2022-10-18 15:58:02 +00:00
Werner Lemberg c943d408e0 Minor formatting. 2022-10-18 11:41:00 +02:00
Dominik Röttsches 04272824e0 [sfnt] Guard individual `COLR` v1 paint field reads.
* src/sfnt/ttcolr.c (ENSURE_READ_BYTES): New macro.
(read_paint): Use it – after the start pointer `p` has been checked for
whether it allows reading the format byte, each successive paint table field
read need to be bounds-checked before reading further values.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52404
2022-10-18 08:37:05 +02:00
Xiang Xiao 8493877e78 * builds/toplevel.mk: Prefix all paths with `$(TOP_DIR)/`.
This is useful for builds that are not started from the root directory.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 08:49:53 +02:00
Liu Kunpeng(柳鲲鹏) bb59c3c958 * src/base/ftsynth.c (FT_GlyphSlot_Slant): New API with custom slant.
* include/freetype/ftsynth.h (FT_GlyphSlot_Slant): Declare it.
2022-10-16 22:10:19 -04:00
Alexei Podtelezhnikov 3ab1875cd2 Note the lack of floating-point data types. 2022-10-14 22:06:23 -04:00
Werner Lemberg 5182264a40 [cff] Remove `FT_CONFIG_OPTION_NO_GLYPH_NAMES`.
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.
2022-10-10 12:41:49 +02:00
Werner Lemberg 0d66abca4b Synchronize `ftoption.h` flavours. 2022-10-10 12:41:19 +02:00
Werner Lemberg 141d979af7 Minor comment changes. 2022-10-10 12:25:51 +02:00
Alexei Podtelezhnikov 15f6873495 Improve FT_Get_Name_Index docs and place it next to FT_Get_Glyph_Name. 2022-10-04 23:36:09 -04:00
Alexei Podtelezhnikov 0417527d5b [autofit] Reset the face charmap directly.
There is no need to validate the original charmap in `FT_Set_Charmap`.
It can be reset directly.

* src/autofit/afglobal.c (af_face_globals_compute_style_coverage):
Use direct assignment.
* src/autofit/af{latin,cjk,indic}.c (af_latin_metrics_init): Ditto.
2022-10-03 19:23:26 -04:00
Alexei Podtelezhnikov 1b6dce84f9 * src/type1/t1afm.c (T1_Read_PFM): Set charmaps directly.
As with the previous commit, we can avoid the validation checks
of `FT_Set_Charmap` and set it directly when choosing from the
available list.
2022-10-03 19:18:48 -04:00
Alexei Podtelezhnikov 8faf57dd17 * src/cache/ftccmap.c (FTC_CMapCache_Lookup): Avoid `FT_Set_Charmap`.
Set charmap aggressively without all validations of `FT_Set_Charmap`
because we take it from the available array and only temporarily.
Even CMap Format 14 will gracefully return 0.
2022-10-03 17:13:30 +00:00
Alexei Podtelezhnikov b93f20ab7a * src/cache/ftcbasic.c (ftc_basic_family_get_count): Remove redundancy. 2022-10-03 15:10:12 +00:00
Werner Lemberg de8f14a8e4 * src/psaux/pshints.c (cf2_hintmap_insertHint): Fix midpoint computation.
Replace '(start + end) / 2' with 'start + (end - start) / 2' to avoid
overflow.

Fixes #1180.
2022-09-30 23:25:02 +02:00
Werner Lemberg 2adb810c3d * src/psaux/pshints.c (cf2_hintmap_build): Improve debugging output. 2022-09-30 17:00:10 +02:00
mlugg 905270925d [truetype] Fix undefined pointer arithmetic.
* src/truetype/ttgxvar.c (tt_var_get_item_delta, ft_var_load_mvar): Use
`FT_OFFSET`.
2022-09-29 20:44:41 +02:00
Alexei Podtelezhnikov ff66e912d0 * src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Use lighter FT_DivFix. 2022-09-29 17:46:23 +00:00
Ali Chraghi 5faa1df8b9 [base] FT_Attach_Stream: Make `parameters` argument constant. 2022-09-29 19:30:20 +02:00
Azamat Hackimov 3f3427c6f3 * src/tools/*.py: Migrate to Python 3.
Fixes #1185, closes !205. Formatting changes according to PEP8.
2022-09-28 22:35:49 -04:00
Dominik Röttsches df2601395f [sfnt] Guard access in 'COLR' table when requesting child table pointer.
* src/sfnt/ttcolr.c (tt_face_get_colorline_stops, read_paint): Tighten
pointer bounds checks.
(get_child_table_pointer): Check whether incoming pointer `p` lies within
the 'COLR' table.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51816
2022-09-27 18:18:59 +02:00
Ben Wagner bd41700773 [sfnt] Add SVG document bounds checking.
Add a check that the document content is actually contained within the
`SVG ` table.  Without this check a malformed font may claim arbitrary
memory as its document content.

* src/sfnt/ttsvg.c (tt_face_load_svg): Take `numEntries` into account when
testing 'documentRecord' extents.
(find_doc): Rename `stream` to `document_records` for clarity.
(tt_face_load_svg_doc): Split `doc` from `doc_list` pointer for clarity.
Test that the document content is contained within the table.
Ensure minimum length of document before testing for gzip format.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51812
2022-09-27 07:31:32 +02:00
Alexei Podtelezhnikov c9c326312f [base] Clean up the bitmap flow control.
* src/base/ftbitmap.c (FT_Bitmap_Copy): Flip the copy if its pitch
is trully opposite, zero is not a positive value.
(FT_Bitmap_Convert): Set negative pitch as needed, accept negative
alignment values.
2022-09-22 20:40:21 -04:00
Alexei Podtelezhnikov c456eeb47a [base] Discard and recreate bitmaps for copying and converting.
Reusing target bitmaps for copying and converting is permitted.  It is,
however, pointless to preserve their content before overwriting.  Free-
malloc might be faster than realloc.

* src/base/ftbitmap.c (FT_Bitmap_Copy, FT_Bitmap_Convert): Free
an old buffer and create a new one.
2022-09-22 15:09:17 +00:00
Dominik Röttsches 33ceac2afc Reject 'COLR' table if version is 1 but header too small.
* src/sfnt/ttcolr.c (tt_face_load_colr): If the version is determined to
be 1, then the table size has to be at least the size of the v1 header.
Also, for peeking the number of base glyphs and entries in the layer list,
ensure that the table is sufficiently long.

Fixes #1179.  Original patch by Sergey Temnikov.
2022-09-16 18:55:24 +02:00
Werner Lemberg a0d1536452 * src/otvalid/otvgsub.c (otv_SingleSubst_validate): Fix format 1 handling.
Fixes #1181.
2022-09-15 09:14:06 +02:00
Dominik Röttsches 8e68439a6f [truetype] Reject 'fvar' loading when `num_instances` is too small.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): Reject retrieving master when
'fvar' values locally do not match with sanitized values from initialization
at `sfnt_init_face` time.

Reported as

  https://bugs.chromium.org/p/chromium/issues/detail?id=1360295
2022-09-06 17:18:17 +02:00
Dominik Röttsches 91a7fae777 [sfnt] Handle variable `COLR` v1 fonts without delta set index map
Fixes #1178.

* src/sfnt/ttcolr.c (get_deltas_for_var_index_base): Set outer index to
0 and inner index to the delta index when retrieving deltas if the
`COLR` table has no delta set index map.
2022-09-05 15:52:58 +02:00
Dominik Röttsches 6d62076ae5 [sfnt] Pointer sanity checks before reading layer info in 'COLR' v0
* src/sfnt/ttcolr.c (tt_face_get_colr_layer): Check that the pointer to
read from is within the 'COLR' table.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50633
2022-09-05 12:23:31 +02:00
Werner Lemberg 048f2e247c [autofit] Minor fix.
* src/autofit/afglobal.c (af_face_globals_compute_style_coverage): Avoid
compiler warning.
2022-09-05 10:43:59 +02:00
Dominik Röttsches a1017e2655 [sfnt] Don't require 'gvar' table to support variation fonts.
Fixes #1172.

* src/sfnt/sfobjs.c (sfnt_load_face): Tag font as Multiple Masters font if
`fvar` is present; do not require other tables to be present.

* src/truetype/ttgxvar.c (tt_set_mm_blend): Allow for a missing 'gvar' table
when setting variation coordinates.  However, if a 'gvar' table is actually
present, do perform a sanity check and fail on malformedness.
(TT_Get_MM_Var): Don't assume 'fvar' needs 'gvar' or 'CFF2 tables in all
cases, which is an overly tight check.
2022-09-05 10:36:22 +02:00
Alexei Podtelezhnikov dd91f6e7f5 * src/base/ftver.rc: Explicitly use UTF-16.
Fixes #1177 to avoid mistranslation and other problems.
2022-08-26 22:24:02 -04:00
Dominik Röttsches 4797b2ff22 [sfnt] Avoid undefined shifts in `COLR` v1 color line retrieval
* src/sfnt/ttcolr.c (tt_face_get_colorline_stops): Disambiguate shift
behavior by using multiplication using macros from ftcalc.h.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50573
2022-08-26 12:08:34 +03:00
Sean Farrell 395da3d72a CMakeLists.txt (FT_ENABLE_ERROR_STRINGS): New configuration option.
This option uncomments FreeType configuration macro
`FT_CONFIG_OPTION_ERROR_STRINGS` to make function `FT_Error_String` return
meaningful error strings.

This option is off by default.
2022-08-21 19:58:35 +02:00
Chris Liddell 37b718d589 [base, type1] Better handling of out-of-memory situations.
This follows similar code in `cff_slot_done`.

* src/base/ftobjs.c (ft_glyphslot_done), src/type1/t1objs.c
(T1_GlyphSlot_Done): Check `internal` pointer.

The Type1 problems was reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50057.
2022-08-21 19:41:45 +02:00
Tim-Philipp Müller 7cd3f19f21 ci: bump windows image and use newer runner and vs2019
The old 1809 runner will be decommissioned at some point.
2022-08-06 11:52:32 +00:00
@udoudou 90e1e39f50 * src/cache/ftcmanag.c (FTC_Manager_New): Initialize `cur_weight`.
See !192.
2022-08-03 22:54:38 -04:00
Alexei Podtelezhnikov dcb5fc5bcd * src/sfnt/ttload.c: Trace formatting updates. 2022-08-02 17:10:25 +00:00
Alexei Podtelezhnikov d53c114165 * src/psaux/psobjs.c (ps_table_release): Remove redundant casting. 2022-08-02 12:57:39 +00:00
Alexei Podtelezhnikov 480be443b7 * src/base/ftobjs.c (Mac_Read_sfnt_Resource): Reduce casting. 2022-08-01 22:59:58 -04:00
Alexei Podtelezhnikov 039b9071f3 [cache] Remove some casts, clean up tracing.
* src/cache/ftcbasic.c (FTC_ImageCache_Lookup, FTC_SBitCache_Lookup):
Clean up tracing types.
* src/cache/ftccache.c (ftc_node_destroy): Ditto.
* src/cache/ftcmanag.c (FTC_Manager_Check): Ditto.
(FTC_Manager_Check, FTC_Node_Unref): Remove a cast.
* src/cache/ftccmap.c (FTC_CMapCache_Lookup): Ditto.
2022-08-01 20:19:12 -04:00
Alexei Podtelezhnikov a18ad83e8b [autofit] Updated to reduce casting (cont'd).
* src/autofit/afmodule.h (AF_ModuleRec): Change `default_script` type.
* src/autofit/afglobal.c (af_face_globals_compute_style_coverage):
Remove casting.
* src/autofit/afmodule.c (af_property_{set,get}): Updated accordingly.
2022-08-01 13:20:13 -04:00
Alexei Podtelezhnikov 4f195185ee [autofit] Updated to reduce casting.
* src/autofit/afglobal.h (AF_FaceGlobalsRec): Change `glyph_count` type.
* src/autofit/afglobal.c (af_face_globals_compute_style_coverage,
af_face_globals_get_metrics, af_face_globals_is_digit,
af_face_globals_new): Changed local types and updated accordingly.
* src/autofit/aflatin.c (af_latin_metrics_init_blues): Ditto.
2022-08-01 09:52:43 -04:00
Alexei Podtelezhnikov 9de432f7f2 [psaux] Remove unused structure field.
* include/freetype/internal/psaux.h (PS_TableRec): Remove `num_elems`.
* src/psaux/psobjs.c (ps_table_new): Remoove its initialization.
2022-07-31 22:13:34 -04:00
Dominik Röttsches 919561ca8c [sfnt] Implement VarClipBox.
* src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Depending on the
format, read `var_index_base`, then retrieve and apply scaled deltas.
2022-07-30 15:24:58 +02:00
Dominik Röttsches 649352ab73 [sfnt] Fix typo in clip box computation.
* src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Use appropriate
scale factor for `yMin` and `yMax`.
2022-07-30 15:10:17 +02:00
Alexei Podtelezhnikov ee72e28503 [autofit] Use unsigned accounting for hints.
* 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.
2022-07-29 22:55:28 -04:00
Alexei Podtelezhnikov fd02c369da * src/autofit/afhints.h: Remove dead code. 2022-07-29 22:54:38 -04:00
Werner Lemberg 2af6903b15 * src/base/ftglyph.c (FT_Get_Glyph): Set `*aglyph` to NULL in case of error. 2022-07-29 22:57:18 +02:00
Werner Lemberg a3749a64cd Fix compilation if `TT_CONFIG_OPTION_GX_VAR_SUPPORT` is not set.
* src/sfnt/ttcolr.c: Protect relevant code with
`TT_CONFIG_OPTION_GX_VAR_SUPPORT`.
2022-07-29 22:21:12 +02:00
Werner Lemberg 38dc768a42 Fix clang14 compiler warnings.
* 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`.
2022-07-29 21:53:28 +02:00
Alexei Podtelezhnikov 284956b5b1 [pfr] Fortify the kerning code.
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.
2022-07-26 12:23:15 -04:00
Werner Lemberg 182295cbcf [pfr] Add some safety guards.
* src/pfr/pfrload.c (pfr_phy_font_load): Check resolutions and number of
characters.

Fixes #1174.
2022-07-26 16:50:19 +02:00
Werner Lemberg 1f005c0918 * src/pfr/*.c: Trivial improvements and formatting. 2022-07-26 16:22:27 +02:00
Werner Lemberg 9a00282efc * configure: s/egrep/grep -E/
`egrep` is deprecated.
2022-07-24 19:49:56 +02:00
Ben Wagner 0417e54bec [base] Build outlines in amortized constant time.
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.
2022-07-23 23:30:22 +02:00
Dominik Röttsches 275b116b40 [sfnt] Support variable 'COLR' v1 `PaintVarSkew*`.
* 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.
2022-07-09 05:59:45 +02:00
Dominik Röttsches 44fd524ee4 [sfnt] Support variable 'COLR' v1 `PaintVarRotate*`.
* 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.
2022-07-09 05:59:45 +02:00
Dominik Röttsches 603fef28a6 [sfnt] Support 'COLR' v1 variable `PaintVarScale*`.
* 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.
2022-07-09 05:59:41 +02:00
Dominik Röttsches d134b9e37b [sfnt] Support for 'COLR' v1 variable translate.
* src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration value
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSLATE`.
(read_paint): Handle new enumeration value.
2022-07-09 05:44:58 +02:00
Dominik Röttsches 8ec531c26c [sfnt] Support for 'COLR' v1 variable transforms.
* src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration value
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSFORM`.
(read_paint): Handle new enumeration value.
2022-07-09 05:43:28 +02:00
Dominik Röttsches 9c4ad2a901 [sfnt] Deltas for 'COLR' v1 gradient coordinates.
* 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'.
2022-07-09 05:41:27 +02:00
Dominik Röttsches 3414fef74f [sfnt] Support variable 'COLR' v1 color lines.
* 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.
2022-07-08 11:51:07 +02:00
Dominik Röttsches 7c151abb69 [sfnt] Apply variation deltas to `PaintVarSolid`.
* 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`.
2022-07-07 19:48:19 +02:00
Dominik Röttsches 8a9192f68e [sfnt] Check safety of cast to `TT_Driver` before accessing member.
* src/sfnt/ttcolr.c (VARIABLE_COLRV1_ENABLED): Access
`enable_variable_colrv1` only if driver class matches.
2022-07-07 19:36:49 +02:00
Stephen Holdaway d5d048bbfe doc: Clarify description of `FT_Stream_IoFunc`.
The existing documentation comments on `FT_Stream_IoFunc` hinted at the dual
seek/read behavior required for custom stream implementations to work, but
it didn't explicitly explain it.  Without looking at the internals of
FreeType, it was easy for someone to assume their implementation should
handle both seek and read operations all the time.  If this is done, you get
a variety of errors, but mostly just `Unknown_File_Format` (error code
0x02).
2022-07-06 12:55:40 +02:00
Dominik Röttsches 31b14fd4dc [sfnt] Load variation store for 'COLR' v1.
* 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.
2022-07-04 16:34:02 +02:00
Chris Liddell 1a242558be [base] Improve error handling in `FT_GlyphLoader_CheckPoints`.
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`.
2022-07-03 06:58:23 +02:00
Thomas Sondergaard 55a97b0cb1 CMakeLists.txt: Provide both 'freetype' and 'Freetype::Freetype' targets.
FreeType can be located by consuming projects that use
`find_package(Freetype)` either via the old `MODULE` path (which uses
`FindFreetype.cmake` supplied by CMake), or via the new `CONFIG` path (which
uses `freetype-config.cmake` as supplied by this project).  Up to this point
the CMake module has supplied the target `Freetype::Freetype` and the config
file provided by this project the target `freetype`.  Now we supply both
`freetype` and `Freetype::Freetype` so that consuming projects can always
use the target `Freetype::Freetype` regardless of what path was taken by
`find_package(Freetype)`.

Fixes #1165.
2022-07-03 06:48:15 +02:00
Werner Lemberg 31005d98a4 include/freetype/ftmm.h: Improve documentation. 2022-07-02 09:34:13 +02:00
Dominik Röttsches bec4ef415e [base] Round values in `FT_MulAdd_Fix`.
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.
2022-07-01 14:01:08 +02:00
Werner Lemberg de27955c2a Minor formatting. 2022-07-01 06:33:50 +02:00
Dominik Röttsches 0607e0e959 Fix initialisation of temp variable in new FT_MulAddFix
src/truetype/ttgxvar.c (FT_MulAddFix): Initialise `temp`.
2022-06-30 10:55:50 +03:00
Dominik Röttsches dece953516 [truetype] Perform variation store delta computation with 64-bit precision.
* 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`.
2022-06-29 20:27:11 +02:00
Dominik Röttsches 15fef219d6 New function `FT_MulAddFix` to compute the sum of fixed-point products.
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.
2022-06-29 20:12:04 +02:00
Werner Lemberg 2db58e061e CMakeLists.txt: Move inclusion of `FindPkgConfig` down.
It must come after `CMAKE_TOOLCHAIN_FILE`.

Fixes #1167.
2022-06-22 12:16:00 +02:00
Dominik Röttsches 117df36b4c [sfnt] Upgrade stop_offset to FT_Fixed from FT_F2Dot14 2022-06-22 09:33:20 +00:00
Alexei Podtelezhnikov 5e48c88d57 * docs/CHANGES: Announce impending Infinality removal. 2022-06-21 17:34:29 +00:00
Alexei Podtelezhnikov 9006ff7d10 * ttgload.c (TT_Process_Composite_Glyph): Fix a signedness warning. 2022-06-21 17:10:56 +00:00
Werner Lemberg 2848378be5 s/fixed point/fixed-point/ 2022-06-21 17:08:04 +02:00
Werner Lemberg 40c6f97326 .gitlab-ci.yml: Correctly upgrade `meson`. 2022-06-21 14:45:42 +02:00
Dominik Röttsches 4b6f92e6b3 Proposal: Feature control for variable COLRv1
* 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.
2022-06-21 12:25:46 +03:00
Xavier Claessens b861b24157 [meson] Disable FreeType in HarfBuzz fallback.
This avoids cyclic subproject configuration when the 'harfbuzz' feature is
enabled, or `--wrap-mode=forcefallback` is used, but HarfBuzz is built as a
subproject.  HarfBuzz does the same and disables HarfBuzz support when
configuring FreeType as a subproject.

* meson.build (harfbuzz_dep): Implement it.

* subprojects/harfbuzz.wrap: New file.

* .gitlab-ci.yml [windows meson]: Use latest version of the meson 0.59
  series, which has a necessary bug fix to make CI work.
2022-06-21 08:09:16 +02:00
Alexei Podtelezhnikov 47103b2f19 [truetype] Clean up phantom point accounting.
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.
2022-06-18 23:09:17 -04:00
Alexei Podtelezhnikov 705f416184 [truetype/GX] Clean up phantom point adjustment.
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.
2022-06-18 23:02:26 -04:00
Ben Wagner f7daf9d293 [stream] Fix reading s32 when long is s64
`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
2022-06-18 12:58:23 -04:00
Alexei Podtelezhnikov d9b8a69e9a [truetype/GX] Fix an old typo.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Vertical
advance is measured along y-coordinate.
2022-06-16 22:13:25 -04:00
Alexei Podtelezhnikov 9c706dcca7 [truetype/GX] Clean up advance adjustment (Brrr).
* src/truetype/ttgload.c (load_truetype_glyph): Remove remaining code.
2022-06-16 16:11:51 +00:00
Ben Wagner 9079521002 [type1] Directly search for eexec in private dict
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
2022-06-16 14:51:57 +00:00
Alexei Podtelezhnikov d6fc8c6ba0 [truetype/GX] Clean up advance adjustment.
* 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.
2022-06-15 18:28:50 -04:00
Ben Wagner 8bb7722a53 [gzip] Handle inflate returning Z_NEED_DICT
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
2022-06-14 04:49:29 +00:00
Ben Wagner 58395dd200 [woff] Don't allocate table entries until needed
* src/sfnt/sfwoff.c (woff_open_font): delay allocating space for the
table entries until they are actually written out with the data.
2022-06-13 15:32:28 -04:00
Alexei Podtelezhnikov 8b6bcc92c5 * src/sfnt/sfwoff2.c (woff2_open_font): Partial revert.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47981.
2022-06-12 09:04:13 -04:00
Alexei Podtelezhnikov e7482ff4c2 * src/lzw/ftzopen.c (ft_lzwstate_stack_grow): Cosmetic macro change. 2022-06-11 23:47:19 -04:00
Alexei Podtelezhnikov 73631b9530 [woff, woff2] Avoid buffer zeroing.
* src/sfnt/sfwoff.c (woff_open_font): Use Q-macros.
* src/sfnt/sfwoff2.c: Ditto.
(reconstruct_font): Allocate table_entry on stack.
2022-06-11 16:10:40 -04:00
Alexei Podtelezhnikov 4fef1fcede [smooth] Fix GCC LTO crashes on Windows.
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`.
2022-06-10 11:34:56 -04:00
bruvzg 9acefc4f51 * src/smooth/ftgrays.c [FT_STATIC_RASTER]: Fix compilation. 2022-06-09 10:51:07 -04:00
Ben Wagner b11074cf6d [svg] Set linear advances when loading SVG glyphs
* 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
2022-06-06 16:55:17 -04:00
Ben Wagner c26872ed59 [svg] Clear correct flags for doc ownership
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
2022-06-01 17:27:38 +00:00
Alexei Podtelezhnikov d685798123 [docs] Correct favicon. 2022-05-31 22:40:55 -04:00
Alexei Podtelezhnikov 8addad6065 [docs] Use hinted favicon. 2022-05-31 22:38:24 -04:00
Alexei Podtelezhnikov c26f0d0d7e [docs] Update favicon. 2022-05-26 23:48:26 -04:00
Behdad Esfahbod (بهداد اسفهبد) b98dd169a1 * src/sfnt/ttmtx.c (tt_face_get_metrics): Apply variations unconditionally.
This causes a speed-up of approx. 20% for getting advance widths.
2022-05-25 14:49:37 +02:00
Dominik Röttsches 7838c78f53 [truetype] Support reading 32bit/16bit VarStore deltas
* 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.
2022-05-23 16:18:28 +03:00
Dominik Röttsches 9aa99f2262 [truetype] Handle 0xFFFF special value inside delta retrieval function
* 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.
2022-05-20 17:20:08 +03:00
Dominik Röttsches a4c4566b6d [truetype, snft] Add service methods for `DeltaSetIdxMap` and `VarStore`.
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.
2022-05-19 07:14:05 +02:00
Dominik Röttsches 5f19f49c81 [truetype] Move deallocation of `DeltaSetIdxMap` into own function.
This is a preparation for handling `DeltaSetIdxMap` and `VarStore` as a
FreeType service.

* src/truetype/ttgxvar.c (ft_var_done_delta_set_index_map): New function.
(tt_done_blend): Use it.
2022-05-19 06:09:17 +02:00
Werner Lemberg e3ac7bb64a * builds/toplevel.mk (do-dist): Don't remove meson wrap files.
Fixes #1157.
2022-05-18 16:12:19 +02:00
Werner Lemberg b4b7c3f607 * subprojects/zlib.wrap: Update to zlib version 1.2.12. 2022-05-18 16:02:21 +02:00
Werner Lemberg c8a9c88975 REAMDE: Mention that gitlab's 'download' button doesn't work.
This is because the `git archive` command doesn't preserve submodules.

Note that currently there is no support for disabling the 'download' button
in gitlab (https://gitlab.com/gitlab-org/gitlab/-/issues/17032).

Fixes issue #1158.
2022-05-18 07:06:58 +02:00
Werner Lemberg 5d49473f85 [truetype] Handle inner/outer index values 0xFFFF/0xFFFF.
This was introduced in OpenType 1.8.4.

* src/truetype/ttgxvar.c (ft_var_load_delta_set_index_mapping,
tt_hvadvance_adjust, ft_var_load_mvar, tt_apply_mvar): Handle special
inner/outer index values.
(ft_var_load_item_variation_store): Add test.

Fixes #1154.
2022-05-11 18:15:02 +02:00
Werner Lemberg e8ebfe988b * Version 2.12.1 released.
==========================

Tag sources with `VER-2-12-1'.

* docs/VERSION.TXT: Add entry for version 2.12.1.
* docs/CHANGES, docs/release: Updated.

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html, builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html, builds/wince/vc2008-ce/index.html,
docs/freetype-config.1: s/2.12.0/2.12.1/, s/2120/2121/.

* include/freetype/freetype.h (FREETYPE_PATCH): Set to 1.

* builds/unix/configure.raw (version_info): Set to 24:3:18.
* CMakeLists.txt (VERSION_PATCH): Set to 1.
2022-05-01 07:09:34 +02:00
Anuj Verma 7b3ebb9c12 [sdf] Do not throw errors for invisible glyphs.
* src/sdf/ftsdfrend.c (ft_sdf_render, ft_bsdf_render): Return `FT_Err_Ok` if
width or height is zero, since some glyphs do not generate visible bitmaps.

Fixes #1150.
2022-04-30 19:38:11 +02:00
Werner Lemberg 62bc04f4c5 * src/sfnt/sfobjs.c (sfnt_load_face): Set `FT_FACE_FLAG_COLOR` for SVG fonts.
Fixes #1151.
2022-04-30 15:37:14 +02:00
Brendan Shanks 6fb7b7a09d autogen.sh: Fix building when freetype is itself a git submodule.
There are situations where .git is not a directory, like when
freetype is a submodule in another repository.
2022-04-26 16:07:42 -07:00
Alexei Podtelezhnikov ed4d0710f1 [builds/windows] Simplify non-desktop UWP check.
Fixes mingw compilation described in !159.

* builds/windows/ftsystem.c: Do not use WINAPI_FAMILY_PARTITION macro.
2022-04-25 19:05:11 -04:00
Alexei Podtelezhnikov 581dd06405 [truetype] Reset IUP flags in `TT_RunIns`.
Fixes #1148 by moving the flag initialization back, partly reverting
7809007a and fd03dcc1.  Initializing these flags elsewhere skips 'cvt'.

* src/truetype/ttinterp.c (TT_RunIns): Initialize the IUP flag here...
(TT_Run_Context): ... instead of here.
2022-04-25 08:03:08 -04:00
Xavier Claessens d59c7ce1b9 [meson] Remove `default_library=both` from `default_options`.
It is inconsistent with what all other Meson projects do.

It also prevents static linking to FreeType when it is a subproject because
`default_options` in a subproject takes precedence on values set on the main
project.  For example, building 'GStreamer' with `-Ddefault_library=static`
would still dynamically link on FreeType unless the user also sets
`-Dfreetype2:default_library=static`.

* meson.build: Updated.

* .gitlab-ci.yml: Retain `both` option for testing.
2022-04-24 17:01:56 +02:00
Werner Lemberg 079a22da03 * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=46792
2022-04-19 09:34:10 +02:00
Georg Brandl 978eefee54 * src/cff/cffgload.c (cff_slot_load) [FT_CONFIG_OPTION_SVG]: Fix segfault.
This can happen if the function is called with `size` being `NULL`.

Fixes #1147.
2022-04-16 15:39:11 +02:00
Steve Lhomme 3100c8120e .gitlab-ci.yml: Add a Universal Windows build target
It's compiled for Windows 10 and up, ensuring UNICODE is set (default for UWP)
and selecting the proper WINAPI_FAMILY (WINAPI_FAMILY_APP).

Do not try to run the UWP exe in the Docker as it doesn't work.
2022-04-14 10:53:13 +00:00
Ben Wagner a1ca701023 [sfnt] Correct FT_ColorStopIterator documentation.
* include/freetype/ftcolor.h (FT_ColorStopIterator): the user should not
 set `p` to NULL before calling `FT_Get_Colorline_Stops`. `p` and
`num_color_stops` are set by `FT_Get_Paint`. `p` and
`current_color_stop` are updated by `FT_Get_Colorline_Stops`.
2022-04-04 15:28:54 -04:00
Werner Lemberg aee6b94727 * builds/unix/configure.raw: Add option `--with-librsvg`.
Since 'librsvg' is written in Rust, this option allows distributions to
avoid a dependency on the entire Rust toolchain to provide the FreeType demo
programs.

Suggested by Lars Wendler in !156.
2022-04-01 14:55:12 +02:00
Werner Lemberg fc08295650 * src/sfnt/sfwoff.c (reconstruct_glyf): Fix gcc 10 warning. 2022-04-01 14:50:44 +02:00
Werner Lemberg 1603378b91 [gzip] Update sources to zlib 1.2.12. 2022-04-01 10:47:23 +02:00
Eric Jing 89d5cce58d CMakeLists.txt: Fix `Info.plist` path.
When building a framework using CMake with `add_subdirectory`, CMake must be
able to find `freetype-Info.plist` when configuring the framework
properties.

Fixes #1145.
2022-04-01 08:55:22 +02:00
Werner Lemberg 695d606ae5 Whitespace. 2022-04-01 08:50:33 +02:00
Ben Wagner d247c56278 [truetype] Use SUB_LONG for component offset.
* src/truetype/ttgload.c (TT_Process_Composite_Component): do it.

Bug: https://crbug.com/1309429
2022-04-01 05:50:41 +00:00
Werner Lemberg 385345037e CMakeList.txt: Update code to handle recent changes for `freetype.pc`.
Fixes #1144.
2022-03-31 20:52:43 +02:00
Werner Lemberg 8a33164dad CMakeLists.txt: s/PKG_CONFIG/PKGCONFIG/, s/REQUIRED_/REQUIRES_/. 2022-03-31 20:51:58 +02:00
Werner Lemberg e50798b720 * Version 2.12.0 released.
==========================

Tag sources with `VER-2-12-0'.

* docs/VERSION.TXT: Add entry for version 2.12.0.
* docs/CHANGES, docs/release: Updated.

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html, builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html, builds/wince/vc2008-ce/index.html,
docs/freetype-config.1: s/2.11.1/2.12.0/, s/2111/2120/.

* include/freetype/freetype.h (FREETYPE_MINOR): Set to 12.
(FREETYPE_PATCH): Set to 0.

* builds/unix/configure.raw (version_info): Set to 24:2:18.
* CMakeLists.txt (VERSION_MINOR): Set to 12.
(VERSION_PATCH): Set to 0.

* builds/toplevel.mk (do-dist): Generate `ChangeLog` entries for all commits
since version 2.11.0 (when we stopped creating this file manually).
2022-03-31 13:55:50 +02:00
Werner Lemberg 87989a1435 Fix clang++ warnings.
* src/base/ftglyph.c (ft_svg_glyph_prepare), src/base/ftobj.c
(ft_glyphslot_init), src/cache/ftccmap.c (ftc_cmap_node_new),
src/cache/ftcimage.c (FTC_INode_New), src/lzw/ftlzw.c (FT_Stream_OpenLZW),
src/psaux/psobjs.c (ps_parser_load_field), src/pshinter/pshglob.c
(psh_globals_new), src/sfnt/ttsvg.c (tt_face_load_svg_doc): Initialize
variables used for allocation.

* src/sdf/ftsdf.c (split_sdf_conic, split_sdf_cubic): Change type of
`max_splits` to FT_UInt.
(sdf_generate_bounding_box): Add cast.
2022-03-31 07:49:35 +02:00
Werner Lemberg 97cdbb24f7 Whitespace. 2022-03-30 20:50:28 +02:00
Werner Lemberg 119e404b89 [builds] Fix creation of `freetype2.pc` for static-only builds.
We have to help `pkg-config` since it can't recognize that there is no
shared library installed.

Note that meson already does exactly the same.

* builds/unix/configure.raw (REQUIRES_PRIVATE, LIBS_PRIVATE): Rename to...
(PKGCONFIG_REQUIRES_PRIVATE, PKGCONFIG_LIBS_PRIVATE): This.  Adjust them
depending on `$enable_shared`.
(PKGCONFIG_REQUIRES, PKGCONFIG_LIBS): New variables.

* builds/unix/freetype2.in, builds/unix/unix-def.in: Use new and updated
variables.
2022-03-30 18:20:34 +00:00
Werner Lemberg a8e4563c34 Add `FT_FACE_FLAG_SBIX_OVERLAY` and `FT_HAS_SBIX_OVERLAY`.
* include/freetype/freetype.h (FT_FACE_FLAG_SBIX_OVERLAY,
FT_HAS_SBIX_OVERLAY): New macro.

* src/sfnt/ttsbit.c (tt_face_load_sbit): Handle `FT_FACE_FLAG_SBIX_OVERLAY`.
Remove obsolete tracing message.
2022-03-25 06:37:41 +00:00
Werner Lemberg 1949a7ec3a Add `FT_PARAM_TAG_IGNORE_SBIX`.
This is another bit to handle 'sbix' tables as described in the OpenType
specification.

* include/freetype/ftparams.h (FT_PARAM_TAG_IGNORE_SBIX): New macro.

* src/sfnt/sfobjc.c (is_apple_sbix): Rename to...
(has_sbix): ... this.
Check for more sbit tables.
Handle `FT_PARAM_TAG_IGNORE_SBIX` to eventually control `has_sbix`.
Only call sbit table loader if an sbit table is present.
2022-03-25 06:37:41 +00:00
Werner Lemberg ac4c1ebf7e [truetype] Fix 'sbix' table handling.
* 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.
2022-03-25 06:37:41 +00:00
Werner Lemberg 907715a6a2 Add `FT_FACE_FLAG_SBIX` and `FT_HAS_SBIX`.
Fonts with 'sbix' tables need special handling by the application.

* include/freetype/freetype.h (FT_FACE_FLAG_SBIX, FT_HAS_SBIX): New macros.

* src/sfnt/sfobjs.c (sfnt_load_face): Set `FT_FACE_FLAG_SBIX` if 'sbix'
table is present.
2022-03-25 06:37:41 +00:00
Werner Lemberg 06727a5257 * include/freetype/freetype.h (FT_LOAD_SBITS_ONLY): Tag macro as public. 2022-03-25 06:37:41 +00:00
Carlo Bramini 127c1e8331 [builds/windows] Fix WCE support.
* builds/windows/ftsystem.c [_WIN32_WCE]: Include <malloc.h> needed by
_alloca.
2022-03-23 22:53:07 -04:00
Steve Lhomme 0574692c6d [build/windows] Improve UWP support.
* builds/windows/ftsystem.c [UWP]: Wrap CreateFile2 into CreateFileA.
2022-03-23 22:46:15 -04:00
Werner Lemberg fc15ebe0a6 * src/sfnt/ttkern.c (tt_face_get_kerning): Exit early if no table.
Fixes #1141.
2022-03-21 11:17:28 +01:00
Ben Wagner a960be9e5e [woff2] Support overlap flag for simple glyphs.
In the woff2 spec it has been proposed to allow the OVERLAP_SIMPLE flag
to be retained through the woff2 format [0].

[0] https://www.w3.org/TR/WOFF2/#glyf_table_format

* src/sfnt/sfwoff2.h (GLYF_OVERLAP_SIMPLE): add glyf flag.

* src/sfnt/sfwoff2.c (reconstruct_glyf): parse optionFlags and
overlapSimpleBitmap[]. (store_points): set OVERLAP_SIMPLE on first point's
flag if the overlap bit is set.
2022-03-20 07:27:43 +00:00
Werner Lemberg d2c3bbcd8e [cff] Synchronize `cff_slot_load` with `TT_Load_Glyph`.
* src/cff/cffgload.c (IS_DEFAULT_INSTANCE): New macro.
(cff_slot_load): Use it.
2022-03-19 19:31:25 +01:00
Werner Lemberg 0c2bdb01a2 * src/base/ftobjs.c (FT_Request_Size): Guard `face->size`.
Fixes #1140.
2022-03-19 09:37:28 +01:00
Werner Lemberg d014387ad4 * src/base/ftobjs.c (ft_open_face_internal): Thinko. 2022-03-19 09:30:45 +01:00
Ben Wagner 7789f2bb79 [doc] FT_OUTLINE_OVERLAP was introduced in 2.10.3.
* include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): Document when added.
2022-03-19 06:20:53 +00:00
Werner Lemberg 22a0cccb4d * src/base/ftobjs.c (ft_open_face_internal): Properly guard `face_index`.
We must ensure that the cast to `FT_Int` doesn't change the sign.

Fixes #1139.
2022-03-19 06:40:17 +01:00
Werner Lemberg 53dfdcd819 [sfnt] Avoid invalid face index.
Fixes #1138.

* src/sfnt/sfobjs.c (sfnt_init_face), src/sfnt/sfwoff2.c (woff2_open_font):
Check `face_index` before decrementing.
2022-03-17 19:24:16 +01:00
Werner Lemberg 1e2eb65048 Documentation, whitespace. 2022-03-07 10:13:44 +01:00
Anuj Verma 360e2507a3 [sdf] Fix corner checks and improve performance.
* src/sdf/ftsdf.c (sdf_generate_bounding_box): Always check for a corner if
two distances (for different curves) are very close.

(sdf_conic_to): Check whether the conic curve can be treated as a line
(which happens if the control point coincides with any end point).
2022-03-05 17:00:10 +01:00
Anuj Verma 2600ef637e [sdf] Implement deviation-based splitting for Bezier curves.
* src/sdf/ftsdf.c (split_sdf_cubic, split_sdf_shape): Add checks to figure
out the deviation of Bezier curves and stop splitting if the curve is flat
enough.

* src/sdf/ftsdfcommon.h (ONE_PIXEL): New macro.
2022-03-05 16:53:45 +01:00
Anuj Verma 5499d7bf81 * include/freetype/freetype.h: Improve SDF documentation. 2022-03-05 16:44:23 +01:00
Ben Wagner 335224beee [sfnt] Fix bounds check in SVG.
The `SVG_DOCUMENT_LIST_MINIMUM_SIZE` macro is non trivial and not
protected by parentheses. As a result, the expression
`table_size - SVG_DOCUMENT_LIST_MINIMUM_SIZE` expands to
`table_size - 2U + SVG_DOCUMENT_RECORD_SIZE` instead of the expected
`table_size - (2U + SVG_DOCUMENT_RECORD_SIZE)`. This causes an incorrect
bounds check which may lead to reading past the end of the `SVG ` table.

* src/sfnt/ttsvg.c (tt_face_load_svg): wrap macro definitions in
parentheses.

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45179
2022-03-03 16:42:54 -05:00
Ben Wagner 034e5dbf92 [psaux] Full bounds check for OtherSubr 19.
It is possible for OtherSubr 19 to be invoked when `decoder->buildchar` is
NULL (so that `decoder->len_buildchar` is 0), the `blend` is non-NULL with
`blend->num_designs` set to 2, and the user supplied `idx` to be large (for
example 0xFFFFFFFE).  Since these are all `FT_UInt32` the existing bounds
check overflows in a well defined manner, allowing for an invalid call to
`memcpy`.

In addition, it is possible to call OtherSubr 19 with
`decoder->len_buildchar`, `blend->num_designs`, and `idx` all zero (implying
that `blend->weight_vector` and `decoder->buildchar` are NULL).  This passes
the bounds check (it is logically always fine to copy nothing starting at
index zero) but may invoke undefined behavior in `ft_memcpy` if it is backed
by `memcpy`.  Calling `memcpy` with either the `src` or `dst` NULL is
undefined behavior (even if `count` is zero).

* src/psaux/psintrp.c (cf2_interpT2CharString): Correctly check that
`blend->num_designs` can be copied to `decoder->buildchar[idx]`.
Also avoid passing NULL to `ft_memcpy`.

Bug: https://crbug.com/1299259
2022-02-23 17:42:55 +01:00
suzuki toshiya bcdfa38692 [cmake] Drop the support of CMake 2.x.
* CMakeLists.txt: Require CMake 3.0 (released on 2014) or newer.

The issue #1059 reports the difficulty to support both of
CMake 2.x and newer one by single CMakeLists.txt without
the inflation of cmake_policy() workarounds.

For better maintainability, the support of CMake 2.x is
dropped.
2022-02-21 10:44:42 +09:00
Werner Lemberg 6c5522c6f8 * src/bdf/README: Updated. 2022-02-19 13:37:07 +01:00
Werner Lemberg ca46bc0cf2 * builds/mac/ftmac.c, src/base/ftmac.c: s|FT_MAC_H|<freetype/ftmac.h>|. 2022-02-19 13:36:25 +01:00
Werner Lemberg 5b26e92a0f src/sfnt/ttkern.c (tt_face_load_kern): Micro-optimize.
A kerning table can be handled by binary search if it has equal entries.

Fixes #1132.
2022-02-19 07:20:24 +01:00
Steve Lhomme 20ec99be7e [builds/windows] Add support for legacy UWP builds.
* builds/windows/ftsystem.c: Add neccessary macro substitutions to
enable strict UWP builds.

See !141.

Co-authored-by: Alexei Podtelezhnikov <apodtele@gmail.com>
2022-02-17 13:35:52 -05:00
Werner Lemberg 01d4deb061 ftmm.h: Minor documentation improvement. 2022-02-16 14:51:44 +01:00
Alexei Podtelezhnikov 00ae29fcd2 [pshinter] Tune PSH_STRONG_THRESHOLD_MAXIMUM value.
Before the change, the hinting engine frequently confused horizontal
stem and serif hints making some stems too thin and some serifs too
thick. The value was tuned using serif fonts from the URW+ base 35
collection.

* src/pshinter/pshalgo.c [PSH_STRONG_THRESHOLD_MAXIMUM]: s/30/12/.
2022-02-12 23:42:08 -05:00
Werner Lemberg 5a53e51b5c t1tables.h: Documentation improvements. 2022-02-12 07:58:43 +01:00
Werner Lemberg c67ecb8c3a t1tables.h: Whitespace. 2022-02-12 07:52:57 +01:00
Werner Lemberg 338b4e8846 [type42] Fix `FT_Get_PS_Font_Private` for this format.
Since Type42 fonts don't have a 'Private' dictionary, the return value
should be `FT_Err_Invalid_Argument`.

* src/type42/t42drivr.c (t42_ps_get_font_private): Removed.
(t42_service_ps_info): Updated.
2022-02-11 19:32:49 +01:00
Alexei Podtelezhnikov 1680885aa5 [pshinter] Clear reused mask.
In PS hinter, memory allocations persist until the module is done.
Therefore, we have to clear reused masks.

* src/pshinter/pshrec.c (ps_mask_table_alloc): Clear reused mask.
2022-02-09 16:41:07 +00:00
Alexei Podtelezhnikov 0447df71e7 [pshinter] Use unsigned indices.
This reduces casting and eliminates some checks.

* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_table_merge,
ps_dimension_add_t1stem, ps_hints_t1stem3): Updated.
(ps_dimension_add_counter): Updated, unnecessary checks removed.
2022-02-09 15:04:58 +00:00
Alexei Podtelezhnikov ed0e2e76d8 [pshinter] Fix mask merging.
We forgot to update the number of bits when merging a larger mask
into a smaller one.  This fix might have rendering effects.

* src/pshinter/pshrec.c (ps_mask_table_merge): Inherit the number
of bits from a larger mask. There is no need to zero unused bits,
already zeroed during allocation.
(ps_mask_clear_bit): Removed.
(ps_mask_ensure): Minor.
2022-02-08 16:35:14 -05:00
Alexei Podtelezhnikov 7c6b2f20b0 [pshinter] Revise the hint table handling.
* src/pshinter/pshrec.c (ps_hint_table_ensure): Remove redundant size
check; avoid array zeroing because it is fully initialized when used.
(ps_hint_table_alloc): Fix off-by-one comparison and remove another
zeroing of the array elements.
2022-02-08 14:37:34 +00:00
Werner Lemberg 24db55ecb8 Various minor doc fixes. 2022-02-06 21:06:52 +01:00
Alexei Podtelezhnikov a173aead31 [builds/windows] Add SVG to to project files.
* builds/windows/vc2010/freetype.vcxproj: Updated.
* builds/windows/vc2010/freetype.vcxproj.filters: Updated.
* builds/windows/visualc/freetype.vcproj: Updated.
2022-02-06 08:25:52 -05:00
Alexei Podtelezhnikov dd8676b277 * src/winfonts/winfnt.c (fnt_face_get_dll_font): Trace font resources. 2022-02-03 14:32:50 +00:00
Eric Jing 56d182a74d [cmake] Fix build on MacOS.
* CMakeLists.txt (CMAKE_OSX_ARCHITECTURES): Update value to fix the building
of a framework on MacOS.

* builds/mac/freetype-Info.plist (CFBundleExecutable): Make identifier
lowercase only.

Fixes #1127.
2022-02-02 18:15:28 +01:00
Alexei Podtelezhnikov 8e39e42ee9 [psaux] Revise `PS_Table` handling.
The old impleemntation was not using `FT_REALLOC`, buing too careful
with the offset rebasing.  It shoudl be safe to rely on the base
movements.

* src/psaux/psobjs.c (reallocate_t1_table, shift_elements): Combine
into...
(ps_table_realloc): ... this function based on `FT_REALLOC`.
(ps_table_done): Simplified.
(ps_table_add): Updated.
2022-02-02 11:35:14 -05:00
Alexei Podtelezhnikov c6dd509b99 * src/cache/ftcmru.c (FTC_MruList_New): Explain zeroing. 2022-02-02 11:32:58 -05:00
Alexei Podtelezhnikov 946e1353ea [cache] Partially revert 9870b6c07e.
Fix crashes reported by Werner.

* src/cache/ftcmru.c (FTC_MruList_New): Use `FT_ALLOC` again.
2022-01-31 14:19:07 +00:00
Werner Lemberg 36ee3160a0 freetype.h: Minor documentation improvement. 2022-01-31 10:37:56 +01:00
Alexei Podtelezhnikov 983d435865 [cache] Fix fallouts from edd4fedc54.
Reported by Werner.

* src/cache/ftcimage.c (FTC_INode_New): Always initialize FT_Glyph.
* src/cache/ftcsbits.c (FTC_SNode_New): Always initialize FT_SBit.
2022-01-30 22:13:51 -05:00
Alexei Podtelezhnikov bee8886408 Clean-up - do not doubt FT_FREE.
* src/base/ftobjs.c (memory_stream_close): Do not reassign zero
after `FT_FREE`.
* src/sfnt/sfwoff.c (sfnt_stream_close): Ditto.
* src/sfnt/sfwoff2.c (stream_close): Ditto.
* src/psaux/psobjs.c (ps_parser_load_field): Ditto.
* src/truetype/ttgxvar.c (ft_var_load_avar, tt_set_mm_blend,
tt_set_mm_blend): Ditto.
2022-01-30 21:55:21 -05:00
Werner Lemberg 7fd03a3e25 * CMakeLists.txt: Include 'FindPkgConfig' module.
Older cmake versions don't provide `pkg_check_modules` by default.

Fixes #1126.
2022-01-30 20:50:42 +01:00
Alexei Podtelezhnikov da877c8693 * src/psaux/psobjs.c (ps_parser_load_field): Reduce `string` scope. 2022-01-29 22:46:56 -05:00
suzuki toshiya 35740aa6a9 [cmake] Check the availability of `bzip2.pc'.
(CMakeLists.txt): Check the availability of `bzip2.pc'.

* If `bzip2.pc' is available, Requires.private should include
bzip2, but Libs.private should not include -lbz2.

* If `bzip2.pc' is unavailable, Requires.private cannot include
bzip2, but Libs.private should include -lbz2.

Fix #897.
2022-01-29 01:36:12 +00:00
Werner Lemberg fa226478b1 * unix/configure.raw: We need 'librsvg' version 2.46.0 or newer.
Older versions don't have function `rsvg_handle_get_intrinsic_dimensions`.
2022-01-28 15:20:12 +01:00
Alexei Podtelezhnikov b34741c1cc Minor clean-ups.
* 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.
2022-01-27 22:55:34 -05:00
Ben Wagner e34a860a07 Document `FT_Outline_Decompose` degenerate segments.
`FT_Outline_Decompose` does not filter out and can return degenerate
segments in an outline. This can be surprising when attemping to
stroke such an outline. Clarify the existing documentation on this
matter to cover all forms of degeneracy (without specifying exactly
how they will be reported), why they might arise, and better explain in
what cases they may be an issue.

* include/freetype/ftoutlin.h (FT_Outline_Decompose): update
documentation.

Fixes #952.
2022-01-27 21:49:47 +01:00
Anuj Verma ab1c98ac18 Fix sdf computation while `USE_SQUARED_DISTANCES`.
Function `map_fixed_to_sdf` expects spread to be absolute
and not squared.

* src/sdf/ftbsdf.c (finalize_sdf): Pass absolute spread
while `map_fixed_to_sdf`.

* src/sdf/ftsdf.c (sdf_generate_bounding_box): Ditto.
2022-01-27 18:01:08 +05:30
Tapish Ojha 3d77756e73 [sfnt] Improve sRGB constants.
* src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use slightly
more precise values.

Fixes #1018.
2022-01-27 08:43:19 +01:00
Werner Lemberg 9476cb7eb3 docs/release: Updated. 2022-01-27 08:32:42 +01:00
Alexei Podtelezhnikov 837f0345a9 * src/pfr/pfrload.c (pfr_phy_font_load): Use FT_QNEW_ARRAY. 2022-01-26 15:49:24 -05:00
Alexei Podtelezhnikov 0ac535900b * src/sdf/ftsdf.c (sdf_*_new): Use standard macro. 2022-01-26 14:02:27 -05:00
Alexei Podtelezhnikov 09223ef929 [pcf] Delay encoding allocation and avoid its zeroing.
* src/pcf/pcfread.c (pcf_get_encodings): Refactor and use FT_QNEW_ARRAY.
2022-01-26 11:23:38 -05:00
Werner Lemberg 267c6918d1 Aarg, typo. 2022-01-25 14:46:36 +01:00
Werner Lemberg 9af1127fbe freetype.h: More updates to `FT_LOAD_COLOR` description. 2022-01-25 14:45:10 +01:00
Werner Lemberg 8b7226bb43 * builds/unix/configure.raw (FT_DEMO_CFLAGS): Pass `-DHAVE-LIBRSVG`.
This helps in decoupling library support from `pkg-config` for other
platforms.
2022-01-25 14:28:45 +01:00
Werner Lemberg 6a8e95b7a0 Update documentation for `FT_LOAD_COLOR`. 2022-01-25 08:49:41 +01:00
Ben Wagner 5e9caaee78 [pshinter] Ensure all point flags are initialized.
Only off curve point flags were fully initialized.

* src/pshinter/pshalgo.c (psh_glyph_init): always initialize flags.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43930
2022-01-24 12:24:59 -05:00
Werner Lemberg 657745212b .mailmap: Typo. 2022-01-24 07:57:20 +01:00
Werner Lemberg ef48a33271 * src/svg/ftsvg.c (ft_svg_property_set): Disallow NULL pointers. 2022-01-23 19:05:15 +01:00
Werner Lemberg cddfe6574b .mailmap: Updated. 2022-01-23 12:37:48 +01:00
Werner Lemberg 21d0fa3742 More documentation on handling OT-SVG. 2022-01-23 12:23:47 +01:00
Werner Lemberg 9c1538525b * src/svg/ftsvg.c: Rename `svg_hooks` to `svg-hooks` for consistency. 2022-01-23 08:56:17 +01:00
Werner Lemberg 112527dd44 [sfnt] Reject malformed SVG tables.
* src/sfnt/ttsvg.c (SVG_TABLE_HEADER_SIZE, SVG_DOCUMENT_RECORD_SIZE,
SVG_DOCUMENT_LIST_MINIMUM_SIZE, SVG_MINIMUM_SIZE): New macros.
(tt_face_load_svg): Check offsets.
Check table and record sizes.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43918
2022-01-22 12:09:08 +01:00
Alexei Podtelezhnikov 706c79a1da * src/psaux/psobjs.c (ps_table_new): Revert to zeroing. 2022-01-21 22:46:35 -05:00
Alexei Podtelezhnikov 0d2b4952a3 [psaux, type1, type42] Avoid annecessary zeroing.
* src/psaux/psobjs.c (ps_table_new): Use FT_QNEW_ARRAY.
* src/type1/t1load.c (parse_encoding): Ditto.
* src/type42/t42parse.c (t42_parse_encoding): Ditto.
2022-01-20 14:47:01 -05:00
Werner Lemberg 02fa26f4cd [builds/unix] Handle 'librsvg' for demo programs.
* builds/unix/configure.raw: Check for 'librsvg'.
(LIB_CLOCK_GETTIME): Don't call `AC_SUBST` on this but on...
(FT_DEMO_CFLAGS, FT_DEMO_LDFLAGS): ... these two new variables.

* builds/unix/unix-cc.in (LIB_CLOCK_GETTIME): Replaced by...
(FT_DEMO_CFLAGS, FT_DEMO_LDFLAGS): ... these two new variables.
2022-01-20 16:45:18 +00:00
Moazin Khatti 0bf49bd229 Add 'svg' module for OT-SVG rendering.
* CMakeLists.txt (BASE_SRCS): Add svg module file.
* meson.build (ft2_public_headers): Add `otsvg.h`.

* modules.cfg (RASTER_MODULES): Add `svg` module.

* builds/meson/parse_modules_cfg.py: Add svg module.

* include/freetype/config/ftmodule.h: Add `ft_svg_renderer_class`.
* include/freetype/fterrdef.h: Add `Invalid_SVG_Document` and
`Missing_SVG_Hooks` error codes.
* include/freetype/internal/fttrace.h: Add tracing for `otsvg`.
* include/freetype/internal/svginterface.h: New file.  It adds an interface
to enable the presetting hook from the `base` module.
* include/freetype/otsvg.h (SVG_Lib_Init_Func, SVG_Lib_Free_Func,
SVG_Lib_Render_Func, SVG_Lib_Preset_Slot_Func): New hooks for SVG rendering.
(SVG_RendererHooks): New structure to access them.

* src/base/ftobjs.c: Include `svginterface.h`.
(ft_glyphslot_preset_bitmap): Add code for presetting the slot for SVG
glyphs.
(ft_add_renderer): Updated.

* src/svg/*: New files.
2022-01-20 16:45:18 +00:00
Moazin Khatti 97c09a803e Add `FT_Glyph` support for OT-SVG glyphs.
* include/freetype/ftglyph.h (FT_SvgGlyphRec, FT_SvgGlyph): New structure.

* src/base/ftglyph.c: Include `otsvg.h`.
(ft_svg_glyph_init, ft_svg_glyph_done, ft_svg_glyph_copy,
ft_svg_glyph_transform, ft_svg_glyph_prepare): New function.
(ft_svg_glyph_class): New class.
(FT_New_Glyph, FT_Glyph_To_Bitmap): Updated to handle OT-SVG glyphs.
* src/base/ftglyph.h: Updated.
2022-01-20 16:45:18 +00:00
Moazin Khatti 5cf01aa2b2 [truetype, cff] Add code to load SVG document.
* 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.
2022-01-20 16:45:18 +00:00
Moazin Khatti f93a897afe Add code to load OT-SVG glyph documents.
* include/freetype/config/ftheader.h (FT_OTSVG_H): New macro.
* include/freetype/freetype.h (FT_FACE_FLAG_SVG, FT_HAS_SVG): New macros.
(FT_LOAD_SVG_ONLY): New internal macro.
* include/freetype/ftimage.h (FT_Glyph_Format): New enumeration value
`FT_GLYPH_FORMAT_SVG`.
* include/freetype/internal/ftobjs.h (FT_GLYPH_OWN_GZIP_SVG): New macro.
* include/freetype/internal/fttrace.h: Add `ttsvg` for `ttsvg.c`.
* include/freetype/internal/sfnt.h(load_svg, free_svg, load_svg_doc): New
functions.
* include/freetype/internal/tttypes.h (TT_FaceRec): Add `svg` for
the SVG table.
* include/freetype/otsvg.h (FT_SVG_DocumentRec): New structure to hold the
SVG document and other necessary information of an OT-SVG glyph in a glyph
slot.
* include/freetype/tttags.h (TTAG_SVG): New macro.

* src/base/ftobjs.c: Include `otsvg.h`.
(ft_glyphslot_init): Allocate `FT_SVG_DocumentRec` in `slot->other`
if the SVG table exists.
(ft_glyphslot_clear): Free it upon clean-up if it is a GZIP compressed
glyph.
(ft_glyphslot_done): Free the document data if it is a GZIP compressed
glyph.
(FT_Load_Glyph): Don't auto-hint SVG documents.

* src/cache/ftcbasic.c (ftc_basic_family_load_glyph): Add support for
FT_GLYPH_FORMAT_SVG.

* src/sfnt/rules.mk (SFNT_DRV_SRC): Add `ttsvg.c`.
* src/sfnt/sfdriver.c: Include `ttsvg.h`.
(sfnt_interface): Add `tt_face_load_svg`, `tt_face_free_svg` and
`tt_face_load_svg_doc`.
* src/sfnt/sfnt.c: Include `ttsvg.c`.
* src/sfnt/sfobjs.c (sfnt_load_face, sfnt_done_face): Add code to load and
free data of the the SVG table.
* src/sfnt/ttsvg.c: New file, implementing `tt_face_load_svg`,
`tt_face_free_svg` and `tt_face_load_svg_doc`.
* src/sfnt/ttsvg.h: Declarations of the SVG functions in
`ttsvg.c`.
2022-01-20 16:45:18 +00:00
Moazin Khatti 06c1a25e63 Add flag `FT_CONFIG_OPTION_SVG`.
This flag is going to be used to conditionally compile support for OT-SVG
glyphs.  FreeType will do the parsing and rely on external hooks for
rendering of OT-SVG glyphs.

* devel/ftoption.h, include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_SVG): New flag.
2022-01-20 16:45:18 +00:00
Alexei Podtelezhnikov 0b635b1eb2 [pshinter] Avoid unnecessary zeroing.
* src/pshinter/pshalgo.c (psh_hint_table_init,psh_glyph_init,
psh_glyph_interpolate_normal_points): Use FT_QNEW_ARRAY.
2022-01-20 15:06:25 +00:00
Alexei Podtelezhnikov 99a940f84a * include/freetype/freetype.h: Clarify `FT_Size` life cycle. 2022-01-20 15:06:09 +00:00
Alexei Podtelezhnikov 054782c48e [base] Undefined scale means no scale.
It might be surprising that FreeType does not have default ppem and
the size has to be set explicitly or face undefined behavior with
undefined variables and errors. This offers an alternative to
missing or zero scale by simply setting FT_LOAD_NO_SCALE.  Defined
behavior is bettr than undefined one.

This is alternative to !132 and discussed in
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43708

* src/base/ftobjs.c (FT_Load_Glyph): Deal with zero scale.
* include/freetype/freetype.h: Document it.
2022-01-19 22:14:06 -05:00
Alexei Podtelezhnikov 773e31c783 * src/autofit/afglobal.c (af_face_globals_new): Reduce zeroing.
Everything in AF_FaceGlobals is initialized except metrics.  Those
are zeroed here and initialized on demand later.
2022-01-18 14:05:46 -05:00
Alexei Podtelezhnikov d118bf8e35 [bdf,type1] Avoid unnecessary hash zeroing.
* src/bdf/bdflib.c (_bdf_parse_start): Use `FT_QALLOC`.
* src/type1/t1load.c (parse_subrs): Use `FT_QNEW`.
2022-01-15 23:09:53 -05:00
Ozkan Sezer 3f6497bdc5 Add Watcom C/C++ calling.
In the unlikely case the source is built with OpenWatcom's -ec?
switches to enforce a calling convention, the qsort() compare
function must still be set to __watcall.

* include/freetype/internal/compiler-macros.h (FT_COMPARE_DEF):
Updated.
2022-01-15 22:44:28 -05:00
Ben Wagner 5e227133c1 [pshinter] Avoid accessing uninitialized zone.
The `normal_top.count` may be 0, implying no `normal_top.zones` exist.
The code must not access these (non-existent) `normal_top.zones`.

* src/pshinter/pshalgo.c (ps_hints_apply): Do not assume that
`normal_top.zones[0]` is initialized. Test `normal_top.count`
before using `normal_top.zones[0]`. Do not rescale if there are no
`zones`.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43675
2022-01-15 17:21:39 -05:00
Alexei Podtelezhnikov edd4fedc54 [cache] Avoid unnecessary zeroing.
* src/cache/ftccmap.c (ftc_cmap_node_new): Use `FT_QNEW`.
* src/cache/ftcimage.c (FTC_INode_New): Ditto.
* src/cache/ftcsbits.c (FTC_SNode_New): Ditto.
2022-01-14 22:53:57 -05:00
Ozkan Sezer 11ea89b51c Add Watcom C/C++ support.
* include/freetype/config/integer-types.h: Make sure `long long` is
used then available.
* include/freetype/internal/ftcalc.h (FT_MSB): Add Watcom C/C++ pragma.
2022-01-14 22:07:44 -05:00
Alexei Podtelezhnikov ba5d661f34 * src/sdf/ftbsdf.c (ED): s/near/prox/.
This works around the Watcom C definition of `near` as restricted
__near.
2022-01-14 21:54:17 -05:00
Alexei Podtelezhnikov 7f7bf6f0f0 * include/freetype/internal/compiler-macros.h [FT_COMPARE_DEF]: Tighten.
This works around Watcom C library using __watcall.
2022-01-14 20:33:28 -05:00
Alexei Podtelezhnikov 7eb9a9dbbe * src/pshinter/pshglob.c (psh_globals_new): Avoid zeroing.
This large allocation is followed by careful initialization. Whatever
is missed should be initialized manually.
2022-01-14 14:40:11 -05:00
Alexei Podtelezhnikov 81b81feb62 * src/base/fthash.c (hash_insert): Avoid unnecessary zeroing. 2022-01-14 18:22:23 +00:00
Alexei Podtelezhnikov 904ad21266 * src/bdf/bdflib.c (_bdf_parse_glyphs): Remove redundant assignment. 2022-01-13 23:38:56 -05:00
Alexei Podtelezhnikov ee52b57121 * src/lzw/ftlzw.c (FT_Stream_OpenLZW): Avoid unnecessary zeroing. 2022-01-13 09:45:48 -05:00
Ben Wagner 6ee8951956 [bzip2] Reset bzip stream on any error.
According to the bzip documentation it is undefined what will happen if
`BZ2_bzDecompress` is called on a `bz_stream` it has previously returned an
error against.  If `BZ2_bzDecompress` returns anything other than `BZ_OK`
the only valid next action is `BZ2_bzDecompressEnd`.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43564

* src/bzip2/ftbzip2.c (FT_BZip2FileRec_): Add `reset` to track the need to
reset the stream.
(ft_bzip2_file_init): Initialize `reset` to 0.
(ft_bzip2_file_reset): Set `reset` to 0 after resetting.
(ft_bzip2_file_fill_output): Set `reset` to 1 when `BZ2_bzDecompress`
returns anything other than `BZ_OK`.
2022-01-13 08:21:36 +01:00
Werner Lemberg b647dbdeb8 .gitlab-ci.yml: Minor comment cleanups. 2022-01-12 06:22:15 +01:00
Azamat H. Hackimov ca44a236a0 .gitlab-ci.yml: Add steps to `before_script` to ensure recent CA.
Fetch current list of valid CAs from Windows Update and manually import them
to trusted datastore.  This action is required to make downloads work from
sites that need recent Let's Encrypt ISRG Root X1 certificate.
2022-01-12 06:22:15 +01:00
Ben Wagner f1d3b9f10a Revert "[bzip2] Avoid use of uninitialized memory."
This reverts commit d276bcb7f0.

The original commit did avoid the use of uninitialized memory. However,
it appears that the original commit is no longer required. The
underlying issue was resolved by a change in freetype2-testing "Build
bzip2 correctly." [0]. Prior to [0] bzip2 was built without msan, so
bzip2 writes were not tracked or considered initialized. Clearing
`buffer` in the original commit allowed msan to see the `buffer` content
initialized once in FreeType code, but msan saw no writes into buffer
from bzip2.  With bzip2 now built with msan, the bzip2 writes are
properly instrumented and msan sees the bzip2 writes into the buffer. As
a result the original commit can be safely reverted to allow for better
detection of other uninitialized data scenarios.

* src/bzip2/ftbzip2.c (FT_Stream_OpenBzip2): Revert to using `FT_QNEW`.

[0] 3c052a837a
2022-01-11 17:15:35 -05:00
Ben Wagner e838c37c2c [type42] Track how much type42 ttf data is available.
Currently `T42_Open_Face` eagerly allocates 12 bytes for the ttf header
data which it expects `t42_parse_sfnts` to fill out from /sfnts data.
However, there is no guarantee that `t42_parse_sfnts` will actually be
called while parsing the type42 data as the /sfnts array may be missing
or very short. This is also confusing behavior as it means
`T42_Open_Face` is tightly coupled to the implementation of the very
distant `t42_parse_sfnts` code which requires at least 12 bytes to
already be reserved in `face->ttf_data`.

`t42_parse_sfnts` itself eagerly updates `face->ttf_size` to track how
much space is reserved for ttf data instead of traking how much data has
actually been written into `face->ttf_data`. It will also act strangely
in the presense of multiple /sfnts arrays.

* src/type42/t42objs.c (T42_Open_Face): ensure `ttf_data` is initialized
to NULL. Free `ttf_data` on error.

* src/type42/t42parse.c (t42_parse_sfnts): delay setting `ttf_size` and
set it to the actual number of bytes read. Ensure `ttf_data` is freed
if there are multiple /sfnts arrays or there are any errors.
2022-01-11 14:58:18 -05:00
Dominik Röttsches 3876846e26 [sfnt] Fix limit checks for `COLR` v1 ClipBoxes
* src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Fix off-by-one in
limit checks.
2022-01-11 13:40:20 +02:00
Werner Lemberg d0cfb4e1b2 Update all copyright notices. 2022-01-11 10:54:10 +01:00
Werner Lemberg 947fddc8da * src/sfnt/ttcolr.c (read_paint): Fix undefined left-shift operation.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43151
2022-01-11 08:27:26 +00:00
Werner Lemberg 639a02154b * src/type42/t42objs.c (T42_Open_Face): Avoid use of uninitialized memory.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43508
2022-01-11 09:14:48 +01:00
Werner Lemberg 33626164e8 .gitlab-ci.yml: Fix typo in previous commit. 2022-01-11 08:01:30 +01:00
Werner Lemberg 4c0db60772 .gitlab-ci.yml: Update Windows image.
The old image produced errors like

```
Downloading zlib patch from
  https://wrapdb.mesonbuild.com/v2/zlib_1.2.11-5/get_patch
A fallback URL could be specified using patch_fallback_url key in the wrap file
WrapDB connection failed to
  https://wrapdb.mesonbuild.com/v2/zlib_1.2.11-5/get_patch
with error
  <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify
   failed: certificate has expired (_ssl.c:1122)>
```
2022-01-11 07:52:28 +01:00
Werner Lemberg 2e62b7446b * subprojects/zlib.wrap: Update from upstream. 2022-01-11 05:37:56 +01:00
Werner Lemberg 4a89112b2a * src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Add limit checks.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40716
2022-01-10 18:31:17 +00:00
Werner Lemberg 3f9b78fc79 [zlib] Don't typedef `ptrdiff_t`.
While using zlib in 'solo' mode (via the `Z_SOLO` macro), we actually
include some standard header files, making the typedef fail on systems where
the native `ptrdiff_t` type differs.

Fixes #1124.

* src/zlib/zutil.h: Comment out definition; it doesn't work on Windows.

* src/zlib/patches/freetype-zlib.diff: Updated.
2022-01-10 18:24:56 +01:00
Werner Lemberg da8a8b8bcf [zlib] Some organizational changes.
We now first apply zlib's `zlib2ansi` script, then FreeType's patch file.

* src/gzip/README.freetype: Updated.

* patches/0001-zlib-Fix-zlib-sources-to-compile-for-FreeType.patch: Renamed
to...
* patches/freetype-zlib.diff: This.
Clean up description, then regenerate it as follows:

  - Copy unmodified files from `zlib` repository.
  - Run `zlib2ansi` script.
  - Run `git diff -R > patches/freetype-zlib.diff.new`.
  - Insert patch description of old diff file, then replace old diff with
    new diff file.
2022-01-10 18:13:10 +01:00
David Turner a25e85ed95 [gzip] Update sources to zlib 1.2.11
This can be tested by building with the Unix development build

  make setup devel
  make

or by building the freetype-demos programs with

  meson setup build -Dfreetype2:zlib=internal
  meson compile -C out

and trying to run `ftview` with a `.pcf.gz` font file.

* src/gzip/ftgzip.c, src/gzip/rules.mk: Update for new zlib sources.  Also
remove the temporary fix introduced in commit 6a431038 to work around the
fact that the internal sources were too old.

* src/gzip/README.freetype: New file describing the origin of the sources
and how they were modified.

* src/gzip/patches/*: Patch files applied to original sources.

* src/gzip/*: Updated zlib sources with the patch file(s) from
`src/gzip/patches/` applied, followed by a conversion with zlib's
`zlib2ansi` script.
2022-01-09 23:16:00 +01:00
David Turner 0d34386366 [meson] Change Zlib configuration option.
* meson_options.txt, meson.build: Change the format of the 'zlib' meson
build configuration option to be a combo with the following choices:

  - none: Do not support gzip-compressed streams at all.

  - internal: Support gzip-compressed streams using the copy of the gzip
    sources under `src/gzip/`; this should only be used during development
    to ensure these work properly.

  - external: Support gzip-compressed streams using the 'zlib' Meson
    subproject, linked as a static library.

  - system: Support gzip-compressed streams using a system-installed version
    of zlib.

  - auto: Support gzip-compressed streams using a system-installed version
    of zlib, if available, or using the 'zlib' subproject otherwise.  This
    is the default.

  - disabled: Backward-compatible alias for 'none'.

  - enabled: Backward-compatible alias for 'auto'.
2022-01-09 21:38:29 +01:00
Werner Lemberg d276bcb7f0 [bzip2] Avoid use of uninitialized memory.
* src/bzip2/ftbzip2.c (FT_Stream_OpenBzip2): Don't use `FT_QNEW` but
`FT_NEW` for setting up `zip` to avoid uninitialized memory access while
handling malformed PCF fonts later on.

Fixes

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42800
2022-01-09 07:48:59 +01:00
Alexei Podtelezhnikov ca01112894 [sfnt] Fix off-by-one error.
The 0-base index is equal to the number of previosly parsed entries.
It is an error to adjust it by one to get the number truncated by
a stream error.  This is probably inconsequential because valid
entries are correctly accounted for.

* src/sfnt/ttload.c (check_table_dir): Do not adjust the truncated
number of tables.
2022-01-08 22:28:44 -05:00
Werner Lemberg 7a493e3a40 [sfnt, type42] Correct previous commit.
Really fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42773.

* src/sfnt/ttload.c (check_table_dir): Revert change.

* src/type42/t42.parse.c (t42_parse_sfnts): Don't use `FT_QREALLOC` but
`FT_REALLOC` for setting up `ttf_data` to avoid uninitialized memory access
while handling malformed TrueType fonts later on.
2022-01-08 10:28:19 +01:00
Werner Lemberg bf9b1ef905 * src/sfnt/ttload.c (check_table_dir): Initialize `table`.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42773
2022-01-07 10:25:52 +01:00
Werner Lemberg b5c2172f59 [sfnt] Avoid 'runtime error: applying zero offset to null pointer'.
* src/sfnt/ttsbit.c (tt_sbit_decoder_load_byte_aligned): Exit early if
`line` is NULL.
2022-01-07 06:53:44 +01:00
Werner Lemberg 5aa2a5c34a [autofit, pshinter] Use `FT_OFFSET`.
This avoids

```
runtime error: applying zero offset to null pointer
```

warnings of clang's undefined behaviour sanitizer.

* src/autofit/afcjk.c (af_cjk_hints_link_segments,
af_cjk_hints_compute_edges, af_cjk_hints_compute_blue_edges,
af_cjk_hint_edges, af_cjk_align_edge_points): Do it.

* src/autofit/afhints.c (af_glyph_hints_align_edge_points,
af_glyph_hints_align_strong_points): Ditto.

* src/autofit/aflatin.c (af_latin_metrics_init_widths,
af_latin_hints_link_segments, af_latin_hints_compute_edges,
af_latin_hints_compute_blue_edges, af_latin_hint_edges): Ditto.

* src/pshinter/pshalgo.c (psh_hint_table_init): Ditto.
2022-01-07 06:41:36 +01:00
Ben Wagner afb4ca0151 [truetype] Reset localpoints when varying cvt.
When iterating over the cvt tuples and reading in the points it is necessary
to set all of `localpoints`, `points`, and `point_count` in all cases.  The
existing code did not reset `localpoints` to `NULL` when there were no
private point numbers.  If the previous tuple did have private point numbers
and set `localpoints` to `ALL_POINTS` this would not be cleared and the
wrong branch would be taken later, leading to possible heap buffer overflow.

* src/truetype/ttgxvar.c (tt_face_vary_cvt): Reset `localpoints` to `NULL`
when it isn't valid.

Fixes: https://crbug.com/1284742
2022-01-06 19:13:00 +01:00
Werner Lemberg 2b672e7210 * builds/unix/configure.raw: Restore `SYSTEM_ZLIB` variable.
This was accidentally removed with commit 93ebcbd0 almost eight years ago.
2022-01-02 18:33:03 +01:00
Alexander Borsuk 4eb6cb8818 Fix warnings for CMake Unity builds.
* src/cache/ftcbasic.c (FT_COMPONENT): Undefine macro before redefinition.
* src/smooth/ftgrays.c (TRUNC, FRACT): Ditto.
2021-12-27 07:48:04 +01:00
Alexander Borsuk 4f35711844 Clang-Tidy warning fixes.
* src/base/ftobjs.c (FT_Get_Paint): Operator has equivalent nested operands.
* src/bdf/bdflib.c (_bdf_add_property): Value stored to `fp` is never read.
* src/sdf/ftbsdf.c (bsdf_init_distance_map): Value stored to `pixel` is
never read.
* src/sdf/ftsdf.c (split_sdf_shape): Value stored to `error` is never read.
2021-12-18 11:09:15 +01:00
Eli Schwartz d6a5c57727 * meson.build: Optimize lookup for `python3` program.
The python module's `find_installation` method is intended to provide
routines for compiling and installing python modules into the
`site-packages` directory.  It does a couple of slow things, including run
an introspection command to scrape sysconfig info from the detected
interpreter, which are not needed for the sole use case of invoking the
found installation as an executable.

Furthermore, when invoked without the name or path of a python binary, it is
hardcoded to always look for `python3` corresponding to the interpreter
meson itself uses to run.  So using `find_installation` did not even allow
detecting `python2` as a fallback.

Instead, switch to a simple `find_program` lookup that finishes as soon as
the program is found.
2021-12-17 10:47:13 +01:00
Eli Schwartz 57fd61805f * builds/meson/*.py: Fix name of python executable for auxiliary scripts.
The previous change to check the return code of `run_command` invocations
caused the CI to fail.  Although most scripts used `python_exe` as the
program command, the script to determine the project version did not.

But, all scripts used `python` as the shebang, and this is not available on
all systems.  Particularly Debian does not provide a `python` command,
though `python3` does exist.  This meant that formerly the version number
was lacking, and now the build simply fails.

Instead, rely on `python3` since it is guaranteed to exist when running
meson, and `python2` is end of life anyway.
2021-12-17 10:45:29 +01:00
Eli Schwartz e342f83c0b * meson.build: Check the return value of `run_command`.
By default, errors are not checked and a command that is somehow broken will
just capture incorrect output (likely an empty string).  Current development
versions of meson now raise a warning for this implicit behavior, and advise
explicitly setting the `check:` keyword argumend to determine whether a
failing return code should be considered an error.

Since none of the commands in this project are expected to fail, mark them
as required to succeed.
2021-12-17 10:38:57 +01:00
Alexei Podtelezhnikov 0da2a1155e [truetype] Upstream the hdmx binary search.
* 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.
2021-12-13 11:44:24 -05:00
Alexei Podtelezhnikov fd03dcc122 [truetype] Reset the IUP-called flags for each subglyph.
This fixes fall-out from 7809007a5b, 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.
2021-12-12 12:29:04 -05:00
Alexei Podtelezhnikov 7add5b2bcb [truetype] Binary search through the `hdmx` records.
The `hdmx` table is supposed to be sorted by ppem size, which
enables binary search.  We also drop the check for the sufficient
length of the record because it is now enforced when the table
is loaded.

* include/freetype/internal/tttypes.h (TT_FaceRec): Store the `hdmx`
record pointers sorted by ppem instead of ppem's themselves.
* src/truetype/ttpload.c (tt_face_load_hdmx): Prudently sort records.
(tt_face_get_device_metrics): Implement binary search to retrieve
advances.
2021-12-11 22:54:06 -05:00
Alexei Podtelezhnikov a8ef33e3ae [truetype] Honor FT_LOAD_ADVANCE_ONLY if `hdmx` is usable.
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.
2021-12-11 22:42:46 -05:00
Alexei Podtelezhnikov 6c831d658f [truetype] Initialize the loader with `hdmx` data.
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.
2021-12-11 22:34:27 -05:00
Alexei Podtelezhnikov 7809007a5b [truetype] Relocate subpixel flag setting.
`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.
2021-12-11 22:22:57 -05:00
Alexei Podtelezhnikov a35b081ebc [truetype] Limit INSTCTRL appication within specs.
* src/truetype/ttinterp.c (Ins_INSTCTRL): Limit its global effects
to the CVT program and local effects to the glyph program.

This also fixes an Infinality buglet. The `ignore_x_mode` should be
locally unset by the glyph program.
2021-12-11 22:12:25 -05:00
Ben Wagner bad92be927 [bdf] Fix use of uninitialized value.
In _bdf_readstream if the data contained no newline then the buffer
would continue to grow and uninitialized data read until either the
uninitialized data contained a newline or the buffer reached its
maxiumum size. The assumption was that the line was always too long and
the buffer had been filled, however this case can also happen when there
is not enough data to fill the buffer.

Correct this by properly setting the cursor to the end of the available
data, which may be different from the end of the buffer. This may still
result in one extra allocation, but only on malformed fonts.

* src/bdf/bdflib.c (_bfd_readstream): Correctly update cursor. Remove
unread set of `avail`.

Bug: https://lists.nongnu.org/archive/html/freetype-devel/2021-12/msg00001.html
2021-12-09 17:07:58 -05:00
Alexei Podtelezhnikov 012b00f3e6 [truetype] Reduce Infinality footprint again.
* src/truetype/ttgload.c (compute_glyph_metrics): Streamline and
prioritize the Infinality checks to use `hdmx`.
2021-12-07 10:19:06 -05:00
Cameron Cawley 1f95189875 [builds/windows] Guard some non-ancient API.
We can support Windows 98 and NT 4.0 in principle...

* builds/windows/ftdebug.c, builds/windows/ftsystem.c: Check for the
ancient SDK using _WIN32_WINDOWS, _WIN32_WCE, or _WIN32_WINNT.
2021-12-06 23:08:46 -05:00
Cameron Cawley 9a533aa27f * builds/windows/visualc/freetype.vcproj: Add missing file. 2021-12-06 21:46:47 -05:00
662 changed files with 32070 additions and 14961 deletions

View File

@ -1,20 +1,28 @@
# CI setup for FreeType.
# https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/540
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
stages:
- build
# FIXME: Use --werror once warnings are fixed.
variables:
MESON_ARGS: --fatal-meson-warnings
MESON_ARGS: --fatal-meson-warnings --default-library=both
MESON_ARGS_WINDOWS: ${MESON_ARGS} --force-fallback-for=zlib
.build windows common:
# See
# https://gitlab.freedesktop.org/gstreamer/gst-ci/container_registry/213
image: 'registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:v14-master'
# TODO: should probably get its own image at some point instead of reusing the GStreamer one
# See https://gitlab.freedesktop.org/gstreamer/gstreamer/container_registry/18035 for latest
image: "registry.freedesktop.org/gstreamer/gstreamer/amd64/windows:2022-07-29.3-main"
stage: 'build'
tags:
- 'docker'
- 'windows'
- '1809'
- '2022'
- 'gstreamer-windows'
.build linux common:
@ -34,50 +42,97 @@ variables:
# Make sure any failure in PowerShell scripts is fatal.
ErrorActionPreference: 'Stop'
WarningPreference: 'Stop'
# Uncomment the following key if need to pass custom args, as well with
# the `$env:MESON_ARGS` line in the `script:` blocks.
# Uncomment the following key if you need to pass custom args, as well
# with the `$env:MESON_ARGS` line in the `script:` blocks.
# MESON_ARGS: >-
# -Dfoo=enabled
# -Dbar=disabled
before_script:
# Make sure meson is up to date, so we don't need to rebuild the image
# Update RootCAs in order to access to some sites.
- certutil -generateSSTFromWU "C:\roots.sst"
- Import-Certificate -CertStoreLocation "Cert:\LocalMachine\Root" "C:\roots.sst"
# Make sure meson is up to date so we don't need to rebuild the image
# with each release.
- pip3 install meson==0.59.1
- pip3 install -U 'meson==0.59.*'
- pip3 install --upgrade certifi
- pip3 install -U ninja
# Generate a UWP cross-file in case it's used
- $PSDefaultParameterValues['Out-File:Encoding'] = 'ASCII'
- echo "[binaries]" > uwp-crossfile.meson
- echo "c = 'cl'" >> uwp-crossfile.meson
- echo "strip = ['true']" >> uwp-crossfile.meson
- echo "[built-in options]" >> uwp-crossfile.meson
- echo "c_args = ['-DWINAPI_FAMILY=WINAPI_FAMILY_APP', '-DUNICODE', '-D_WIN32_WINNT=0x0A00', '-we4013']" >> uwp-crossfile.meson
- echo "c_winlibs = ['windowsapp.lib']" >> uwp-crossfile.meson
script:
# For some reason, options are separated by newlines instead of spaces,
# so we have to replace them first.
#- $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
#
# - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
#
# Gitlab executes PowerShell in docker, but `VsDevCmd.bat` is a batch
# script. Environment variables substitutions is done by PowerShell
# before calling `cmd.exe`, that's why we use `$env:FOO` instead of
# `%FOO%`.
- cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH $env:VS_UWP &&
meson setup build $env:MESON_ARGS_WINDOWS $env:MESON_ARGS_UWP &&
meson compile --verbose -C build
$env:MESON_WINDOWS_TESTS"
.build windows msbuild:
extends: '.build windows common'
variables:
# Make sure any failure in PowerShell scripts is fatal.
ErrorActionPreference: 'Stop'
WarningPreference: 'Stop'
script:
- git submodule update --init --recursive
- cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
meson setup build $env:MESON_ARGS_WINDOWS &&
meson compile --verbose -C build &&
meson test -C build &&
meson test -C build --benchmark"
MSBuild.exe -clp:ForceConsoleColor -t:Rebuild
-p:Configuration=Debug
-p:Platform=$env:PLATFORM
-p:UserDefines=FT_DEBUG_LOGGING
MSBuild.sln"
# Format of job names:
# <OS> <Build-Tool> <Build-Params> <Architecture>
# <OS> <Build-Tool> <Build-Params> <Architecture>:
# Windows jobs
windows meson vs2017 amd64:
# Windows jobs.
windows meson vs2019 amd64:
extends: '.build windows meson'
variables:
ARCH: 'amd64'
MESON_WINDOWS_TESTS: '&& meson test -C build && meson test -C build --benchmark'
windows meson vs2017 x86:
windows meson vs2019 x86:
extends: '.build windows meson'
variables:
ARCH: 'x86'
MESON_WINDOWS_TESTS: '&& meson test -C build && meson test -C build --benchmark'
windows meson vs2019 amd64 uwp:
extends: '.build windows meson'
variables:
ARCH: 'amd64'
VS_UWP: '-app_platform=UWP'
MESON_ARGS_UWP: '--cross-file uwp-crossfile.meson -Dc_winlibs="windowsapp.lib"'
windows msbuild vs2019 amd64:
extends: '.build windows msbuild'
variables:
ARCH: 'amd64'
PLATFORM: 'x64'
# Linux Jobs
# Jobs with "libs" in the name force enable libraries.
# They are disabled in rest of the jobs.
# Linux Jobs.
#
# Jobs with "libs" in the name force-enable libraries.
# They are disabled for the remaining jobs.
linux autotools:
extends: '.build linux common'
script: |
@ -120,7 +175,8 @@ linux autotools libs clang:
linux meson:
extends: '.build linux common'
script: |
meson setup build -Dbrotli=disabled \
meson setup build ${MESON_ARGS} \
-Dbrotli=disabled \
-Dbzip2=disabled \
-Dharfbuzz=disabled \
-Dpng=disabled \
@ -132,7 +188,8 @@ linux meson:
linux meson libs:
extends: '.build linux common'
script: |
meson setup build -Dbrotli=enabled \
meson setup build ${MESON_ARGS} \
-Dbrotli=enabled \
-Dbzip2=enabled \
-Dharfbuzz=disabled \
-Dpng=disabled \
@ -163,6 +220,9 @@ linux cmake libs:
cmake --build build --target install
# MacOS jobs.
macos autotools:
extends: '.build macos common'
before_script:
@ -192,7 +252,7 @@ macos meson:
- pip3 install -U meson
- pip3 install --upgrade certifi
- pip3 install -U ninja
- meson setup build
- meson setup build ${MESON_ARGS}
- meson compile --verbose -C build
- sudo meson install -C build

View File

@ -1,7 +1,9 @@
Alexander Borsuk <me@alex.bio> <alexander.borsuk@qnective.com>
Behdad Esfahbod (بهداد اسفهبد) <behdad@behdad.org> <behdad.esfahbod@gmail.com>
Behdad Esfahbod (بهداد اسفهبد) <behdad@behdad.org> <behdad@google.com>
Behdad Esfahbod (بهداد اسفهبد) <behdad@behdad.org>
Ewald Hew (Hew Yih Shiuan 丘毅宣) <ewaldhew@gmail.com>
Moazin Khatti (موؤذن کھٹی) <moazinkhatri@gmail.com>
Priyesh Kumar (प्रियेश कुमार) <priyeshkkumar@gmail.com>
Alexei Podtelezhnikov (Алексей Подтележников) <apodtele@gmail.com>
Nikhil Ramakrishnan (निखिल रामकृष्णन) <ramakrishnan.nikhil@gmail.com>
@ -13,9 +15,11 @@ Suzuki, Toshiya (鈴木俊哉) <mpsuzuki@hiroshima-u.ac.jp> sssa <sssa@sssas-pow
Suzuki, Toshiya (鈴木俊哉) <mpsuzuki@hiroshima-u.ac.jp> suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
Bram Tassyns <bramt@enfocus.be> bram tassyns <BramT@enfocus.be>
Bram Tassyns <bramt@enfocus.be> <BramT@enfocus.com>
Anurag Thakur (अनुराग ठाकुर) <anuthadev@gmail.com>
David Turner <david@freetype.org> <david.turner.dev@gmail.com>
David Turner <david@freetype.org> <digit@google.com>
Anuj Verma (अनुज वर्मा) <anujv@iitbhilai.ac.in>
Ben Wagner <bungeman@gmail.com> Bungeman <bungeman@gmail.com>
Ben Wagner <bungeman@gmail.com>
Ben Wagner <bungeman@gmail.com> <bungeman@google.com>
Ben Wagner <bungeman@gmail.com> <bungeman@chromium.org>
Nikolaus Waxweiler <madigens@gmail.com> <nikolaus.waxweiler@daltonmaag.com>

View File

@ -1,6 +1,6 @@
# CMakeLists.txt
#
# Copyright (C) 2013-2021 by
# Copyright (C) 2013-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# Written originally by John Cary <cary@txcorp.com>
@ -61,6 +61,8 @@
#
# Some notes.
#
# - Say `cmake -LAH` to see all configuration options.
#
# - `cmake' creates configuration files in
#
# <build-directory>/include/freetype/config
@ -106,10 +108,9 @@
# (this is compatible with the same CMake variables in zlib's CMake
# support).
# FreeType explicitly marks the API to be exported and relies on the compiler
# to hide all other symbols. CMake supports a C_VISBILITY_PRESET property
# starting with 2.8.12.
cmake_minimum_required(VERSION 2.8.12)
# To minimize the number of cmake_policy() workarounds,
# CMake >= 3 is requested.
cmake_minimum_required(VERSION 3.0...3.5)
if (NOT CMAKE_VERSION VERSION_LESS 3.3)
# Allow symbol visibility settings also on static libraries. CMake < 3.3
@ -162,8 +163,8 @@ endif ()
project(freetype C)
set(VERSION_MAJOR "2")
set(VERSION_MINOR "11")
set(VERSION_PATCH "1")
set(VERSION_MINOR "13")
set(VERSION_PATCH "2")
# Generate LIBRARY_VERSION and LIBRARY_SOVERSION.
set(LIBTOOL_REGEX "version_info='([0-9]+):([0-9]+):([0-9]+)'")
@ -216,6 +217,8 @@ cmake_dependent_option(FT_REQUIRE_BROTLI
"Require support of compressed WOFF2 fonts." OFF
"NOT FT_DISABLE_BROTLI" OFF)
option(FT_ENABLE_ERROR_STRINGS
"Enable support for meaningful error descriptions." OFF)
# Disallow in-source builds
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
@ -239,12 +242,14 @@ if (BUILD_FRAMEWORK)
message(FATAL_ERROR
"You should use Xcode generator with BUILD_FRAMEWORK enabled")
endif ()
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
set(BUILD_SHARED_LIBS ON)
endif ()
# Find dependencies
include(FindPkgConfig)
if (NOT FT_DISABLE_HARFBUZZ)
set(HARFBUZZ_MIN_VERSION "2.0.0")
if (FT_REQUIRE_HARFBUZZ)
@ -271,11 +276,16 @@ if (NOT FT_DISABLE_ZLIB)
endif ()
if (NOT FT_DISABLE_BZIP2)
# Genuine BZip2 does not provide bzip2.pc, but some platforms have it.
# For better dependency in freetype2.pc, bzip2.pc is searched
# regardless of the availability of libbz2. If bzip2.pc is found,
# Requires.private is used instead of Libs.private.
if (FT_REQUIRE_BZIP2)
find_package(BZip2 REQUIRED)
else ()
find_package(BZip2)
endif ()
pkg_check_modules(PC_BZIP2 bzip2)
endif ()
if (NOT FT_DISABLE_BROTLI)
@ -287,7 +297,7 @@ if (NOT FT_DISABLE_BROTLI)
endif ()
# Create the configuration file
if (UNIX)
if (UNIX AND NOT WIN32)
check_include_file("unistd.h" HAVE_UNISTD_H)
check_include_file("fcntl.h" HAVE_FCNTL_H)
@ -348,6 +358,12 @@ if (BROTLIDEC_FOUND)
FTOPTION_H "${FTOPTION_H}")
endif ()
if (FT_ENABLE_ERROR_STRINGS)
string(REGEX REPLACE
"/\\* +(#define +FT_CONFIG_OPTION_ERROR_STRINGS) +\\*/" "\\1"
FTOPTION_H "${FTOPTION_H}")
endif ()
set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
if (EXISTS "${FTOPTION_H_NAME}")
file(READ "${FTOPTION_H_NAME}" ORIGINAL_FTOPTION_H)
@ -400,16 +416,17 @@ set(BASE_SRCS
src/sdf/sdf.c
src/sfnt/sfnt.c
src/smooth/smooth.c
src/svg/svg.c
src/truetype/truetype.c
src/type1/type1.c
src/type42/type42.c
src/winfonts/winfnt.c
)
if (UNIX)
list(APPEND BASE_SRCS "builds/unix/ftsystem.c")
elseif (WIN32)
if (WIN32)
list(APPEND BASE_SRCS "builds/windows/ftsystem.c")
elseif (UNIX)
list(APPEND BASE_SRCS "builds/unix/ftsystem.c")
else ()
list(APPEND BASE_SRCS "src/base/ftsystem.c")
endif ()
@ -485,42 +502,55 @@ if (BUILD_FRAMEWORK)
)
set_target_properties(freetype PROPERTIES
FRAMEWORK TRUE
MACOSX_FRAMEWORK_INFO_PLIST builds/mac/freetype-Info.plist
MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/builds/mac/freetype-Info.plist
PUBLIC_HEADER "${PUBLIC_HEADERS}"
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
)
endif ()
# 'freetype-interface' is an interface library, to be accessed with
# `EXPORT_NAME Freetype::Freetype`. This is the target name provided by
# CMake's `FindFreetype.cmake`, so we provide it for compatibility.
add_library(freetype-interface INTERFACE)
set_target_properties(freetype-interface PROPERTIES
EXPORT_NAME Freetype::Freetype
INTERFACE_LINK_LIBRARIES freetype)
set(PKG_CONFIG_REQUIRED_PRIVATE "")
set(PKG_CONFIG_LIBS_PRIVATE "")
set(PKGCONFIG_REQUIRES "")
set(PKGCONFIG_REQUIRES_PRIVATE "")
set(PKGCONFIG_LIBS "-L\${libdir} -lfreetype")
set(PKGCONFIG_LIBS_PRIVATE "")
if (ZLIB_FOUND)
target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "zlib")
list(APPEND PKGCONFIG_REQUIRES_PRIVATE "zlib")
endif ()
if (BZIP2_FOUND)
target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
list(APPEND PKG_CONFIG_LIBS_PRIVATE "-lbz2")
if (PC_BZIP2_FOUND)
list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2")
else ()
list(APPEND PKGCONFIG_LIBS_PRIVATE "-lbz2")
endif ()
endif ()
if (PNG_FOUND)
target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libpng")
list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libpng")
endif ()
if (HarfBuzz_FOUND)
target_link_libraries(freetype PRIVATE ${HarfBuzz_LIBRARY})
target_include_directories(freetype PRIVATE ${HarfBuzz_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
list(APPEND PKGCONFIG_REQUIRES_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
endif ()
if (BROTLIDEC_FOUND)
target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES})
target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS})
target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libbrotlidec")
list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libbrotlidec")
endif ()
@ -547,7 +577,7 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
# Generate the pkg-config file
file(READ "${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in" FREETYPE2_PC_IN)
string(REPLACE ";" ", " PKG_CONFIG_REQUIRED_PRIVATE "${PKG_CONFIG_REQUIRED_PRIVATE}")
string(REPLACE ";" ", " PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE}")
string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX}
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
@ -559,10 +589,26 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%ft_version%" "${LIBTOOL_CURRENT}.${LIBTOOL_REVISION}.${LIBTOOL_AGE}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%REQUIRES_PRIVATE%" "${PKG_CONFIG_REQUIRED_PRIVATE}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%LIBS_PRIVATE%" "${PKG_CONFIG_LIBS_PRIVATE}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
if (BUILD_SHARED_LIBS)
string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" "${PKGCONFIG_REQUIRES_PRIVATE}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" "${PKGCONFIG_LIBS_PRIVATE}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
else ()
string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES} ${PKGCONFIG_REQUIRES_PRIVATE}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" ""
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS} ${PKGCONFIG_LIBS_PRIVATE}"
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" ""
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
endif ()
set(FREETYPE2_PC_IN_NAME "${PROJECT_BINARY_DIR}/freetype2.pc")
if (EXISTS "${FREETYPE2_PC_IN_NAME}")
@ -586,7 +632,7 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
COMPATIBILITY SameMajorVersion)
install(
TARGETS freetype
TARGETS freetype freetype-interface
EXPORT freetype-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@ -29,12 +29,16 @@ The contributed BDF and PCF drivers come with a license similar to
that of the X Window System. It is compatible to the above two
licenses (see files `src/bdf/README` and `src/pcf/README`). The same
holds for the source code files `src/base/fthash.c` and
`include/freetype/internal/fthash.h`; they wer part of the BDF driver
`include/freetype/internal/fthash.h`; they were part of the BDF driver
in earlier FreeType versions.
The gzip module uses the zlib license (see `src/gzip/zlib.h`) which
too is compatible to the above two licenses.
The files `src/autofit/ft-hb.c` and `src/autofit/ft-hb.h` contain code
taken almost verbatim from the HarfBuzz file `hb-ft.cc`, which uses
the 'Old MIT' license, compatible to the above two licenses.
The MD5 checksum support (only used for debugging in development
builds) is in the public domain.

2
MSBuild.rsp Normal file
View File

@ -0,0 +1,2 @@
#/p:WindowsTargetPlatformVersion=10.0.16299.0
/p:Configuration="Release"

View File

@ -1,6 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio Express 2012 for Windows Desktop
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetype", "freetype.vcxproj", "{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}"
#
# You can build FreeType with MSBuild as follows
#
# MSBuild.exe -t:Rebuild
# -p:Configuration=Debug
# -p:Platform=x64
# -p:UserDefines=FT_DEBUG_LOGGING
# MSBuild.sln
#
# or with different appropriate switches. The library file
# freetype.dll and/or freetype.lib should appear in the objs/
# folder. A copy should be sent to ../freetype-demos/bin/
# to be used with the demo programs.
#
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetype", "builds\windows\vc2010\freetype.vcxproj", "{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

14
README
View File

@ -1,4 +1,4 @@
FreeType 2.11.1
FreeType 2.13.2
===============
Homepage: https://www.freetype.org
@ -16,7 +16,9 @@ Read the files `docs/INSTALL*` for installation instructions; see the
file `docs/LICENSE.TXT` for the available licenses.
For using FreeType's git repository instead of a distribution bundle,
please read file `README.git`.
please read file `README.git`. Note that you have to actually clone
the repository; using a snapshot will not work (in other words, don't
use gitlab's 'Download' button).
The FreeType 2 API reference is located in directory `docs/reference`;
use the file `index.html` as the top entry point. [Please note that
@ -30,9 +32,9 @@ sites. Go to
and download one of the following files.
freetype-doc-2.11.1.tar.xz
freetype-doc-2.11.1.tar.gz
ftdoc2111.zip
freetype-doc-2.13.2.tar.xz
freetype-doc-2.13.2.tar.gz
ftdoc2132.zip
To view the documentation online, go to
@ -92,7 +94,7 @@ Enjoy!
----------------------------------------------------------------------
Copyright (C) 2006-2021 by
Copyright (C) 2006-2024 by
David Turner, Robert Wilhelm, and Werner Lemberg.
This file is part of the FreeType project, and may only be used,

View File

@ -89,7 +89,7 @@ address:
----------------------------------------------------------------------
Copyright (C) 2005-2021 by
Copyright (C) 2005-2024 by
David Turner, Robert Wilhelm, and Werner Lemberg.
This file is part of the FreeType project, and may only be used,

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (C) 2005-2021 by
# Copyright (C) 2005-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -182,7 +182,7 @@ copy_submodule_files ()
cp $DLG_SRC_DIR/* src/dlg
}
if test -d ".git"; then
if test -e ".git"; then
DLG_INC_DIR=subprojects/dlg/include/dlg
DLG_SRC_DIR=subprojects/dlg/src/dlg
@ -190,8 +190,7 @@ if test -d ".git"; then
:
else
echo "Checking out submodule in \`subprojects/dlg':"
git submodule init
git submodule update
git submodule update --init
fi
copy_submodule_files

View File

@ -1,7 +1,7 @@
README for the builds/amiga subdirectory.
Copyright (C) 2005-2021 by
Copyright (C) 2005-2024 by
Werner Lemberg and Detlef Würkner.
This file is part of the FreeType project, and may only be used, modified,

View File

@ -4,7 +4,7 @@
/* */
/* Amiga-specific configuration file (specification only). */
/* */
/* Copyright (C) 2005-2021 by */
/* Copyright (C) 2005-2024 by */
/* Werner Lemberg and Detlef Würkner. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -4,7 +4,7 @@
/* */
/* Amiga-specific FreeType module selection. */
/* */
/* Copyright (C) 2005-2021 by */
/* Copyright (C) 2005-2024 by */
/* Werner Lemberg and Detlef Würkner. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -5,7 +5,7 @@
#
# Copyright (C) 2005-2021 by
# Copyright (C) 2005-2024 by
# Werner Lemberg and Detlef Würkner.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -4,7 +4,7 @@
#
# Copyright (C) 2005-2021 by
# Copyright (C) 2005-2024 by
# Werner Lemberg and Detlef Würkner.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 2005-2021 by
# Copyright (C) 2005-2024 by
# Werner Lemberg and Detlef Würkner.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -4,7 +4,7 @@
*
* Debugging and logging component for amiga (body).
*
* Copyright (C) 1996-2021 by
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, Werner Lemberg, and Detlef Wuerkner.
*
* This file is part of the FreeType project, and may only be used,

View File

@ -4,7 +4,7 @@
/* */
/* Amiga-specific FreeType low-level system interface (body). */
/* */
/* Copyright (C) 1996-2021 by */
/* Copyright (C) 1996-2024 by */
/* David Turner, Robert Wilhelm, Werner Lemberg and Detlef Würkner. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -5,7 +5,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -2,7 +2,7 @@
# FreeType 2 configuration rules for a BeOS system
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -1,6 +1,6 @@
# FindBrotliDec.cmake
#
# Copyright (C) 2019-2021 by
# Copyright (C) 2019-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# Written by Werner Lemberg <wl@gnu.org>

View File

@ -1,6 +1,6 @@
# iOS.cmake
#
# Copyright (C) 2014-2021 by
# Copyright (C) 2014-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# Written by David Wimsey <david@wimsey.us>

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
# Copyright (C) 2015-2021 by
# Copyright (C) 2015-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 2003-2021 by
# Copyright (C) 2003-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 2003-2021 by
# Copyright (C) 2003-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 2003-2021 by
# Copyright (C) 2003-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 2005-2021 by
# Copyright (C) 2005-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -299,7 +299,7 @@ refdoc:
$(PUBLIC_DIR)/config/*.h \
$(PUBLIC_DIR)/cache/*.h
@echo Building static site...
cd $(DOC_DIR) && mkdocs build
cd $(DOC_DIR) && $(PYTHON) -m mkdocs build
@echo Done.
# Variables for running `refdoc' with Python's `virtualenv'. The

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -200,14 +200,6 @@ environment by Metrowerks. GCC for MPW and Symantec
behaviours are not tested at all. Building ftdemos
for classic MacOS and working test is required.
4-3. Porting Jam onto MPW
-------------------------
FreeType uses Jam (and FT-Jam) for unified cross-
platform building tool. At present, Jam is not ported
to MPW. To update classic MacOS support easily,
building by Jam is expected on MPW.
APPENDIX I
----------

View File

@ -9,7 +9,7 @@
<string>English</string>
<key>CFBundleExecutable</key>
<string>FreeType</string>
<string>freetype</string>
<key>CFBundleGetInfoString</key>
<string>FreeType ${PROJECT_VERSION}</string>

View File

@ -5,7 +5,7 @@
/* Mac FOND support. Written by just@letterror.com. */
/* Heavily Fixed by mpsuzuki, George Williams and Sean McBride */
/* */
/* Copyright (C) 1996-2021 by */
/* Copyright (C) 1996-2024 by */
/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -97,7 +97,7 @@
#define FT_DEPRECATED_ATTRIBUTE
#include FT_MAC_H
#include <freetype/ftmac.h>
/* undefine blocking-macros in ftmac.h */
#undef FT_GetFile_From_Mac_Name

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2020-2021 by
# Copyright (C) 2020-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2020-2021 by
# Copyright (C) 2020-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2020-2021 by
# Copyright (C) 2020-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2020-2021 by
# Copyright (C) 2020-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -84,18 +84,25 @@ def generate_ftmodule(lists):
)
for module in lists["RASTER_MODULES"]:
name = {
"raster": "ft_raster1",
"smooth": "ft_smooth",
names = {
"raster": ("ft_raster1",),
"smooth": ("ft_smooth",),
"svg": ("ft_svg",),
"sdf": ("ft_sdf", "ft_bitmap_sdf"),
}.get(module)
result += (
"FT_USE_MODULE( FT_Renderer_Class, %s_renderer_class )\n" % name
)
for name in names:
result += (
"FT_USE_MODULE( FT_Renderer_Class, %s_renderer_class )\n" % name
)
for module in lists["AUX_MODULES"]:
if module in ("psaux", "psnames", "otvalid", "gxvalid"):
name = {
"gxvalid": "gxv",
"otvalid": "otv",
}.get(module, module)
result += (
"FT_USE_MODULE( FT_Module_Class, %s_module_class )\n" % module
"FT_USE_MODULE( FT_Module_Class, %s_module_class )\n" % name
)
result += "/* EOF */\n"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2020-2021 by
# Copyright (C) 2020-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -5,7 +5,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -2,7 +2,7 @@
// FreeType 2 project for the symbian platform
//
// Copyright (C) 2008-2021 by
// Copyright (C) 2008-2024 by
// David Turner, Robert Wilhelm, and Werner Lemberg.
//
// This file is part of the FreeType project, and may only be used, modified,

View File

@ -2,7 +2,7 @@
// FreeType 2 makefile for the symbian platform
//
// Copyright (C) 2008-2021 by
// Copyright (C) 2008-2024 by
// David Turner, Robert Wilhelm, and Werner Lemberg.
//
// This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -139,12 +139,12 @@ ifdef check_platform
ifneq ($(is_unix),)
distclean:
$(RM) builds/unix/config.cache
$(RM) builds/unix/config.log
$(RM) builds/unix/config.status
$(RM) builds/unix/unix-def.mk
$(RM) builds/unix/unix-cc.mk
$(RM) builds/unix/freetype2.pc
$(RM) $(TOP_DIR)/builds/unix/config.cache
$(RM) $(TOP_DIR)/builds/unix/config.log
$(RM) $(TOP_DIR)/builds/unix/config.status
$(RM) $(TOP_DIR)/builds/unix/unix-def.mk
$(RM) $(TOP_DIR)/builds/unix/unix-cc.mk
$(RM) $(TOP_DIR)/builds/unix/freetype2.pc
$(RM) nul
endif # test is_unix
@ -170,17 +170,16 @@ endif # test check_platform
check_out_submodule:
$(info Checking out submodule in `subprojects/dlg')
git submodule init
git submodule update
git -C $(TOP_DIR) submodule update --init
copy_submodule:
$(info Copying files from `subprojects/dlg' to `src/dlg' and `include/dlg')
ifeq ($(wildcard include/dlg),)
mkdir $(subst /,$(SEP),include/dlg)
ifeq ($(wildcard $(TOP_DIR)/include/dlg),)
mkdir $(subst /,$(SEP),$(TOP_DIR)/include/dlg)
endif
$(COPY) $(subst /,$(SEP),subprojects/dlg/include/dlg/output.h include/dlg)
$(COPY) $(subst /,$(SEP),subprojects/dlg/include/dlg/dlg.h include/dlg)
$(COPY) $(subst /,$(SEP),subprojects/dlg/src/dlg/dlg.c src/dlg)
$(COPY) $(subst /,$(SEP),$(TOP_DIR)/subprojects/dlg/include/dlg/output.h $(TOP_DIR)/include/dlg)
$(COPY) $(subst /,$(SEP),$(TOP_DIR)/subprojects/dlg/include/dlg/dlg.h $(TOP_DIR)/include/dlg)
$(COPY) $(subst /,$(SEP),$(TOP_DIR)/subprojects/dlg/src/dlg/dlg.c $(TOP_DIR)/src/dlg)
# We always need the list of modules in ftmodule.h.
@ -198,27 +197,22 @@ modules:
include $(TOP_DIR)/builds/modules.mk
# get FreeType version string, using a
# poor man's `sed' emulation with make's built-in string functions
# get FreeType version string using built-in string functions
#
hash := \#
work := $(strip $(shell $(CAT) \
$(subst /,$(SEP),$(TOP_DIR)/include/freetype/freetype.h)))
work := $(subst |,x,$(work))
work := $(subst $(space),|,$(work))
work := $(subst \#define|FREETYPE_MAJOR|,$(space),$(work))
work := $(word 2,$(work))
major := $(subst |,$(space),$(work))
major := $(firstword $(major))
work := $(subst \#define|FREETYPE_MINOR|,$(space),$(work))
work := $(word 2,$(work))
minor := $(subst |,$(space),$(work))
minor := $(firstword $(minor))
work := $(subst $(hash)define$(space)FREETYPE_MAJOR$(space),MAjOR=,$(work))
work := $(subst $(hash)define$(space)FREETYPE_MINOR$(space),MInOR=,$(work))
work := $(subst $(hash)define$(space)FREETYPE_PATCH$(space),PAtCH=,$(work))
work := $(subst \#define|FREETYPE_PATCH|,$(space),$(work))
work := $(word 2,$(work))
patch := $(subst |,$(space),$(work))
patch := $(firstword $(patch))
major := $(subst MAjOR=,,$(filter MAjOR=%,$(work)))
minor := $(subst MInOR=,,$(filter MInOR=%,$(work)))
patch := $(subst PAtCH=,,$(filter PAtCH=%,$(work)))
work :=
# ifneq ($(findstring x0x,x$(patch)x),)
# version := $(major).$(minor)
@ -294,30 +288,29 @@ CHANGELOG_SCRIPT = ~/git/config/gitlog-to-changelog
do-dist: distclean refdoc
@# Without removing the files, `autoconf' and friends follow links.
rm -f builds/unix/aclocal.m4
rm -f builds/unix/configure.ac
rm -f builds/unix/configure
rm -f $(TOP_DIR)/builds/unix/aclocal.m4
rm -f $(TOP_DIR)/builds/unix/configure.ac
rm -f $(TOP_DIR)/builds/unix/configure
sh autogen.sh
rm -rf builds/unix/autom4te.cache
rm -rf $(TOP_DIR)/builds/unix/autom4te.cache
cp $(CONFIG_GUESS) builds/unix
cp $(CONFIG_SUB) builds/unix
cp $(CONFIG_GUESS) $(TOP_DIR)/builds/unix
cp $(CONFIG_SUB) $(TOP_DIR)/builds/unix
@# Generate `ChangeLog' file with commits since previous release.
@# Generate `ChangeLog' file with commits since release 2.11.0
@# (when we stopped creating this file manually).
$(CHANGELOG_SCRIPT) \
--format='%B%n' \
--no-cluster \
-- `git describe --tags \
--abbrev=0 \
$(version_tag)^`..$(version_tag) \
-- VER-2-11-0..$(version_tag) \
> ChangeLog
@# Remove intermediate files created by the `refdoc' target.
rm -rf docs/markdown
rm -f docs/mkdocs.yml
rm -rf $(TOP_DIR)/docs/markdown
rm -f $(TOP_DIR)/docs/mkdocs.yml
@# Remove more stuff related to git.
rm -rf subprojects
rm -rf $(TOP_DIR)/subprojects/dlg
# EOF

View File

@ -2,7 +2,7 @@
#
# Process this file with autoconf to produce a configure script.
#
# Copyright (C) 2001-2021 by
# Copyright (C) 2001-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -17,7 +17,7 @@ AC_CONFIG_SRCDIR([ftconfig.h.in])
# Don't forget to update `docs/VERSIONS.TXT'!
version_info='24:1:18'
version_info='26:1:20'
AC_SUBST([version_info])
ft_version=`echo $version_info | tr : .`
AC_SUBST([ft_version])
@ -50,7 +50,7 @@ if test ${cross_compiling} = yes; then
AC_MSG_CHECKING([for suffix of native executables])
rm -f a.* b.* a_out.exe conftest.*
echo > conftest.c "int main() { return 0;}"
echo > conftest.c "int main(void) { return 0;}"
${CC_BUILD} conftest.c || AC_MSG_ERROR([native C compiler is not working])
rm -f conftest.c
if test -x a.out -o -x b.out -o -x conftest; then
@ -163,9 +163,6 @@ fi
AC_SUBST([FTSYS_SRC])
AC_CHECK_FUNCS([memcpy memmove])
# get compiler flags right
#
# We try to make the compiler work for C99-strict source. Even if the
@ -317,6 +314,12 @@ if test x"$with_zlib" = xyes -a "$have_zlib" = no; then
AC_MSG_ERROR([external zlib support requested but library not found])
fi
SYSTEM_ZLIB=
if test "$have_zlib" != no; then
SYSTEM_ZLIB=yes
fi
AC_SUBST([SYSTEM_ZLIB])
# check for system libbz2
@ -400,16 +403,12 @@ if test x"$with_png" = xyes -o x"$with_png" = xauto; then
have_libpng="yes (LIBPNG_CFLAGS and LIBPNG_LIBS)"
else
# fall back to config script
AC_MSG_CHECKING([for libpng-config])
if which libpng-config > /dev/null 2>&1; then
AC_CHECK_PROG(have_libpng, [libpng-config], [yes (libpng-config)], [no])
if test "$have_libpng" != no; then
LIBPNG_CFLAGS=`libpng-config --cflags`
LIBPNG_LIBS=`libpng-config --ldflags`
libpng_libspriv=`libpng-config --static --ldflags`
libpng_libsstaticconf="$libpng_libspriv"
have_libpng="yes (libpng-config)"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
fi
@ -508,19 +507,48 @@ if test x"$with_brotli" = xyes -a "$have_brotli" = no; then
fi
# check for librt
# Checks for the demo programs.
#
# We need `clock_gettime' for the `ftbench' demo program.
#
# The code is modeled after gnulib's file `clock_time.m4', ignoring
# very old Solaris systems.
# FreeType doesn't need this. However, since the demo program repository
# doesn't come with a `configure` script of its own, we integrate the tests
# here for simplicity.
# We need `clock_gettime` from 'librt' for the `ftbench` demo program.
#
# The code is modeled after gnulib's file `clock_time.m4`, ignoring
# very old Solaris systems.
LIB_CLOCK_GETTIME=
AC_SEARCH_LIBS([clock_gettime],
[rt],
[test "$ac_cv_search_clock_gettime" = "none required" \
|| LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
AC_SUBST([LIB_CLOCK_GETTIME])
FT_DEMO_CFLAGS=""
FT_DEMO_LDFLAGS="$LIB_CLOCK_GETTIME"
# 'librsvg' is needed to demonstrate SVG support.
AC_ARG_WITH([librsvg],
[AS_HELP_STRING([--with-librsvg=@<:@yes|no|auto@:>@],
[support OpenType SVG fonts in FreeType demo programs @<:@default=auto@:>@])],
[], [with_librsvg=auto])
have_librsvg=no
if test x"$with_librsvg" = xyes -o x"$with_librsvg" = xauto; then
PKG_CHECK_MODULES([LIBRSVG], [librsvg-2.0 >= 2.46.0],
[have_librsvg="yes (pkg-config)"], [:])
if test "$have_librsvg" != no; then
FT_DEMO_CFLAGS="$FT_DEMO_CFLAGS $LIBRSVG_CFLAGS -DHAVE_LIBRSVG"
FT_DEMO_LDFLAGS="$FT_DEMO_LDFLAGS $LIBRSVG_LIBS"
fi
fi
if test x"$with_librsvg" = xyes -a "$have_librsvg" = no; then
AC_MSG_ERROR([librsvg support requested but library not found])
fi
AC_SUBST([FT_DEMO_CFLAGS])
AC_SUBST([FT_DEMO_LDFLAGS])
# Some options handling SDKs/archs in CFLAGS should be copied
@ -938,14 +966,14 @@ esac
AX_PTHREAD([have_pthread=yes], [have_pthread=no])
# Check for Python and docwriter
PYTHON_MIN_VERSION=3.5
have_py3=no
have_docwriter=no
PIP=pip
AC_CHECK_PROGS([PYTHON], [python3 python], [missing])
if test "x$PYTHON" != "xmissing"; then
AX_PROG_PYTHON_VERSION([3.5], [have_py3=yes], [])
AX_PROG_PYTHON_VERSION([$PYTHON_MIN_VERSION], [have_py3=yes], [])
if test "x$have_py3" = "xyes"; then
PIP="$PYTHON -m $PIP"
@ -962,32 +990,32 @@ fi
# entries in Requires.private are separated by commas
REQUIRES_PRIVATE="$zlib_reqpriv, \
$bzip2_reqpriv, \
$libpng_reqpriv, \
$harfbuzz_reqpriv, \
$brotli_reqpriv"
PKGCONFIG_REQUIRES_PRIVATE="$zlib_reqpriv, \
$bzip2_reqpriv, \
$libpng_reqpriv, \
$harfbuzz_reqpriv, \
$brotli_reqpriv"
# beautify
REQUIRES_PRIVATE=`echo "$REQUIRES_PRIVATE" \
| sed -e 's/^ *//' \
-e 's/ *$//' \
-e 's/, */,/g' \
-e 's/,,*/,/g' \
-e 's/^,*//' \
-e 's/,*$//' \
-e 's/,/, /g'`
PKGCONFIG_REQUIRES_PRIVATE=`echo "$PKGCONFIG_REQUIRES_PRIVATE" \
| sed -e 's/^ *//' \
-e 's/ *$//' \
-e 's/, */,/g' \
-e 's/,,*/,/g' \
-e 's/^,*//' \
-e 's/,*$//' \
-e 's/,/, /g'`
LIBS_PRIVATE="$zlib_libspriv \
$bzip2_libspriv \
$libpng_libspriv \
$harfbuzz_libspriv \
$brotli_libspriv \
$ft2_extra_libs"
PKGCONFIG_LIBS_PRIVATE="$zlib_libspriv \
$bzip2_libspriv \
$libpng_libspriv \
$harfbuzz_libspriv \
$brotli_libspriv \
$ft2_extra_libs"
# beautify
LIBS_PRIVATE=`echo "$LIBS_PRIVATE" \
| sed -e 's/^ *//' \
-e 's/ *$//' \
-e 's/ */ /g'`
PKGCONFIG_LIBS_PRIVATE=`echo "$PKGCONFIG_LIBS_PRIVATE" \
| sed -e 's/^ *//' \
-e 's/ *$//' \
-e 's/ */ /g'`
LIBSSTATIC_CONFIG="-lfreetype \
$zlib_libsstaticconf \
@ -1005,10 +1033,28 @@ LIBSSTATIC_CONFIG=`echo "$LIBSSTATIC_CONFIG" \
-e 's/ *$//' \
-e 's/ */ /g'`
# If FreeType gets installed with `--disable-shared', don't use
# 'private' fields. `pkg-config' only looks into `.pc' files and is
# completely agnostic to whether shared libraries are actually present
# or not. As a consequence, the user had to specify `--static' while
# calling `pkg-config', which configure scripts are normally not
# prepared for.
PKGCONFIG_REQUIRES=
PKGCONFIG_LIBS='-L${libdir} -lfreetype'
if test $enable_shared = "no"; then
PKGCONFIG_REQUIRES="$PKGCONFIG_REQUIRES $PKGCONFIG_REQUIRES_PRIVATE"
PKGCONFIG_REQUIRES_PRIVATE=
PKGCONFIG_LIBS="$PKGCONFIG_LIBS $PKGCONFIG_LIBS_PRIVATE"
PKGCONFIG_LIBS_PRIVATE=
fi
AC_SUBST([ftmac_c])
AC_SUBST([REQUIRES_PRIVATE])
AC_SUBST([LIBS_PRIVATE])
AC_SUBST([PKGCONFIG_REQUIRES])
AC_SUBST([PKGCONFIG_LIBS])
AC_SUBST([PKGCONFIG_REQUIRES_PRIVATE])
AC_SUBST([PKGCONFIG_LIBS_PRIVATE])
AC_SUBST([LIBSSTATIC_CONFIG])
AC_SUBST([hardcode_libdir_flag_spec])
@ -1116,7 +1162,7 @@ if test $have_docwriter = no; then
`make refdoc' will fail since pip package `docwriter' is not installed.
To install, run `$PIP install docwriter', or to use a Python
virtual environment, run `make refdoc-venv' (requires pip package
`virtualenv'). These operations require Python >= 3.5.
`virtualenv'). These operations require Python >= $PYTHON_MIN_VERSION.
])
fi

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -1,6 +1,6 @@
#! /bin/sh
#
# Copyright (C) 2000-2021 by
# Copyright (C) 2000-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -7,8 +7,8 @@ Name: FreeType 2
URL: https://freetype.org
Description: A free, high-quality, and portable font engine.
Version: %ft_version%
Requires:
Requires.private: %REQUIRES_PRIVATE%
Libs: -L${libdir} -lfreetype
Libs.private: %LIBS_PRIVATE%
Requires: %PKGCONFIG_REQUIRES%
Requires.private: %PKGCONFIG_REQUIRES_PRIVATE%
Libs: %PKGCONFIG_LIBS%
Libs.private: %PKGCONFIG_LIBS_PRIVATE%
Cflags: -I${includedir}/freetype2

View File

@ -1,7 +1,7 @@
# Configure paths for FreeType2
# Marcelo Magallon 2001-10-26, based on `gtk.m4` by Owen Taylor
#
# Copyright (C) 2001-2021 by
# Copyright (C) 2001-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -15,7 +15,7 @@
# generated by Autoconf, under the same distribution terms as the rest of
# that program.
#
# serial 6
# serial 7
# AC_CHECK_FT2([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
# Test for FreeType 2, and define FT2_CFLAGS and FT2_LIBS.
@ -121,7 +121,7 @@ AC_DEFUN([AC_CHECK_FT2],
#include <stdlib.h>
int
main()
main(void)
{
FT_Library library;
FT_Error error;

View File

@ -1,6 +1,6 @@
## FreeType specific autoconf tests
#
# Copyright (C) 2002-2021 by
# Copyright (C) 2002-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -4,7 +4,7 @@
*
* UNIX-specific configuration file (specification only).
*
* Copyright (C) 1996-2021 by
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,

View File

@ -4,7 +4,7 @@
*
* Unix-specific FreeType low-level system interface (body).
*
* Copyright (C) 1996-2021 by
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -2,7 +2,7 @@
# FreeType 2 template for Unix-specific compiler definitions
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -106,9 +106,7 @@ endif
# Linker flags.
#
LDFLAGS := @LDFLAGS@
LIB_CLOCK_GETTIME := @LIB_CLOCK_GETTIME@ # for ftbench
LDFLAGS := @LDFLAGS@
# export symbols
#
@ -118,11 +116,15 @@ EXPORTS_LIST := $(OBJ_DIR)/ftexport.sym
CCexe := $(CCraw_build) # used to compile `apinames' only
# Library linking
# Library linking.
#
LINK_LIBRARY = $(LIBTOOL) --mode=link $(CCraw) -o $@ $(OBJECTS_LIST) \
-rpath $(libdir) -version-info $(version_info) \
$(LDFLAGS) -no-undefined \
-export-symbols $(EXPORTS_LIST)
# For the demo programs.
FT_DEMO_CFLAGS := @FT_DEMO_CFLAGS@
FT_DEMO_LDFLAGS := @FT_DEMO_LDFLAGS@
# EOF

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -68,12 +68,14 @@ version_info := @version_info@
# Variables needed for `freetype-config' and `freetype.pc'.
#
PKG_CONFIG := @PKG_CONFIG@
REQUIRES_PRIVATE := @REQUIRES_PRIVATE@
LIBS_PRIVATE := @LIBS_PRIVATE@
LIBSSTATIC_CONFIG := @LIBSSTATIC_CONFIG@
build_libtool_libs := @build_libtool_libs@
ft_version := @ft_version@
PKG_CONFIG := @PKG_CONFIG@
PKGCONFIG_REQUIRES := @PKGCONFIG_REQUIRES@
PKGCONFIG_REQUIRES_PRIVATE := @PKGCONFIG_REQUIRES_PRIVATE@
PKGCONFIG_LIBS := @PKGCONFIG_LIBS@
PKGCONFIG_LIBS_PRIVATE := @PKGCONFIG_LIBS_PRIVATE@
LIBSSTATIC_CONFIG := @LIBSSTATIC_CONFIG@
build_libtool_libs := @build_libtool_libs@
ft_version := @ft_version@
# The directory where all library files are placed.
#
@ -137,15 +139,17 @@ prefix_x := $(subst $(space),\\$(space),$(prefix))
$(OBJ_BUILD)/freetype2.pc: $(TOP_DIR)/builds/unix/freetype2.in
rm -f $@ $@.tmp
sed -e 's|%REQUIRES_PRIVATE%|$(REQUIRES_PRIVATE)|' \
-e 's|%LIBS_PRIVATE%|$(LIBS_PRIVATE)|' \
-e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
-e 's|%exec_prefix%|$(exec_prefix_x)|' \
-e 's|%ft_version%|$(ft_version)|' \
-e 's|%includedir%|$(includedir_x)|' \
-e 's|%libdir%|$(libdir_x)|' \
-e 's|%prefix%|$(prefix_x)|' \
$< \
sed -e 's|%PKGCONFIG_REQUIRES%|$(PKGCONFIG_REQUIRES)|' \
-e 's|%PKGCONFIG_REQUIRES_PRIVATE%|$(PKGCONFIG_REQUIRES_PRIVATE)|' \
-e 's|%PKGCONFIG_LIBS%|$(PKGCONFIG_LIBS)|' \
-e 's|%PKGCONFIG_LIBS_PRIVATE%|$(PKGCONFIG_LIBS_PRIVATE)|' \
-e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
-e 's|%exec_prefix%|$(exec_prefix_x)|' \
-e 's|%ft_version%|$(ft_version)|' \
-e 's|%includedir%|$(includedir_x)|' \
-e 's|%libdir%|$(libdir_x)|' \
-e 's|%prefix%|$(prefix_x)|' \
$< \
> $@.tmp
chmod a-w $@.tmp
mv $@.tmp $@

View File

@ -6,7 +6,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -6,7 +6,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -4,7 +4,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,2 @@
src/tools/apinames -wV include/freetype/*.h > freetype_vms0.opt
mv freetype_vms0.opt freetype_vms.opt

View File

@ -4,7 +4,7 @@
*
* VMS-specific configuration file (specification only).
*
* Copyright (C) 1996-2021 by
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,

View File

@ -4,7 +4,7 @@
/* */
/* VMS-specific FreeType low-level system interface (body). */
/* */
/* Copyright (C) 1996-2021 by */
/* Copyright (C) 1996-2024 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -1,28 +0,0 @@
!
! This is a simple driver file with information used by make.com to
! check if external libraries (like t1lib and freetype) are available on
! the system.
!
! Layout of the file:
!
! - Lines starting with ! are treated as comments
! - Elements in a data line are separated by # signs
! - The elements need to be listed in the following order
! 1.) Name of the Library
! 2.) Location where the object library can be found
! 3.) Location where the include files for the library can be found
! 4.) Include file used to verify library location
! 5.) CPP define to pass to the build to indicate availability of
! the library
!
! Example: The following lines show how definitions
! might look like. They are site specific and the locations of the
! library and include files need almost certainly to be changed.
!
! Location: All of the libaries can be found at the following addresses
!
! ZLIB: http://www.decus.de:8080/www/vms/sw/zlib.htmlx
!
BZ2LIB # sys$library:libbz2.olb # decc$user_include: # bzlib.h # FT_CONFIG_OPTION_SYSTEM_ZLIB
PNGLIB # sys$library:libpng.olb # sys$library: # png.h # FT_CONFIG_OPTION_SYSTEM_ZLIB
ZLIB # sys$library:libz.olb # sys$library: # zlib.h # FT_CONFIG_OPTION_SYSTEM_ZLIB

View File

@ -4,7 +4,7 @@
*
* Debugging and logging component for WinCE (body).
*
* Copyright (C) 1996-2021 by
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,

View File

@ -21,7 +21,7 @@ the following targets:
<li>PPC/SP WM6 (Windows Mobile 6)</li>
</ul>
It compiles the following libraries from the FreeType 2.11.1 sources:</p>
It compiles the following libraries from the FreeType 2.13.2 sources:</p>
<ul>
<pre>

View File

@ -21,7 +21,7 @@ the following targets:
<li>PPC/SP WM6 (Windows Mobile 6)</li>
</ul>
It compiles the following libraries from the FreeType 2.11.1 sources:</p>
It compiles the following libraries from the FreeType 2.13.2 sources:</p>
<ul>
<pre>

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -4,7 +4,7 @@
*
* Debugging and logging component for Win32 (body).
*
* Copyright (C) 1996-2021 by
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
@ -136,6 +136,8 @@
va_start( ap, fmt );
vfprintf( stderr, fmt, ap );
#if ( defined( _WIN32_WINNT ) && _WIN32_WINNT >= 0x0400 ) || \
( defined( _WIN32_WCE ) && _WIN32_WCE >= 0x0600 )
if ( IsDebuggerPresent() )
{
static char buf[1024];
@ -144,6 +146,7 @@
vsnprintf( buf, sizeof buf, fmt, ap );
OutputDebugStringA( buf );
}
#endif
va_end( ap );
}
@ -159,6 +162,8 @@
va_start( ap, fmt );
vfprintf( stderr, fmt, ap );
#if ( defined( _WIN32_WINNT ) && _WIN32_WINNT >= 0x0400 ) || \
( defined( _WIN32_WCE ) && _WIN32_WCE >= 0x0600 )
if ( IsDebuggerPresent() )
{
static char buf[1024];
@ -167,6 +172,7 @@
vsnprintf( buf, sizeof buf, fmt, ap );
OutputDebugStringA( buf );
}
#endif
va_end( ap );
exit( EXIT_FAILURE );

View File

@ -4,7 +4,7 @@
*
* Windows-specific FreeType low-level system interface (body).
*
* Copyright (C) 2021 by
* Copyright (C) 2021-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
@ -196,19 +196,77 @@
}
#ifdef _WIN32_WCE
/* non-desktop Universal Windows Platform */
#if defined( WINAPI_FAMILY ) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP
#define PACK_DWORD64( hi, lo ) ( ( (DWORD64)(hi) << 32 ) | (DWORD)(lo) )
#define CreateFileMapping( a, b, c, d, e, f ) \
CreateFileMappingFromApp( a, b, c, PACK_DWORD64( d, e ), f )
#define MapViewOfFile( a, b, c, d, e ) \
MapViewOfFileFromApp( a, b, PACK_DWORD64( c, d ), e )
FT_LOCAL_DEF( HANDLE )
CreateFileA( LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile )
CreateFileA( LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile )
{
int len;
LPWSTR lpFileNameW;
int len;
LPWSTR lpFileNameW;
CREATEFILE2_EXTENDED_PARAMETERS createExParams = {
sizeof ( CREATEFILE2_EXTENDED_PARAMETERS ),
dwFlagsAndAttributes & 0x0000FFFF,
dwFlagsAndAttributes & 0xFFF00000,
dwFlagsAndAttributes & 0x000F0000,
lpSecurityAttributes,
hTemplateFile };
/* allocate memory space for converted path name */
len = MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
lpFileName, -1, NULL, 0 );
lpFileNameW = (LPWSTR)_alloca( len * sizeof ( WCHAR ) );
if ( !len || !lpFileNameW )
{
FT_ERROR(( "FT_Stream_Open: cannot convert file name to LPWSTR\n" ));
return INVALID_HANDLE_VALUE;
}
/* now it is safe to do the translation */
MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
lpFileName, -1, lpFileNameW, len );
/* open the file */
return CreateFile2( lpFileNameW, dwDesiredAccess, dwShareMode,
dwCreationDisposition, &createExParams );
}
#endif
#if defined( _WIN32_WCE )
/* malloc.h provides implementation of alloca()/_alloca() */
#include <malloc.h>
FT_LOCAL_DEF( HANDLE )
CreateFileA( LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile )
{
int len;
LPWSTR lpFileNameW;
/* allocate memory space for converted path name */
@ -233,10 +291,15 @@
dwFlagsAndAttributes, hTemplateFile );
}
#endif
#if defined( _WIN32_WCE ) || defined ( _WIN32_WINDOWS ) || \
!defined( _WIN32_WINNT ) || _WIN32_WINNT <= 0x0400
FT_LOCAL_DEF( BOOL )
GetFileSizeEx( HANDLE hFile,
PLARGE_INTEGER lpFileSize )
GetFileSizeEx( HANDLE hFile,
PLARGE_INTEGER lpFileSize )
{
lpFileSize->u.LowPart = GetFileSize( hFile,
(DWORD *)&lpFileSize->u.HighPart );
@ -248,7 +311,7 @@
return TRUE;
}
#endif /* _WIN32_WCE */
#endif
/* documentation is in ftobjs.h */

View File

@ -168,7 +168,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4001</DisableSpecificWarnings>
<DisableSpecificWarnings>4001;4267</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
@ -195,7 +195,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4001</DisableSpecificWarnings>
<DisableSpecificWarnings>4001;4267</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
@ -248,7 +248,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4001</DisableSpecificWarnings>
<DisableSpecificWarnings>4001;4267</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
@ -274,7 +274,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4001</DisableSpecificWarnings>
<DisableSpecificWarnings>4001;4267</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
@ -328,7 +328,7 @@
<DisableLanguageExtensions>true</DisableLanguageExtensions>
<WarningLevel>Level4</WarningLevel>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4001</DisableSpecificWarnings>
<DisableSpecificWarnings>4001;4267</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<IntrinsicFunctions>true</IntrinsicFunctions>
@ -356,7 +356,7 @@
<DisableLanguageExtensions>true</DisableLanguageExtensions>
<WarningLevel>Level4</WarningLevel>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4001</DisableSpecificWarnings>
<DisableSpecificWarnings>4001;4267</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
@ -409,7 +409,7 @@
<DisableLanguageExtensions>true</DisableLanguageExtensions>
<WarningLevel>Level4</WarningLevel>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4001</DisableSpecificWarnings>
<DisableSpecificWarnings>4001;4267</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<IntrinsicFunctions>true</IntrinsicFunctions>
@ -435,7 +435,7 @@
<DisableLanguageExtensions>true</DisableLanguageExtensions>
<WarningLevel>Level4</WarningLevel>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4001</DisableSpecificWarnings>
<DisableSpecificWarnings>4001;4267</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
@ -485,6 +485,7 @@
<ClCompile Include="..\..\..\src\sfnt\sfnt.c" />
<ClCompile Include="..\..\..\src\smooth\smooth.c" />
<ClCompile Include="..\..\..\src\sdf\sdf.c" />
<ClCompile Include="..\..\..\src\svg\svg.c" />
<ClCompile Include="..\..\..\src\truetype\truetype.c" />
<ClCompile Include="..\..\..\src\type1\type1.c" />
<ClCompile Include="..\..\..\src\type42\type42.c" />

View File

@ -68,6 +68,9 @@
<ClCompile Include="..\..\..\src\smooth\smooth.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\svg\svg.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\truetype\truetype.c">
<Filter>Source Files</Filter>
</ClCompile>
@ -143,4 +146,4 @@
<Filter>Source Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
</Project>

View File

@ -12,7 +12,7 @@
<p>This directory contains solution and project files for
Visual&nbsp;C++&nbsp;2010 or newer, named <tt>freetype.sln</tt>,
and <tt>freetype.vcxproj</tt>. It compiles the following libraries
from the FreeType 2.11.1 sources:</p>
from the FreeType 2.13.2 sources:</p>
<ul>
<li>freetype.dll using 'Release' or 'Debug' configurations</li>

View File

@ -434,10 +434,18 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\src\sdf\sdf.c"
>
</File>
<File
RelativePath="..\..\..\src\smooth\smooth.c"
>
</File>
<File
RelativePath="..\..\..\src\svg\svg.c"
>
</File>
<Filter
Name="FT_MODULES"
>

View File

@ -12,7 +12,7 @@
<p>This directory contains project files <tt>freetype.dsp</tt> for
Visual C++ 6.0, and <tt>freetype.vcproj</tt> for Visual C++ 2002
through 2008, which you might need to upgrade automatically.
It compiles the following libraries from the FreeType 2.11.1 sources:</p>
It compiles the following libraries from the FreeType 2.13.2 sources:</p>
<ul>
<li>freetype.dll using 'Release' or 'Debug' configurations</li>

View File

@ -21,7 +21,7 @@ the following targets:
<li>PPC/SP WM6 (Windows Mobile 6)</li>
</ul>
It compiles the following libraries from the FreeType 2.11.1 sources:</p>
It compiles the following libraries from the FreeType 2.13.2 sources:</p>
<ul>
<pre>

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -3,7 +3,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -5,7 +5,7 @@
#
# Copyright (C) 1996-2021 by
# Copyright (C) 1996-2024 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

Some files were not shown because too many files have changed in this diff Show More