Commit Graph

2008 Commits

Author SHA1 Message Date
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 24db55ecb8 Various minor doc fixes. 2022-02-06 21:06:52 +01:00
Werner Lemberg 36ee3160a0 freetype.h: Minor documentation improvement. 2022-01-31 10:37:56 +01: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
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 6a8e95b7a0 Update documentation for `FT_LOAD_COLOR`. 2022-01-25 08:49:41 +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 21d0fa3742 More documentation on handling OT-SVG. 2022-01-23 12:23:47 +01: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 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 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
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
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 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
Werner Lemberg d0cfb4e1b2 Update all copyright notices. 2022-01-11 10:54:10 +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
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 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
Werner Lemberg 3f83daeecb * Version 2.11.1 released.
==========================

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

* docs/VERSION.TXT: Add entry for version 2.11.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.11.0/2.11.1/, s/2110/2111/.

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

* builds/unix/configure.raw (version_info): Set to 24:1:18.
* CMakeLists.txt (VERSION_PATCH): Set to 1.

* builds/toplevel.mk (version_tag, CHANGELOG_SCRIPT): New variables.
(do-dist): Generate `ChangeLog` file with all commits since last release.
2021-12-02 13:33:12 +01:00
Werner Lemberg 3cabd142ce Update `CHANGES` files, other minor whitespace and documentation issues. 2021-11-22 19:58:21 +01:00
Alexei Podtelezhnikov f8a4163a45 * include/freetype/fttypes.h (FT_MAKE_TAG): Remove the same casting. 2021-11-20 07:01:26 -05:00
Werner Lemberg 8c8f51c558 Avoid undefined left-shifts.
We really have to use double casts to avoid issues with C's and C++'s
signedness propagation rules in implicit casts.

Reported as

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

* include/freetype/config/public-macros.h (FT_STATIC_CAST,
FT_REINTERPRET_CAST): Modify macro to take two arguments.
Update all callers.
(FT_STATIC_BYTE_CAST): New macro.

* include/freetype/freetype.h (FT_ENC_TAG): Use `FT_STATIC_BYTE_CAST`.
* include/freetype/ftimage.h (FT_IMAGE_TAG): Ditto.
* include/freetype/fttypes.h (FT_MAKE_TAG): Ditto.
Use `FT_Tag` for casting.

* src/ftraster/ftmisc.h (FT_MAKE_TAG): Removed, no longer needed.
(FT_STATIC_BYTE_CAST): New macro.

* src/smooth/ftgrays.c (FT_STATIC_CAST): Replace with...
(FT_STATIC_BYTE_CAST): ... this.
2021-11-20 07:58:31 +01:00
Werner Lemberg 9079c5d91a Provide C++ versions for public macros with casts.
Many FreeType clients use C++.  However `g++ -Wold-style-cast` warns for
macros with C-style casts even for system header files; this also affects
directories included with `-isystem`.  While this could be seen as a problem
with g++, the problem is more a philosophical one: Over the time, C and C++
diverged more and more, and some features of C are no longer the 'right'
solution in C++.

* include/freetype/config/public-macros.h (FT_STATIC_CAST,
FT_REINTERPRET_CAST): New macros.

* include/freetype/freetype.h (FT_ENC_TAG, FT_LOAD_TARGET_,
FT_LOAD_TARGET_MODE): Use `FT_STATIC_CAST`.
Correctly handle negative 'signed char' input.
* include/freetype/ftimage.h (FT_IMAGE_TAG): Ditto.
* include/freetype/fttypes.h (FT_MAKE_TAG, FT_BOOL): Ditto.
* include/freetype/ftmodapi.h (FT_FACE_DRIVER_NAME): Use
`FT_REINTERPRET_CAST`.

* src/smooth/ftgrays.c (FT_STATIC_CAST)[STANDALONE_]: New macro.
[!STANDALONE]: Include `FT_CONFIG_CONFIG_H`.

Fixes #1116.
2021-11-18 19:28:07 +00:00
Alexei Podtelezhnikov 42e617238a Explicitly define `FT_MSB` for Clang.
* include/freetype/internal/ftcalc.h [__clang__] (FT_MSB): Updated.
2021-11-11 23:06:36 -05:00
Alexei Podtelezhnikov 188c7d6670 Additional `FT_MSB` macro definitions.
Better macros for Windoes CE and ARM in general, based on !109
from metarutaiga.

* include/freetype/internal/ftcalc.h [_MSC_VER] (FT_MSB): Updated.
2021-11-09 22:47:26 -05:00
Alexei Podtelezhnikov 7f4b9bfbc9 [dlg] Define DLG_STATIC explicitly.
DLG_STATIC is intended to disable Windows DLL linking attributes.
It does not hurt to define it explicitly when we wrap DLG code.
This fixes tons of LNK4286 and C4273 warnings from MSVC if we
forget to define DLG_STATIC as a compiler option.

* builds/windows/vc2010/freetype.vcxproj: Remove DLG_STATIC option.
* src/dlg/dlgwrap.c [FT_DEBUG_LOGGING]: Define DLG_STATIC.
* include/freetype/internal/ftdebug.h [FT_DEBUG_LOGGING]: Ditto.
2021-11-07 10:20:16 -05:00
Dominik Röttsches d3d3ff76d1 [sfnt] Clarify `COLR` v1 FT_Paint* format representations
* include/freetype/ftcolor.h (FT_PaintLinearGradient,
FT_PaintRadialGradient, FT_PaintSweepGradient, FT_PaintTransform,
FT_PaintTranslate, FT_PaintScale, FT_PaintRotate, FT_PaintSkew): Clarify
16.16 fixed point representation of struct fields.
* src/sfnt/ttcolr.c (read_paint): Shift coordinates for
FT_PaintLinearGradient, FT_PaintRadialGradient, FT_PaintSweepGradient
accordingly.

Fixes: https://gitlab.freedesktop.org/freetype/freetype/-/issues/1110
2021-11-03 08:28:10 +00:00
Alexei Podtelezhnikov 793c012635 [woff] Optimize table tagging.
* include/freetype/internal/wofftypes.h (WOFF_TableRec): Use
32-bit tag.
* src/sfnt/sfwoff.c (woff_open_font): Use 32-bit tag.
2021-10-27 22:36:11 -04:00
Alexei Podtelezhnikov a577bbcb5b [woff2] Optimize table tagging.
Fixes #1107.

* include/freetype/internal/wofftypes.h (WOFF2_TableRec): Use
32-bit tag.
* src/sfnt/sfwoff2.c (compare_tags, find_table, woff2_open_font):
Use 32-bit tag.
* src/sfnt/woff2tags.[ch] (woff2_known_tags): Use static storage and
return 32-bit tag.
2021-10-27 22:24:27 -04:00
Ben Wagner c71eb22dde Fix typos in memory macros.
FT_QNEW_ARRAY and FT_QRENEW_ARRAY were using the non-Q
FT_MEM_NEW_ARRAY and FT_MEM_RENEW_ARRAY. Change these to use the Q
versions. Also fix the one issue discovered in tt_face_load_name
where table->names is created with FT_QNEW_ARRAY but the extra
string member is not initialized to NULL.

* include/freetype/internal/ftmemory.h (FT_Q(RE)NEW_ARRAY):
Use FT_MEM_Q(RE)NEW_ARRAY as needed.

