Commit Graph

79 Commits

Author SHA1 Message Date
Priyeshkkumar b528826f69 Merging master branch with priyeshLogLibrary branch 2020-07-28 13:43:28 +05:30
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
Werner Lemberg e5038be704 Update all copyright notices. 2020-01-19 17:05:19 +01:00
Alexei Podtelezhnikov e13c1f46dc Solidify VC2005 builds.
* include/freetype/internal/ftcalc.h (FT_MSB) [_MSC_VER]: Explicitly
declare `_BitScanReverse' intrinsic.
* builds/windows/visualc/freetype.vcproj [Debug]: Disable intrinsics.
2019-05-31 22:31:47 -04:00
Werner Lemberg 7585997024 Update all copyright notices. 2019-02-23 10:07:09 +01:00
Werner Lemberg f686ad46a3 Update copyright years. 2019-01-22 20:31:44 +01:00
Nikhil Ramakrishnan ae5d1a4cec * include/*.*: Convert comments to markdown.
This commit was created by applying scripts `markify.py' and
`markdown-format.bash' to all C header files, followed by minor
clean-up.

No change in functionality, of course.

Scripts used:
https://github.com/nikramakrishnan/freetype-docs.git: Commit dfce31e.

http://lists.nongnu.org/archive/html/freetype-devel/2018-08/msg00013.html:
With patches applied.
2018-08-25 16:16:56 +05:30
Werner Lemberg 77f0814a31 Add macros for handling over-/underflowing `FT_Int64' values.
* include/freetype/internal/ftcalc.h (ADD_INT64, SUB_INT64,
MUL_INT64, DIV_INT64) [FT_LONG64]: New macros.

* src/base/ftcalc.c (ft_corner_orientation) [FT_LONG64]: Use
`SUB_INT64' and `MUL_INT64'.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10028
2018-08-23 17:53:54 +02:00
Armin Hasitzka fda356b742 * include/freetype/internal/ftcalc.h: Add macros for handling
harmless over-/underflowing `FT_Int' values.

* src/sfnt/sfdriver.c (fixed2float): Fix negation of
`(int)(-2147483648)'.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9423
2018-07-16 18:45:23 +02:00
Werner Lemberg 396051daee s/xxx specific foo/xxx-specific foo/. 2018-07-02 15:52:36 +02:00
Werner Lemberg cc3333902b New base function `FT_Matrix_Check' (#54019).
* src/base/ftcalc.c (FT_Matrix_Check): New base function to properly
reject degenerate font matrices.

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

* src/cff/cffparse.c (cff_parse_font_matrix), src/cid/cidload.c
(cid_parse_font_matrix), src/type1/t1load.c (t1_parse_font_matrix),
src/type42/t42parse.c (t42_parse_font_matrix): Use
`FT_Matrix_Check'.
2018-06-24 06:26:09 +02:00
Nikhil Ramakrishnan e13599a036 Change documentation markup tags to lowercase.
Implemented as per discussion in

  http://lists.nongnu.org/archive/html/freetype-devel/2018-06/msg00073.html