* src/sfnt/ttload.c (tt_face_load_name): Initialize `entry->string`.
2021-10-15 22:18:38 -04:00
Alexei Podtelezhnikov 3b036820d6 [cid] Signedness revisions.
Unsigned checks are simpler.

* include/freetype/t1tables.h (CID_FaceInfoRec): Change to unsignd
`num_dicts`.
* src/cid/cidparse.h (CID_Parser): Change to unsigned `num_dict`.

* src/cid/cidgload.c (cid_load_glyph): Updated.
* src/cid/cidload.c (cid_load_keyword, parse_fd_array,
parse_expansion_factor, parse_font_name, cid_read_subrs,
cid_face_open): Updated.
* src/cid/cidobjs.c (cid_face_done): Updated.
* src/cid/cidparse.c (cid_parser_new): Updated.
2021-10-10 23:11:10 -04:00
Alexei Podtelezhnikov 22befeef82 Signedness revisions.
This eliminates explicit casting by switching to unsigned fields.
The revisions mostly impact the handling of CID fonts.

* include/freetype/fttypes.h (FT_Data): Change to unsigned `length`.
* include/freetype/t1tables.h (CID_FaceDictRec): Ditto for `sd_bytes`.
(CID_FaceInfoRec): Ditto for `gd_bytes` and `gd_bytes`.
* include/freetype/internal/tttypes.h (TT_LoaderRec): Ditto for
`byte_len`.

* src/cid/cidgload.c (cid_load_glyph): Updated.
* src/cid/cidload.h (cid_get_offset): Update argument.
* src/cid/cidload.c (cid_get_offset, cid_read_subrs, cid_face_open):
Updated.
* src/cff/cffgload.c (cff_get_glyph_data, cff_free_glyph_data):
Updated.
* src/psaux/psft.c (cf2_getT1SeacComponent): Updated.
* src/truetype/ttgload.c (TT_Process_Composite_Glyph,
load_truetype_glyph): Updated.
2021-10-07 22:41:56 -04:00
Alexei Podtelezhnikov bbab0a675e * include/freetype/internal/ftgloadr.h: Add missing header.
Noticed by Jouk Jansen.
2021-10-04 23:55:46 -04:00
Alexei Podtelezhnikov 311764fabb Additional `FT_MSB` macro definitions.
* include/freetype/internal/ftcalc.h [__DECC,_CRAYC]: Use builtins
and intrinsics.
2021-10-01 11:50:12 -04:00
Alexei Podtelezhnikov 766b2c19e2 Propagate sign when reading OFF3.
Signed 24-bit values are extremely rare.  FreeType only reads them in
PFR fonts with bitmap strikes conditionally. They have not been seen
in the known fonts.  That is why this bug could never be discovered.
`FT_FRAME_OFF3` propagates sign correctly.

* include/freetype/internal/ftstream.h (FT_PEEK_OFF3, FT_PEEK_OFF3_LE):
Propagate sign into 32-bit value.
(FT_GET_OFF3, FT_READ_OFF3): Needed fixing but removed as unused.
2021-09-24 22:14:22 -04:00
Alexei Podtelezhnikov a29e020059 Use NULL for pointers only.
* src/bdf/bdflib.c (*): Code changes.
* include/freetype/freetype.h: Comments only.
* src/cff/cffload.c, src/cff/cffobjs.c: Ditto.
* src/winfonts/winfnt.c: Ditto.
2021-09-23 23:10:26 -04:00
Werner Lemberg 6d19b29fbc Minor documentation fixes and improvements. 2021-09-23 08:46:01 +02:00
Alexei Podtelezhnikov 3b573e4527 Reference `fopen` in the docs. 2021-09-22 22:22:13 -04:00
Alexei Podtelezhnikov e942a31007 [truetype] Tweak `loca` clamping.
Fixes #1095.

* src/truetype/ttpload.c (tt_face_load_loca): Fix up clamping.
* include/freetype/internal/tttypes.h (TT_Face): Correct docs.
2021-09-09 22:17:46 -04:00
Alexei Podtelezhnikov 7482c98f15 [base] Clean up stream reading.
* src/base/ftstream.c (FT_Stream_ReadUShort, FT_Stream_ReadUOffset,
FT_Stream_ReadULong and their LE variants): Remove unnecessary
initialization and slightly refactor.
(FT_Stream_GetByte, FT_Stream_ReadByte): Rename to return unsigned
value and align with sister functions.

* include/freetype/internal/ftstream.h (FT_Stream_GetByte,
FT_Stream_ReadByte): Update prototypes and caller macros.
2021-09-01 22:18:29 -04:00
Alexei Podtelezhnikov 78f2bd0bd3 Whitespace formatting. 2021-08-22 22:32:07 -04:00
Alexei Podtelezhnikov d92aa23fd7 Decorate const arguments.
* src/base/ftglyph.c (FT_Glyph_Transform, FT_Glyph_To_Bitmap): Do it.
* include/freetype/ftglyph.h (FT_Glyph_Transform, FT_Glyph_To_Bitmap):
Do it.
2021-08-22 13:12:45 -04:00
Alexei Podtelezhnikov ffdac8d67e Determine `long long` availability based on its size.
MSVC, for example, used `long long` even without full C99 support.

* include/freetype/config/ftstdlib.h: Check if `long long` limits are
defined in <limits.h>.
* include/freetype/config/integer-types.h: Check `long long` size and
use it to typedef FT_Int64.
2021-08-19 20:41:55 -04:00
Alexei Podtelezhnikov 02ba0fc81e Readily use `long long` as a 64-bit type in C99 mode.
* include/freetype/config/integer-types.h (FT_INT64):
FT_CONFIG_OPTION_FORCE_INT64 is no longer required to use `long long`.
2021-08-18 23:27:48 -04:00
Alexei Podtelezhnikov 857038399a Use FT_INT64 instead of FT_LONG64.
* include/freetype/config/integer-types.h: Remove synonymous FT_LONG64.
* include/freetype/internal/ftcalc.h: s/FT_LONG64/FT_INT64/.
* src/base/ftcalc.c: Ditto.
* src/base/fttrigon.c: Ditto.
* src/smooth/ftgrays.c: Ditto.
2021-08-18 23:05:51 -04:00
Werner Lemberg f11f3ed15b [base] Fix ppem size overflow.
Fixes #1086.

* src/base/ftobjs.c (FT_Request_Metrics): Add return value.
Check whether ppem values fit into unsigned short values.
(FT_Request_Size): Updated.

* include/freetype/internal/ftobjs.h: Updated.

* src/cff/cffobjs.c (cff_size_request), src/cid/cidobjs.c
(cid_size_request), src/truetype/ttdriver.c (tt_size_request),
src/type1/t1objs.c (T1_Size_Request): Updated.
2021-08-18 07:27:02 +02:00
Dominik Röttsches e40ae7569a [sfnt] Add missing blend mode 'plus' to 'COLR' v1.
* include/freetype/ftcolor.h (FT_Composite_Mode): Add missing blend mode
'plus' after it was added to the spec.
2021-08-09 19:25:26 +02:00
Werner Lemberg 2c853b38a7 include/freetype/freetype.h (FT_Encoding): Improve documentation.
Based on a suggestion by Antony Lee <anntzer.lee@gmail.com>.
2021-08-08 00:22:34 +02:00
Dominik Röttsches 47cf8ebf4a [sfnt] Add API for retrieving a 'COLR' v1 'ClipBox' table.
The optional 'COLR' v1 glyph-specific clip box helps upstream graphics
libraries allocate a sufficiently large bitmap for a glyph without having to
traverse the glyph graph for that.  See

  https://github.com/googlefonts/colr-gradients-spec/issues/251

for background on the introduction of this specification change.

* include/freetype/ftcolor.h (FT_ClipBox): New structure.
(FT_Get_Color_Glyph_ClipBox): New function declaration.

* include/freetype/internal/sfnt.h (TT_Get_Color_Glyph_ClipBox_Func):
New function type.
(SFNT_Interface, FT_DEFINE_SFNT_INTERFACE): Use it.

* src/base/ftobjs.c (FT_Get_Color_Glyph_ClipBox): New function to link API
with SFNT implementation.

* src/sfnt/sfdriver.c (sfnt_interface): Updated.
* src/sfnt/ttcolr.c (Colr): New field `clip_list`.
(tt_face_load_colr): Parse global clip list offset.
(tt_face_get_color_glyph_clipbox): New function to find the clip box for a
glyph id from the clip list array.
* src/sfnt/ttcolr.h: Updated.
2021-08-07 14:44:05 +02:00
Dominik Röttsches 30a82e1e5d [sfnt] 'COLR' v1 PaintSweepGradient spec update
* src/sfnt/ttcolr.c (read_paint): PaintSweepGradient follows other
spec changes and now has the angles specified as F2DOT14, reflect
that in the implementation.
* include/freetype/ftcolor.h (FT_PaintSweepGradient): Update
documentation.
2021-07-29 06:12:51 +00:00
Dominik Röttsches 66189807b8 [sfnt] 'COLR' v1 PaintSkew related spec updates
* src/sfnt/ttcolr.c (read_paint): Implement spec changes around
PaintSkew, PaintSkewAroundCenter.  Update parsing to read shorter
values as changed in the spec.
* include/freetype/ftcolor.h (FT_PaintSkew): Update documentation.
2021-07-29 06:01:34 +00:00
Dominik Röttsches 48df0fa652 [sfnt] PaintRotate/PaintRotateAroundCenter spec updates
* src/sfnt/ttcolr.c (read_paint): Implement spec change where
PaintRotate and PaintRotateAroundCenter were split for a more
compact format definition.  Update parsing to read shorter values
as changed in the spec.
* include/freetype/ftcolor.h (FT_PaintRotate): Update documentation.
2021-07-29 05:59:30 +00:00
Werner Lemberg 801cd842e2 * Version 2.11.0 released.
==========================

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

* docs/VERSION.TXT: Add entry for version 2.11.0.
* 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.10.4/2.11.0/, s/2104/2110/.

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

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