No change in functionality, of course.
2018-06-18 03:40:29 +05:30
Werner Lemberg f999375a9a [GSoC] include/*.*, devel/*.*: Convert block comments to `light' style.
This second and final monster commit was created by applying Nikhil's
scripts `docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.

No change in functionality, of course.

I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
2018-06-03 22:00:42 +02:00
Alexei Podtelezhnikov 2f218a4c3a * include/freetype/internal/ftcalc.h (FT_MSB): Verified `_MSC_VER'.
Actually `_BitScanReverse' is available since VS2005.
2018-05-18 08:57:30 -04:00
Werner Lemberg 840b844301 * include/freetype/internal/ftcalc.h (FT_MSB): Use `_MSC_VER' value.
Older VC versions don't provide `_BitScanReverse'.  We test for VC
2013.

Reported by John Emmas <john@creativepost.co.uk>.
2018-05-18 10:57:51 +02:00
Werner Lemberg 2cac1c3542 s/inline/__inline/ for MSVC.
Reported by John Emmas <john@creativepost.co.uk>.

* include/freetype/internal/ftcalc.h (FT_MSB) [_MSC_VER]: Do it.
2018-05-17 19:40:44 +02:00
Arkady Shapkin 84eebf4802 Use MS VC++'s _BitScanReverse to calculate MSB (patch #9636).
* include/freetype/internal/ftcalc.h (FT_MSB) [_MSC_VER]: Implement
it.
2018-05-12 06:18:07 +02:00
Werner Lemberg 0a0c22569d Update copyright year. 2018-01-02 09:33:57 +01:00
Ben Wagner 7819aeb622 Avoid Microsoft compiler warnings (#51331).
While clang's sanitizer recommends a cast to unsigned for safe
negation (to handle -INT_MIN), both MSVC and Visualc emit warning
C4146 if an unsigned value gets negated.

* include/freetype/internal/ftcalc.h (NEG_LONG, NEG_INT32),
src/base/ftcalc.c (FT_MOVE_SIGN): Replace negation with a
subtraction.
2017-06-28 22:57:41 +02:00
Werner Lemberg faf34d29e2 Remove unused macros.
* include/freetype/internal/ftcalc.h (ADD_INT, SUB_INT, MUL_INT,
NEG_INT): Deleted.
2017-06-09 20:31:24 +02:00
Werner Lemberg dcd8de272f */*: Remove `OVERFLOW_' prefix.
This increases readability.
2017-06-09 11:21:58 +02:00
Werner Lemberg c5a225413f ftcalc.h: Avoid left-shift of negative numbers.
Reported as

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

* include/freetype/internal/ftcalc.h (INT_TO_F26DOT6,
INT_TO_F2DOT14, INT_TO_FIXED, F2DOT14_TO_FIXED): Use multiplication.
2017-06-03 06:13:10 +02:00
Werner Lemberg e66d7300fe [cff] 32bit integer overflow run-time errors 2/2 (#46149).
This commit handles the new engine.

* include/freetype/internal/ftcalc.h (OVERFLOW_ADD_INT32,
OVERFLOW_SUB_INT32, OVERFLOW_MUL_INT32, NEG_INT, NEG_LONG,
NEG_INT32): New macros.

* src/cff/cf2ft.c (cf2_getScaleAndHintFlag): Use OVERFLOW_ADD_INT32.

* src/cff/cf2hints.c (cf2_getWindingMomentum, cf2_hint_init,
cf2_hintmap_map, cf2_glyphpath_hintPoint,
cf2_glyphpath_computeIntersection, cf2_glyphpath_computeOffset,
cf2_glyphpath_lineTo, cf2_glyphpath_curveTo): Use
OVERFLOW_ADD_INT32, OVERFLOW_SUB_INT32, OVERFLOW_MUL_INT32, and
NEG_INT32 where appropriate.

* src/cff/cf2intrp.c (cf2_doFlex, cf2_doBlend,
cf2_interpT2CharString): Ditto.
Also add some other code where needed to avoid overflow.
2017-05-31 16:16:50 +02:00
Werner Lemberg fbe2fe4c75 Handle some integer overflow run-time errors (#46149, #48979).
This commit (mainly for 32bit CPUs) is the first of a series of
similar commits to handle known integer overflows.  Basically, all
of them are harmless, since they affect rendering of glyphs only,
not posing security threats.  It is expected that fuzzying will show
up more overflows, to be fixed in due course.

The idea is to mark places where overflows can occur, using macros
that simply cast to unsigned integers, because overflow arithmetic
is well defined in this case.  Doing so suppresses run-time errors
of sanitizers without adding computational overhead.

* include/freetype/internal/ftcalc.h (OVERFLOW_ADD_INT,
OVERFLOW_SUB_INT, OVERFLOW_MUL_INT, OVERFLOW_ADD_LONG,
OVERFLOW_SUB_LONG, OVERFLOW_MUL_LONG): New macros.

* src/base/ftcalc.c (FT_RoundFix, FT_CeilFix, FT_Matrix_Multiply,
FT_Matrix_Multiply_Scaled, FT_Vector_Transform_Scaled,
ft_corner_orientation): Use new macros.

* src/base/ftoutln.c (FT_Outline_Get_Orientation): Use new macros.
2017-05-29 13:29:28 +02:00
Werner Lemberg 9d04fa7015 * include/freetype/internal/ftcalc.h (FLOAT_TO_FIXED): Remove.
This macro is not used.
2017-05-28 07:57:24 +02:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg 37412ff9f4 Don't use macro names that contain `__' [1/2].
Such macro names are reserved for both C and C++.