* builds/toplevel.mk (dist): Ignore more git-related files.
2021-07-19 18:07:51 +02:00
Alex Richardson f7c6a06cb7 Support architectures where `long` is smaller than pointers.
I am currently trying to compile FreeType for CHERI-extended ISAs
(CHERI-RISC-V and Arm's Morello), but I am getting compiler warnings
from the `FT_UINT_TO_POINTER` macro.  When compiling with the CHERI
Clang compiler, not using `uinptr_t` for casts between integers an
pointers results in the following `-Werror` build failures:

```
In file included from .../src/truetype/truetype.c:22:
  .../src/truetype/ttgload.c:1925:22: error:
    cast from provenance-free integer type to pointer type will
    give pointer that can not be dereferenced
    [-Werror,-Wcheri-capability-misuse]
  node->data = FT_UINT_TO_POINTER( glyph_index );
               ^
  .../include/freetype/internal/compiler-macros.h:79:34: note:
    expanded from macro 'FT_UINT_TO_POINTER'
```

* include/freetype/internal/compiler-macros.h (FT_UINT_TO_POINTER):
The ISO C standard compliant fix for this would be to use
`uintptr_t` from `stdint.h`, but I am not sure if this is supported
by the minimum compiler version.  Therefore, use the
compiler-defined `__UINTPTR_TYPE__` macro (supported in GCC 4.6+ and
Clang since about 3.0) before checking for `_WIN64` and falling back
to `unsigned long`.
2021-07-15 12:09:04 +02:00
Oleg Oshmyan 5d27b10f4c [base] Fix `FT_Open_Face`'s handling of user-supplied streams.
This was already true (though undocumented) most of the time, but
not if `FT_NEW` inside `FT_Stream_New` failed or if the
`FT_OPEN_XXX` flags were bad.

Normally, `FT_Open_Face` calls `FT_Stream_New`, which returns the
user-supplied stream unchanged, and in case of any subsequent error
in `FT_Open_Face`, the stream is closed via `FT_Stream_Free`.

Up to now, however, `FT_Stream_New` allocates a new stream even if
it is already given one by the user.  If this allocation fails, the
user-supplied stream is not returned to `FT_Open_Face` and never
closed.  Moreover, the user cannot detect this situation: all they
see is that `FT_Open_Face` returns `FT_Err_Out_Of_Memory`, but that
can also happen after a different allocation fails within the main
body of `FT_Open_Face`, when the user's stream has already been
closed by `FT_Open_Face`.  It is plausible that the user stream's
`close` method frees memory allocated for the stream object itself,
so the user cannot defensively free it upon `FT_Open_Face` failure
lest it ends up doubly freed.  All in all, this ends up leaking the
memory/resources used by user's stream.

Furthermore, `FT_Stream_New` simply returns an error if the
`FT_OPEN_XXX` flags are unsupported, which can mean either an
invalid combination of flags or a perfectly innocent
`FT_OPEN_STREAM` on a FreeType build that lacks stream support.
With this patch, the user-supplied stream is closed even in these
cases, so the user can be sure that if `FT_Open_Face` failed, the
stream is definitely closed.

* src/base/ftobjs.c (FT_Stream_New): Don't allocate a buffer
unnecessarily.
Move error-handling code to make the control flow more obvious.
Close user-supplied stream if the flags are unsupported.
`FT_Stream_Open` always sets `pathname.pointer`, so remove the
redundant (re)assignment.  None of the `FT_Stream_Open...` functions
uses `stream->memory`, so keep just one assignment at the end,
shared among all possible control flow paths.
('Unsupported flags' that may need a stream closure can be either an
invalid combination of multiple `FT_OPEN_XXX` mode flags or a clean
`FT_OPEN_STREAM` flag on a FreeType build that lacks stream
support.)
2021-07-13 11:00:48 +02:00
Oleg Oshmyan a4c8f21ae7 [base] Reject combinations of incompatible `FT_OPEN_XXX` flags.
The three modes are mutually exclusive, and the documentation of the
`FT_OPEN_XXX` constants notes this.  However, there was no check to
validate this in the code, and the documentation on `FT_Open_Args`
claimed that the corresponding bits were checked in a well-defined
order, implying it was valid (if useless) to specify more than one.
Ironically, this documented order did not agree with the actual
code, so it could not be relied upon; hopefully, nobody did this and
nobody will be hurt by the new validation.

Even if multiple mode bits were allowed, they could cause memory
leaks: if both `FT_OPEN_STREAM` and `stream` are set along with
either `FT_OPEN_MEMORY` or `FT_OPEN_PATHNAME`, then `FT_Stream_New`
allocated a new stream but `FT_Open_Face` marked it as an 'external'
stream, so the stream object was never released.

* src/base/ftobjs.c (FT_Stream_New): Reject incompatible
`FT_OPEN_XXX` flags.
2021-07-13 10:44:38 +02:00
Anuj Verma e592982a83 [sdf] Improve documentation. 2021-07-13 10:00:22 +02:00
Werner Lemberg 205d1ae43e Small clean-ups for the last few commits.
* include/freetype/fttrace.h (afwarp): Removed.
2021-07-12 22:03:25 +02:00
David Turner 2f11522a2a Remove experimental auto-hinting 'warp' mode.
This feature was always experimental, and probably nevery worked
properly. This patch completely removes it from the source code,
except for a documentation block describing it for historical
purpose.
2021-07-12 09:25:22 +02:00
David Turner 15e889800a Remove experimental "Latin2" writing system (FT_OPTION_AUTOFIT2)
This code has always been experimental and was never compiled
anyway (FT_OPTION_AUTOFIT2 does not appear in ftoption.h or even
any of our build files).
2021-07-12 09:25:07 +02:00
Dominik Röttsches 286da6c528 [sfnt] Support PaintScale in 'COLR' v1 parsing.
* include/freetype/ftcolor.h (FT_PaintFormat): Renumber values, add
`FT_COLR_PAINTFORMAT_SCALE`.
(FT_PaintScale): New structure to represent 'PaintScale*' tables.
(FT_COLR_Paint): Updated.

* src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration.
(read_paint): Parse 'PaintScale' and friends.
2021-07-01 06:49:03 +02:00
Werner Lemberg 90ecac4118 Update `CHANGES` file; other minor doc fixes. 2021-06-30 10:23:42 +02:00
Werner Lemberg e1b1b5422c ftcolor.h: Minor grammar fix. 2021-06-29 06:07:00 +02:00
Werner Lemberg ff40776591 [base] Add trace level to logging output.
Some practical debugging work has shown that displaying level X of
an `FT_TRACEX` macro in the output of `FT2_DEBUG="...  -v"` would be
very helpful to find out which trace level should be selected.  As
an example, we now get output like

```
[ttobjs:2]    TTF driver
[ttobjs:2]      SFNT driver
[sfobjs:2]      not a font using the SFNT container format
[t1objs:2]    Type 1 driver
[stream:7]    FT_Stream_EnterFrame: 14 bytes
```

* include/freetype/internal/ftdebug.h (FT_LOGGING_TAGX): New macro.
(FT_LOG): Use it to add the trace level to the logging tag.

* include/freetype/internal/fttrace.h (FT_MAX_TRACE_LEVEL_LENGTH):
Adjust.

* docs/DEBUG: Updated.
2021-06-25 09:24:07 +02:00
Werner Lemberg 1e65e6051a fterrors.h: Fix documentation extraction of `FT_Error_String`. 2021-06-23 08:14:42 +02:00
Dominik Röttsches 4cb21b9a92 [sfnt] s/PaintTransformed/PaintTransform/, s/transformed/transform/.
* include/freetype/ftcolor.h (FT_PaintTransformed, FT_PaintFormat,
FT_COLR_Paint): Do it to make it harmonize with other names such as
'PaintTranslate'.

* src/sfnt/ttcolr.c (read_paint, tt_face_get_paint): Ditto.
2021-06-22 20:50:48 +02:00
Dominik Röttsches 284eec1e18 Move 'COLR' API to `ftcolor.h`.
* include/freetype/freetype.h: Cut section layer managament
containing 'COLR' v0 and v1 API and move it to `ftcolor.h` as
requested by Werner on freetype-devel.
* include/freetype/ftcolor.h: Paste that section.
2021-06-22 20:33:33 +02:00
Werner Lemberg bcd73f7dbc freetype.h: Mark 'COLR' v1 API as experimental. 2021-06-20 16:23:40 +02:00
Werner Lemberg 08f66322e3 More various documentation improvements and fixes. 2021-06-08 18:23:16 +02:00
Werner Lemberg d586927d16 Various documentation improvements and fixes. 2021-06-08 17:44:53 +02:00
Werner Lemberg 36ee71714f [sdf] Formatting and improved comments. 2021-06-08 09:00:39 +02:00
Anuj Verma 2b1d556269 [sdf] Use 8 bits for final SDF output instead of 16bits.
Since 8-bits is enough to represent SDF data we no longer require
16-bits for  this purpose. Also, we now normalize the output data
to use the entire 8-bit range efficiently. For example: if we use
3.5 format with a spread of 1 we basically only use the starting
5-bits. By normalizing we can use the entire 8-bit range.

* include/freetype/freetype.h (FT_Render_Mode): Updated description
for `FT_RENDER_MODE_SDF` regarding this change.

* include/freetype/ftimage.h (FT_Pixel_Mode): Removed
`FT_PIXEL_MODE_GRAY16` since no longer required.

* include/freetype/fttypes.h (FT_F6Dot10): Removed since no longer
required.

* src/sdf/ftsdfrend.c (ft_sdf_render, ft_bsdf_render): Allocate 8-bit
bitmap instead of 16-bit buffer.

* src/sdf/ftsdfcommon.h (map_fixed_to_sdf): Added function to convert
16.16 distance value to our desired format.

* src/sdf/ftsdf.c (sdf_generate_with_overlaps,
sdf_generate_bounding_box): Use the new `map_fixed_to_sdf` function
and also use 8-bit output buffer.

* src/sdf/ftbsdf.c (finalize_sdf): Output to a 8-bit buffer instead
of 16-bit buffer.
2021-06-08 08:29:34 +05:30
Werner Lemberg 0d1c306e51 [psaux] Guard and trace AFM kern data allocation.
Reported as

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

* include/freetype/internal/fttrace.h: Add 'afmparse' trace
component.

* src/psaux/afmparse.c (FT_COMPONENT): Define.
(afm_parse_track_kern, afm_parse_kern_pairs): Protect against
allocations bombs.
Add tracing.
(afm_parse_kern_data): Don't allow multiple kern data sections.
2021-05-25 11:27:56 +02:00
Alexei Podtelezhnikov 81852fbccc Prioritize the anti-aliasing renderer module.
* modules.cfg: Reorder the renderers.
* include/freetype/config/ftmodule.h: Ditto.
2021-05-18 22:18:17 -04:00
Alexei Podtelezhnikov 02dec61731 Typo. 2021-04-18 10:24:31 -04:00
Werner Lemberg f7d7e7f9f7 freetype.h: Documentation typos. 2021-02-27 12:14:02 +01:00
Dominik Röttsches 215ae25330 [sfnt] Update paint format values to support non-variable paints.
* freetype.h (FT_PaintFormat): Update paint format identifiers after
a specification change.  The specification was updated to have
sibling formats, variable and non-variable variants for each.
Reflect that here.

* sfnt/ttcolr.c (read_paint): Remove parsing of variable indices as
the non-variable formats no longer have them.
2021-02-16 13:15:41 +01:00
Werner Lemberg d51452e3ec Add new function `FT_Get_Transform`.
See

  https://github.com/harfbuzz/harfbuzz/issues/2428

for some reasons to introduce this function.

* include/freetype/freetype.h, src/base/ftobjs.c (FT_Get_Transform):
Implement it.
2021-02-13 08:52:58 +01:00
Werner Lemberg d93a011933 Minor editing of last commit; formatting. 2021-02-13 07:50:04 +01:00
Alexei Podtelezhnikov 70fd20e67e Decorate qsort callbacks with cdecl.
* include/freetype/internal/compiler-macros.h (FT_COMPARE_DEF):
Add new macro.
* src/base/ftrfork.c, src/bdf/bdflib.c, src/gxvalid/gxvcommn.c,
src/psaux/afmparse.c, src/psnames/psmodule.c, src/type1/t1afm.c,
src/sfnt/sfwoff.c, src/sfnt/sfwoff2.c: Update qsort callbacks.

Fixes #1026 when compiling FreeType with an unusual calling convention
while the C library qsort still expects cdecl.
2021-02-12 19:28:05 -05:00
Dominik Röttsches 54c5ad5c92 [sfnt] Implement 'COLR' v1 sweep gradients.
* freetype.h (FT_PaintSweepGradient): Add `FT_PaintSweepGradient` to
represent a 'COLR' v1 sweep gradient.
Update format.
(FT_PaintFormat): Update shifted paint formats.
Sync with spec.
* sfnt/ttcolr.c (read_paint): Logic to parse sweep gradients.
Fix struct access in radial gradient implementation.
2021-02-11 14:20:03 +01:00
Dominik Röttsches 64f01bfedd [sfnt] Provide optional root transform for 'COLR' v1 glyph graph.
* include/freetype/freetype.h (FT_Get_Color_Glyph_Paint):
Additional function argument root_transform to control whether
root transform should be returned.
(FT_OpaquePaint): Additional tracking field to denote whether
root transform is to be returned.
* include/freetype/internal/sfnt.h
(TT_Get_Color_Glyph_Paint_Func): Propagate additional argument.
* src/base/ftobjs.c (FT_Get_Color_Glyph_Paint): Ditto.
* src/sfnt/ttcolr.c (tt_face_get_colr_glyph_paint): Return root
transform reflecting the size and tranform configured on
FT_Face.
(read_paint): Initialize and track status of insert_root_transform
flag.
2021-02-10 18:51:04 +01:00
Werner Lemberg 324612ceb2 Always provide logging API.
It's easier to have stubs if FT_DEBUG_LOGGING is undefined than to
modify `ftexport.sym` conditionally.

Problem reported by Alexei.

* src/base/ftdebug.c: Include `ftlogging.h`.

(FT_Trace_Set_Level, FT_Trace_Set_Default_Level, FT_Set_Log_Handler,
FT_Set_Default_Log_Handler) [!FT_DEBUG_LOGGING]: Provide stubs.
2021-01-31 14:28:44 +01:00
Werner Lemberg c7cc947c0f Minor documentation fixes. 2021-01-23 15:45:10 +01:00
Werner Lemberg b6e8a71266 Update all copyright notices. 2021-01-17 07:18:48 +01:00
Dominik Röttsches 53fea87745 Add config option to test for 'COLR' v1 support in headers.
* include/freetype/config/ftoption.h (TT_SUPPORT_COLRV1): New macro
so that clients can test whether the FreeType checkout that they are
building against supports the 'COLR' v1 API.  This is intended to be
a temporary solution until 'COLR' v1 support is released in a
FreeType version and such a check can be made by using the version
number instead.
2021-01-14 16:06:03 +01:00
Dominik Röttsches d3e95d97a0 [sfnt] Register 'COLR' v1 API in driver (#59703).
* include/freetype/internal/sfnt.h (TT_Get_Color_Glyph_Paint_Func,
TT_Get_Paint_Layers_Func, TT_Get_Colorline_Stops_Func,
TT_Get_Paint_Func): New function pointer types.
(SFNT_Interface): Add them.
(FT_DEFINE_SFNT_INTERFACE): Updated.

* src/sfnt/sfdriver.c (PUT_COLOR_LAYERS_V1): New macro.
(sfnt_interface): Add new function pointers.
2021-01-14 15:56:04 +01:00
Dominik Röttsches 08dba4dc35 Add new methods required for 'COLR' v1 to public API (#59703).
* include/freetype/freetype.h (FT_Get_Color_Glyph_Paint): New method
for retrieving the root paint object for a color glyph by specifying
a glyph ID.
(FT_Get_Paint_Layers): New method for retrieving the layers of a
`PaintColorGlyph`.
(FT_Get_ColorLine_Stops): New method for retrieving the stops of a
color.
(FT_Get_Paint): New method for resolving an `FT_OpaquePaint` into an
`FT_COLR_Paint` object.
2021-01-14 15:50:37 +01:00
Dominik Röttsches f57c24db63 Add types required for 'COLR' v1 to public API (#59703).
* include/freetype/freetype.h (FT_PaintFormat, FT_ColorStopIterator,
FT_ColorIndex, FT_ColorStop, FT_PaintExtend, FT_ColorLine,
FT_Affine23, FT_CompositeMode, FT_OpaquePaint, FT_PaintColrLayers,
FT_PaintSolid, FT_PaintLinearGradient, FT_PaintRadialGradient,
FT_PaintGlyph, FT_PaintColrGlyph, FT_PaintTransformed,
FT_PaintTranslate, FT_PaintRotate, FT_PaintSkew, FT_PaintComposite,
FT_COLR_Paint): Adding structs and enum to represent paint format,
color stop information, gradient extend information, structs to
reference paint offsets, and to define transforms and compositions.
Adding a union type to represent the union of the structs,
distinguished by `FT_PaintFormat`.
2021-01-14 15:47:34 +01:00
Werner Lemberg cbc14b10e6 Fix ABI incompatibility.
* include/freetype/ftimage.h (FT_Pixel_Mode): Don't insert
`FT_PIXEL_MODE_GRAY16' but append it.

* src/base/ftobjs.c (pixel_modes): Updated.
2021-01-07 10:13:15 +01:00
Alexei Podtelezhnikov 6369058eee [dlg] Move the headers to include/dlg to simplify their use.
* autogen.sh, builds/toplevel.mk: Copy headers to incluide/dlg.
* builds/freetype.mk, builds/windows/vc2010/freetype.vcxproj:
Simplify included path.
* include/freetype/internal/ftdebug.h: Simplify #include.
* src/dlg/rules.mk, .gitignore: Updated.
2021-01-07 00:13:23 -05:00
Werner Lemberg bca740d566 Typo. 2020-12-26 08:55:49 +01:00
Werner Lemberg b6c8542dfc * src/base/ftobjs.c (pixel_modes): Updated. 2020-12-26 08:51:46 +01:00
Werner Lemberg aa1b5362d3 [sdf] Fix tracing.
* include/freetype/internal.fttrace.h: Add 'bsdf' component.

* src/sdf/ftbsdf.c, src/sdf/ftsdf.c (FT_COMPONENT): Define.
2020-12-24 08:32:04 +01:00
Anuj Verma c6f394bf7d [sdf] Add 'sdf' module to non-gnumake build systems.
* include/freetype/config/ftmodule.h: Add both the 'sfd' and 'bsfd'
renderers to the list of modules.

* CMakeLists.txt (BASE_SRCS): Add 'sdf' single-object module.
2020-12-24 07:23:48 +01:00
Anuj Verma 879ca87f0b [sdf] Add build infrastructure.
* src/sdf/module.mk, src/sfd/rules.mk: New files.

* src/sdf/ftsdf.h (ft_sdf_raster): New forward declaration.

* include/freetype/ftmoderr.h (FT_MODERRDEF): Add error definition
for the 'sdf' module.

* include/freetype/internal/fttrace.h (FT_TRACE_DEF): Add trace
definition for the `sdf' module.

* modules.cfg (RASTER_MODULES): Add the `sdf' module to the list of
rasterizers.
2020-12-24 07:23:48 +01:00
Anuj Verma ec9b6c314d Add data types required for the forthcoming 'sdf' module.
* include/freetype/freetype.h (FT_Render_Mode): Add new render mode
`FT_RENDER_MODE_SDF`, which will be used to generate SDF.

* include/freetype/ftimage.h (FT_Pixel_Mode): Add new pixel mode
`FT_PIXEL_MODE_GRAY16`, which will be the output of the 'sdf'
module.
(FT_RASTER_FLAG_SDF): New raster flag to be used internally by the
'sdf' module.

* include/freetype/fttypes.h (FT_F6Dot10): New data type.
2020-12-24 07:23:47 +01:00
Werner Lemberg 7bdf386e75 ftmodapi.h: Replace 0xA0 characters with spaces. 2020-12-17 22:47:05 +01:00
Alexei Podtelezhnikov c948df52e4 * include/freetype/ftmodapi.h (FT_FACE_DRIVER_NAME): New public macro.
The driver name is needed for `FT_Property_Set' and `FT_Property_Get'.
2020-12-17 15:53:51 -05:00
Alexei Podtelezhnikov 84b3616c94 Documentation edits. 2020-12-16 22:07:57 -05:00
Chris Liddell f6be92767d [truetype] Fix incremental metrics (#59503).
* src/truetype/ttgload.c (tt_get_metrics, load_truetype_glyph):
Previously, the code would populate the phantom points before
calling the `get_glyph_metrics` callback.  For formats like PCL XL
format 1, class 2 downloaded fonts (where metrics are removed from
the TTF header), this causes problems when the hinting program uses
the phantom points (misplaced and distorted glyphs) due to the
metrics being unset (all zeros).
(tt_get_metrics_incr_overrides): Renamed to...
(tt_get_metrics_incremental): ... this.  Updated caller

* include/freetype/ftincrem.h: Update the documentation to make it
clearer that `get_glyph_metrics` is to retrieve metrics from a
non-standard source, but *not* for the purpose of imposing custom
metrics.
2020-12-16 06:08:54 +01:00
Alexei Podtelezhnikov 9cc89717be Documentation edits. 2020-12-15 22:36:19 -05:00
Werner Lemberg 015a9b8d8f */*: s/FT_LOGGING/FT_DEBUG_LOGGING/. 2020-12-07 10:27:42 +01:00
Werner Lemberg a6adb25626 * src/*: Don't use more than one '\n' in `FT_TRACE` and `FT_ERROR`.
This ensures good logging output, with all lines having a proper
prefix (if requested).
2020-12-05 09:43:45 +01:00
Werner Lemberg fcdab61ed1 [build] Use gcc (and clang) in C99 mode.
Other compilers are unchanged.

* builds/compiler/gcc-dev.mk, builds/compiler/gcc.mk (ANSIFLAGS):
s/-ansi/-std=c99/.

* builds/freetype.mk (FT_CFLAGS): Remove `-std=c99`.

* builds/unix/configure.raw: Handle C99.
Remove no longer needed test for gcc 4.6 and earlier.
2020-12-05 09:43:42 +01:00
Werner Lemberg ce43d808dc [base] Implement vertical alignment of log printing.
Based on a patch by Priyesh.

* include/freetype/internal/fttrace.h (FT_MAX_TRACE_LEVEL_LENGTH):
New macro.

* src/base/ftdebug.c, builds/windows/ftdebug.c (ft_log_handler):
Print logs after a fixed width to handle different lengths of
`FT_COMPONENT` entries.
Use `ft_strrchr` to check for final newline character.
2020-12-04 16:19:42 +01:00
Priyesh Kumar 2a46d1f04e [base] Add public API to change log handling function.
* include/freetype/ftlogging.h (FT_Custom_Log_Handler): New function
typedef to store the custom callback logging function.
(FT_Set_Log_Handler, FT_Set_Default_Log_Handler): New functions to
set and reset custom log handler.

* include/freetype/internal/ftdebug.h (custom_output_handler): New
variable to support a custom callback logging function.
(FT_Logging_Callback): A new function typedef to print log using
custom callback logging function, which is set using
`FT_Set_Log_Handler`.
(FT_Log): Use it.

* src/base/ftdebug.c (FT_Set_Log_Handler,
FT_Set_Default_Log_Handler, FT_Logging_Callback): Add function
definitions.
2020-12-04 16:19:36 +01:00
Priyesh Kumar 5fea76cf0f [base] Add public API to change the levels of tracing components.
* include/freetype/ftlogging.h: New header file.

* include/freetype/internal/ftdebug.h [FT_LOGGING]: Include
`ftlogging.h`.

* src/base/ftdebug.c (ft_custom_trace_level): New variable.
(ft_debug_init): Update to support change of levels of tracing
components of FreeType at run-time.
(FT_Trace_Set_Level): New function to change the levels of tracing
components at run-time.
(FT_Trace_Set_Default_Level): New function to reset the levels of
tracing components back to default.
2020-12-01 09:25:53 +01:00
Priyesh Kumar d00cbc3f90 [base] Updates to print timestamp and name of `FT_COMPONENT` in logs.
* include/freetype/internal/ftdebug.h (FT_LOGGING_TAG,
FT_LOGGING_TAG_): New macros to resolve the value of `FT_COMPONENT'
into a string.
(ft_add_tag, ft_remove_tag): New functions to add and remove dlg tags.

* src/base/ftdebug.c: Add new variables to control the logging of
timestamp and name of `FT_COMPONENT` along with actual logs.
(ft_add_tag, ft_remove_tag): Add function definitions.
(ft_log_handler): Updates to print timestamp and name of
`FT_COMPONENT`.
(ft_debug_init) [FT_LOGGING]: Users can now control the logging of
timestamp and name of `FT_COMPONENT` by adding tags in the
`FT2_DEBUG` environment variable.
2020-12-01 09:25:53 +01:00
Priyesh Kumar d46bada285 [base] Add functions and variables to print logs to a file.
* include/freetype/internal/ftdebug.h: Added dlg's header files.
(FT_LOG): New macro to redirect trace logs to dlg's API's whenever
`FT_LOGGING' is defined.
(ft_logging_init, ft_logging_deinit): New functions to handle
initialization and uninitialization of logging related variables.
(ft_log_handler): New function to handle logs of FreeType.

* src/base/ftdebug.c: Add necessary logging related variables.
(ft_logging_init, ft_logging_deinit, ft_log_handler): Add function
definitions.

* src/base/ftinit.c (FT_Init_FreeType) [FT_LOGGING]: Call
`ft_logging_init`.
(FT_Done_FreeType) [FT_LOGGING]: Call `ft_logging_deinit`.

* src/base/ftobjs.c (FT_New_Library): Call `ft_debug_init` only if
`FT_LOGGING` is not defined.
2020-12-01 09:25:39 +01:00
Priyesh Kumar 34b1c897c1 [builds] Necessary changes to make 'dlg' compile.
* autogen.sh (copy_submodule_files): New script to copy all the
necessary source and include files from `submodules/dlg` to
`src/dlg`.

* src/dlg/dlgwrap.c: New wrapper file for `src/dlg.c`.  It enables
the build of 'dlg' if the `FT_LOGGING` macro is defined.

* src/dlg/rules.mk: New sub-Makefile.

* builds/freetype.mk (DLG_DIR): New variable to include the
header files of the 'dlg' library.
(INCLUDES): Add `DLG_DIR`.
(FT_CFLAGS): Add `-std=c99' flag.
Include `src/dlg/rules.mk` file to build 'dlg' library.
(OBJ_S, OBJ_M): Add `DLG_OBJS_M` and `DLG_OBJS_S`.

* builds/toplevel.mk: For builds directly from the git repository
we need to copy files from `submodule/dlg` to `src/dlg`.

* include/freetype/config/ftoption.h, devel/ftoption.h (FT_LOGGING):
New macro to enable or disable the logging facility in FreeType.
2020-12-01 09:20:32 +01:00
Jan Alexander Steffens (heftig) 22bb0660a3 Fix documentation build.
The empty line after `* @description:` caused the refdoc build to fail,
see

  https://github.com/freetype/docwriter/issues/77
2020-11-03 22:36:29 +01:00
Alexei Podtelezhnikov b049cadeb1 Mention external modules. 2020-11-02 14:26:44 -05:00
Werner Lemberg 6fca2e5b1b Minor clean-ups of last commit. 2020-10-31 06:52:18 +01:00
Alexei Podtelezhnikov 681c7e2387 Better scan converter documentation. 2020-10-30 23:03:12 -04:00
Alexei Podtelezhnikov 5cbd052dfb Add preamble. 2020-10-30 13:53:17 -04:00
Werner Lemberg e9a7015ec8 Avoid non-ASCII character in public header file. 2020-10-30 08:29:38 +01:00
Werner Lemberg 101e62a286 ftimage.h: Improve description of `FT_Span`.
From Piotr Grochowski <piotrunio-2004@wp.pl>.
2020-10-30 08:07:53 +01:00
Werner Lemberg 6a2b3e4007 * Version 2.10.4 released.
==========================

Tag sources with `VER-2-10-4'.

* docs/VERSION.TXT: Add entry for version 2.10.4.
* 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.10.3/2.10.4/, s/2103/2104/.

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

* builds/unix/configure.raw (version_info): Set to 23:4:17.
* CMakeLists.txt (VERSION_PATCH): Set to 4.
2020-10-20 07:13:33 +02:00
Alexei Podtelezhnikov 82d331556c Unnest markdown. 2020-10-11 21:56:50 -04:00
Werner Lemberg 337670af0a * Version 2.10.3 released.
==========================

Tag sources with `VER-2-10-3'.

* docs/VERSION.TXT: Add entry for version 2.10.3.

* 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.10.2/2.10.3/, s/2102/2103/.

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

* builds/unix/configure.raw (version_info): Set to 23:3:17.
* CMakeLists.txt (VERSION_PATCH): Set to 3.
2020-10-10 18:14:57 +02:00
Werner Lemberg c9f588be56 Document changes to last release. 2020-10-10 12:48:18 +02:00
Alexei Podtelezhnikov ab6a21b733 Documentation updates. 2020-09-18 22:32:20 -04:00
Alexei Podtelezhnikov d8228a0070 Improve FT_Outline_Render docs. 2020-08-28 22:28:47 -04:00
Alexei Podtelezhnikov f9f6adb625 [truetype] Retain OVERLAP_SIMPLE and OVERLAP_COMPOUND.
For glyphs with OVERLAP_SIMPLE or OVERLAP_COMPOUND, set
FT_OUTLINE_OVERLAP to render them with direct oversampling, which
mitigates artifacts (see 3bb512bc9f).

* include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): Redefine to rhyme
with OVERLAP_SIMPLE.
* src/base/ftgloadr.c (FT_GlyphLoader_Rewind): Reset outline flags.
* src/truetype/ttgload.c
(TT_Load_Simple_Glyph): Retain OVERLAP_SIMPLE.
(load_truetype_glyph): Retain OVERLAP_COMPOUND.
2020-08-05 08:24:15 -04:00
Werner Lemberg 8b3601324f Minor typos, formatting. 2020-08-04 10:48:42 +02:00
Alexei Podtelezhnikov 986a340dd5 Unbreak compilation. 2020-07-28 23:20:59 -04:00
Alexei Podtelezhnikov f76f7fdecd Hide internal functions with SunPro.
* include/freetype/internal/compiler-macros.h
(FT_INTERNAL_FUNCTION_ATTRIBUTE) <__SUNPRO_C>: Define as __hidden.
2020-07-28 23:13:51 -04:00
Anuj Verma 3273521f40 Fix static compilation with Visual C.
* include/freetype/internal/compiler-macros.h
(FT_INTERNAL_FUNCTION_ATTRIBUTE) <_WIN32>: Define as empty.
2020-07-28 18:34:37 +02:00
Werner Lemberg fffc303a7f Formatting, improving comments. 2020-07-28 18:33:15 +02:00
Werner Lemberg b7c467b6ef [doc] Stem darkening is off by default for CFF driver.
Bug reported by Ishi Tatsuyuki <ishitatsuyuki@gmail.com>.
2020-07-15 09:15:25 +02:00
David Turner 5fe7c044c2 freetype.h (FT_Set_Transform): Minor documentation update.
In order to mention the limited accuracy of `FT_Matrix' coefficients
and encourage client code to perform the transform themselves with
floating point values instead.
2020-07-14 16:25:59 +02:00
Ben Wagner b1286b32a9 Document `FT_Face_Rec_::box' with variable fonts (#54969).
As pointed out in the "Note:" in the section of

  https://docs.microsoft.com/en-us/typography/opentype/spec/otvaroverview#variation-data-tables-and-miscellaneous-requirements

  ... the xMin, yMin, xMax, yMax, macStyle and lowestRecPPEM fields in
  the font header ('head') table are not supported by variation data and
  should only be used in relation to the default instance for the font.

Document that `FT_Face_Rec_::box' does not vary with OpenType variable
fonts.
2020-07-10 18:07:11 +02:00
Werner Lemberg 96fb73efd5 Fix clang warnings.
* include/freetype/internal/autohint.h
(FT_DECLARE_AUTOHINTER_INTERFACE): New macro.
* src/autofit/afmodule.h: Use it to declare
`af_autofitter_interface'.

* include/freetype/internal/ftobjs.h (FT_DECLARE_GLYPH): New macro.
* src/base/ftbase.h: Use it to declare `ft_bitmap_glyph_class' and
`ft_outline_glyph_class'.

* src/base/ftglyph.c: Include `ftbase.h'.

* src/cff/cffparse.c (cff_parser_run): Fix type of `t2_size'.

* src/pcf/pcfdrivr.c (pcf_cmap_char_next): Fix type of `result'.

* src/psaux/psauxmod.c (psaux_module_class): Use `FT_DEFINE_MODULE'.
* src/psaux/psauxmod.h: Declare `afm_parser_funcs',
`t1_cmap_classes', `cff_decoder_funcs', and `psaux_module_class'.

* src/pshinter/pshmod.c: Include `pshmod.h'.

* src/sfnt/sfwoff2.c (ROUND4, WRITE_SHORT): Fix implicit sign
conversion.
(compute_ULong_sum): Fix return type.
Fix implicit sign conversion.
(store_points): Fix type of `last_flag', `repeat_count', and `flag'.
Use casts to avoid warnings.
(reconstruct_glyf): Fix implicit sign conversion.
Use cast to avoid warning.
(get_x_mins): Fix implicit sign conversion.
* src/sfnt/ttcmap.c: Undef `TTCMAPCITEM'.
* src/sfnt/ttcmap.h: Define `TTCMAPCITEM' and include `ttcmapc.h' to
declare cmap classes.

* src/smooth/ftsmooth.c (ft_smooth_overlap_spans): Use cast.

* src/truetype/ttinterp.c (Ins_MIAP): Fix typo.
2020-07-07 16:58:14 +02:00
David Turner 0f35b042e0 [build] Really fix multi and C++ builds.
The following builds were still failing due to previous changes:

  make multi
  make multi CC="c++"
  make CC="c++"

This patch fixes the issues, which were missing includes to get the
right macro definitions in multi-build mode.

Also, `FT_UNUSED' is actually used by third-party code, so move it
back to `public-macros.h' to avoid breaking it.

* include/freetype/config/public-macros.h (FT_EXPORT): Remove
special definition for C++.
(FT_UNUSED): Define here instead of...
* include/freetype/config/compiler-macros.h: ... here.
(FT_FUNCTION_DECLARATION): Remove special definition for C++.
(FT_LOCAL_ARRAY_DEF): Fix definition.

* src/cache/ftccback.h, src/lzw/ftzopen.h, src/gxvalid/gxvmort.h,
src/gxvalid/gxvmorx.h: Add `FT_BEGIN_HEADER' and `FT_END_HEADER'.
2020-07-07 06:51:09 +02:00
David Turner cb4a943bc4 [build] Fix multi and C++ builds.
The following builds were failing due to previous changes:

  make multi
  make multi CC="c++"

* include/freetype/config/ftconfig.h: Remove `FT_END_HEADER'.

* include/freetype/config/ftheader.h (FT_BEGIN_HEADER,
FT_END_HEADER): Protect against redefinition.

* src/cache/ftccache.h, src/cache/ftcmru.h, src/pcf/pcfutil.h,
src/psaux/pserror.h, src/psaux/psft.h, src/psaux/psstack.h,
src/sfnt/woff2tags.h: Include `compiler-macros.h'.

* src/sfnt/woff2tags.c: Include `woff2tags.h'.
2020-07-06 11:49:00 +02:00
David Turner b0667d2d36 [build] Improve visibility support of library function names.
* include/freetype/config/public-macros.h
(FT_PUBLIC_FUNCTION_ATTRIBUTE): New macro to tag functions as
public (and thus exportable).
(FT_EXPORT): Use it.

* include/freetype/config/compiler-macros.h
(FT_INTERNAL_FUNCTION_ATTRIBUTE): New macro to tag functions as
internal to the library (and thus hidden).  Note that on ELF
systems, all internal functions have hidden visibility, which avoids
the need to enforce this when invoking the compiler (e.g., with an
option like `-fvisibility=hidden').

(FT_FUNCTION_DECLARATION, FT_FUNCTION_DEFINITION): New base macros
to deal with C and C++ linkage issues at the same time.

(FT_LOCAL, FT_LOCAL_DEF, FT_LOCAL_ARRAY, FT_LOCAL_ARRAY_DEF,
FT_BASE, FT_BASE_DEF, FT_EXPORT_VAR, FT_BASE_CALLBACK,
FT_BASE_CALLBACK_DEF): Redefined using new macros.
2020-07-05 11:03:23 +02:00
David Turner bb66c8d8cf [build] Split off more stuff from `ftconfig.h'.
* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off macro definitions
required by the FreeType API headers to...
* include/freetype/config/public-macros.h: ...this new file.

* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off macro definitions used
by the library but not to be exposed to clients to...
* include/freetype/config/compiler-macros.h: ...this new file.

* include/freetype/internal/*.h, src/raster/ftraster.h: Include
`compiler-macros.h' where needed.
2020-07-05 10:42:23 +02:00
David Turner 0322efb5e5 [build] Move mac support code to `mac-support.h'.
* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off mac-specific stuff
to...
* include/freetype/config/mac-support.h: ...this new file.

* CMakeLists.txt, builds/unix/configure.raw: Remove `/undef ->
#undef' string replacement; the affected code is no longer part of
the `ftconfig.h' template.
2020-07-05 09:59:29 +02:00
David Turner bd7251ac97 [build] Put integer type definitions into `integer-types.h'.
Refactor some of the `ftconfig.h' headers and template to move the
definition of the FreeType integer types (e.g., `FT_Int16') to a
common header file `freetype/config/integer-types.h'.

* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off integer type
definition stuff to...
* include/freetype/config/integer-types.h: ...this new file.

* builds/unix/ftconfig.h.in: Control the definition of
`FT_SIZEOF_INT' and `FT_SIZEOF_LONG' with macro
`FT_USE_AUTOCONF_SIZEOF_TYPES'.  If these are not defined, auto
detection happens in `integer-types.h' as usual based on `INTXX_MAX'
values.  Otherwise the autoconf-detected values are used.

* builds/unix/configure.raw (CPPFLAGS): Don't include path to
`config' directory.  Instead, ...
(FT_CONFIG_STANDARD_LIBRARY_H): Use complete path.
2020-07-05 09:52:23 +02:00
Alexei Podtelezhnikov 3bb512bc9f [smooth] Introduce direct oversampling for overlaps.
This implements oversampling to metigate artifacts in pixels partially
covered by overlapping contours.  It turns out that the 4x4
oversampling is sufficient but, at least, quadruples the rendering
time.  The outline has to set FT_OUTLINE_OVERLAP to use this method.

* include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): New flag.
* src/smooth/ftsmooth.c (ft_smooth_render): Check it to...
(ft_smooth_raster_overlap): ... inflate outline and set up direct
rendering for oversampling with...
(ft_smooth_overlap_spans): ... new span function that integrates them.
2020-07-03 22:29:34 -04:00
Alexei Podtelezhnikov de088b1dfd Simplify unused macro. 2020-06-19 22:46:30 -04:00
Werner Lemberg 1658685967 Remove redundant inclusion of `ft2build.h'.
* */*: Remove `#include <ft2build.h>' where possible.

* include/freetype/freetype.h: Remove cpp error about missing
inclusion of `ft2build.h'.
2020-06-13 21:15:45 +02:00
David Turner e13391333f Make macros for header file names optional.
We no longer have to take care of the 8.3 file name limit; this
allows us (a) to introduce longer, meaningful file names, and (b) to
avoid macro names in `#include' lines altogether since some
compilers (most notably Visual C++) doesn't support this properly.

*/*: Replace

   #include FOO_H

with

   #include <freetype/foo.h>

or something similar.  Also update the documentation.
2020-06-08 13:31:55 +02:00
David Turner 4eee13404d Remove Jamfile files from the tree.
These have not been used in a very, very long time, so better remove
them.  A corresponding patch will be submitted to the
`freetype2-demos' repository.

* src/Jamfile, src/*/Jamfile, Jamrules: Delete.
2020-05-18 17:56:06 +02:00