*/*: Replace macros of the form `__XXX_H__' with `XXX_H_'.
2016-01-12 21:37:13 +01:00
Werner Lemberg 663f2d7a23 * include/freetype/internal/ftcalc.h: Don't use `register' keyword.
This fixes compiler warnings.

Reported by Behdad.
2015-11-21 06:30:43 +01:00
Werner Lemberg eb1bba9be4 Fix some clang compiler warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY), src/cff/cf2intrp.c
(cf2_interpT2CharString), src/truetype/ttgload.c
(load_truetype_glyph), src/truetype/ttgxvar.c (tt_handle_deltas),
src/truetype/ttinterp.c (Ins_INSTCTRL): Fix signedness issues.
2015-06-30 09:46:39 +02:00
Alexei Podtelezhnikov 884e4e67ee [base] Implement fast vector normalization.
The function uses Newton's iterations instead of dividing vector
components by its length, which needs a square root. This is,
literally, a bit less accurate but a lot faster.

* src/base/ftcalc.c (FT_Vector_NormLen): New function.
2015-06-29 22:32:05 -04:00
Werner Lemberg 392cf22f8a Another adjustment to header locations.
This change is a result of a discussion thread on freetype-devel

  http://lists.nongnu.org/archive/html/freetype-devel/2015-06/msg00041.html

Re-introduce the `freetype2' subdirectory for all FreeType header
files after installation, and rename the `freetype2' subdirectory in
the git repository to `freetype'.

* include/freetype2: Renamed to...
* include/freetype: This.

* CMakeLists.txt (PUBLIC_HEADERS, PUBLIC_CONFIG_HEADERS,
PRIVATE_HEADERS): Updated.
Update creation of `ftconfig.h'.
Install generated `ftconfig.h'.

* Jamfile (HDRMACRO, RefDoc), autogen.sh: Updated.

* builds/amiga/include/config/ftconfig.h, builds/freetype.mk
(PUBLIC_DIR), builds/symbian/bld.inf, builds/toplevel.mk (work),
builds/unix/freetype2.in: Updated.

* builds/unix/freetype-config.in: Updated.
* builds/unix/configure.raw: Don't check for `rmdir'.
* builds/unix/unix-def.in (DELDIR): Use `rm -rf', which is portable
according to the autoconf info manual.
* builds/unix/install.mk (install, uninstall,
distclean_project_unix): Update and simplify.

* builds/wince/*, builds/windows/*: Updated.

* devel/ft2build.h, include/ft2build.h: Updated.

* include/freetype2/config/ftheader.h,
include/freetype2/internal/ftserv.h,
include/freetype2/internal/internal.h: Update all header file
macros.

* src/tools/chktrcmp.py (TRACE_DEF_FILES): Updated.

* docs/*: Updated.
2015-06-26 06:48:00 +02:00
Werner Lemberg fae3820764 Simplify header file hierarchy.
This large patch changes the header file directory layout from
`include/freetype/...' to `include/...', effectively removing one
level.  Since the file `ft2build.h' is also located in `include'
(and it stays there even after installation), all FreeType header
files are now in a single directory.

Applications that use (a) `freetype-config' or FreeType's
`pkg-config' file to get the include directory for the compiler, and
(b) the documented way for header inclusion like

  #include <ft2build.h>
  #include FT_FREETYPE_H
  ...

don't need any change to the source code.

* include/freetype/*: Move up to...
* include/*: ... this directory.

* builds/amiga/include/freetype/*: Move up to...
* builds/amiga/include/*: ... this directory.

*/*: Essentially do `s@/freetype/@/@' where appropriate.

* CMakeList.txt: Simplify.
* builds/unix/freetype-config.in, builds/unix/freetype2.in: For
`--cflags', return a single directory.
* builds/unix/install.mk (install): No longer try to remove `cache'
and `internal' subdirectories; instead, remove the `freetype'
subdirectory.
2013-11-13 08:55:46 +01:00
Werner Lemberg bcd8c0b0eb Remove `FT_SqrtFixed' function.
It's no longer used.

* include/freetype/internal/ftcalc.h, src/base/ftcalc.c: Do it.
2013-08-27 21:36:03 +02:00
Werner Lemberg f6aa089f12 */* [FT_CONFIG_OPTION_OLD_INTERNALS]: Remove macro and guarded code. 2013-05-10 07:58:47 +02:00
Werner Lemberg 4cd5fd463e Remove trailing whitespace. 2013-01-24 13:33:06 +01:00
Werner Lemberg e9f330adf6 [base] Make `FT_Hypot' really internal.
* include/freetype/fttrigon.h (FT_Hypot): Move to...
* include/freetype/internal/ftcalc.h: This file.

* src/base/fttrigon.c (FT_Hypot): Move to...
* src/base/ftcalc.c: This file.
Include FT_TRIGONOMETRY_H.

* src/truetype/ttgload.c: Don't include FT_TRIGONOMETRY_H.
2013-01-24 09:12:56 +01:00
Alexei Podtelezhnikov 869fb8c49d [base] Split out MSB function.
* src/base/fttrigon.c (ft_trig_prenorm): Borrow from here.
* include/freetype/internal/ftcalc.h (FT_MSB): Declare here.
* src/base/ftcalc.c (FT_MSB): Define here.
2013-01-23 19:43:28 -05:00
Alexei Podtelezhnikov a692170a23 Call it fixed-point. 2013-01-12 19:17:05 -05:00
Werner Lemberg 83c0ebabc2 Fix conditional compilation.
* include/freetype/internal/ftcalc.h (FT_MulDiv_No_Round): Don't
enclose with `TT_USE_BYTECODE_INTERPRETER'; we now need the function
elsewhere also.

* src/autofit/afcjk.h: Use AF_CONFIG_OPTION_CJK.

* src/truetype/ttgload.c (tt_loader_init): Fix compiler warning.

* src/truetype/ttinterp.c (Ins_MSIRP): Fix compiler warning.

* src/truetype/ttinterp.h: Use
TT_CONFIG_OPTION_BYTECODE_INTERPRETER.
2012-06-27 08:16:06 +02:00
Werner Lemberg f1ec084292 s/maximal/maximum/ everywhere, s/minimal/minimum/ where appropriate. 2012-03-11 13:48:25 +01:00
Werner Lemberg f79df78a53 Code beautification.
* src/type1/t1load.c (FT_INT_TO_FIXED): Removed.
Replace everywhere with INT_TO_FIXED.
(FT_FIXED_TO_INT): Move to ...
* include/freetype/internal/ftcalc.h (FIXED_TO_INT): Here.
Update all users.
2009-06-21 20:17:01 +02:00
Werner Lemberg e6e6eade04 Finish fix of scaling bug of CID-keyed CFF subfonts.
* include/freetype/internal/ftcalc.h, src/base/ftcalc.c
(FT_Matrix_Multiply_Scaled, FT_Vector_Transform_Scaled): New
functions.

* src/cff/cffobjs.h (CFF_Internal): New struct.  It is used to
provide global hinting data for both the top-font and all subfonts
(with proper scaling).

* src/cff/cffobjs.c (cff_make_private_dict): New function, using
code from `cff_size_init'.
(cff_size_init, cff_size_done, cff_size_select, cff_size_request):
Use CFF_Internal and handle subfonts.
(cff_face_init): Handle top-dict and subfont matrices correctly;
apply some heuristic in case of unlikely matrix concatenation
results.  This has been discussed with people from Adobe (thanks
goes mainly to David Lemon) who confirm that the CFF specs are fuzzy
and not correct.

* src/cff/cffgload.h (cff_decoder_prepare): Add `size' argument.

* src/cff/cffgload.c (cff_builder_init): Updated.
(cff_decoder_prepare): Handle hints globals for subfonts.
Update all callers.
(cff_slot_load): Handling scaling of subfonts properly.

* src/cff/cffparse.c (cff_parse_fixed_dynamic): New function.
(cff_parse_font_matrix): Use it.

* src/cff/cfftypes.h (CFF_FontDictRec): Make `units_per_em'
FT_ULong.

* docs/CHANGES: Document it.
2008-05-14 23:05:38 +00:00
Werner Lemberg 111b5aefca * src/base/ftcalc.c: Don't use `long long' but `FT_Int64'.
Formatting
2006-11-03 09:40:12 +00:00
David Turner effd15de89 - merging af_corner_XXX and psh_corner_XXX functions into ft_corner_XXX versions in ftcalc.c
- more auto-fitter debugging support
2006-11-02 17:21:02 +00:00
David Turner 6aa260ce61 support for "automatic unpatented hinting" added
we still need to determine the list of "trick" CJK fonts
that are going to toggle the bytecode interpreter instead
of the auto-hinter
2006-08-25 22:45:13 +00:00
Werner Lemberg 8e6f8c4d79 Formatting, copyright years, documentation improvements. 2006-02-17 08:07:09 +00:00
David Turner cda2d957dc * builds/amiga/src/base/ftsystem.c, devel/ftoption.h
include/freetype/ftcache.h, include/freetype/ftoutln.h,
      include/freetype/cache/ftccache.h, include/freetype/cache/ftccmap.h,
      include/freetype/config/ftoption.h, include/freetype/internal/ftcalc.h,
      include/freetype/internal/ftdriver.h,
      include/freetype/internal/ftmemory.h,
      include/freetype/internal/ftobjs.h, include/freetype/internal/ftrfork.h,
      include/freetype/internal/psaux.h, include/freetype/internal/sfnt.h,
      include/freetype/internal/t1types.h, include/freetype/internal/tttypes.h,
      src/base/ftcalc.c, src/base/ftdbgmem.c, src/base/ftobjs.c,
      src/base/ftsystem.c, src/base/ftutil.c, src/bdf/bdfdrivr.c,
      src/cache/ftccache.c, src/cache/ftccback.h, src/cache/ftccmap.c,
      src/cache/ftcmanag.c, src/cff/cffdrivr.c, src/cid/cidriver.c,
      src/pcf/pcfdrivr.c, src/pfr/pfrdrivr.c, src/psaux/psauxmod.c,
      src/sfnt/sfdriver.c, src/truetype/ttdriver.c, src/type1/t1driver.c,
      src/type1/t1objs.c, src/type42/t42drivr.c, src/winfonts/winfnt.c:

    massive changes to the internals to respect the internal object layouts
    and exported functions of FreeType 2.1.7. Note that the cache sub-system
    cannot be fully retrofitted, unfortunately.
2006-02-16 22:45:31 +00:00