diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-01-09 06:16:46 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-01-09 06:16:46 +0000 |
commit | 332064c92a01296b5dd2d25524d0f8286ccdd107 (patch) | |
tree | dd2ed3985a9b4b4915a06f1498f2dfa01c434457 /Build/source/libs/freetype2/freetype-src/src | |
parent | 6156096c6ae42a04e2c3e058f23f48feb17b9bea (diff) |
freetype 2.9.0
git-svn-id: svn://tug.org/texlive/trunk@46256 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src')
416 files changed, 8366 insertions, 5380 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/Jamfile b/Build/source/libs/freetype2/freetype-src/src/Jamfile index c0bc02249c0..562480c94a1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/Jamfile b/Build/source/libs/freetype2/freetype-src/src/autofit/Jamfile index 9a3dc8a4f31..01b866ec61a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/autofit Jamfile # -# Copyright 2003-2017 by +# Copyright 2003-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afangles.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afangles.c index ccdae841362..c65a3ae23e9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afangles.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afangles.c @@ -5,7 +5,7 @@ /* Routines used to compute vector angles with limited accuracy */ /* and very high speed. It also contains sorting routines (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.c index fedeacf7975..61ab7957f0c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.c @@ -7,7 +7,7 @@ /* */ /* Auto-fitter data for blue strings (body). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.cin b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.cin index f9080c54d4e..4913e2eb6f2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.cin +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.cin @@ -4,7 +4,7 @@ /* */ /* Auto-fitter data for blue strings (body). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.dat b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.dat index f62eb82a1ad..d3cc4284b87 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.dat +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.dat @@ -2,7 +2,7 @@ // // Auto-fitter data for blue strings. // -// Copyright 2013-2017 by +// Copyright 2013-2018 by // David Turner, Robert Wilhelm, and Werner Lemberg. // // This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.h index 99ef51cd4ae..56b591aa8df 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.h @@ -7,7 +7,7 @@ /* */ /* Auto-fitter data for blue strings (specification). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.hin b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.hin index 268bcbc531e..682147cb30d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.hin +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.hin @@ -4,7 +4,7 @@ /* */ /* Auto-fitter data for blue strings (specification). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afcjk.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afcjk.c index 897533d148d..21b6bffa332 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afcjk.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afcjk.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for CJK writing system (body). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -16,9 +16,9 @@ /***************************************************************************/ /* - * The algorithm is based on akito's autohint patch, available here: + * The algorithm is based on akito's autohint patch, archived at * - * http://www.kde.gr.jp/~akito/patch/freetype2/ + * https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/ * */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afcjk.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afcjk.h index 84f892f909b..d229c0c9cff 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afcjk.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afcjk.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for CJK writing system (specification). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afcover.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afcover.h index 1b18c666abf..6eeb8fc9fb7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afcover.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afcover.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter coverages (specification only). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afdummy.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afdummy.c index 61c32db5bfb..f30c517cbb3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afdummy.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afdummy.c @@ -5,7 +5,7 @@ /* Auto-fitter dummy routines to be used if no hinting should be */ /* performed (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afdummy.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afdummy.h index ebaa7d76ea2..b382acd92ae 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afdummy.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afdummy.h @@ -5,7 +5,7 @@ /* Auto-fitter dummy routines to be used if no hinting should be */ /* performed (specification). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/aferrors.h b/Build/source/libs/freetype2/freetype-src/src/autofit/aferrors.h index dde182f3c8f..e5de54360f7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/aferrors.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/aferrors.h @@ -4,7 +4,7 @@ /* */ /* Autofitter error codes (specification only). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afglobal.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afglobal.c index 85bef001f74..3d09c53e8a0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afglobal.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afglobal.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter routines to compute global hinting values (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afglobal.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afglobal.h index de6142ea261..489ed46d9ee 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afglobal.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afglobal.h @@ -5,7 +5,7 @@ /* Auto-fitter routines to compute global hinting values */ /* (specification). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.c index 1b21c06c2c7..0666dbc8e20 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -314,8 +314,12 @@ AF_DUMP(( "Table of points:\n" )); if ( hints->num_points ) + { AF_DUMP(( " index hedge hseg vedge vseg flags " + /* " XXXXX XXXXX XXXXX XXXXX XXXXX XXXXXX" */ " xorg yorg xscale yscale xfit yfit" )); + /* " XXXXX XXXXX XXXX.XX XXXX.XX XXXX.XX XXXX.XX" */ + } else AF_DUMP(( " (none)\n" )); @@ -420,9 +424,14 @@ dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" )); if ( axis->num_segments ) + { AF_DUMP(( " index pos delta dir from to " + /* " XXXXX XXXXX XXXXX XXXXX XXXX XXXX" */ " link serif edge" + /* " XXXX XXXXX XXXX" */ " height extra flags\n" )); + /* " XXXXXX XXXXX XXXXXXXXXXX" */ + } else AF_DUMP(( " (none)\n" )); @@ -564,8 +573,12 @@ 10.0 * hints->y_scale / 65536.0 / 64.0 )); if ( axis->num_edges ) + { AF_DUMP(( " index pos dir link serif" + /* " XXXXX XXXX.XX XXXXX XXXX XXXXX" */ " blue opos pos flags\n" )); + /* " X XXXX.XX XXXX.XX XXXXXXXXXXX" */ + } else AF_DUMP(( " (none)\n" )); diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.h index 16638b10308..3326ebc44e7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines (specification). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -62,7 +62,7 @@ FT_BEGIN_HEADER * * by David Turner and Werner Lemberg * - * http://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf + * https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf * * with appropriate updates. * diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afindic.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afindic.c index 23be46ed515..dfbea5f34c1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afindic.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afindic.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for Indic writing system (body). */ /* */ -/* Copyright 2007-2017 by */ +/* Copyright 2007-2018 by */ /* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afindic.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afindic.h index ec9e2631617..5688738e6e0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afindic.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afindic.h @@ -5,7 +5,7 @@ /* Auto-fitter hinting routines for Indic writing system */ /* (specification). */ /* */ -/* Copyright 2007-2017 by */ +/* Copyright 2007-2018 by */ /* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.c b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.c index 02b3b8bbd3c..9f1b54056f1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for latin writing system (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.h b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.h index d80e125ddcd..432cccce4e2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.h @@ -5,7 +5,7 @@ /* Auto-fitter hinting routines for latin writing system */ /* (specification). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin2.c b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin2.c index fb424451165..5c713781189 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin2.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin2.c @@ -9,7 +9,7 @@ /* */ /* Auto-fitter hinting routines for latin writing system (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin2.h b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin2.h index 2d0b154f580..0129dc707e6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin2.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin2.h @@ -10,7 +10,7 @@ /* Auto-fitter hinting routines for latin writing system */ /* (specification). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afloader.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afloader.c index 067ebd17f63..a55550b3385 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afloader.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afloader.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter glyph loading routines (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afloader.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afloader.h index 2578abed165..d4d72d15830 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afloader.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afloader.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter glyph loading routines (specification). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.c index 9d7ba224dad..dcaa17a27e9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter module implementation (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -56,7 +56,7 @@ #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H -#include FT_AUTOHINTER_H +#include FT_DRIVER_H #include FT_SERVICE_PROPERTIES_H diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.h index 0571d14d591..56f64eaf231 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter module implementation (specification). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afpic.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afpic.c index 3125e03e27e..d48d016a0e8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afpic.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for autofit module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afpic.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afpic.h index 8cd33921232..0c734567859 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afpic.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for autofit module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afranges.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afranges.c index 7f37eea1e00..1355c5e7cc3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afranges.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afranges.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter Unicode script ranges (body). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afranges.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afranges.h index 72d9eaad2c3..ba3b5e7ccbc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afranges.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afranges.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter Unicode script ranges (specification). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afscript.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afscript.h index cb815dbb40a..6ac193f6a71 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afscript.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afscript.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter scripts (specification only). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afshaper.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afshaper.c index d259964217a..f30828173cf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afshaper.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afshaper.c @@ -4,7 +4,7 @@ /* */ /* HarfBuzz interface for accessing OpenType features (body). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -104,10 +104,10 @@ { hb_face_t* face; - hb_set_t* gsub_lookups; /* GSUB lookups for a given script */ - hb_set_t* gsub_glyphs; /* glyphs covered by GSUB lookups */ - hb_set_t* gpos_lookups; /* GPOS lookups for a given script */ - hb_set_t* gpos_glyphs; /* glyphs covered by GPOS lookups */ + hb_set_t* gsub_lookups = NULL; /* GSUB lookups for a given script */ + hb_set_t* gsub_glyphs = NULL; /* glyphs covered by GSUB lookups */ + hb_set_t* gpos_lookups = NULL; /* GPOS lookups for a given script */ + hb_set_t* gpos_glyphs = NULL; /* glyphs covered by GPOS lookups */ hb_script_t script; const hb_tag_t* coverage_tags; @@ -127,11 +127,6 @@ face = hb_font_get_face( globals->hb_font ); - gsub_lookups = hb_set_create(); - gsub_glyphs = hb_set_create(); - gpos_lookups = hb_set_create(); - gpos_glyphs = hb_set_create(); - coverage_tags = coverages[style_class->coverage]; script = scripts[style_class->script]; @@ -168,6 +163,7 @@ script_tags[1] = HB_TAG_NONE; } + gsub_lookups = hb_set_create(); hb_ot_layout_collect_lookups( face, HB_OT_TAG_GSUB, script_tags, @@ -178,13 +174,6 @@ if ( hb_set_is_empty( gsub_lookups ) ) goto Exit; /* nothing to do */ - hb_ot_layout_collect_lookups( face, - HB_OT_TAG_GPOS, - script_tags, - NULL, - coverage_tags, - gpos_lookups ); - FT_TRACE4(( "GSUB lookups (style `%s'):\n" " ", af_style_names[style_class->style] )); @@ -193,6 +182,7 @@ count = 0; #endif + gsub_glyphs = hb_set_create(); for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups, &idx ); ) { #ifdef FT_DEBUG_LEVEL_TRACE @@ -220,10 +210,19 @@ " ", af_style_names[style_class->style] )); + gpos_lookups = hb_set_create(); + hb_ot_layout_collect_lookups( face, + HB_OT_TAG_GPOS, + script_tags, + NULL, + coverage_tags, + gpos_lookups ); + #ifdef FT_DEBUG_LEVEL_TRACE count = 0; #endif + gpos_glyphs = hb_set_create(); for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gpos_lookups, &idx ); ) { #ifdef FT_DEBUG_LEVEL_TRACE diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afshaper.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afshaper.h index 9185d190031..7efd9f6a4e6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afshaper.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afshaper.h @@ -4,7 +4,7 @@ /* */ /* HarfBuzz interface for accessing OpenType features (specification). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afstyles.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afstyles.h index 281559eea2c..e2688b3fc25 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afstyles.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afstyles.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter styles (specification only). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/aftypes.h b/Build/source/libs/freetype2/freetype-src/src/autofit/aftypes.h index 718dab70b64..a50013439bf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/aftypes.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/aftypes.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter types (specification only). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afwarp.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afwarp.c index f99aa6d9874..2a75ea7b35f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afwarp.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afwarp.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter warping algorithm (body). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afwarp.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afwarp.h index 2e85cbd851a..520b1be907c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afwarp.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afwarp.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter warping algorithm (specification). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afwrtsys.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afwrtsys.h index 86749a2a830..4675f3242d1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afwrtsys.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afwrtsys.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter writing systems (specification only). */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/autofit.c b/Build/source/libs/freetype2/freetype-src/src/autofit/autofit.c index bbedad7b5f5..c1605160a1c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/autofit.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/autofit.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter module (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/module.mk b/Build/source/libs/freetype2/freetype-src/src/autofit/module.mk index c4e249b6f1e..ff05f83e7ec 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2003-2017 by +# Copyright 2003-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/rules.mk b/Build/source/libs/freetype2/freetype-src/src/autofit/rules.mk index ec4e1302d18..75171b412cf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2003-2017 by +# Copyright 2003-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/base/Jamfile b/Build/source/libs/freetype2/freetype-src/src/base/Jamfile index 9e9a91b2017..2b47b8a242a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/base/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/base Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -26,6 +26,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) base ; ftobjs ftoutln ftpic + ftpsprop ftrfork ftsnames ftstream diff --git a/Build/source/libs/freetype2/freetype-src/src/base/basepic.c b/Build/source/libs/freetype2/freetype-src/src/base/basepic.c index 57fb8169ad1..bc804064416 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/basepic.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/basepic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for base. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/basepic.h b/Build/source/libs/freetype2/freetype-src/src/base/basepic.h index 258d4ce2ba6..492d1ede564 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/basepic.h +++ b/Build/source/libs/freetype2/freetype-src/src/base/basepic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for base. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftadvanc.c b/Build/source/libs/freetype2/freetype-src/src/base/ftadvanc.c index 1557607fc53..230c84d6ad4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftadvanc.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftadvanc.c @@ -4,7 +4,7 @@ /* */ /* Quick computation of advance widths (body). */ /* */ -/* Copyright 2008-2017 by */ +/* Copyright 2008-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -116,9 +116,12 @@ FT_Int32 flags, FT_Fixed *padvances ) { + FT_Error error = FT_Err_Ok; + FT_Face_GetAdvancesFunc func; - FT_UInt num, end, nn; - FT_Error error = FT_Err_Ok; + + FT_UInt num, end, nn; + FT_Int factor; if ( !face ) @@ -152,16 +155,17 @@ return FT_THROW( Unimplemented_Feature ); flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY; + factor = ( flags & FT_LOAD_NO_SCALE ) ? 1 : 1024; for ( nn = 0; nn < count; nn++ ) { error = FT_Load_Glyph( face, start + nn, flags ); if ( error ) break; - /* scale from 26.6 to 16.16 */ + /* scale from 26.6 to 16.16, unless NO_SCALE was requested */ padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT ) - ? face->glyph->advance.y * 1024 - : face->glyph->advance.x * 1024; + ? face->glyph->advance.y * factor + : face->glyph->advance.x * factor; } return error; diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftapi.c b/Build/source/libs/freetype2/freetype-src/src/base/ftapi.c index 4262d37e399..32d6e95d199 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftapi.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftapi.c @@ -4,7 +4,7 @@ /* */ /* The FreeType compatibility functions (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftbase.c b/Build/source/libs/freetype2/freetype-src/src/base/ftbase.c index 55f7359942f..a1bdbaf6eac 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftbase.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftbase.c @@ -4,7 +4,7 @@ /* */ /* Single object library component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,6 +29,7 @@ #include "ftobjs.c" #include "ftoutln.c" #include "ftpic.c" +#include "ftpsprop.c" #include "ftrfork.c" #include "ftsnames.c" #include "ftstream.c" diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftbase.h b/Build/source/libs/freetype2/freetype-src/src/base/ftbase.h index 2072284f060..7e8cfad9590 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftbase.h +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftbase.h @@ -2,9 +2,9 @@ /* */ /* ftbase.h */ /* */ -/* The FreeType private functions used in base module (specification). */ +/* Private functions used in the `base' module (specification). */ /* */ -/* Copyright 2008-2017 by */ +/* Copyright 2008-2018 by */ /* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,6 +27,8 @@ FT_BEGIN_HEADER +#ifdef FT_CONFIG_OPTION_MAC_FONTS + /* MacOS resource fork cannot exceed 16MB at least for Carbon code; */ /* see https://support.microsoft.com/en-us/kb/130437 */ #define FT_MAC_RFORK_MAX_LEN 0x00FFFFFFUL @@ -65,6 +67,8 @@ FT_BEGIN_HEADER ft_raccess_rule_by_darwin_vfs( FT_Library library, FT_UInt rule_index ); #endif +#endif /* FT_CONFIG_OPTION_MAC_FONTS */ + FT_END_HEADER diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftbbox.c b/Build/source/libs/freetype2/freetype-src/src/base/ftbbox.c index 6e19da63cb3..151e85c97a5 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftbbox.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftbbox.c @@ -4,7 +4,7 @@ /* */ /* FreeType bbox computation (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftbdf.c b/Build/source/libs/freetype2/freetype-src/src/base/ftbdf.c index 40f0ca2bb80..c4ea502fbc2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftbdf.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftbdf.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing BDF-specific strings (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftbitmap.c b/Build/source/libs/freetype2/freetype-src/src/base/ftbitmap.c index e567a0453ec..93efb094479 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftbitmap.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftbitmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility functions for bitmaps (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -153,38 +153,36 @@ FT_UInt ypixels ) { FT_Error error; - int pitch; - int new_pitch; + unsigned int pitch; + unsigned int new_pitch; FT_UInt bpp; - FT_UInt i, width, height; + FT_UInt width, height; unsigned char* buffer = NULL; width = bitmap->width; height = bitmap->rows; - pitch = bitmap->pitch; - if ( pitch < 0 ) - pitch = -pitch; + pitch = (unsigned int)FT_ABS( bitmap->pitch ); switch ( bitmap->pixel_mode ) { case FT_PIXEL_MODE_MONO: bpp = 1; - new_pitch = (int)( ( width + xpixels + 7 ) >> 3 ); + new_pitch = ( width + xpixels + 7 ) >> 3; break; case FT_PIXEL_MODE_GRAY2: bpp = 2; - new_pitch = (int)( ( width + xpixels + 3 ) >> 2 ); + new_pitch = ( width + xpixels + 3 ) >> 2; break; case FT_PIXEL_MODE_GRAY4: bpp = 4; - new_pitch = (int)( ( width + xpixels + 1 ) >> 1 ); + new_pitch = ( width + xpixels + 1 ) >> 1; break; case FT_PIXEL_MODE_GRAY: case FT_PIXEL_MODE_LCD: case FT_PIXEL_MODE_LCD_V: bpp = 8; - new_pitch = (int)( width + xpixels ); + new_pitch = width + xpixels; break; default: return FT_THROW( Invalid_Glyph_Format ); @@ -194,7 +192,7 @@ if ( ypixels == 0 && new_pitch <= pitch ) { /* zero the padding */ - FT_UInt bit_width = (FT_UInt)pitch * 8; + FT_UInt bit_width = pitch * 8; FT_UInt bit_last = ( width + xpixels ) * bpp; @@ -235,31 +233,58 @@ { FT_UInt len = ( width * bpp + 7 ) >> 3; + unsigned char* in = bitmap->buffer; + unsigned char* out = buffer; + + unsigned char* limit = bitmap->buffer + pitch * bitmap->rows; + unsigned int delta = new_pitch - pitch; + + + FT_MEM_ZERO( out, new_pitch * ypixels ); + out += new_pitch * ypixels; - for ( i = 0; i < bitmap->rows; i++ ) - FT_MEM_COPY( buffer + (FT_UInt)new_pitch * ( ypixels + i ), - bitmap->buffer + (FT_UInt)pitch * i, - len ); + while ( in < limit ) + { + FT_MEM_COPY( out, in, len ); + in += pitch; + out += pitch; + + FT_MEM_ZERO( out, delta ); + out += delta; + } } else { FT_UInt len = ( width * bpp + 7 ) >> 3; + unsigned char* in = bitmap->buffer; + unsigned char* out = buffer; + + unsigned char* limit = bitmap->buffer + pitch * bitmap->rows; + unsigned int delta = new_pitch - pitch; - for ( i = 0; i < bitmap->rows; i++ ) - FT_MEM_COPY( buffer + (FT_UInt)new_pitch * i, - bitmap->buffer + (FT_UInt)pitch * i, - len ); + + while ( in < limit ) + { + FT_MEM_COPY( out, in, len ); + in += pitch; + out += pitch; + + FT_MEM_ZERO( out, delta ); + out += delta; + } + + FT_MEM_ZERO( out, new_pitch * ypixels ); } FT_FREE( bitmap->buffer ); bitmap->buffer = buffer; - if ( bitmap->pitch < 0 ) - new_pitch = -new_pitch; - /* set pitch only, width and height are left untouched */ - bitmap->pitch = new_pitch; + if ( bitmap->pitch < 0 ) + bitmap->pitch = -(int)new_pitch; + else + bitmap->pitch = (int)new_pitch; return FT_Err_Ok; } @@ -444,7 +469,7 @@ * A gamma of 2.2 is fair to assume. And then, we need to * undo the premultiplication too. * - * http://accessibility.kde.org/hsl-adjusted.php + * https://accessibility.kde.org/hsl-adjusted.php * * We do the computation with integers only, applying a gamma of 2.0. * We guarantee 32-bit arithmetic to avoid overflow but the resulting diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftcalc.c b/Build/source/libs/freetype2/freetype-src/src/base/ftcalc.c index 00d63c6e6ba..f4ff45f8ef1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftcalc.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftcalc.c @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftcid.c b/Build/source/libs/freetype2/freetype-src/src/base/ftcid.c index 398396b8453..f5184649bfb 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftcid.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftcid.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing CID font information. */ /* */ -/* Copyright 2007-2017 by */ +/* Copyright 2007-2018 by */ /* Derek Clegg and Michael Toftdal. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftdbgmem.c b/Build/source/libs/freetype2/freetype-src/src/base/ftdbgmem.c index 242246bfd12..c33d8acb4e1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftdbgmem.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftdbgmem.c @@ -4,7 +4,7 @@ /* */ /* Memory debugger (body). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -826,7 +826,7 @@ FT_Int result = 0; - if ( getenv( "FT2_DEBUG_MEMORY" ) ) + if ( ft_getenv( "FT2_DEBUG_MEMORY" ) ) { table = ft_mem_table_new( memory ); if ( table ) @@ -839,7 +839,7 @@ memory->realloc = ft_mem_debug_realloc; memory->free = ft_mem_debug_free; - p = getenv( "FT2_ALLOC_TOTAL_MAX" ); + p = ft_getenv( "FT2_ALLOC_TOTAL_MAX" ); if ( p ) { FT_Long total_max = ft_strtol( p, NULL, 10 ); @@ -852,7 +852,7 @@ } } - p = getenv( "FT2_ALLOC_COUNT_MAX" ); + p = ft_getenv( "FT2_ALLOC_COUNT_MAX" ); if ( p ) { FT_Long total_count = ft_strtol( p, NULL, 10 ); @@ -865,7 +865,7 @@ } } - p = getenv( "FT2_KEEP_ALIVE" ); + p = ft_getenv( "FT2_KEEP_ALIVE" ); if ( p ) { FT_Long keep_alive = ft_strtol( p, NULL, 10 ); diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftdebug.c b/Build/source/libs/freetype2/freetype-src/src/base/ftdebug.c index 20c617089ff..fe263091014 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftdebug.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftdebug.c @@ -4,7 +4,7 @@ /* */ /* Debugging and logging component (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -161,7 +161,7 @@ FT_BASE_DEF( void ) ft_debug_init( void ) { - const char* ft2_debug = getenv( "FT2_DEBUG" ); + const char* ft2_debug = ft_getenv( "FT2_DEBUG" ); if ( ft2_debug ) diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftfntfmt.c b/Build/source/libs/freetype2/freetype-src/src/base/ftfntfmt.c index dcbeba0053a..a2900ceb098 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftfntfmt.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftfntfmt.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file for font formats (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftfstype.c b/Build/source/libs/freetype2/freetype-src/src/base/ftfstype.c index cec4fb30250..e6cdf6e2ec6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftfstype.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftfstype.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file to access FSType data (body). */ /* */ -/* Copyright 2008-2017 by */ +/* Copyright 2008-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftgasp.c b/Build/source/libs/freetype2/freetype-src/src/base/ftgasp.c index 477b72558cd..4f80bba630c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftgasp.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftgasp.c @@ -4,7 +4,7 @@ /* */ /* Access of TrueType's `gasp' table (body). */ /* */ -/* Copyright 2007-2017 by */ +/* Copyright 2007-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftgloadr.c b/Build/source/libs/freetype2/freetype-src/src/base/ftgloadr.c index 8134003b4b6..47202496b9c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftgloadr.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftgloadr.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph loader (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftglyph.c b/Build/source/libs/freetype2/freetype-src/src/base/ftglyph.c index 3f78a8c36b5..6759aa25d0e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftglyph.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftglyph.c @@ -4,7 +4,7 @@ /* */ /* FreeType convenience functions to handle glyphs (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftgxval.c b/Build/source/libs/freetype2/freetype-src/src/base/ftgxval.c index ff24d336df6..19e2d6acb5a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftgxval.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftgxval.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for validating TrueTypeGX/AAT tables (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* Masatake YAMATO, Redhat K.K, */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftinit.c b/Build/source/libs/freetype2/freetype-src/src/base/ftinit.c index b3b08fa5416..1fa4721094a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftinit.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftinit.c @@ -4,7 +4,7 @@ /* */ /* FreeType initialization layer (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftlcdfil.c b/Build/source/libs/freetype2/freetype-src/src/base/ftlcdfil.c index 60c813fd9e0..5c38911a907 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftlcdfil.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftlcdfil.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for color filtering of subpixel bitmap glyphs (body). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -31,8 +31,41 @@ #define FT_SHIFTCLAMP( x ) ( x >>= 8, (FT_Byte)( x > 255 ? 255 : x ) ) + + /* add padding according to filter weights */ + FT_BASE_DEF (void) + ft_lcd_padding( FT_Pos* Min, + FT_Pos* Max, + FT_GlyphSlot slot ) + { + FT_Byte* lcd_weights; + FT_Bitmap_LcdFilterFunc lcd_filter_func; + + + /* Per-face LCD filtering takes priority if set up. */ + if ( slot->face && slot->face->internal->lcd_filter_func ) + { + lcd_weights = slot->face->internal->lcd_weights; + lcd_filter_func = slot->face->internal->lcd_filter_func; + } + else + { + lcd_weights = slot->library->lcd_weights; + lcd_filter_func = slot->library->lcd_filter_func; + } + + if ( lcd_filter_func == ft_lcd_filter_fir ) + { + *Min -= lcd_weights[0] ? 43 : + lcd_weights[1] ? 22 : 0; + *Max += lcd_weights[4] ? 43 : + lcd_weights[3] ? 22 : 0; + } + } + + /* FIR filter used by the default and light filters */ - FT_BASE( void ) + FT_BASE_DEF( void ) ft_lcd_filter_fir( FT_Bitmap* bitmap, FT_Render_Mode mode, FT_LcdFiveTapFilter weights ) @@ -305,21 +338,21 @@ return FT_THROW( Invalid_Argument ); } - library->lcd_filter = filter; - return FT_Err_Ok; } #else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - FT_BASE( void ) - ft_lcd_filter_fir( FT_Bitmap* bitmap, - FT_Render_Mode mode, - FT_LcdFiveTapFilter weights ) + /* add padding according to accommodate outline shifts */ + FT_BASE_DEF (void) + ft_lcd_padding( FT_Pos* Min, + FT_Pos* Max, + FT_GlyphSlot slot ) { - FT_UNUSED( bitmap ); - FT_UNUSED( mode ); - FT_UNUSED( weights ); + FT_UNUSED( slot ); + + *Min -= 21; + *Max += 21; } diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftmac.c b/Build/source/libs/freetype2/freetype-src/src/base/ftmac.c index 4e76585e5f5..fd4c0cc274f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftmac.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftmac.c @@ -8,7 +8,7 @@ /* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */ /* classic platforms built by MPW. */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftmm.c b/Build/source/libs/freetype2/freetype-src/src/base/ftmm.c index 43877ece45b..800441bcac8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftmm.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftmm.c @@ -4,7 +4,7 @@ /* */ /* Multiple Master font support (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -148,6 +148,25 @@ /* documentation is in ftmm.h */ FT_EXPORT_DEF( FT_Error ) + FT_Done_MM_Var( FT_Library library, + FT_MM_Var* amaster ) + { + FT_Memory memory; + + + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + + memory = library->memory; + FT_FREE( amaster ); + + return FT_Err_Ok; + } + + + /* documentation is in ftmm.h */ + + FT_EXPORT_DEF( FT_Error ) FT_Set_MM_Design_Coordinates( FT_Face face, FT_UInt num_coords, FT_Long* coords ) @@ -203,6 +222,10 @@ error = FT_ERR( Invalid_Argument ); if ( service_mm->set_var_design ) error = service_mm->set_var_design( face, num_coords, coords ); + + /* internal error code -1 means `no change'; we can exit immediately */ + if ( error == -1 ) + return FT_Err_Ok; } if ( !error ) @@ -275,6 +298,10 @@ error = FT_ERR( Invalid_Argument ); if ( service_mm->set_mm_blend ) error = service_mm->set_mm_blend( face, num_coords, coords ); + + /* internal error code -1 means `no change'; we can exit immediately */ + if ( error == -1 ) + return FT_Err_Ok; } if ( !error ) @@ -322,6 +349,10 @@ error = FT_ERR( Invalid_Argument ); if ( service_mm->set_mm_blend ) error = service_mm->set_mm_blend( face, num_coords, coords ); + + /* internal error code -1 means `no change'; we can exit immediately */ + if ( error == -1 ) + return FT_Err_Ok; } if ( !error ) @@ -426,4 +457,52 @@ } + /* documentation is in ftmm.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Set_Named_Instance( FT_Face face, + FT_UInt instance_index ) + { + FT_Error error; + + FT_Service_MultiMasters service_mm = NULL; + FT_Service_MetricsVariations service_mvar = NULL; + + + /* check of `face' delayed to `ft_face_get_mm_service' */ + + error = ft_face_get_mm_service( face, &service_mm ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service_mm->set_instance ) + error = service_mm->set_instance( face, instance_index ); + } + + if ( !error ) + { + (void)ft_face_get_mvar_service( face, &service_mvar ); + + if ( service_mvar && service_mvar->metrics_adjust ) + service_mvar->metrics_adjust( face ); + } + + /* enforce recomputation of auto-hinting data */ + if ( !error && face->autohint.finalizer ) + { + face->autohint.finalizer( face->autohint.data ); + face->autohint.data = NULL; + } + + if ( !error ) + { + face->face_index = ( instance_index << 16 ) | + ( face->face_index & 0xFFFFL ); + face->face_flags &= ~FT_FACE_FLAG_VARIATION; + } + + return error; + } + + /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c b/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c index 6db8136cfce..8d07e35ae37 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c @@ -4,7 +4,7 @@ /* */ /* The FreeType private base classes (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,12 +19,16 @@ #include <ft2build.h> #include FT_LIST_H #include FT_OUTLINE_H +#include FT_FONT_FORMATS_H + #include FT_INTERNAL_VALIDATE_H #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_RFORK_H #include FT_INTERNAL_STREAM_H -#include FT_INTERNAL_SFNT_H /* for SFNT_Load_Table_Func */ +#include FT_INTERNAL_SFNT_H /* for SFNT_Load_Table_Func */ +#include FT_INTERNAL_POSTSCRIPT_AUX_H /* for PS_Driver */ + #include FT_TRUETYPE_TABLES_H #include FT_TRUETYPE_TAGS_H #include FT_TRUETYPE_IDS_H @@ -37,8 +41,7 @@ #include FT_SERVICE_KERNING_H #include FT_SERVICE_TRUETYPE_ENGINE_H -#include FT_AUTOHINTER_H -#include FT_CFF_DRIVER_H +#include FT_DRIVER_H #ifdef FT_CONFIG_OPTION_MAC_FONTS #include "ftbase.h" @@ -328,6 +331,138 @@ FT_BASE_DEF( void ) + ft_glyphslot_preset_bitmap( FT_GlyphSlot slot, + FT_Render_Mode mode, + const FT_Vector* origin ) + { + FT_Outline* outline = &slot->outline; + FT_Bitmap* bitmap = &slot->bitmap; + + FT_Pixel_Mode pixel_mode; + + FT_BBox cbox; + FT_Pos x_shift = 0; + FT_Pos y_shift = 0; + FT_Pos x_left, y_top; + FT_Pos width, height, pitch; + + + if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) ) + return; + + if ( origin ) + { + x_shift = origin->x; + y_shift = origin->y; + } + + /* compute the control box, and grid-fit it, */ + /* taking into account the origin shift */ + FT_Outline_Get_CBox( outline, &cbox ); + + cbox.xMin += x_shift; + cbox.yMin += y_shift; + cbox.xMax += x_shift; + cbox.yMax += y_shift; + + switch ( mode ) + { + case FT_RENDER_MODE_MONO: + pixel_mode = FT_PIXEL_MODE_MONO; +#if 1 + /* undocumented but confirmed: bbox values get rounded */ + /* unless the rounded box can collapse for a narrow glyph */ + if ( cbox.xMax - cbox.xMin < 64 ) + { + cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); + cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); + } + else + { + cbox.xMin = FT_PIX_ROUND_LONG( cbox.xMin ); + cbox.xMax = FT_PIX_ROUND_LONG( cbox.xMax ); + } + + if ( cbox.yMax - cbox.yMin < 64 ) + { + cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); + cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); + } + else + { + cbox.yMin = FT_PIX_ROUND_LONG( cbox.yMin ); + cbox.yMax = FT_PIX_ROUND_LONG( cbox.yMax ); + } +#else + cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); + cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); + cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); + cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); +#endif + break; + + case FT_RENDER_MODE_LCD: + pixel_mode = FT_PIXEL_MODE_LCD; + ft_lcd_padding( &cbox.xMin, &cbox.xMax, slot ); + goto Round; + + case FT_RENDER_MODE_LCD_V: + pixel_mode = FT_PIXEL_MODE_LCD_V; + ft_lcd_padding( &cbox.yMin, &cbox.yMax, slot ); + goto Round; + + case FT_RENDER_MODE_NORMAL: + case FT_RENDER_MODE_LIGHT: + default: + pixel_mode = FT_PIXEL_MODE_GRAY; + Round: + cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); + cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); + cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); + cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); + } + + x_shift = SUB_LONG( x_shift, cbox.xMin ); + y_shift = SUB_LONG( y_shift, cbox.yMin ); + + x_left = cbox.xMin >> 6; + y_top = cbox.yMax >> 6; + + width = ( (FT_ULong)cbox.xMax - (FT_ULong)cbox.xMin ) >> 6; + height = ( (FT_ULong)cbox.yMax - (FT_ULong)cbox.yMin ) >> 6; + + switch ( pixel_mode ) + { + case FT_PIXEL_MODE_MONO: + pitch = ( ( width + 15 ) >> 4 ) << 1; + break; + + case FT_PIXEL_MODE_LCD: + width *= 3; + pitch = FT_PAD_CEIL( width, 4 ); + break; + + case FT_PIXEL_MODE_LCD_V: + height *= 3; + /* fall through */ + + case FT_PIXEL_MODE_GRAY: + default: + pitch = width; + } + + slot->bitmap_left = (FT_Int)x_left; + slot->bitmap_top = (FT_Int)y_top; + + bitmap->pixel_mode = (unsigned char)pixel_mode; + bitmap->num_grays = 256; + bitmap->width = (unsigned int)width; + bitmap->rows = (unsigned int)height; + bitmap->pitch = pitch; + } + + + FT_BASE_DEF( void ) ft_glyphslot_set_bitmap( FT_GlyphSlot slot, FT_Byte* buffer ) { @@ -669,9 +804,13 @@ * Determine whether we need to auto-hint or not. * The general rules are: * - * - Do only auto-hinting if we have a hinter module, a scalable font - * format dealing with outlines, and no transforms except simple - * slants and/or rotations by integer multiples of 90 degrees. + * - Do only auto-hinting if we have + * + * - a hinter module, + * - a scalable font format dealing with outlines, + * - not a tricky font, and + * - no transforms except simple slants and/or rotations by + * integer multiples of 90 degrees. * * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't * have a native font hinter. @@ -701,8 +840,15 @@ else { FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); + FT_Bool is_light_type1; + /* only the new Adobe engine (for both CFF and Type 1) is `light'; */ + /* we use `strstr' to catch both `Type 1' and `CID Type 1' */ + is_light_type1 = + ft_strstr( FT_Get_Font_Format( face ), "Type 1" ) != NULL && + ((PS_Driver)driver)->hinting_engine == FT_HINTING_ADOBE; + /* the check for `num_locations' assures that we actually */ /* test for instructions in a TTF and not in a CFF-based OTF */ /* */ @@ -710,8 +856,9 @@ /* check the size of the `fpgm' and `prep' tables, too -- */ /* the assumption is that there don't exist real TTFs where */ /* both `fpgm' and `prep' tables are missing */ - if ( ( mode == FT_RENDER_MODE_LIGHT && - !FT_DRIVER_HINTS_LIGHTLY( driver ) ) || + if ( ( mode == FT_RENDER_MODE_LIGHT && + ( !FT_DRIVER_HINTS_LIGHTLY( driver ) && + !is_light_type1 ) ) || ( FT_IS_SFNT( face ) && ttface->num_locations && ttface->max_profile.maxSizeOfInstructions == 0 && @@ -731,8 +878,8 @@ /* XXX: This is really a temporary hack that should disappear */ /* promptly with FreeType 2.1! */ /* */ - if ( FT_HAS_FIXED_SIZES( face ) && - ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) + if ( FT_HAS_FIXED_SIZES( face ) && + ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) { error = driver->clazz->load_glyph( slot, face->size, glyph_index, @@ -800,7 +947,7 @@ /* compute the linear advance in 16.16 pixels */ if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 && - ( FT_IS_SCALABLE( face ) ) ) + FT_IS_SCALABLE( face ) ) { FT_Size_Metrics* metrics = &face->size->metrics; @@ -848,28 +995,37 @@ } } - FT_TRACE5(( " x advance: %d\n" , slot->advance.x )); - FT_TRACE5(( " y advance: %d\n" , slot->advance.y )); - - FT_TRACE5(( " linear x advance: %d\n" , slot->linearHoriAdvance )); - FT_TRACE5(( " linear y advance: %d\n" , slot->linearVertAdvance )); - - /* do we need to render the image now? */ + /* do we need to render the image or preset the bitmap now? */ if ( !error && + ( load_flags & FT_LOAD_NO_SCALE ) == 0 && slot->format != FT_GLYPH_FORMAT_BITMAP && - slot->format != FT_GLYPH_FORMAT_COMPOSITE && - load_flags & FT_LOAD_RENDER ) + slot->format != FT_GLYPH_FORMAT_COMPOSITE ) { FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); - if ( mode == FT_RENDER_MODE_NORMAL && - (load_flags & FT_LOAD_MONOCHROME ) ) + if ( mode == FT_RENDER_MODE_NORMAL && + load_flags & FT_LOAD_MONOCHROME ) mode = FT_RENDER_MODE_MONO; - error = FT_Render_Glyph( slot, mode ); + if ( load_flags & FT_LOAD_RENDER ) + error = FT_Render_Glyph( slot, mode ); + else + ft_glyphslot_preset_bitmap( slot, mode, NULL ); } + FT_TRACE5(( "FT_Load_Glyph: index %d, flags %x\n", + glyph_index, load_flags )); + FT_TRACE5(( " x advance: %f\n", slot->advance.x / 64.0 )); + FT_TRACE5(( " y advance: %f\n", slot->advance.y / 64.0 )); + FT_TRACE5(( " linear x advance: %f\n", + slot->linearHoriAdvance / 65536.0 )); + FT_TRACE5(( " linear y advance: %f\n", + slot->linearVertAdvance / 65536.0 )); + FT_TRACE5(( " bitmap %dx%d, mode %d\n", + slot->bitmap.width, slot->bitmap.rows, + slot->bitmap.pixel_mode )); + Exit: return error; } @@ -2441,7 +2597,8 @@ internal->no_stem_darkening = -1; #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - ft_memset( internal->lcd_weights, 0, FT_LCD_FILTER_FIVE_TAPS ); + /* Per-face filtering can only be set up by FT_Face_Properties */ + internal->lcd_filter_func = NULL; #endif } @@ -2864,18 +3021,6 @@ metrics->height = bsize->height << 6; metrics->max_advance = bsize->x_ppem; } - - FT_TRACE5(( "FT_Select_Metrics:\n" )); - FT_TRACE5(( " x scale: %d (%f)\n", - metrics->x_scale, metrics->x_scale / 65536.0 )); - FT_TRACE5(( " y scale: %d (%f)\n", - metrics->y_scale, metrics->y_scale / 65536.0 )); - FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); - FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); - FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); - FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); - FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); - FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); } @@ -2984,18 +3129,6 @@ metrics->x_scale = 1L << 16; metrics->y_scale = 1L << 16; } - - FT_TRACE5(( "FT_Request_Metrics:\n" )); - FT_TRACE5(( " x scale: %d (%f)\n", - metrics->x_scale, metrics->x_scale / 65536.0 )); - FT_TRACE5(( " y scale: %d (%f)\n", - metrics->y_scale, metrics->y_scale / 65536.0 )); - FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); - FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); - FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); - FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); - FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); - FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); } @@ -3005,6 +3138,7 @@ FT_Select_Size( FT_Face face, FT_Int strike_index ) { + FT_Error error = FT_Err_Ok; FT_Driver_Class clazz; @@ -3018,36 +3152,37 @@ if ( clazz->select_size ) { - FT_Error error; + error = clazz->select_size( face->size, (FT_ULong)strike_index ); + FT_TRACE5(( "FT_Select_Size (%s driver):\n", + face->driver->root.clazz->module_name )); + } + else + { + FT_Select_Metrics( face, (FT_ULong)strike_index ); - error = clazz->select_size( face->size, (FT_ULong)strike_index ); + FT_TRACE5(( "FT_Select_Size:\n" )); + } #ifdef FT_DEBUG_LEVEL_TRACE - { - FT_Size_Metrics* metrics = &face->size->metrics; - - - FT_TRACE5(( "FT_Select_Size (font driver's `select_size'):\n" )); - FT_TRACE5(( " x scale: %d (%f)\n", - metrics->x_scale, metrics->x_scale / 65536.0 )); - FT_TRACE5(( " y scale: %d (%f)\n", - metrics->y_scale, metrics->y_scale / 65536.0 )); - FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); - FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); - FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); - FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); - FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); - FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); - } -#endif + { + FT_Size_Metrics* metrics = &face->size->metrics; - return error; - } - FT_Select_Metrics( face, (FT_ULong)strike_index ); + FT_TRACE5(( " x scale: %d (%f)\n", + metrics->x_scale, metrics->x_scale / 65536.0 )); + FT_TRACE5(( " y scale: %d (%f)\n", + metrics->y_scale, metrics->y_scale / 65536.0 )); + FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); + FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); + FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); + FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); + FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); + FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); + } +#endif - return FT_Err_Ok; + return error; } @@ -3057,6 +3192,7 @@ FT_Request_Size( FT_Face face, FT_Size_Request req ) { + FT_Error error = FT_Err_Ok; FT_Driver_Class clazz; FT_ULong strike_index; @@ -3076,55 +3212,52 @@ if ( clazz->request_size ) { - FT_Error error; - - error = clazz->request_size( face->size, req ); -#ifdef FT_DEBUG_LEVEL_TRACE - { - FT_Size_Metrics* metrics = &face->size->metrics; - - - FT_TRACE5(( "FT_Request_Size (font driver's `request_size'):\n" )); - FT_TRACE5(( " x scale: %d (%f)\n", - metrics->x_scale, metrics->x_scale / 65536.0 )); - FT_TRACE5(( " y scale: %d (%f)\n", - metrics->y_scale, metrics->y_scale / 65536.0 )); - FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); - FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); - FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); - FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); - FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); - FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); - } -#endif - - return error; + FT_TRACE5(( "FT_Request_Size (%s driver):\n", + face->driver->root.clazz->module_name )); } - - /* - * The reason that a driver doesn't have `request_size' defined is - * either that the scaling here suffices or that the supported formats - * are bitmap-only and size matching is not implemented. - * - * In the latter case, a simple size matching is done. - */ - if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) ) + else if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) ) { - FT_Error error; - - + /* + * The reason that a driver doesn't have `request_size' defined is + * either that the scaling here suffices or that the supported formats + * are bitmap-only and size matching is not implemented. + * + * In the latter case, a simple size matching is done. + */ error = FT_Match_Size( face, req, 0, &strike_index ); if ( error ) return error; return FT_Select_Size( face, (FT_Int)strike_index ); } + else + { + FT_Request_Metrics( face, req ); - FT_Request_Metrics( face, req ); + FT_TRACE5(( "FT_Request_Size:\n" )); + } - return FT_Err_Ok; +#ifdef FT_DEBUG_LEVEL_TRACE + { + FT_Size_Metrics* metrics = &face->size->metrics; + + + FT_TRACE5(( " x scale: %d (%f)\n", + metrics->x_scale, metrics->x_scale / 65536.0 )); + FT_TRACE5(( " y scale: %d (%f)\n", + metrics->y_scale, metrics->y_scale / 65536.0 )); + FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); + FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); + FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); + FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); + FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); + FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); + } +#endif + + return error; } @@ -3653,16 +3786,11 @@ { #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING if ( properties->data ) + { ft_memcpy( face->internal->lcd_weights, properties->data, FT_LCD_FILTER_FIVE_TAPS ); - else - { - /* Value NULL indicates `no custom weights, use library */ - /* defaults', signaled by filling the weight field with zeros. */ - ft_memset( face->internal->lcd_weights, - 0, - FT_LCD_FILTER_FIVE_TAPS ); + face->internal->lcd_filter_func = ft_lcd_filter_fir; } #else error = FT_THROW( Unimplemented_Feature ); @@ -4414,43 +4542,97 @@ */ /* we use FT_TRACE3 in this block */ - if ( ft_trace_levels[trace_bitmap] >= 3 ) + if ( !error && + ft_trace_levels[trace_bitmap] >= 3 && + slot->bitmap.buffer ) { + FT_Bitmap bitmap; + FT_Error err; + + + FT_Bitmap_Init( &bitmap ); + /* we convert to a single bitmap format for computing the checksum */ - if ( !error && slot->bitmap.buffer ) + /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */ + err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); + if ( !err ) { - FT_Bitmap bitmap; - FT_Error err; + MD5_CTX ctx; + unsigned char md5[16]; + unsigned long coverage = 0; + int i, j; + int rows = (int)bitmap.rows; + int pitch = bitmap.pitch; + + + FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, mode %d\n", + rows, pitch, slot->bitmap.pixel_mode )); + + for ( i = 0; i < rows; i++ ) + for ( j = 0; j < pitch; j++ ) + coverage += bitmap.buffer[i * pitch + j]; + FT_TRACE3(( " Total coverage: %lu\n", coverage )); - FT_Bitmap_Init( &bitmap ); + MD5_Init( &ctx ); + if ( bitmap.buffer ) + MD5_Update( &ctx, bitmap.buffer, + (unsigned long)rows * (unsigned long)pitch ); + MD5_Final( md5, &ctx ); - /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */ - err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); - if ( !err ) + FT_TRACE3(( " MD5 checksum: " )); + for ( i = 0; i < 16; i++ ) + FT_TRACE3(( "%02X", md5[i] )); + FT_TRACE3(( "\n" )); + } + + FT_Bitmap_Done( library, &bitmap ); + } + + /* + * Dump bitmap in Netpbm format (PBM or PGM). + */ + + /* we use FT_TRACE7 in this block */ + if ( !error && + ft_trace_levels[trace_bitmap] >= 7 && + slot->bitmap.rows < 128U && + slot->bitmap.width < 128U && + slot->bitmap.buffer ) + { + int rows = (int)slot->bitmap.rows; + int width = (int)slot->bitmap.width; + int pitch = slot->bitmap.pitch; + int i, j, m; + unsigned char* topleft = slot->bitmap.buffer; + + if ( pitch < 0 ) + topleft -= pitch * ( rows - 1 ); + + FT_TRACE7(( "Netpbm image: start\n" )); + switch ( slot->bitmap.pixel_mode ) + { + case FT_PIXEL_MODE_MONO: + FT_TRACE7(( "P1 %d %d\n", width, rows )); + for ( i = 0; i < rows; i++ ) { - MD5_CTX ctx; - unsigned char md5[16]; - int i; - unsigned int rows = bitmap.rows; - unsigned int pitch = (unsigned int)bitmap.pitch; - - - MD5_Init( &ctx ); - if ( bitmap.buffer ) - MD5_Update( &ctx, bitmap.buffer, rows * pitch ); - MD5_Final( md5, &ctx ); - - FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n" - " ", - rows, pitch )); - for ( i = 0; i < 16; i++ ) - FT_TRACE3(( "%02X", md5[i] )); - FT_TRACE3(( "\n" )); + for ( j = 0; j < width; ) + for ( m = 128; m > 0 && j < width; m >>= 1, j++ ) + FT_TRACE7(( " %d", ( topleft[i * pitch + j / 8] & m ) != 0 )); + FT_TRACE7(( "\n" )); } + break; - FT_Bitmap_Done( library, &bitmap ); + default: + FT_TRACE7(( "P2 %d %d 255\n", width, rows )); + for ( i = 0; i < rows; i++ ) + { + for ( j = 0; j < width; j += 1 ) + FT_TRACE7(( " %3u", topleft[i * pitch + j] )); + FT_TRACE7(( "\n" )); + } } + FT_TRACE7(( "Netpbm image: end\n" )); } #undef FT_COMPONENT @@ -4995,9 +5177,9 @@ #ifdef FT_CONFIG_OPTION_PIC Fail: ft_pic_container_destroy( library ); -#endif FT_FREE( library ); return error; +#endif } diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftotval.c b/Build/source/libs/freetype2/freetype-src/src/base/ftotval.c index 5fa098691e8..a2944a7950c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftotval.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftotval.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for validating OpenType tables (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftoutln.c b/Build/source/libs/freetype2/freetype-src/src/base/ftoutln.c index 9ceb9cf1ba7..9c29ade92fb 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftoutln.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftoutln.c @@ -4,7 +4,7 @@ /* */ /* FreeType outline management (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -540,8 +540,8 @@ for ( n = 0; n < outline->n_points; n++ ) { - vec->x += xOffset; - vec->y += yOffset; + vec->x = ADD_LONG( vec->x, xOffset ); + vec->y = ADD_LONG( vec->y, yOffset ); vec++; } } diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftpatent.c b/Build/source/libs/freetype2/freetype-src/src/base/ftpatent.c index 9900f99bfcd..e23ee2e3f48 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftpatent.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftpatent.c @@ -5,7 +5,7 @@ /* FreeType API for checking patented TrueType bytecode instructions */ /* (body). Obsolete, retained for backward compatibility. */ /* */ -/* Copyright 2007-2017 by */ +/* Copyright 2007-2018 by */ /* David Turner. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftpfr.c b/Build/source/libs/freetype2/freetype-src/src/base/ftpfr.c index 5cc0b707264..bfe13520eb9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftpfr.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftpfr.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing PFR-specific data (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftpic.c b/Build/source/libs/freetype2/freetype-src/src/base/ftpic.c index 0f84fddc98b..1492e1809a5 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftpic.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services (body). */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftpsprop.c b/Build/source/libs/freetype2/freetype-src/src/base/ftpsprop.c new file mode 100644 index 00000000000..459b5e6054c --- /dev/null +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftpsprop.c @@ -0,0 +1,285 @@ +/***************************************************************************/ +/* */ +/* ftpsprop.c */ +/* */ +/* Get and set properties of PostScript drivers (body). */ +/* See `ftdriver.h' for available properties. */ +/* */ +/* Copyright 2017-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include <ft2build.h> +#include FT_DRIVER_H +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_POSTSCRIPT_PROPS_H + + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_psprops + + + FT_BASE_CALLBACK_DEF( FT_Error ) + ps_property_set( FT_Module module, /* PS_Driver */ + const char* property_name, + const void* value, + FT_Bool value_is_string ) + { + FT_Error error = FT_Err_Ok; + PS_Driver driver = (PS_Driver)module; + +#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_UNUSED( value_is_string ); +#endif + + + if ( !ft_strcmp( property_name, "darkening-parameters" ) ) + { + FT_Int* darken_params; + FT_Int x1, y1, x2, y2, x3, y3, x4, y4; + +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_Int dp[8]; + + + if ( value_is_string ) + { + const char* s = (const char*)value; + char* ep; + int i; + + + /* eight comma-separated numbers */ + for ( i = 0; i < 7; i++ ) + { + dp[i] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( *ep != ',' || s == ep ) + return FT_THROW( Invalid_Argument ); + + s = ep + 1; + } + + dp[7] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( !( *ep == '\0' || *ep == ' ' ) || s == ep ) + return FT_THROW( Invalid_Argument ); + + darken_params = dp; + } + else +#endif + darken_params = (FT_Int*)value; + + x1 = darken_params[0]; + y1 = darken_params[1]; + x2 = darken_params[2]; + y2 = darken_params[3]; + x3 = darken_params[4]; + y3 = darken_params[5]; + x4 = darken_params[6]; + y4 = darken_params[7]; + + if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || + y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 || + x1 > x2 || x2 > x3 || x3 > x4 || + y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 ) + return FT_THROW( Invalid_Argument ); + + driver->darken_params[0] = x1; + driver->darken_params[1] = y1; + driver->darken_params[2] = x2; + driver->darken_params[3] = y2; + driver->darken_params[4] = x3; + driver->darken_params[5] = y3; + driver->darken_params[6] = x4; + driver->darken_params[7] = y4; + + return error; + } + + else if ( !ft_strcmp( property_name, "hinting-engine" ) ) + { +#if defined( CFF_CONFIG_OPTION_OLD_ENGINE ) || \ + defined( T1_CONFIG_OPTION_OLD_ENGINE ) + const char* module_name = module->clazz->module_name; +#endif + + +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + + + if ( !ft_strcmp( s, "adobe" ) ) + driver->hinting_engine = FT_HINTING_ADOBE; + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + else if ( !ft_strcmp( module_name, "cff" ) && + !ft_strcmp( s, "freetype" ) ) + driver->hinting_engine = FT_HINTING_FREETYPE; +#endif + +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + else if ( ( !ft_strcmp( module_name, "type1" ) || + !ft_strcmp( module_name, "t1cid" ) ) && + !ft_strcmp( s, "freetype" ) ) + driver->hinting_engine = FT_HINTING_FREETYPE; +#endif + + else + return FT_THROW( Invalid_Argument ); + } + else +#endif /* FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES */ + { + FT_UInt* hinting_engine = (FT_UInt*)value; + + + if ( *hinting_engine == FT_HINTING_ADOBE +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + || ( *hinting_engine == FT_HINTING_FREETYPE && + !ft_strcmp( module_name, "cff" ) ) +#endif +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + || ( *hinting_engine == FT_HINTING_FREETYPE && + ( !ft_strcmp( module_name, "type1" ) || + !ft_strcmp( module_name, "t1cid" ) ) ) +#endif + ) + driver->hinting_engine = *hinting_engine; + else + error = FT_ERR( Unimplemented_Feature ); + + return error; + } + } + + else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) + { +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + long nsd = ft_strtol( s, NULL, 10 ); + + + if ( !nsd ) + driver->no_stem_darkening = FALSE; + else + driver->no_stem_darkening = TRUE; + } + else +#endif + { + FT_Bool* no_stem_darkening = (FT_Bool*)value; + + + driver->no_stem_darkening = *no_stem_darkening; + } + + return error; + } + + else if ( !ft_strcmp( property_name, "random-seed" ) ) + { + FT_Int32 random_seed; + + +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + + + random_seed = (FT_Int32)ft_strtol( s, NULL, 10 ); + } + else +#endif + random_seed = *(FT_Int32*)value; + + if ( random_seed < 0 ) + random_seed = 0; + + driver->random_seed = random_seed; + + return error; + } + + FT_TRACE0(( "ps_property_set: missing property `%s'\n", + property_name )); + return FT_THROW( Missing_Property ); + } + + + FT_BASE_CALLBACK_DEF( FT_Error ) + ps_property_get( FT_Module module, /* PS_Driver */ + const char* property_name, + void* value ) + { + FT_Error error = FT_Err_Ok; + PS_Driver driver = (PS_Driver)module; + + + if ( !ft_strcmp( property_name, "darkening-parameters" ) ) + { + FT_Int* darken_params = driver->darken_params; + FT_Int* val = (FT_Int*)value; + + + val[0] = darken_params[0]; + val[1] = darken_params[1]; + val[2] = darken_params[2]; + val[3] = darken_params[3]; + val[4] = darken_params[4]; + val[5] = darken_params[5]; + val[6] = darken_params[6]; + val[7] = darken_params[7]; + + return error; + } + + else if ( !ft_strcmp( property_name, "hinting-engine" ) ) + { + FT_UInt hinting_engine = driver->hinting_engine; + FT_UInt* val = (FT_UInt*)value; + + + *val = hinting_engine; + + return error; + } + + else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) + { + FT_Bool no_stem_darkening = driver->no_stem_darkening; + FT_Bool* val = (FT_Bool*)value; + + + *val = no_stem_darkening; + + return error; + } + + FT_TRACE0(( "ps_property_get: missing property `%s'\n", + property_name )); + return FT_THROW( Missing_Property ); + } + + +/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftrfork.c b/Build/source/libs/freetype2/freetype-src/src/base/ftrfork.c index f5ad2874d8f..c3a2b9151ac 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftrfork.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftrfork.c @@ -4,7 +4,7 @@ /* */ /* Embedded resource forks accessor (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ @@ -478,7 +478,7 @@ } -#ifndef FT_MACINTOSH +#if defined( FT_CONFIG_OPTION_MAC_FONTS ) && !defined( FT_MACINTOSH ) static FT_RFork_Rule raccess_get_rule_type_from_rule_index( FT_Library library, FT_UInt rule_index ) diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftsnames.c b/Build/source/libs/freetype2/freetype-src/src/base/ftsnames.c index 36094500889..90ea1e2be7b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftsnames.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftsnames.c @@ -7,7 +7,7 @@ /* */ /* This is _not_ used to retrieve glyph names! */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftstream.c b/Build/source/libs/freetype2/freetype-src/src/base/ftstream.c index a3f8c8b3c9e..18df7dcfef6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftstream.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftstream.c @@ -4,7 +4,7 @@ /* */ /* I/O stream support (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftstroke.c b/Build/source/libs/freetype2/freetype-src/src/base/ftstroke.c index d32de0d62bb..6ae18190679 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftstroke.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftstroke.c @@ -4,7 +4,7 @@ /* */ /* FreeType path stroker (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftsynth.c b/Build/source/libs/freetype2/freetype-src/src/base/ftsynth.c index 5cf386f48d8..c28346707bd 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftsynth.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftsynth.c @@ -4,7 +4,7 @@ /* */ /* FreeType synthesizing code for emboldening and slanting (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftsystem.c b/Build/source/libs/freetype2/freetype-src/src/base/ftsystem.c index 324f949a495..6adebdb9383 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftsystem.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftsystem.c @@ -4,7 +4,7 @@ /* */ /* ANSI-specific FreeType low-level system interface (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/fttrigon.c b/Build/source/libs/freetype2/freetype-src/src/base/fttrigon.c index 7a4d17c8296..d6dd098c426 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/fttrigon.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/fttrigon.c @@ -4,7 +4,7 @@ /* */ /* FreeType trigonometric functions (body). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/fttype1.c b/Build/source/libs/freetype2/freetype-src/src/base/fttype1.c index 4d16a6371a5..aa8f8ccbbb4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/fttype1.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/fttype1.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file for PS names support (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftutil.c b/Build/source/libs/freetype2/freetype-src/src/base/ftutil.c index 7bd5bee87c4..4de5f2c145d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftutil.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftutil.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file for memory and list management (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftwinfnt.c b/Build/source/libs/freetype2/freetype-src/src/base/ftwinfnt.c index 05baa02da6a..11bd28afb7a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftwinfnt.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftwinfnt.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing Windows FNT specific info (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/base/rules.mk b/Build/source/libs/freetype2/freetype-src/src/base/rules.mk index 2a1e93cb005..6491f5d8a6b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/base/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -45,6 +45,7 @@ BASE_SRC := $(BASE_DIR)/basepic.c \ $(BASE_DIR)/ftobjs.c \ $(BASE_DIR)/ftoutln.c \ $(BASE_DIR)/ftpic.c \ + $(BASE_DIR)/ftpsprop.c \ $(BASE_DIR)/ftrfork.c \ $(BASE_DIR)/ftsnames.c \ $(BASE_DIR)/ftstream.c \ diff --git a/Build/source/libs/freetype2/freetype-src/src/bdf/Jamfile b/Build/source/libs/freetype2/freetype-src/src/bdf/Jamfile index f382b51db7f..d9e441c1887 100644 --- a/Build/source/libs/freetype2/freetype-src/src/bdf/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/bdf/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/bdf Jamfile # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/bdf/README b/Build/source/libs/freetype2/freetype-src/src/bdf/README index b761aba2b28..996ac2d2aae 100644 --- a/Build/source/libs/freetype2/freetype-src/src/bdf/README +++ b/Build/source/libs/freetype2/freetype-src/src/bdf/README @@ -13,7 +13,7 @@ This code implements a BDF driver for the FreeType library, following the Adobe Specification V 2.2. The specification of the BDF font format is available from Adobe's web site: - http://partners.adobe.com/public/developer/en/font/5005.BDF_Spec.pdf + https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5005.BDF_Spec.pdf Many good bitmap fonts in bdf format come with XFree86 (www.XFree86.org). They do not define vertical metrics, because the X Consortium BDF diff --git a/Build/source/libs/freetype2/freetype-src/src/bdf/bdfdrivr.c b/Build/source/libs/freetype2/freetype-src/src/bdf/bdfdrivr.c index fb778100072..ca937f89ce3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/bdf/bdfdrivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/bdf/bdfdrivr.c @@ -813,7 +813,7 @@ THE SOFTWARE. bitmap->rows = glyph.bbx.height; bitmap->width = glyph.bbx.width; - if ( glyph.bpr > INT_MAX ) + if ( glyph.bpr > FT_INT_MAX ) FT_TRACE1(( "BDF_Glyph_Load: too large pitch %d is truncated\n", glyph.bpr )); bitmap->pitch = (int)glyph.bpr; /* same as FT_Bitmap.pitch */ diff --git a/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c b/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c index bf10887fd46..2f5c99d5448 100644 --- a/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c +++ b/Build/source/libs/freetype2/freetype-src/src/bdf/bdflib.c @@ -705,11 +705,11 @@ for ( v = 0; sbitset( ddigits, *s ); s++ ) { - if ( v < ( ULONG_MAX - 9 ) / 10 ) + if ( v < ( FT_ULONG_MAX - 9 ) / 10 ) v = v * 10 + a2i[(int)*s]; else { - v = ULONG_MAX; + v = FT_ULONG_MAX; break; } } @@ -738,11 +738,11 @@ for ( v = 0; sbitset( ddigits, *s ); s++ ) { - if ( v < ( LONG_MAX - 9 ) / 10 ) + if ( v < ( FT_LONG_MAX - 9 ) / 10 ) v = v * 10 + a2i[(int)*s]; else { - v = LONG_MAX; + v = FT_LONG_MAX; break; } } @@ -763,11 +763,11 @@ for ( v = 0; sbitset( ddigits, *s ); s++ ) { - if ( v < ( USHRT_MAX - 9 ) / 10 ) + if ( v < ( FT_USHORT_MAX - 9 ) / 10 ) v = (unsigned short)( v * 10 + a2i[(int)*s] ); else { - v = USHRT_MAX; + v = FT_USHORT_MAX; break; } } diff --git a/Build/source/libs/freetype2/freetype-src/src/bzip2/Jamfile b/Build/source/libs/freetype2/freetype-src/src/bzip2/Jamfile index f369d4ace0d..3548eab5975 100644 --- a/Build/source/libs/freetype2/freetype-src/src/bzip2/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/bzip2/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/bzip2 Jamfile # -# Copyright 2010-2017 by +# Copyright 2010-2018 by # Joel Klinghed # # based on `src/lzw/Jamfile' diff --git a/Build/source/libs/freetype2/freetype-src/src/bzip2/ftbzip2.c b/Build/source/libs/freetype2/freetype-src/src/bzip2/ftbzip2.c index 7fc71e7079a..16019485a9b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/bzip2/ftbzip2.c +++ b/Build/source/libs/freetype2/freetype-src/src/bzip2/ftbzip2.c @@ -8,7 +8,7 @@ /* parse compressed PCF fonts, as found with many X11 server */ /* distributions. */ /* */ -/* Copyright 2010-2017 by */ +/* Copyright 2010-2018 by */ /* Joel Klinghed. */ /* */ /* based on `src/gzip/ftgzip.c' */ diff --git a/Build/source/libs/freetype2/freetype-src/src/bzip2/rules.mk b/Build/source/libs/freetype2/freetype-src/src/bzip2/rules.mk index f63ddc4d344..95954d75208 100644 --- a/Build/source/libs/freetype2/freetype-src/src/bzip2/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/bzip2/rules.mk @@ -2,7 +2,7 @@ # FreeType 2 BZIP2 support configuration rules # -# Copyright 2010-2017 by +# Copyright 2010-2018 by # Joel Klinghed. # # based on `src/lzw/rules.mk' diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/Jamfile b/Build/source/libs/freetype2/freetype-src/src/cache/Jamfile index 0880af83822..53f4c7b6032 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/cache/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cache Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcache.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftcache.c index 8226188314b..1b425af911f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcache.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcache.c @@ -4,7 +4,7 @@ /* */ /* The FreeType Caching sub-system (body only). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcbasic.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftcbasic.c index e804776ab4e..994aa12286f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcbasic.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcbasic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType basic cache interface (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftccache.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftccache.c index 37dc3abb1df..12ec585a253 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftccache.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftccache.c @@ -4,7 +4,7 @@ /* */ /* The FreeType internal cache interface (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftccache.h b/Build/source/libs/freetype2/freetype-src/src/cache/ftccache.h index d3c11ce082c..859c547e466 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftccache.h +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftccache.h @@ -4,7 +4,7 @@ /* */ /* FreeType internal cache interface (specification). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftccback.h b/Build/source/libs/freetype2/freetype-src/src/cache/ftccback.h index 2681e8c0226..e51d8d6e559 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftccback.h +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftccback.h @@ -4,7 +4,7 @@ /* */ /* Callback functions of the caching sub-system (specification only). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftccmap.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftccmap.c index 2fa84979c83..d20b0f48fe7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftccmap.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftccmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType CharMap cache (body) */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcerror.h b/Build/source/libs/freetype2/freetype-src/src/cache/ftcerror.h index 84fe52f546a..a26cd5935bc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcerror.h +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcerror.h @@ -4,7 +4,7 @@ /* */ /* Caching sub-system error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcglyph.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftcglyph.c index d2468f2f43c..782cc0ed09e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcglyph.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcglyph.c @@ -4,7 +4,7 @@ /* */ /* FreeType Glyph Image (FT_Glyph) cache (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcglyph.h b/Build/source/libs/freetype2/freetype-src/src/cache/ftcglyph.h index cab58ed311e..23c24d223f4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcglyph.h +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcglyph.h @@ -4,7 +4,7 @@ /* */ /* FreeType abstract glyph cache (specification). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcimage.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftcimage.c index 359f818cce2..77a100153e0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcimage.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcimage.c @@ -4,7 +4,7 @@ /* */ /* FreeType Image cache (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcimage.h b/Build/source/libs/freetype2/freetype-src/src/cache/ftcimage.h index 14049af9d27..24a221053b0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcimage.h +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcimage.h @@ -4,7 +4,7 @@ /* */ /* FreeType Generic Image cache (specification) */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcmanag.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftcmanag.c index edec2b6b5b9..2bcd9df5026 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcmanag.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcmanag.c @@ -4,7 +4,7 @@ /* */ /* FreeType Cache Manager (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcmanag.h b/Build/source/libs/freetype2/freetype-src/src/cache/ftcmanag.h index 556842e131c..b4b47553568 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcmanag.h +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcmanag.h @@ -4,7 +4,7 @@ /* */ /* FreeType Cache Manager (specification). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcmru.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftcmru.c index e293269f2f1..1087be4d890 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcmru.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcmru.c @@ -4,7 +4,7 @@ /* */ /* FreeType MRU support (body). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcmru.h b/Build/source/libs/freetype2/freetype-src/src/cache/ftcmru.h index c4c330d558b..82396b917d0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcmru.h +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcmru.h @@ -4,7 +4,7 @@ /* */ /* Simple MRU list-cache (specification). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcsbits.c b/Build/source/libs/freetype2/freetype-src/src/cache/ftcsbits.c index 2f9336decd5..018f1ecdb71 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcsbits.c +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcsbits.c @@ -4,7 +4,7 @@ /* */ /* FreeType sbits manager (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/ftcsbits.h b/Build/source/libs/freetype2/freetype-src/src/cache/ftcsbits.h index 1e15ce9764c..206a1bb3fc3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/ftcsbits.h +++ b/Build/source/libs/freetype2/freetype-src/src/cache/ftcsbits.h @@ -4,7 +4,7 @@ /* */ /* A small-bitmap cache (specification). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cache/rules.mk b/Build/source/libs/freetype2/freetype-src/src/cache/rules.mk index 62046895059..558935976dc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cache/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/cache/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2000-2017 by +# Copyright 2000-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile b/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile index e6dd05fc15a..53c904fcfe2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cff Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -23,15 +23,6 @@ SubDir FT2_TOP $(FT2_SRC_DIR) cff ; cffobjs cffparse cffpic - cf2arrst - cf2blues - cf2error - cf2font - cf2ft - cf2hints - cf2intrp - cf2read - cf2stack ; } else diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cff.c b/Build/source/libs/freetype2/freetype-src/src/cff/cff.c index 397f6dfafe9..1a755d5dadd 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cff.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cff.c @@ -4,7 +4,7 @@ /* */ /* FreeType OpenType driver component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,15 +27,4 @@ #include "cffload.c" #include "cffobjs.c" -#include "cf2arrst.c" -#include "cf2blues.c" -#include "cf2error.c" -#include "cf2font.c" -#include "cf2ft.c" -#include "cf2hints.c" -#include "cf2intrp.c" -#include "cf2read.c" -#include "cf2stack.c" - - /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c index 4adce7a54d9..e45ae1127bf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h index 7792e042483..856a43dd1b9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,7 +19,7 @@ #ifndef CFFCMAP_H_ #define CFFCMAP_H_ -#include "cffobjs.h" +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H FT_BEGIN_HEADER diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c index 38bfc2ca3dd..df896848da4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c @@ -4,7 +4,7 @@ /* */ /* OpenType font driver implementation (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,16 +21,20 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_POSTSCRIPT_PROPS_H #include FT_SERVICE_CID_H #include FT_SERVICE_POSTSCRIPT_INFO_H #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_TT_CMAP_H +#include FT_SERVICE_CFF_TABLE_LOAD_H #include "cffdrivr.h" #include "cffgload.h" #include "cffload.h" #include "cffcmap.h" #include "cffparse.h" +#include "cffobjs.h" #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_SERVICE_MULTIPLE_MASTERS_H @@ -43,7 +47,7 @@ #include FT_SERVICE_FONT_FORMAT_H #include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_PROPERTIES_H -#include FT_CFF_DRIVER_H +#include FT_DRIVER_H /*************************************************************************/ @@ -214,8 +218,8 @@ { #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* no fast retrieval for blended MM fonts without VVAR table */ - if ( !ttface->is_default_instance && - !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) + if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) && + !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) return FT_THROW( Unimplemented_Feature ); #endif @@ -237,8 +241,10 @@ &dummy, &ah ); - FT_TRACE5(( " idx %d: advance height %d font units\n", - start + nn, ah )); + FT_TRACE5(( " idx %d: advance height %d font unit%s\n", + start + nn, + ah, + ah == 1 ? "" : "s" )); advances[nn] = ah; } } @@ -246,8 +252,8 @@ { #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* no fast retrieval for blended MM fonts without HVAR table */ - if ( !ttface->is_default_instance && - !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) + if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) && + !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) return FT_THROW( Unimplemented_Feature ); #endif @@ -266,8 +272,10 @@ &dummy, &aw ); - FT_TRACE5(( " idx %d: advance width %d font units\n", - start + nn, aw )); + FT_TRACE5(( " idx %d: advance width %d font unit%s\n", + start + nn, + aw, + aw == 1 ? "" : "s" )); advances[nn] = aw; } } @@ -493,11 +501,89 @@ } + static FT_Error + cff_ps_get_font_extra( CFF_Face face, + PS_FontExtraRec* afont_extra ) + { + CFF_Font cff = (CFF_Font)face->extra.data; + FT_Error error = FT_Err_Ok; + + + if ( cff && cff->font_extra == NULL ) + { + CFF_FontRecDict dict = &cff->top_font.font_dict; + PS_FontExtraRec* font_extra = NULL; + FT_Memory memory = face->root.memory; + FT_String* embedded_postscript; + + + if ( FT_ALLOC( font_extra, sizeof ( *font_extra ) ) ) + goto Fail; + + font_extra->fs_type = 0U; + + embedded_postscript = cff_index_get_sid_string( + cff, + dict->embedded_postscript ); + if ( embedded_postscript ) + { + FT_String* start_fstype; + FT_String* start_def; + + + /* Identify the XYZ integer in `/FSType XYZ def' substring. */ + if ( ( start_fstype = ft_strstr( embedded_postscript, + "/FSType" ) ) != NULL && + ( start_def = ft_strstr( start_fstype + + sizeof ( "/FSType" ) - 1, + "def" ) ) != NULL ) + { + FT_String* s; + + + for ( s = start_fstype + sizeof ( "/FSType" ) - 1; + s != start_def; + s++ ) + { + if ( *s >= '0' && *s <= '9' ) + { + if ( font_extra->fs_type >= ( FT_USHORT_MAX - 9 ) / 10 ) + { + /* Overflow - ignore the FSType value. */ + font_extra->fs_type = 0U; + break; + } + + font_extra->fs_type *= 10; + font_extra->fs_type += (FT_UShort)( *s - '0' ); + } + else if ( *s != ' ' && *s != '\n' && *s != '\r' ) + { + /* Non-whitespace character between `/FSType' and next `def' */ + /* - ignore the FSType value. */ + font_extra->fs_type = 0U; + break; + } + } + } + } + + cff->font_extra = font_extra; + } + + if ( cff ) + *afont_extra = *cff->font_extra; + + Fail: + return error; + } + + FT_DEFINE_SERVICE_PSINFOREC( cff_service_ps_info, (PS_GetFontInfoFunc) cff_ps_get_font_info, /* ps_get_font_info */ - (PS_GetFontExtraFunc) NULL, /* ps_get_font_extra */ + (PS_GetFontExtraFunc) cff_ps_get_font_extra, /* ps_get_font_extra */ (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, /* ps_has_glyph_names */ /* unsupported with CFF fonts */ (PS_GetFontPrivateFunc)NULL, /* ps_get_font_private */ @@ -735,231 +821,12 @@ * PROPERTY SERVICE * */ - static FT_Error - cff_property_set( FT_Module module, /* CFF_Driver */ - const char* property_name, - const void* value, - FT_Bool value_is_string ) - { - FT_Error error = FT_Err_Ok; - CFF_Driver driver = (CFF_Driver)module; - -#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - FT_UNUSED( value_is_string ); -#endif - - - if ( !ft_strcmp( property_name, "darkening-parameters" ) ) - { - FT_Int* darken_params; - FT_Int x1, y1, x2, y2, x3, y3, x4, y4; - -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - FT_Int dp[8]; - - - if ( value_is_string ) - { - const char* s = (const char*)value; - char* ep; - int i; - - - /* eight comma-separated numbers */ - for ( i = 0; i < 7; i++ ) - { - dp[i] = (FT_Int)ft_strtol( s, &ep, 10 ); - if ( *ep != ',' || s == ep ) - return FT_THROW( Invalid_Argument ); - - s = ep + 1; - } - - dp[7] = (FT_Int)ft_strtol( s, &ep, 10 ); - if ( !( *ep == '\0' || *ep == ' ' ) || s == ep ) - return FT_THROW( Invalid_Argument ); - - darken_params = dp; - } - else -#endif - darken_params = (FT_Int*)value; - - x1 = darken_params[0]; - y1 = darken_params[1]; - x2 = darken_params[2]; - y2 = darken_params[3]; - x3 = darken_params[4]; - y3 = darken_params[5]; - x4 = darken_params[6]; - y4 = darken_params[7]; - - if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || - y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 || - x1 > x2 || x2 > x3 || x3 > x4 || - y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 ) - return FT_THROW( Invalid_Argument ); - - driver->darken_params[0] = x1; - driver->darken_params[1] = y1; - driver->darken_params[2] = x2; - driver->darken_params[3] = y2; - driver->darken_params[4] = x3; - driver->darken_params[5] = y3; - driver->darken_params[6] = x4; - driver->darken_params[7] = y4; - - return error; - } - else if ( !ft_strcmp( property_name, "hinting-engine" ) ) - { -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - - - if ( !ft_strcmp( s, "adobe" ) ) - driver->hinting_engine = FT_CFF_HINTING_ADOBE; -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - else if ( !ft_strcmp( s, "freetype" ) ) - driver->hinting_engine = FT_CFF_HINTING_FREETYPE; -#endif - else - return FT_THROW( Invalid_Argument ); - } - else -#endif - { - FT_UInt* hinting_engine = (FT_UInt*)value; - - - if ( *hinting_engine == FT_CFF_HINTING_ADOBE -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - || *hinting_engine == FT_CFF_HINTING_FREETYPE -#endif - ) - driver->hinting_engine = *hinting_engine; - else - error = FT_ERR( Unimplemented_Feature ); - - return error; - } - } - else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) - { -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - long nsd = ft_strtol( s, NULL, 10 ); - - - if ( !nsd ) - driver->no_stem_darkening = FALSE; - else - driver->no_stem_darkening = TRUE; - } - else -#endif - { - FT_Bool* no_stem_darkening = (FT_Bool*)value; - - - driver->no_stem_darkening = *no_stem_darkening; - } - - return error; - } - else if ( !ft_strcmp( property_name, "random-seed" ) ) - { - FT_Int32 random_seed; - - -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - - - random_seed = (FT_Int32)ft_strtol( s, NULL, 10 ); - } - else -#endif - random_seed = *(FT_Int32*)value; - - if ( random_seed < 0 ) - random_seed = 0; - - driver->random_seed = random_seed; - - return error; - } - - FT_TRACE0(( "cff_property_set: missing property `%s'\n", - property_name )); - return FT_THROW( Missing_Property ); - } - - - static FT_Error - cff_property_get( FT_Module module, /* CFF_Driver */ - const char* property_name, - const void* value ) - { - FT_Error error = FT_Err_Ok; - CFF_Driver driver = (CFF_Driver)module; - - - if ( !ft_strcmp( property_name, "darkening-parameters" ) ) - { - FT_Int* darken_params = driver->darken_params; - FT_Int* val = (FT_Int*)value; - - - val[0] = darken_params[0]; - val[1] = darken_params[1]; - val[2] = darken_params[2]; - val[3] = darken_params[3]; - val[4] = darken_params[4]; - val[5] = darken_params[5]; - val[6] = darken_params[6]; - val[7] = darken_params[7]; - - return error; - } - else if ( !ft_strcmp( property_name, "hinting-engine" ) ) - { - FT_UInt hinting_engine = driver->hinting_engine; - FT_UInt* val = (FT_UInt*)value; - - - *val = hinting_engine; - - return error; - } - else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) - { - FT_Bool no_stem_darkening = driver->no_stem_darkening; - FT_Bool* val = (FT_Bool*)value; - - - *val = no_stem_darkening; - - return error; - } - - FT_TRACE0(( "cff_property_get: missing property `%s'\n", - property_name )); - return FT_THROW( Missing_Property ); - } - FT_DEFINE_SERVICE_PROPERTIESREC( cff_service_properties, - (FT_Properties_SetFunc)cff_property_set, /* set_property */ - (FT_Properties_GetFunc)cff_property_get ) /* get_property */ + (FT_Properties_SetFunc)ps_property_set, /* set_property */ + (FT_Properties_GetFunc)ps_property_get ) /* get_property */ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT @@ -1028,6 +895,17 @@ } + static FT_Error + cff_set_instance( CFF_Face face, + FT_UInt instance_index ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->set_instance( FT_FACE( face ), instance_index ); + } + + FT_DEFINE_SERVICE_MULTIMASTERSREC( cff_service_multi_masters, @@ -1038,6 +916,7 @@ (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */ (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */ + (FT_Set_Instance_Func) cff_set_instance, /* set_instance */ (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ (FT_Done_Blend_Func) cff_done_blend /* done_blend */ @@ -1088,6 +967,22 @@ #endif + /* + * CFFLOAD SERVICE + * + */ + + FT_DEFINE_SERVICE_CFFLOADREC( + cff_service_cff_load, + + (FT_Get_Standard_Encoding_Func)cff_get_standard_encoding, + (FT_Load_Private_Dict_Func) cff_load_private_dict, + (FT_FD_Select_Get_Func) cff_fd_select_get, + (FT_Blend_Check_Vector_Func) cff_blend_check_vector, + (FT_Blend_Build_Vector_Func) cff_blend_build_vector + ) + + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -1102,7 +997,7 @@ #if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \ defined TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_DEFINE_SERVICEDESCREC9( + FT_DEFINE_SERVICEDESCREC10( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, @@ -1113,10 +1008,11 @@ FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, + FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET ) #elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES - FT_DEFINE_SERVICEDESCREC7( + FT_DEFINE_SERVICEDESCREC8( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, @@ -1125,10 +1021,11 @@ FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, + FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET ) #elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_DEFINE_SERVICEDESCREC8( + FT_DEFINE_SERVICEDESCREC9( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, @@ -1138,10 +1035,11 @@ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, + FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET ) #else - FT_DEFINE_SERVICEDESCREC6( + FT_DEFINE_SERVICEDESCREC7( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, @@ -1149,7 +1047,8 @@ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, + FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET ) #endif @@ -1208,7 +1107,7 @@ FT_MODULE_DRIVER_HAS_HINTER | FT_MODULE_DRIVER_HINTS_LIGHTLY, - sizeof ( CFF_DriverRec ), + sizeof ( PS_DriverRec ), "cff", 0x10000L, 0x20000L, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h index 05381e66db9..ad7c3ad70a8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h @@ -4,7 +4,7 @@ /* */ /* High-level OpenType driver interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h index 40808c10513..b2e1bfaf9db 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h @@ -4,7 +4,7 @@ /* */ /* CFF error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c index 20f3a2c28e9..c58471ce861 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,13 +21,12 @@ #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H #include FT_INTERNAL_CALC_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #include FT_OUTLINE_H -#include FT_CFF_DRIVER_H +#include FT_DRIVER_H -#include "cffobjs.h" #include "cffload.h" #include "cffgload.h" -#include "cf2ft.h" /* for cf2_decoder_parse_charstrings */ #include "cfferrs.h" @@ -42,623 +41,6 @@ #define FT_COMPONENT trace_cffgload -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - - typedef enum CFF_Operator_ - { - cff_op_unknown = 0, - - cff_op_rmoveto, - cff_op_hmoveto, - cff_op_vmoveto, - - cff_op_rlineto, - cff_op_hlineto, - cff_op_vlineto, - - cff_op_rrcurveto, - cff_op_hhcurveto, - cff_op_hvcurveto, - cff_op_rcurveline, - cff_op_rlinecurve, - cff_op_vhcurveto, - cff_op_vvcurveto, - - cff_op_flex, - cff_op_hflex, - cff_op_hflex1, - cff_op_flex1, - - cff_op_endchar, - - cff_op_hstem, - cff_op_vstem, - cff_op_hstemhm, - cff_op_vstemhm, - - cff_op_hintmask, - cff_op_cntrmask, - cff_op_dotsection, /* deprecated, acts as no-op */ - - cff_op_abs, - cff_op_add, - cff_op_sub, - cff_op_div, - cff_op_neg, - cff_op_random, - cff_op_mul, - cff_op_sqrt, - - cff_op_blend, - - cff_op_drop, - cff_op_exch, - cff_op_index, - cff_op_roll, - cff_op_dup, - - cff_op_put, - cff_op_get, - cff_op_store, - cff_op_load, - - cff_op_and, - cff_op_or, - cff_op_not, - cff_op_eq, - cff_op_ifelse, - - cff_op_callsubr, - cff_op_callgsubr, - cff_op_return, - - /* Type 1 opcodes: invalid but seen in real life */ - cff_op_hsbw, - cff_op_closepath, - cff_op_callothersubr, - cff_op_pop, - cff_op_seac, - cff_op_sbw, - cff_op_setcurrentpoint, - - /* do not remove */ - cff_op_max - - } CFF_Operator; - - -#define CFF_COUNT_CHECK_WIDTH 0x80 -#define CFF_COUNT_EXACT 0x40 -#define CFF_COUNT_CLEAR_STACK 0x20 - - /* count values which have the `CFF_COUNT_CHECK_WIDTH' flag set are */ - /* used for checking the width and requested numbers of arguments */ - /* only; they are set to zero afterwards */ - - /* the other two flags are informative only and unused currently */ - - static const FT_Byte cff_argument_counts[] = - { - 0, /* unknown */ - - 2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, /* rmoveto */ - 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, - 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, - - 0 | CFF_COUNT_CLEAR_STACK, /* rlineto */ - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - - 0 | CFF_COUNT_CLEAR_STACK, /* rrcurveto */ - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - - 13, /* flex */ - 7, - 9, - 11, - - 0 | CFF_COUNT_CHECK_WIDTH, /* endchar */ - - 2 | CFF_COUNT_CHECK_WIDTH, /* hstem */ - 2 | CFF_COUNT_CHECK_WIDTH, - 2 | CFF_COUNT_CHECK_WIDTH, - 2 | CFF_COUNT_CHECK_WIDTH, - - 0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */ - 0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */ - 0, /* dotsection */ - - 1, /* abs */ - 2, - 2, - 2, - 1, - 0, - 2, - 1, - - 1, /* blend */ - - 1, /* drop */ - 2, - 1, - 2, - 1, - - 2, /* put */ - 1, - 4, - 3, - - 2, /* and */ - 2, - 1, - 2, - 4, - - 1, /* callsubr */ - 1, - 0, - - 2, /* hsbw */ - 0, - 0, - 0, - 5, /* seac */ - 4, /* sbw */ - 2 /* setcurrentpoint */ - }; - -#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** GENERIC CHARSTRING PARSING *********/ - /********** *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_builder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph builder. */ - /* */ - /* <InOut> */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting is active. */ - /* */ - static void - cff_builder_init( CFF_Builder* builder, - TT_Face face, - CFF_Size size, - CFF_GlyphSlot glyph, - FT_Bool hinting ) - { - builder->path_begun = 0; - builder->load_points = 1; - - builder->face = face; - builder->glyph = glyph; - builder->memory = face->root.memory; - - if ( glyph ) - { - FT_GlyphLoader loader = glyph->root.internal->loader; - - - builder->loader = loader; - builder->base = &loader->base.outline; - builder->current = &loader->current.outline; - FT_GlyphLoader_Rewind( loader ); - - builder->hints_globals = NULL; - builder->hints_funcs = NULL; - - if ( hinting && size ) - { - FT_Size ftsize = FT_SIZE( size ); - CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data; - - - if ( internal ) - { - builder->hints_globals = (void *)internal->topfont; - builder->hints_funcs = glyph->root.internal->glyph_hints; - } - } - } - - builder->pos_x = 0; - builder->pos_y = 0; - - builder->left_bearing.x = 0; - builder->left_bearing.y = 0; - builder->advance.x = 0; - builder->advance.y = 0; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_builder_done */ - /* */ - /* <Description> */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* <Input> */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ - static void - cff_builder_done( CFF_Builder* builder ) - { - CFF_GlyphSlot glyph = builder->glyph; - - - if ( glyph ) - glyph->root.outline = *builder->base; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_compute_bias */ - /* */ - /* <Description> */ - /* Computes the bias value in dependence of the number of glyph */ - /* subroutines. */ - /* */ - /* <Input> */ - /* in_charstring_type :: The `CharstringType' value of the top DICT */ - /* dictionary. */ - /* */ - /* num_subrs :: The number of glyph subroutines. */ - /* */ - /* <Return> */ - /* The bias value. */ - static FT_Int - cff_compute_bias( FT_Int in_charstring_type, - FT_UInt num_subrs ) - { - FT_Int result; - - - if ( in_charstring_type == 1 ) - result = 0; - else if ( num_subrs < 1240 ) - result = 107; - else if ( num_subrs < 33900U ) - result = 1131; - else - result = 32768U; - - return result; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_decoder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph decoder. */ - /* */ - /* <InOut> */ - /* decoder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* slot :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting is active. */ - /* */ - /* hint_mode :: The hinting mode. */ - /* */ - FT_LOCAL_DEF( void ) - cff_decoder_init( CFF_Decoder* decoder, - TT_Face face, - CFF_Size size, - CFF_GlyphSlot slot, - FT_Bool hinting, - FT_Render_Mode hint_mode ) - { - CFF_Font cff = (CFF_Font)face->extra.data; - - - /* clear everything */ - FT_ZERO( decoder ); - - /* initialize builder */ - cff_builder_init( &decoder->builder, face, size, slot, hinting ); - - /* initialize Type2 decoder */ - decoder->cff = cff; - decoder->num_globals = cff->global_subrs_index.count; - decoder->globals = cff->global_subrs; - decoder->globals_bias = cff_compute_bias( - cff->top_font.font_dict.charstring_type, - decoder->num_globals ); - - decoder->hint_mode = hint_mode; - } - - - /* this function is used to select the subfont */ - /* and the locals subrs array */ - FT_LOCAL_DEF( FT_Error ) - cff_decoder_prepare( CFF_Decoder* decoder, - CFF_Size size, - FT_UInt glyph_index ) - { - CFF_Builder *builder = &decoder->builder; - CFF_Font cff = (CFF_Font)builder->face->extra.data; - CFF_SubFont sub = &cff->top_font; - FT_Error error = FT_Err_Ok; - - - /* manage CID fonts */ - if ( cff->num_subfonts ) - { - FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index ); - - - if ( fd_index >= cff->num_subfonts ) - { - FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" )); - error = FT_THROW( Invalid_File_Format ); - goto Exit; - } - - FT_TRACE3(( " in subfont %d:\n", fd_index )); - - sub = cff->subfonts[fd_index]; - - if ( builder->hints_funcs && size ) - { - FT_Size ftsize = FT_SIZE( size ); - CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data; - - - /* for CFFs without subfonts, this value has already been set */ - builder->hints_globals = (void *)internal->subfonts[fd_index]; - } - } - - decoder->num_locals = sub->local_subrs_index.count; - decoder->locals = sub->local_subrs; - decoder->locals_bias = cff_compute_bias( - decoder->cff->top_font.font_dict.charstring_type, - decoder->num_locals ); - - decoder->glyph_width = sub->private_dict.default_width; - decoder->nominal_width = sub->private_dict.nominal_width; - - decoder->current_subfont = sub; - - Exit: - return error; - } - - - /* check that there is enough space for `count' more points */ - FT_LOCAL_DEF( FT_Error ) - cff_check_points( CFF_Builder* builder, - FT_Int count ) - { - return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 ); - } - - - /* add a new point, do not check space */ - FT_LOCAL_DEF( void ) - cff_builder_add_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y, - FT_Byte flag ) - { - FT_Outline* outline = builder->current; - - - if ( builder->load_points ) - { - FT_Vector* point = outline->points + outline->n_points; - FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; - -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face ); - - - if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE ) - { - point->x = x >> 16; - point->y = y >> 16; - } - else -#endif - { - /* cf2_decoder_parse_charstrings uses 16.16 coordinates */ - point->x = x >> 10; - point->y = y >> 10; - } - *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); - } - - outline->n_points++; - } - - - /* check space for a new on-curve point, then add it */ - FT_LOCAL_DEF( FT_Error ) - cff_builder_add_point1( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ) - { - FT_Error error; - - - error = cff_check_points( builder, 1 ); - if ( !error ) - cff_builder_add_point( builder, x, y, 1 ); - - return error; - } - - - /* check space for a new contour, then add it */ - static FT_Error - cff_builder_add_contour( CFF_Builder* builder ) - { - FT_Outline* outline = builder->current; - FT_Error error; - - - if ( !builder->load_points ) - { - outline->n_contours++; - return FT_Err_Ok; - } - - error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); - if ( !error ) - { - if ( outline->n_contours > 0 ) - outline->contours[outline->n_contours - 1] = - (short)( outline->n_points - 1 ); - - outline->n_contours++; - } - - return error; - } - - - /* if a path was begun, add its first on-curve point */ - FT_LOCAL_DEF( FT_Error ) - cff_builder_start_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ) - { - FT_Error error = FT_Err_Ok; - - - /* test whether we are building a new contour */ - if ( !builder->path_begun ) - { - builder->path_begun = 1; - error = cff_builder_add_contour( builder ); - if ( !error ) - error = cff_builder_add_point1( builder, x, y ); - } - - return error; - } - - - /* close the current contour */ - FT_LOCAL_DEF( void ) - cff_builder_close_contour( CFF_Builder* builder ) - { - FT_Outline* outline = builder->current; - FT_Int first; - - - if ( !outline ) - return; - - first = outline->n_contours <= 1 - ? 0 : outline->contours[outline->n_contours - 2] + 1; - - /* We must not include the last point in the path if it */ - /* is located on the first point. */ - if ( outline->n_points > 1 ) - { - FT_Vector* p1 = outline->points + first; - FT_Vector* p2 = outline->points + outline->n_points - 1; - FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1; - - - /* `delete' last point only if it coincides with the first */ - /* point and if it is not a control point (which can happen). */ - if ( p1->x == p2->x && p1->y == p2->y ) - if ( *control == FT_CURVE_TAG_ON ) - outline->n_points--; - } - - if ( outline->n_contours > 0 ) - { - /* Don't add contours only consisting of one point, i.e., */ - /* check whether begin point and last point are the same. */ - if ( first == outline->n_points - 1 ) - { - outline->n_contours--; - outline->n_points--; - } - else - outline->contours[outline->n_contours - 1] = - (short)( outline->n_points - 1 ); - } - } - - - FT_LOCAL_DEF( FT_Int ) - cff_lookup_glyph_by_stdcharcode( CFF_Font cff, - FT_Int charcode ) - { - FT_UInt n; - FT_UShort glyph_sid; - - - /* CID-keyed fonts don't have glyph names */ - if ( !cff->charset.sids ) - return -1; - - /* check range of standard char code */ - if ( charcode < 0 || charcode > 255 ) - return -1; - - /* Get code to SID mapping from `cff_standard_encoding'. */ - glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode ); - - for ( n = 0; n < cff->num_glyphs; n++ ) - { - if ( cff->charset.sids[n] == glyph_sid ) - return (FT_Int)n; - } - - return -1; - } - - FT_LOCAL_DEF( FT_Error ) cff_get_glyph_data( TT_Face face, FT_UInt glyph_index, @@ -730,1950 +112,6 @@ } -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - - static FT_Error - cff_operator_seac( CFF_Decoder* decoder, - FT_Pos asb, - FT_Pos adx, - FT_Pos ady, - FT_Int bchar, - FT_Int achar ) - { - FT_Error error; - CFF_Builder* builder = &decoder->builder; - FT_Int bchar_index, achar_index; - TT_Face face = decoder->builder.face; - FT_Vector left_bearing, advance; - FT_Byte* charstring; - FT_ULong charstring_len; - FT_Pos glyph_width; - - - if ( decoder->seac ) - { - FT_ERROR(( "cff_operator_seac: invalid nested seac\n" )); - return FT_THROW( Syntax_Error ); - } - - adx += decoder->builder.left_bearing.x; - ady += decoder->builder.left_bearing.y; - -#ifdef FT_CONFIG_OPTION_INCREMENTAL - /* Incremental fonts don't necessarily have valid charsets. */ - /* They use the character code, not the glyph index, in this case. */ - if ( face->root.internal->incremental_interface ) - { - bchar_index = bchar; - achar_index = achar; - } - else -#endif /* FT_CONFIG_OPTION_INCREMENTAL */ - { - CFF_Font cff = (CFF_Font)(face->extra.data); - - - bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar ); - achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar ); - } - - if ( bchar_index < 0 || achar_index < 0 ) - { - FT_ERROR(( "cff_operator_seac:" - " invalid seac character code arguments\n" )); - return FT_THROW( Syntax_Error ); - } - - /* If we are trying to load a composite glyph, do not load the */ - /* accent character and return the array of subglyphs. */ - if ( builder->no_recurse ) - { - FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph; - FT_GlyphLoader loader = glyph->internal->loader; - FT_SubGlyph subg; - - - /* reallocate subglyph array if necessary */ - error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 ); - if ( error ) - goto Exit; - - subg = loader->current.subglyphs; - - /* subglyph 0 = base character */ - subg->index = bchar_index; - subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES | - FT_SUBGLYPH_FLAG_USE_MY_METRICS; - subg->arg1 = 0; - subg->arg2 = 0; - subg++; - - /* subglyph 1 = accent character */ - subg->index = achar_index; - subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; - subg->arg1 = (FT_Int)( adx >> 16 ); - subg->arg2 = (FT_Int)( ady >> 16 ); - - /* set up remaining glyph fields */ - glyph->num_subglyphs = 2; - glyph->subglyphs = loader->base.subglyphs; - glyph->format = FT_GLYPH_FORMAT_COMPOSITE; - - loader->current.num_subglyphs = 2; - } - - FT_GlyphLoader_Prepare( builder->loader ); - - /* First load `bchar' in builder */ - error = cff_get_glyph_data( face, (FT_UInt)bchar_index, - &charstring, &charstring_len ); - if ( !error ) - { - /* the seac operator must not be nested */ - decoder->seac = TRUE; - error = cff_decoder_parse_charstrings( decoder, charstring, - charstring_len, 0 ); - decoder->seac = FALSE; - - cff_free_glyph_data( face, &charstring, charstring_len ); - - if ( error ) - goto Exit; - } - - /* Save the left bearing, advance and glyph width of the base */ - /* character as they will be erased by the next load. */ - - left_bearing = builder->left_bearing; - advance = builder->advance; - glyph_width = decoder->glyph_width; - - builder->left_bearing.x = 0; - builder->left_bearing.y = 0; - - builder->pos_x = adx - asb; - builder->pos_y = ady; - - /* Now load `achar' on top of the base outline. */ - error = cff_get_glyph_data( face, (FT_UInt)achar_index, - &charstring, &charstring_len ); - if ( !error ) - { - /* the seac operator must not be nested */ - decoder->seac = TRUE; - error = cff_decoder_parse_charstrings( decoder, charstring, - charstring_len, 0 ); - decoder->seac = FALSE; - - cff_free_glyph_data( face, &charstring, charstring_len ); - - if ( error ) - goto Exit; - } - - /* Restore the left side bearing, advance and glyph width */ - /* of the base character. */ - builder->left_bearing = left_bearing; - builder->advance = advance; - decoder->glyph_width = glyph_width; - - builder->pos_x = 0; - builder->pos_y = 0; - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_decoder_parse_charstrings */ - /* */ - /* <Description> */ - /* Parses a given Type 2 charstrings program. */ - /* */ - /* <InOut> */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* <Input> */ - /* charstring_base :: The base of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* in_dict :: Set to 1 if function is called from top or */ - /* private DICT (needed for Multiple Master CFFs). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - cff_decoder_parse_charstrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_ULong charstring_len, - FT_Bool in_dict ) - { - FT_Error error; - CFF_Decoder_Zone* zone; - FT_Byte* ip; - FT_Byte* limit; - CFF_Builder* builder = &decoder->builder; - FT_Pos x, y; - FT_Fixed* stack; - FT_Int charstring_type = - decoder->cff->top_font.font_dict.charstring_type; - FT_UShort num_designs = - decoder->cff->top_font.font_dict.num_designs; - FT_UShort num_axes = - decoder->cff->top_font.font_dict.num_axes; - - T2_Hints_Funcs hinter; - - - /* set default width */ - decoder->num_hints = 0; - decoder->read_width = 1; - - /* initialize the decoder */ - decoder->top = decoder->stack; - decoder->zone = decoder->zones; - zone = decoder->zones; - stack = decoder->top; - - hinter = (T2_Hints_Funcs)builder->hints_funcs; - - builder->path_begun = 0; - - zone->base = charstring_base; - limit = zone->limit = charstring_base + charstring_len; - ip = zone->cursor = zone->base; - - error = FT_Err_Ok; - - x = builder->pos_x; - y = builder->pos_y; - - /* begin hints recording session, if any */ - if ( hinter ) - hinter->open( hinter->hints ); - - /* now execute loop */ - while ( ip < limit ) - { - CFF_Operator op; - FT_Byte v; - - - /********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ - v = *ip++; - if ( v >= 32 || v == 28 ) - { - FT_Int shift = 16; - FT_Int32 val; - - - /* this is an operand, push it on the stack */ - - /* if we use shifts, all computations are done with unsigned */ - /* values; the conversion to a signed value is the last step */ - if ( v == 28 ) - { - if ( ip + 1 >= limit ) - goto Syntax_Error; - val = (FT_Short)( ( (FT_UShort)ip[0] << 8 ) | ip[1] ); - ip += 2; - } - else if ( v < 247 ) - val = (FT_Int32)v - 139; - else if ( v < 251 ) - { - if ( ip >= limit ) - goto Syntax_Error; - val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108; - } - else if ( v < 255 ) - { - if ( ip >= limit ) - goto Syntax_Error; - val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108; - } - else - { - if ( ip + 3 >= limit ) - goto Syntax_Error; - val = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) | - ( (FT_UInt32)ip[1] << 16 ) | - ( (FT_UInt32)ip[2] << 8 ) | - (FT_UInt32)ip[3] ); - ip += 4; - if ( charstring_type == 2 ) - shift = 0; - } - if ( decoder->top - stack >= CFF_MAX_OPERANDS ) - goto Stack_Overflow; - - val = (FT_Int32)( (FT_UInt32)val << shift ); - *decoder->top++ = val; - -#ifdef FT_DEBUG_LEVEL_TRACE - if ( !( val & 0xFFFFL ) ) - FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) )); - else - FT_TRACE4(( " %.5f", val / 65536.0 )); -#endif - - } - else - { - /* The specification says that normally arguments are to be taken */ - /* from the bottom of the stack. However, this seems not to be */ - /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */ - /* arguments similar to a PS interpreter. */ - - FT_Fixed* args = decoder->top; - FT_Int num_args = (FT_Int)( args - decoder->stack ); - FT_Int req_args; - - - /* find operator */ - op = cff_op_unknown; - - switch ( v ) - { - case 1: - op = cff_op_hstem; - break; - case 3: - op = cff_op_vstem; - break; - case 4: - op = cff_op_vmoveto; - break; - case 5: - op = cff_op_rlineto; - break; - case 6: - op = cff_op_hlineto; - break; - case 7: - op = cff_op_vlineto; - break; - case 8: - op = cff_op_rrcurveto; - break; - case 9: - op = cff_op_closepath; - break; - case 10: - op = cff_op_callsubr; - break; - case 11: - op = cff_op_return; - break; - case 12: - { - if ( ip >= limit ) - goto Syntax_Error; - v = *ip++; - - switch ( v ) - { - case 0: - op = cff_op_dotsection; - break; - case 1: /* this is actually the Type1 vstem3 operator */ - op = cff_op_vstem; - break; - case 2: /* this is actually the Type1 hstem3 operator */ - op = cff_op_hstem; - break; - case 3: - op = cff_op_and; - break; - case 4: - op = cff_op_or; - break; - case 5: - op = cff_op_not; - break; - case 6: - op = cff_op_seac; - break; - case 7: - op = cff_op_sbw; - break; - case 8: - op = cff_op_store; - break; - case 9: - op = cff_op_abs; - break; - case 10: - op = cff_op_add; - break; - case 11: - op = cff_op_sub; - break; - case 12: - op = cff_op_div; - break; - case 13: - op = cff_op_load; - break; - case 14: - op = cff_op_neg; - break; - case 15: - op = cff_op_eq; - break; - case 16: - op = cff_op_callothersubr; - break; - case 17: - op = cff_op_pop; - break; - case 18: - op = cff_op_drop; - break; - case 20: - op = cff_op_put; - break; - case 21: - op = cff_op_get; - break; - case 22: - op = cff_op_ifelse; - break; - case 23: - op = cff_op_random; - break; - case 24: - op = cff_op_mul; - break; - case 26: - op = cff_op_sqrt; - break; - case 27: - op = cff_op_dup; - break; - case 28: - op = cff_op_exch; - break; - case 29: - op = cff_op_index; - break; - case 30: - op = cff_op_roll; - break; - case 33: - op = cff_op_setcurrentpoint; - break; - case 34: - op = cff_op_hflex; - break; - case 35: - op = cff_op_flex; - break; - case 36: - op = cff_op_hflex1; - break; - case 37: - op = cff_op_flex1; - break; - default: - FT_TRACE4(( " unknown op (12, %d)\n", v )); - break; - } - } - break; - case 13: - op = cff_op_hsbw; - break; - case 14: - op = cff_op_endchar; - break; - case 16: - op = cff_op_blend; - break; - case 18: - op = cff_op_hstemhm; - break; - case 19: - op = cff_op_hintmask; - break; - case 20: - op = cff_op_cntrmask; - break; - case 21: - op = cff_op_rmoveto; - break; - case 22: - op = cff_op_hmoveto; - break; - case 23: - op = cff_op_vstemhm; - break; - case 24: - op = cff_op_rcurveline; - break; - case 25: - op = cff_op_rlinecurve; - break; - case 26: - op = cff_op_vvcurveto; - break; - case 27: - op = cff_op_hhcurveto; - break; - case 29: - op = cff_op_callgsubr; - break; - case 30: - op = cff_op_vhcurveto; - break; - case 31: - op = cff_op_hvcurveto; - break; - default: - FT_TRACE4(( " unknown op (%d)\n", v )); - break; - } - - if ( op == cff_op_unknown ) - continue; - - /* in Multiple Master CFFs, T2 charstrings can appear in */ - /* dictionaries, but some operators are prohibited */ - if ( in_dict ) - { - switch ( op ) - { - case cff_op_hstem: - case cff_op_vstem: - case cff_op_vmoveto: - case cff_op_rlineto: - case cff_op_hlineto: - case cff_op_vlineto: - case cff_op_rrcurveto: - case cff_op_hstemhm: - case cff_op_hintmask: - case cff_op_cntrmask: - case cff_op_rmoveto: - case cff_op_hmoveto: - case cff_op_vstemhm: - case cff_op_rcurveline: - case cff_op_rlinecurve: - case cff_op_vvcurveto: - case cff_op_hhcurveto: - case cff_op_vhcurveto: - case cff_op_hvcurveto: - case cff_op_hflex: - case cff_op_flex: - case cff_op_hflex1: - case cff_op_flex1: - case cff_op_callsubr: - case cff_op_callgsubr: - goto MM_Error; - - default: - break; - } - } - - /* check arguments */ - req_args = cff_argument_counts[op]; - if ( req_args & CFF_COUNT_CHECK_WIDTH ) - { - if ( num_args > 0 && decoder->read_width ) - { - /* If `nominal_width' is non-zero, the number is really a */ - /* difference against `nominal_width'. Else, the number here */ - /* is truly a width, not a difference against `nominal_width'. */ - /* If the font does not set `nominal_width', then */ - /* `nominal_width' defaults to zero, and so we can set */ - /* `glyph_width' to `nominal_width' plus number on the stack */ - /* -- for either case. */ - - FT_Int set_width_ok; - - - switch ( op ) - { - case cff_op_hmoveto: - case cff_op_vmoveto: - set_width_ok = num_args & 2; - break; - - case cff_op_hstem: - case cff_op_vstem: - case cff_op_hstemhm: - case cff_op_vstemhm: - case cff_op_rmoveto: - case cff_op_hintmask: - case cff_op_cntrmask: - set_width_ok = num_args & 1; - break; - - case cff_op_endchar: - /* If there is a width specified for endchar, we either have */ - /* 1 argument or 5 arguments. We like to argue. */ - set_width_ok = in_dict - ? 0 - : ( ( num_args == 5 ) || ( num_args == 1 ) ); - break; - - default: - set_width_ok = 0; - break; - } - - if ( set_width_ok ) - { - decoder->glyph_width = decoder->nominal_width + - ( stack[0] >> 16 ); - - if ( decoder->width_only ) - { - /* we only want the advance width; stop here */ - break; - } - - /* Consumed an argument. */ - num_args--; - } - } - - decoder->read_width = 0; - req_args = 0; - } - - req_args &= 0x000F; - if ( num_args < req_args ) - goto Stack_Underflow; - args -= req_args; - num_args -= req_args; - - /* At this point, `args' points to the first argument of the */ - /* operand in case `req_args' isn't zero. Otherwise, we have */ - /* to adjust `args' manually. */ - - /* Note that we only pop arguments from the stack which we */ - /* really need and can digest so that we can continue in case */ - /* of superfluous stack elements. */ - - switch ( op ) - { - case cff_op_hstem: - case cff_op_vstem: - case cff_op_hstemhm: - case cff_op_vstemhm: - /* the number of arguments is always even here */ - FT_TRACE4(( - op == cff_op_hstem ? " hstem\n" : - ( op == cff_op_vstem ? " vstem\n" : - ( op == cff_op_hstemhm ? " hstemhm\n" : " vstemhm\n" ) ) )); - - if ( hinter ) - hinter->stems( hinter->hints, - ( op == cff_op_hstem || op == cff_op_hstemhm ), - num_args / 2, - args - ( num_args & ~1 ) ); - - decoder->num_hints += num_args / 2; - args = stack; - break; - - case cff_op_hintmask: - case cff_op_cntrmask: - FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" )); - - /* implement vstem when needed -- */ - /* the specification doesn't say it, but this also works */ - /* with the 'cntrmask' operator */ - /* */ - if ( num_args > 0 ) - { - if ( hinter ) - hinter->stems( hinter->hints, - 0, - num_args / 2, - args - ( num_args & ~1 ) ); - - decoder->num_hints += num_args / 2; - } - - /* In a valid charstring there must be at least one byte */ - /* after `hintmask' or `cntrmask' (e.g., for a `return' */ - /* instruction). Additionally, there must be space for */ - /* `num_hints' bits. */ - - if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit ) - goto Syntax_Error; - - if ( hinter ) - { - if ( op == cff_op_hintmask ) - hinter->hintmask( hinter->hints, - (FT_UInt)builder->current->n_points, - (FT_UInt)decoder->num_hints, - ip ); - else - hinter->counter( hinter->hints, - (FT_UInt)decoder->num_hints, - ip ); - } - -#ifdef FT_DEBUG_LEVEL_TRACE - { - FT_UInt maskbyte; - - - FT_TRACE4(( " (maskbytes:" )); - - for ( maskbyte = 0; - maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 ); - maskbyte++, ip++ ) - FT_TRACE4(( " 0x%02X", *ip )); - - FT_TRACE4(( ")\n" )); - } -#else - ip += ( decoder->num_hints + 7 ) >> 3; -#endif - args = stack; - break; - - case cff_op_rmoveto: - FT_TRACE4(( " rmoveto\n" )); - - cff_builder_close_contour( builder ); - builder->path_begun = 0; - x = ADD_LONG( x, args[-2] ); - y = ADD_LONG( y, args[-1] ); - args = stack; - break; - - case cff_op_vmoveto: - FT_TRACE4(( " vmoveto\n" )); - - cff_builder_close_contour( builder ); - builder->path_begun = 0; - y = ADD_LONG( y, args[-1] ); - args = stack; - break; - - case cff_op_hmoveto: - FT_TRACE4(( " hmoveto\n" )); - - cff_builder_close_contour( builder ); - builder->path_begun = 0; - x = ADD_LONG( x, args[-1] ); - args = stack; - break; - - case cff_op_rlineto: - FT_TRACE4(( " rlineto\n" )); - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, num_args / 2 ) ) - goto Fail; - - if ( num_args < 2 ) - goto Stack_Underflow; - - args -= num_args & ~1; - while ( args < decoder->top ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 1 ); - args += 2; - } - args = stack; - break; - - case cff_op_hlineto: - case cff_op_vlineto: - { - FT_Int phase = ( op == cff_op_hlineto ); - - - FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n" - : " vlineto\n" )); - - if ( num_args < 0 ) - goto Stack_Underflow; - - /* there exist subsetted fonts (found in PDFs) */ - /* which call `hlineto' without arguments */ - if ( num_args == 0 ) - break; - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, num_args ) ) - goto Fail; - - args = stack; - while ( args < decoder->top ) - { - if ( phase ) - x = ADD_LONG( x, args[0] ); - else - y = ADD_LONG( y, args[0] ); - - if ( cff_builder_add_point1( builder, x, y ) ) - goto Fail; - - args++; - phase ^= 1; - } - args = stack; - } - break; - - case cff_op_rrcurveto: - { - FT_Int nargs; - - - FT_TRACE4(( " rrcurveto\n" )); - - if ( num_args < 6 ) - goto Stack_Underflow; - - nargs = num_args - num_args % 6; - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, nargs / 2 ) ) - goto Fail; - - args -= nargs; - while ( args < decoder->top ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[2] ); - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[4] ); - y = ADD_LONG( y, args[5] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 6; - } - args = stack; - } - break; - - case cff_op_vvcurveto: - { - FT_Int nargs; - - - FT_TRACE4(( " vvcurveto\n" )); - - if ( num_args < 4 ) - goto Stack_Underflow; - - /* if num_args isn't of the form 4n or 4n+1, */ - /* we enforce it by clearing the second bit */ - - nargs = num_args & ~2; - - if ( cff_builder_start_point( builder, x, y ) ) - goto Fail; - - args -= nargs; - - if ( nargs & 1 ) - { - x = ADD_LONG( x, args[0] ); - args++; - nargs--; - } - - if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) ) - goto Fail; - - while ( args < decoder->top ) - { - y = ADD_LONG( y, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 4; - } - args = stack; - } - break; - - case cff_op_hhcurveto: - { - FT_Int nargs; - - - FT_TRACE4(( " hhcurveto\n" )); - - if ( num_args < 4 ) - goto Stack_Underflow; - - /* if num_args isn't of the form 4n or 4n+1, */ - /* we enforce it by clearing the second bit */ - - nargs = num_args & ~2; - - if ( cff_builder_start_point( builder, x, y ) ) - goto Fail; - - args -= nargs; - if ( nargs & 1 ) - { - y = ADD_LONG( y, args[0] ); - args++; - nargs--; - } - - if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) ) - goto Fail; - - while ( args < decoder->top ) - { - x = ADD_LONG( x, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[3] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 4; - } - args = stack; - } - break; - - case cff_op_vhcurveto: - case cff_op_hvcurveto: - { - FT_Int phase; - FT_Int nargs; - - - FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto\n" - : " hvcurveto\n" )); - - if ( cff_builder_start_point( builder, x, y ) ) - goto Fail; - - if ( num_args < 4 ) - goto Stack_Underflow; - - /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */ - /* we enforce it by clearing the second bit */ - - nargs = num_args & ~2; - - args -= nargs; - if ( cff_check_points( builder, ( nargs / 4 ) * 3 ) ) - goto Stack_Underflow; - - phase = ( op == cff_op_hvcurveto ); - - while ( nargs >= 4 ) - { - nargs -= 4; - if ( phase ) - { - x = ADD_LONG( x, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - y = ADD_LONG( y, args[3] ); - if ( nargs == 1 ) - x = ADD_LONG( x, args[4] ); - cff_builder_add_point( builder, x, y, 1 ); - } - else - { - y = ADD_LONG( y, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[3] ); - if ( nargs == 1 ) - y = ADD_LONG( y, args[4] ); - cff_builder_add_point( builder, x, y, 1 ); - } - args += 4; - phase ^= 1; - } - args = stack; - } - break; - - case cff_op_rlinecurve: - { - FT_Int num_lines; - FT_Int nargs; - - - FT_TRACE4(( " rlinecurve\n" )); - - if ( num_args < 8 ) - goto Stack_Underflow; - - nargs = num_args & ~1; - num_lines = ( nargs - 6 ) / 2; - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, num_lines + 3 ) ) - goto Fail; - - args -= nargs; - - /* first, add the line segments */ - while ( num_lines > 0 ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 2; - num_lines--; - } - - /* then the curve */ - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[2] ); - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[4] ); - y = ADD_LONG( y, args[5] ); - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - } - break; - - case cff_op_rcurveline: - { - FT_Int num_curves; - FT_Int nargs; - - - FT_TRACE4(( " rcurveline\n" )); - - if ( num_args < 8 ) - goto Stack_Underflow; - - nargs = num_args - 2; - nargs = nargs - nargs % 6 + 2; - num_curves = ( nargs - 2 ) / 6; - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, num_curves * 3 + 2 ) ) - goto Fail; - - args -= nargs; - - /* first, add the curves */ - while ( num_curves > 0 ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[2] ); - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[4] ); - y = ADD_LONG( y, args[5] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 6; - num_curves--; - } - - /* then the final line */ - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - } - break; - - case cff_op_hflex1: - { - FT_Pos start_y; - - - FT_TRACE4(( " hflex1\n" )); - - /* adding five more points: 4 control points, 1 on-curve point */ - /* -- make sure we have enough space for the start point if it */ - /* needs to be added */ - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, 6 ) ) - goto Fail; - - /* record the starting point's y position for later use */ - start_y = y; - - /* first control point */ - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* second control point */ - x = ADD_LONG( x, args[2] ); - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* join point; on curve, with y-value the same as the last */ - /* control point's y-value */ - x = ADD_LONG( x, args[4] ); - cff_builder_add_point( builder, x, y, 1 ); - - /* third control point, with y-value the same as the join */ - /* point's y-value */ - x = ADD_LONG( x, args[5] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* fourth control point */ - x = ADD_LONG( x, args[6] ); - y = ADD_LONG( y, args[7] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* ending point, with y-value the same as the start */ - x = ADD_LONG( x, args[8] ); - y = start_y; - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case cff_op_hflex: - { - FT_Pos start_y; - - - FT_TRACE4(( " hflex\n" )); - - /* adding six more points; 4 control points, 2 on-curve points */ - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, 6 ) ) - goto Fail; - - /* record the starting point's y-position for later use */ - start_y = y; - - /* first control point */ - x = ADD_LONG( x, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* second control point */ - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* join point; on curve, with y-value the same as the last */ - /* control point's y-value */ - x = ADD_LONG( x, args[3] ); - cff_builder_add_point( builder, x, y, 1 ); - - /* third control point, with y-value the same as the join */ - /* point's y-value */ - x = ADD_LONG( x, args[4] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* fourth control point */ - x = ADD_LONG( x, args[5] ); - y = start_y; - cff_builder_add_point( builder, x, y, 0 ); - - /* ending point, with y-value the same as the start point's */ - /* y-value -- we don't add this point, though */ - x = ADD_LONG( x, args[6] ); - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case cff_op_flex1: - { - FT_Pos start_x, start_y; /* record start x, y values for */ - /* alter use */ - FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */ - /* algorithm below */ - FT_Int horizontal, count; - FT_Fixed* temp; - - - FT_TRACE4(( " flex1\n" )); - - /* adding six more points; 4 control points, 2 on-curve points */ - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, 6 ) ) - goto Fail; - - /* record the starting point's x, y position for later use */ - start_x = x; - start_y = y; - - /* XXX: figure out whether this is supposed to be a horizontal */ - /* or vertical flex; the Type 2 specification is vague... */ - - temp = args; - - /* grab up to the last argument */ - for ( count = 5; count > 0; count-- ) - { - dx = ADD_LONG( dx, temp[0] ); - dy = ADD_LONG( dy, temp[1] ); - temp += 2; - } - - if ( dx < 0 ) - dx = -dx; - if ( dy < 0 ) - dy = -dy; - - /* strange test, but here it is... */ - horizontal = ( dx > dy ); - - for ( count = 5; count > 0; count-- ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, - (FT_Bool)( count == 3 ) ); - args += 2; - } - - /* is last operand an x- or y-delta? */ - if ( horizontal ) - { - x = ADD_LONG( x, args[0] ); - y = start_y; - } - else - { - x = start_x; - y = ADD_LONG( y, args[0] ); - } - - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case cff_op_flex: - { - FT_UInt count; - - - FT_TRACE4(( " flex\n" )); - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, 6 ) ) - goto Fail; - - for ( count = 6; count > 0; count-- ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, - (FT_Bool)( count == 4 || count == 1 ) ); - args += 2; - } - - args = stack; - } - break; - - case cff_op_seac: - FT_TRACE4(( " seac\n" )); - - error = cff_operator_seac( decoder, - args[0], args[1], args[2], - (FT_Int)( args[3] >> 16 ), - (FT_Int)( args[4] >> 16 ) ); - - /* add current outline to the glyph slot */ - FT_GlyphLoader_Add( builder->loader ); - - /* return now! */ - FT_TRACE4(( "\n" )); - return error; - - case cff_op_endchar: - /* in dictionaries, `endchar' simply indicates end of data */ - if ( in_dict ) - return error; - - FT_TRACE4(( " endchar\n" )); - - /* We are going to emulate the seac operator. */ - if ( num_args >= 4 ) - { - /* Save glyph width so that the subglyphs don't overwrite it. */ - FT_Pos glyph_width = decoder->glyph_width; - - - error = cff_operator_seac( decoder, - 0L, args[-4], args[-3], - (FT_Int)( args[-2] >> 16 ), - (FT_Int)( args[-1] >> 16 ) ); - - decoder->glyph_width = glyph_width; - } - else - { - cff_builder_close_contour( builder ); - - /* close hints recording session */ - if ( hinter ) - { - if ( hinter->close( hinter->hints, - (FT_UInt)builder->current->n_points ) ) - goto Syntax_Error; - - /* apply hints to the loaded glyph outline now */ - error = hinter->apply( hinter->hints, - builder->current, - (PSH_Globals)builder->hints_globals, - decoder->hint_mode ); - if ( error ) - goto Fail; - } - - /* add current outline to the glyph slot */ - FT_GlyphLoader_Add( builder->loader ); - } - - /* return now! */ - FT_TRACE4(( "\n" )); - return error; - - case cff_op_abs: - FT_TRACE4(( " abs\n" )); - - if ( args[0] < 0 ) - { - if ( args[0] == FT_LONG_MIN ) - args[0] = FT_LONG_MAX; - else - args[0] = -args[0]; - } - args++; - break; - - case cff_op_add: - FT_TRACE4(( " add\n" )); - - args[0] = ADD_LONG( args[0], args[1] ); - args++; - break; - - case cff_op_sub: - FT_TRACE4(( " sub\n" )); - - args[0] = SUB_LONG( args[0], args[1] ); - args++; - break; - - case cff_op_div: - FT_TRACE4(( " div\n" )); - - args[0] = FT_DivFix( args[0], args[1] ); - args++; - break; - - case cff_op_neg: - FT_TRACE4(( " neg\n" )); - - if ( args[0] == FT_LONG_MIN ) - args[0] = FT_LONG_MAX; - args[0] = -args[0]; - args++; - break; - - case cff_op_random: - FT_TRACE4(( " random\n" )); - - /* only use the lower 16 bits of `random' */ - /* to generate a number in the range (0;1] */ - args[0] = (FT_Fixed) - ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); - args++; - - decoder->current_subfont->random = - cff_random( decoder->current_subfont->random ); - break; - - case cff_op_mul: - FT_TRACE4(( " mul\n" )); - - args[0] = FT_MulFix( args[0], args[1] ); - args++; - break; - - case cff_op_sqrt: - FT_TRACE4(( " sqrt\n" )); - - if ( args[0] > 0 ) - { - FT_Fixed root = args[0]; - FT_Fixed new_root; - - - for (;;) - { - new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1; - if ( new_root == root ) - break; - root = new_root; - } - args[0] = new_root; - } - else - args[0] = 0; - args++; - break; - - case cff_op_drop: - /* nothing */ - FT_TRACE4(( " drop\n" )); - - break; - - case cff_op_exch: - { - FT_Fixed tmp; - - - FT_TRACE4(( " exch\n" )); - - tmp = args[0]; - args[0] = args[1]; - args[1] = tmp; - args += 2; - } - break; - - case cff_op_index: - { - FT_Int idx = (FT_Int)( args[0] >> 16 ); - - - FT_TRACE4(( " index\n" )); - - if ( idx < 0 ) - idx = 0; - else if ( idx > num_args - 2 ) - idx = num_args - 2; - args[0] = args[-( idx + 1 )]; - args++; - } - break; - - case cff_op_roll: - { - FT_Int count = (FT_Int)( args[0] >> 16 ); - FT_Int idx = (FT_Int)( args[1] >> 16 ); - - - FT_TRACE4(( " roll\n" )); - - if ( count <= 0 ) - count = 1; - - args -= count; - if ( args < stack ) - goto Stack_Underflow; - - if ( idx >= 0 ) - { - while ( idx > 0 ) - { - FT_Fixed tmp = args[count - 1]; - FT_Int i; - - - for ( i = count - 2; i >= 0; i-- ) - args[i + 1] = args[i]; - args[0] = tmp; - idx--; - } - } - else - { - while ( idx < 0 ) - { - FT_Fixed tmp = args[0]; - FT_Int i; - - - for ( i = 0; i < count - 1; i++ ) - args[i] = args[i + 1]; - args[count - 1] = tmp; - idx++; - } - } - args += count; - } - break; - - case cff_op_dup: - FT_TRACE4(( " dup\n" )); - - args[1] = args[0]; - args += 2; - break; - - case cff_op_put: - { - FT_Fixed val = args[0]; - FT_Int idx = (FT_Int)( args[1] >> 16 ); - - - FT_TRACE4(( " put\n" )); - - /* the Type2 specification before version 16-March-2000 */ - /* didn't give a hard-coded size limit of the temporary */ - /* storage array; instead, an argument of the */ - /* `MultipleMaster' operator set the size */ - if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS ) - decoder->buildchar[idx] = val; - } - break; - - case cff_op_get: - { - FT_Int idx = (FT_Int)( args[0] >> 16 ); - FT_Fixed val = 0; - - - FT_TRACE4(( " get\n" )); - - if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS ) - val = decoder->buildchar[idx]; - - args[0] = val; - args++; - } - break; - - case cff_op_store: - /* this operator was removed from the Type2 specification */ - /* in version 16-March-2000 */ - - /* since we currently don't handle interpolation of multiple */ - /* master fonts, this is a no-op */ - FT_TRACE4(( " store\n")); - break; - - case cff_op_load: - /* this operator was removed from the Type2 specification */ - /* in version 16-March-2000 */ - { - FT_Int reg_idx = (FT_Int)args[0]; - FT_Int idx = (FT_Int)args[1]; - FT_Int count = (FT_Int)args[2]; - - - FT_TRACE4(( " load\n" )); - - /* since we currently don't handle interpolation of multiple */ - /* master fonts, we store a vector [1 0 0 ...] in the */ - /* temporary storage array regardless of the Registry index */ - if ( reg_idx >= 0 && reg_idx <= 2 && - idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS && - count >= 0 && count <= num_axes ) - { - FT_Int end, i; - - - end = FT_MIN( idx + count, CFF_MAX_TRANS_ELEMENTS ); - - if ( idx < end ) - decoder->buildchar[idx] = 1 << 16; - - for ( i = idx + 1; i < end; i++ ) - decoder->buildchar[i] = 0; - } - } - break; - - case cff_op_blend: - /* this operator was removed from the Type2 specification */ - /* in version 16-March-2000 */ - { - FT_Int num_results = (FT_Int)( args[0] >> 16 ); - - - FT_TRACE4(( " blend\n" )); - - if ( num_results < 0 ) - goto Syntax_Error; - - if ( num_results * (FT_Int)num_designs > num_args ) - goto Stack_Underflow; - - /* since we currently don't handle interpolation of multiple */ - /* master fonts, return the `num_results' values of the */ - /* first master */ - args -= num_results * ( num_designs - 1 ); - num_args -= num_results * ( num_designs - 1 ); - } - break; - - case cff_op_dotsection: - /* this operator is deprecated and ignored by the parser */ - FT_TRACE4(( " dotsection\n" )); - break; - - case cff_op_closepath: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " closepath (invalid op)\n" )); - - args = stack; - break; - - case cff_op_hsbw: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " hsbw (invalid op)\n" )); - - decoder->glyph_width = - ADD_LONG( decoder->nominal_width, ( args[1] >> 16 ) ); - - decoder->builder.left_bearing.x = args[0]; - decoder->builder.left_bearing.y = 0; - - x = ADD_LONG( decoder->builder.pos_x, args[0] ); - y = decoder->builder.pos_y; - args = stack; - break; - - case cff_op_sbw: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " sbw (invalid op)\n" )); - - decoder->glyph_width = - ADD_LONG( decoder->nominal_width, ( args[2] >> 16 ) ); - - decoder->builder.left_bearing.x = args[0]; - decoder->builder.left_bearing.y = args[1]; - - x = ADD_LONG( decoder->builder.pos_x, args[0] ); - y = ADD_LONG( decoder->builder.pos_y, args[1] ); - args = stack; - break; - - case cff_op_setcurrentpoint: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " setcurrentpoint (invalid op)\n" )); - - x = ADD_LONG( decoder->builder.pos_x, args[0] ); - y = ADD_LONG( decoder->builder.pos_y, args[1] ); - args = stack; - break; - - case cff_op_callothersubr: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " callothersubr (invalid op)\n" )); - - /* subsequent `pop' operands should add the arguments, */ - /* this is the implementation described for `unknown' other */ - /* subroutines in the Type1 spec. */ - /* */ - /* XXX Fix return arguments (see discussion below). */ - args -= 2 + ( args[-2] >> 16 ); - if ( args < stack ) - goto Stack_Underflow; - break; - - case cff_op_pop: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " pop (invalid op)\n" )); - - /* XXX Increasing `args' is wrong: After a certain number of */ - /* `pop's we get a stack overflow. Reason for doing it is */ - /* code like this (actually found in a CFF font): */ - /* */ - /* 17 1 3 callothersubr */ - /* pop */ - /* callsubr */ - /* */ - /* Since we handle `callothersubr' as a no-op, and */ - /* `callsubr' needs at least one argument, `pop' can't be a */ - /* no-op too as it basically should be. */ - /* */ - /* The right solution would be to provide real support for */ - /* `callothersubr' as done in `t1decode.c', however, given */ - /* the fact that CFF fonts with `pop' are invalid, it is */ - /* questionable whether it is worth the time. */ - args++; - break; - - case cff_op_and: - { - FT_Fixed cond = ( args[0] && args[1] ); - - - FT_TRACE4(( " and\n" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case cff_op_or: - { - FT_Fixed cond = ( args[0] || args[1] ); - - - FT_TRACE4(( " or\n" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case cff_op_not: - { - FT_Fixed cond = !args[0]; - - - FT_TRACE4(( " not\n" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case cff_op_eq: - { - FT_Fixed cond = ( args[0] == args[1] ); - - - FT_TRACE4(( " eq\n" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case cff_op_ifelse: - { - FT_Fixed cond = ( args[2] <= args[3] ); - - - FT_TRACE4(( " ifelse\n" )); - - if ( !cond ) - args[0] = args[1]; - args++; - } - break; - - case cff_op_callsubr: - { - FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + - decoder->locals_bias ); - - - FT_TRACE4(( " callsubr (idx %d, entering level %d)\n", - idx, - zone - decoder->zones + 1 )); - - if ( idx >= decoder->num_locals ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " invalid local subr index\n" )); - goto Syntax_Error; - } - - if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " too many nested subrs\n" )); - goto Syntax_Error; - } - - zone->cursor = ip; /* save current instruction pointer */ - - zone++; - zone->base = decoder->locals[idx]; - zone->limit = decoder->locals[idx + 1]; - zone->cursor = zone->base; - - if ( !zone->base || zone->limit == zone->base ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " invoking empty subrs\n" )); - goto Syntax_Error; - } - - decoder->zone = zone; - ip = zone->base; - limit = zone->limit; - } - break; - - case cff_op_callgsubr: - { - FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + - decoder->globals_bias ); - - - FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n", - idx, - zone - decoder->zones + 1 )); - - if ( idx >= decoder->num_globals ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " invalid global subr index\n" )); - goto Syntax_Error; - } - - if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " too many nested subrs\n" )); - goto Syntax_Error; - } - - zone->cursor = ip; /* save current instruction pointer */ - - zone++; - zone->base = decoder->globals[idx]; - zone->limit = decoder->globals[idx + 1]; - zone->cursor = zone->base; - - if ( !zone->base || zone->limit == zone->base ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " invoking empty subrs\n" )); - goto Syntax_Error; - } - - decoder->zone = zone; - ip = zone->base; - limit = zone->limit; - } - break; - - case cff_op_return: - FT_TRACE4(( " return (leaving level %d)\n", - decoder->zone - decoder->zones )); - - if ( decoder->zone <= decoder->zones ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " unexpected return\n" )); - goto Syntax_Error; - } - - decoder->zone--; - zone = decoder->zone; - ip = zone->cursor; - limit = zone->limit; - break; - - default: - FT_ERROR(( "Unimplemented opcode: %d", ip[-1] )); - - if ( ip[-1] == 12 ) - FT_ERROR(( " %d", ip[0] )); - FT_ERROR(( "\n" )); - - return FT_THROW( Unimplemented_Feature ); - } - - decoder->top = args; - - if ( decoder->top - stack >= CFF_MAX_OPERANDS ) - goto Stack_Overflow; - - } /* general operator processing */ - - } /* while ip < limit */ - - FT_TRACE4(( "..end..\n\n" )); - - Fail: - return error; - - MM_Error: - FT_TRACE4(( "cff_decoder_parse_charstrings:" - " invalid opcode found in top DICT charstring\n")); - return FT_THROW( Invalid_File_Format ); - - Syntax_Error: - FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" )); - return FT_THROW( Invalid_File_Format ); - - Stack_Underflow: - FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" )); - return FT_THROW( Too_Few_Arguments ); - - Stack_Overflow: - FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" )); - return FT_THROW( Stack_Overflow ); - } - -#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ - - /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -2704,11 +142,14 @@ FT_Int glyph_index; CFF_Font cff = (CFF_Font)face->other; + PSAux_Service psaux = (PSAux_Service)face->psaux; + const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs; + *max_advance = 0; /* Initialize load decoder */ - cff_decoder_init( &decoder, face, 0, 0, 0, 0 ); + decoder_funcs->init( &decoder, face, 0, 0, 0, 0, 0, 0 ); decoder.builder.metrics_only = 1; decoder.builder.load_points = 0; @@ -2727,12 +168,12 @@ &charstring, &charstring_len ); if ( !error ) { - error = cff_decoder_prepare( &decoder, size, glyph_index ); + error = decoder_funcs->prepare( &decoder, size, glyph_index ); if ( !error ) - error = cff_decoder_parse_charstrings( &decoder, - charstring, - charstring_len, - 0 ); + error = decoder_funcs->parse_charstrings_old( &decoder, + charstring, + charstring_len, + 0 ); cff_free_glyph_data( face, &charstring, &charstring_len ); } @@ -2758,10 +199,14 @@ { FT_Error error; CFF_Decoder decoder; + PS_Decoder psdecoder; TT_Face face = (TT_Face)glyph->root.face; FT_Bool hinting, scaled, force_scaling; CFF_Font cff = (CFF_Font)face->extra.data; + PSAux_Service psaux = (PSAux_Service)face->psaux; + const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs; + FT_Matrix font_matrix; FT_Vector font_offset; @@ -2951,7 +396,7 @@ { #ifdef CFF_CONFIG_OPTION_OLD_ENGINE - CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face ); + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); #endif @@ -2959,8 +404,10 @@ FT_ULong charstring_len; - cff_decoder_init( &decoder, face, size, glyph, hinting, - FT_LOAD_TARGET_MODE( load_flags ) ); + decoder_funcs->init( &decoder, face, size, glyph, hinting, + FT_LOAD_TARGET_MODE( load_flags ), + cff_get_glyph_data, + cff_free_glyph_data ); /* this is for pure CFFs */ if ( load_flags & FT_LOAD_ADVANCE_ONLY ) @@ -2975,23 +422,25 @@ if ( error ) goto Glyph_Build_Finished; - error = cff_decoder_prepare( &decoder, size, glyph_index ); + error = decoder_funcs->prepare( &decoder, size, glyph_index ); if ( error ) goto Glyph_Build_Finished; #ifdef CFF_CONFIG_OPTION_OLD_ENGINE /* choose which CFF renderer to use */ - if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE ) - error = cff_decoder_parse_charstrings( &decoder, - charstring, - charstring_len, - 0 ); + if ( driver->hinting_engine == FT_HINTING_FREETYPE ) + error = decoder_funcs->parse_charstrings_old( &decoder, + charstring, + charstring_len, + 0 ); else #endif { - error = cf2_decoder_parse_charstrings( &decoder, - charstring, - charstring_len ); + psaux->ps_decoder_init( &psdecoder, &decoder, FALSE ); + + error = decoder_funcs->parse_charstrings( &psdecoder, + charstring, + charstring_len ); /* Adobe's engine uses 16.16 numbers everywhere; */ /* as a consequence, glyphs larger than 2000ppem get rejected */ @@ -3004,9 +453,9 @@ force_scaling = TRUE; glyph->hint = hinting; - error = cf2_decoder_parse_charstrings( &decoder, - charstring, - charstring_len ); + error = decoder_funcs->parse_charstrings( &psdecoder, + charstring, + charstring_len ); } } @@ -3044,7 +493,7 @@ Glyph_Build_Finished: /* save new glyph tables, if no error */ if ( !error ) - cff_builder_done( &decoder.builder ); + decoder.builder.funcs.done( &decoder.builder ); /* XXX: anything to do for broken glyph entry? */ } diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h index 0fa93b43985..803f3974fc7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,119 +22,11 @@ #include <ft2build.h> #include FT_FREETYPE_H -#include "cffobjs.h" +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H FT_BEGIN_HEADER - -#define CFF_MAX_OPERANDS 48 -#define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */ - /* only 10 are allowed but there exist */ - /* fonts like `HiraKakuProN-W3.ttf' */ - /* (Hiragino Kaku Gothic ProN W3; */ - /* 8.2d6e1; 2014-12-19) that exceed */ - /* this limit */ -#define CFF_MAX_TRANS_ELEMENTS 32 - - - /*************************************************************************/ - /* */ - /* <Structure> */ - /* CFF_Builder */ - /* */ - /* <Description> */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* <Fields> */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: The current glyph loader. */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* path_begun :: A flag which indicates that a new path has begun. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* hints_funcs :: Auxiliary pointer for hinting. */ - /* */ - /* hints_globals :: Auxiliary pointer for hinting. */ - /* */ - typedef struct CFF_Builder_ - { - FT_Memory memory; - TT_Face face; - CFF_GlyphSlot glyph; - FT_GlyphLoader loader; - FT_Outline* base; - FT_Outline* current; - - FT_Pos pos_x; - FT_Pos pos_y; - - FT_Vector left_bearing; - FT_Vector advance; - - FT_BBox bbox; /* bounding box */ - FT_Bool path_begun; - FT_Bool load_points; - FT_Bool no_recurse; - - FT_Bool metrics_only; - - void* hints_funcs; /* hinter-specific */ - void* hints_globals; /* hinter-specific */ - - } CFF_Builder; - - - FT_LOCAL( FT_Error ) - cff_check_points( CFF_Builder* builder, - FT_Int count ); - - FT_LOCAL( void ) - cff_builder_add_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y, - FT_Byte flag ); - FT_LOCAL( FT_Error ) - cff_builder_add_point1( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ); - FT_LOCAL( FT_Error ) - cff_builder_start_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ); - FT_LOCAL( void ) - cff_builder_close_contour( CFF_Builder* builder ); - - - FT_LOCAL( FT_Int ) - cff_lookup_glyph_by_stdcharcode( CFF_Font cff, - FT_Int charcode ); FT_LOCAL( FT_Error ) cff_get_glyph_data( TT_Face face, FT_UInt glyph_index, @@ -146,74 +38,6 @@ FT_BEGIN_HEADER FT_ULong length ); - /* execution context charstring zone */ - - typedef struct CFF_Decoder_Zone_ - { - FT_Byte* base; - FT_Byte* limit; - FT_Byte* cursor; - - } CFF_Decoder_Zone; - - - typedef struct CFF_Decoder_ - { - CFF_Builder builder; - CFF_Font cff; - - FT_Fixed stack[CFF_MAX_OPERANDS + 1]; - FT_Fixed* top; - - CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1]; - CFF_Decoder_Zone* zone; - - FT_Int flex_state; - FT_Int num_flex_vectors; - FT_Vector flex_vectors[7]; - - FT_Pos glyph_width; - FT_Pos nominal_width; - - FT_Bool read_width; - FT_Bool width_only; - FT_Int num_hints; - FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS]; - - FT_UInt num_locals; - FT_UInt num_globals; - - FT_Int locals_bias; - FT_Int globals_bias; - - FT_Byte** locals; - FT_Byte** globals; - - FT_Byte** glyph_names; /* for pure CFF fonts only */ - FT_UInt num_glyphs; /* number of glyphs in font */ - - FT_Render_Mode hint_mode; - - FT_Bool seac; - - CFF_SubFont current_subfont; /* for current glyph_index */ - - } CFF_Decoder; - - - FT_LOCAL( void ) - cff_decoder_init( CFF_Decoder* decoder, - TT_Face face, - CFF_Size size, - CFF_GlyphSlot slot, - FT_Bool hinting, - FT_Render_Mode hint_mode ); - - FT_LOCAL( FT_Error ) - cff_decoder_prepare( CFF_Decoder* decoder, - CFF_Size size, - FT_UInt glyph_index ); - #if 0 /* unused until we support pure CFF fonts */ /* Compute the maximum advance width of a font through quick parsing */ @@ -223,13 +47,6 @@ FT_BEGIN_HEADER #endif /* 0 */ -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - FT_LOCAL( FT_Error ) - cff_decoder_parse_charstrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_ULong charstring_len, - FT_Bool in_dict ); -#endif FT_LOCAL( FT_Error ) cff_slot_load( CFF_GlyphSlot glyph, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c index 12420384af2..ba49793dc8a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c @@ -4,7 +4,7 @@ /* */ /* OpenType and CFF data/program tables loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,6 +22,7 @@ #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H #include FT_TYPE1_TABLES_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_MULTIPLE_MASTERS_H @@ -1297,7 +1298,9 @@ if ( numOperands > count ) { - FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d args\n", count )); + FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d argument%s\n", + count, + count == 1 ? "" : "s" )); error = FT_THROW( Stack_Underflow ); goto Exit; @@ -1345,19 +1348,14 @@ for ( i = 0; i < numBlends; i++ ) { const FT_Int32* weight = &blend->BV[1]; - FT_Int32 sum; + FT_UInt32 sum; /* convert inputs to 16.16 fixed point */ - sum = cff_parse_num( parser, &parser->stack[i + base] ) * 65536; + sum = cff_parse_num( parser, &parser->stack[i + base] ) * 0x10000; for ( j = 1; j < blend->lenBV; j++ ) - sum = ADD_INT32( - sum, - FT_MulFix( - *weight++, - cff_parse_num( parser, - &parser->stack[delta++] ) * 65536 ) ); + sum += cff_parse_num( parser, &parser->stack[delta++] ) * *weight++; /* point parser stack to new value on blend_stack */ parser->stack[i + base] = subFont->blend_top; @@ -1367,10 +1365,10 @@ /* opcode in both CFF and CFF2 DICTs. See `cff_parse_num' for */ /* decode of this, which rounds to an integer. */ *subFont->blend_top++ = 255; - *subFont->blend_top++ = ( (FT_UInt32)sum & 0xFF000000U ) >> 24; - *subFont->blend_top++ = ( (FT_UInt32)sum & 0x00FF0000U ) >> 16; - *subFont->blend_top++ = ( (FT_UInt32)sum & 0x0000FF00U ) >> 8; - *subFont->blend_top++ = (FT_UInt32)sum & 0x000000FFU; + *subFont->blend_top++ = (FT_Byte)( sum >> 24 ); + *subFont->blend_top++ = (FT_Byte)( sum >> 16 ); + *subFont->blend_top++ = (FT_Byte)( sum >> 8 ); + *subFont->blend_top++ = (FT_Byte)sum; } /* leave only numBlends results on parser stack */ @@ -1558,13 +1556,13 @@ FT_UInt lenNDV, FT_Fixed* NDV ) { - if ( !blend->builtBV || - blend->lastVsindex != vsindex || - blend->lenNDV != lenNDV || - ( lenNDV && - memcmp( NDV, - blend->lastNDV, - lenNDV * sizeof ( *NDV ) ) != 0 ) ) + if ( !blend->builtBV || + blend->lastVsindex != vsindex || + blend->lenNDV != lenNDV || + ( lenNDV && + ft_memcmp( NDV, + blend->lastNDV, + lenNDV * sizeof ( *NDV ) ) != 0 ) ) { /* need to build blend vector */ return TRUE; @@ -1600,7 +1598,8 @@ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; - mm->done_blend( FT_FACE( face ) ); + if (mm) + mm->done_blend( FT_FACE( face ) ); } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ @@ -1945,18 +1944,6 @@ } - FT_LOCAL_DEF( FT_UInt32 ) - cff_random( FT_UInt32 r ) - { - /* a 32bit version of the `xorshift' algorithm */ - r ^= r << 13; - r ^= r >> 17; - r ^= r << 5; - - return r; - } - - /* There are 3 ways to call this function, distinguished by code. */ /* */ /* . CFF_CODE_TOPDICT for either a CFF Top DICT or a CFF Font DICT */ @@ -1980,6 +1967,8 @@ CFF_FontRecDict top = &subfont->font_dict; CFF_Private priv = &subfont->private_dict; + PSAux_Service psaux = (PSAux_Service)face->psaux; + FT_Bool cff2 = FT_BOOL( code == CFF2_CODE_TOPDICT || code == CFF2_CODE_FONTDICT ); FT_UInt stackSize = cff2 ? CFF2_DEFAULT_STACK @@ -2085,7 +2074,7 @@ */ if ( face->root.internal->random_seed == -1 ) { - CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face ); + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); subfont->random = (FT_UInt32)driver->random_seed; @@ -2094,7 +2083,7 @@ do { driver->random_seed = - (FT_Int32)cff_random( (FT_UInt32)driver->random_seed ); + (FT_Int32)psaux->cff_random( (FT_UInt32)driver->random_seed ); } while ( driver->random_seed < 0 ); } @@ -2107,7 +2096,8 @@ do { face->root.internal->random_seed = - (FT_Int32)cff_random( (FT_UInt32)face->root.internal->random_seed ); + (FT_Int32)psaux->cff_random( + (FT_UInt32)face->root.internal->random_seed ); } while ( face->root.internal->random_seed < 0 ); } @@ -2548,6 +2538,8 @@ font->cf2_instance.finalizer( font->cf2_instance.data ); FT_FREE( font->cf2_instance.data ); } + + FT_FREE( font->font_extra ); } diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h index c745e8127b3..14d14e21122 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h @@ -4,7 +4,7 @@ /* */ /* OpenType & CFF data/program tables loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,9 +21,9 @@ #include <ft2build.h> -#include "cfftypes.h" +#include FT_INTERNAL_CFF_TYPES_H #include "cffparse.h" -#include "cffobjs.h" /* for CFF_Face */ +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H /* for CFF_Face */ FT_BEGIN_HEADER @@ -61,9 +61,6 @@ FT_BEGIN_HEADER FT_UInt cid ); - FT_LOCAL( FT_UInt32 ) - cff_random( FT_UInt32 r ); - FT_LOCAL( FT_Error ) cff_font_load( FT_Library library, FT_Stream stream, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c index 61613933ff7..a2d7aec65ef 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -25,13 +25,15 @@ #include FT_TRUETYPE_IDS_H #include FT_TRUETYPE_TAGS_H #include FT_INTERNAL_SFNT_H -#include FT_CFF_DRIVER_H +#include FT_DRIVER_H #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_MULTIPLE_MASTERS_H #include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H #endif +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H #include "cffobjs.h" #include "cffload.h" #include "cffcmap.h" @@ -39,6 +41,9 @@ #include "cfferrs.h" +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_SERVICE_CFF_TABLE_LOAD_H + /*************************************************************************/ /* */ @@ -408,7 +413,7 @@ remove_subset_prefix( FT_String* name ) { FT_Int32 idx = 0; - FT_Int32 length = (FT_Int32)strlen( name ) + 1; + FT_Int32 length = (FT_Int32)ft_strlen( name ) + 1; FT_Bool continue_search = 1; @@ -445,8 +450,8 @@ FT_Int32 family_name_length, style_name_length; - family_name_length = (FT_Int32)strlen( family_name ); - style_name_length = (FT_Int32)strlen( style_name ); + family_name_length = (FT_Int32)ft_strlen( family_name ); + style_name_length = (FT_Int32)ft_strlen( style_name ); if ( family_name_length > style_name_length ) { @@ -493,14 +498,16 @@ SFNT_Service sfnt; FT_Service_PsCMaps psnames; PSHinter_Service pshinter; + PSAux_Service psaux; + FT_Service_CFFLoad cffload; FT_Bool pure_cff = 1; FT_Bool cff2 = 0; FT_Bool sfnt_format = 0; FT_Library library = cffface->driver->root.library; - sfnt = (SFNT_Service)FT_Get_Module_Interface( - library, "sfnt" ); + sfnt = (SFNT_Service)FT_Get_Module_Interface( library, + "sfnt" ); if ( !sfnt ) { FT_ERROR(( "cff_face_init: cannot access `sfnt' module\n" )); @@ -510,8 +517,20 @@ FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); - pshinter = (PSHinter_Service)FT_Get_Module_Interface( - library, "pshinter" ); + pshinter = (PSHinter_Service)FT_Get_Module_Interface( library, + "pshinter" ); + + psaux = (PSAux_Service)FT_Get_Module_Interface( library, + "psaux" ); + if ( !psaux ) + { + FT_ERROR(( "cff_face_init: cannot access `psaux' module\n" )); + error = FT_THROW( Missing_Module ); + goto Exit; + } + face->psaux = psaux; + + FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD ); FT_TRACE2(( "CFF driver\n" )); @@ -614,6 +633,7 @@ cff->pshinter = pshinter; cff->psnames = psnames; + cff->cffload = cffload; cffface->face_index = face_index & 0xFFFF; @@ -690,50 +710,22 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT { - FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)face->var; - FT_Int instance_index = face_index >> 16; + FT_UInt instance_index = (FT_UInt)face_index >> 16; if ( FT_HAS_MULTIPLE_MASTERS( cffface ) && mm && instance_index > 0 ) { - FT_MM_Var* mm_var; - - - error = mm->get_mm_var( cffface, NULL ); + error = mm->set_instance( cffface, instance_index ); if ( error ) goto Exit; - mm->get_var_blend( cffface, NULL, NULL, NULL, &mm_var ); - - if ( mm_var->namedstyle ) - { - FT_Var_Named_Style* named_style; - FT_String* style_name; - - - /* in `face_index', the instance index starts with value 1 */ - named_style = mm_var->namedstyle + instance_index - 1; - error = sfnt->get_name( face, - (FT_UShort)named_style->strid, - &style_name ); - if ( error ) - goto Exit; - - /* set style name; if already set, replace it */ - if ( face->root.style_name ) - FT_FREE( face->root.style_name ); - face->root.style_name = style_name; - - /* finally, select the named instance */ - error = mm->set_var_design( cffface, - mm_var->num_axis, - named_style->coords ); - if ( error ) - goto Exit; - } + if ( var ) + var->metrics_adjust( cffface ); } } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ @@ -876,7 +868,8 @@ cffface->height = (FT_Short)( ( cffface->units_per_EM * 12 ) / 10 ); if ( cffface->height < cffface->ascender - cffface->descender ) - cffface->height = (FT_Short)( cffface->ascender - cffface->descender ); + cffface->height = (FT_Short)( cffface->ascender - + cffface->descender ); cffface->underline_position = (FT_Short)( dict->underline_position >> 16 ); @@ -884,27 +877,32 @@ (FT_Short)( dict->underline_thickness >> 16 ); /* retrieve font family & style name */ - cffface->family_name = cff_index_get_name( - cff, - (FT_UInt)( face_index & 0xFFFF ) ); + if ( dict->family_name ) + { + char* family_name; + + + family_name = cff_index_get_sid_string( cff, dict->family_name ); + if ( family_name ) + cffface->family_name = cff_strcpy( memory, family_name ); + } + + if ( !cffface->family_name ) + { + cffface->family_name = cff_index_get_name( + cff, + (FT_UInt)( face_index & 0xFFFF ) ); + if ( cffface->family_name ) + remove_subset_prefix( cffface->family_name ); + } + if ( cffface->family_name ) { char* full = cff_index_get_sid_string( cff, dict->full_name ); char* fullp = full; char* family = cffface->family_name; - char* family_name = NULL; - - remove_subset_prefix( cffface->family_name ); - - if ( dict->family_name ) - { - family_name = cff_index_get_sid_string( cff, - dict->family_name ); - if ( family_name ) - family = family_name; - } /* We try to extract the style name from the full name. */ /* We need to ignore spaces and dashes during the search. */ @@ -1159,16 +1157,16 @@ FT_LOCAL_DEF( FT_Error ) cff_driver_init( FT_Module module ) /* CFF_Driver */ { - CFF_Driver driver = (CFF_Driver)module; + PS_Driver driver = (PS_Driver)module; FT_UInt32 seed; /* set default property values, cf. `ftcffdrv.h' */ #ifdef CFF_CONFIG_OPTION_OLD_ENGINE - driver->hinting_engine = FT_CFF_HINTING_FREETYPE; + driver->hinting_engine = FT_HINTING_FREETYPE; #else - driver->hinting_engine = FT_CFF_HINTING_ADOBE; + driver->hinting_engine = FT_HINTING_ADOBE; #endif driver->no_stem_darkening = TRUE; diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h index 1dba694c532..616a25b3b59 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,111 +21,11 @@ #include <ft2build.h> -#include FT_INTERNAL_OBJECTS_H -#include "cfftypes.h" -#include FT_INTERNAL_TRUETYPE_TYPES_H -#include FT_SERVICE_POSTSCRIPT_CMAPS_H -#include FT_INTERNAL_POSTSCRIPT_HINTS_H FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_Driver */ - /* */ - /* <Description> */ - /* A handle to an OpenType driver object. */ - /* */ - typedef struct CFF_DriverRec_* CFF_Driver; - - typedef TT_Face CFF_Face; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_Size */ - /* */ - /* <Description> */ - /* A handle to an OpenType size object. */ - /* */ - typedef struct CFF_SizeRec_ - { - FT_SizeRec root; - FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */ - - } CFF_SizeRec, *CFF_Size; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to an OpenType glyph slot object. */ - /* */ - typedef struct CFF_GlyphSlotRec_ - { - FT_GlyphSlotRec root; - - FT_Bool hint; - FT_Bool scaled; - - FT_Fixed x_scale; - FT_Fixed y_scale; - - } CFF_GlyphSlotRec, *CFF_GlyphSlot; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_Internal */ - /* */ - /* <Description> */ - /* The interface to the `internal' field of `FT_Size'. */ - /* */ - typedef struct CFF_InternalRec_ - { - PSH_Globals topfont; - PSH_Globals subfonts[CFF_MAX_CID_FONTS]; - - } CFF_InternalRec, *CFF_Internal; - - - /*************************************************************************/ - /* */ - /* Subglyph transformation record. */ - /* */ - typedef struct CFF_Transform_ - { - FT_Fixed xx, xy; /* transformation matrix coefficients */ - FT_Fixed yx, yy; - FT_F26Dot6 ox, oy; /* offsets */ - - } CFF_Transform; - - - /***********************************************************************/ - /* */ - /* CFF driver class. */ - /* */ - typedef struct CFF_DriverRec_ - { - FT_DriverRec root; - - FT_UInt hinting_engine; - FT_Bool no_stem_darkening; - FT_Int darken_params[8]; - FT_Int32 random_seed; - - } CFF_DriverRec; - - FT_LOCAL( FT_Error ) cff_size_init( FT_Size size ); /* CFF_Size */ @@ -171,10 +71,10 @@ FT_BEGIN_HEADER /* Driver functions */ /* */ FT_LOCAL( FT_Error ) - cff_driver_init( FT_Module module ); /* CFF_Driver */ + cff_driver_init( FT_Module module ); /* PS_Driver */ FT_LOCAL( void ) - cff_driver_done( FT_Module module ); /* CFF_Driver */ + cff_driver_done( FT_Module module ); /* PS_Driver */ FT_END_HEADER diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c index 9d7bf6d22c8..b9611cf548a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (body) */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,10 +21,10 @@ #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_CALC_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #include "cfferrs.h" #include "cffpic.h" -#include "cffgload.h" #include "cffload.h" @@ -949,7 +949,9 @@ goto Exit; } - FT_TRACE4(( " %d values blended\n", numBlends )); + FT_TRACE4(( " %d value%s blended\n", + numBlends, + numBlends == 1 ? "" : "s" )); error = cff_blend_doBlend( subFont, parser, numBlends ); @@ -1299,9 +1301,14 @@ FT_Byte* start, FT_Byte* limit ) { +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + PSAux_Service psaux; +#endif + FT_Byte* p = start; FT_Error error = FT_Err_Ok; FT_Library library = parser->library; + FT_UNUSED( library ); @@ -1388,10 +1395,16 @@ cff_rec.top_font.font_dict.num_axes = parser->num_axes; decoder.cff = &cff_rec; - error = cff_decoder_parse_charstrings( &decoder, - charstring_base, - charstring_len, - 1 ); + psaux = (PSAux_Service)FT_Get_Module_Interface( library, "psaux" ); + if ( !psaux ) + { + FT_ERROR(( "cff_parser_run: cannot access `psaux' module\n" )); + error = FT_THROW( Missing_Module ); + goto Exit; + } + + error = psaux->cff_decoder_funcs->parse_charstrings_old( + &decoder, charstring_base, charstring_len, 1 ); /* Now copy the stack data in the temporary decoder object, */ /* converting it back to charstring number representations */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h index 83d1bba45f2..8a8caeca446 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (specification) */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,7 +21,7 @@ #include <ft2build.h> -#include "cfftypes.h" +#include FT_INTERNAL_CFF_TYPES_H #include FT_INTERNAL_OBJECTS_H diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c index 4e9ba12b3fe..08b74c7cf20 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for cff module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h index 5db39cd6272..8ba4203a8de 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for cff module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,7 +22,6 @@ #include FT_INTERNAL_PIC_H - #ifndef FT_CONFIG_OPTION_PIC #define CFF_SERVICE_PS_INFO_GET cff_service_ps_info @@ -34,6 +33,7 @@ #define CFF_SERVICES_GET cff_services #define CFF_SERVICE_MULTI_MASTERS_GET cff_service_multi_masters #define CFF_SERVICE_METRICS_VAR_GET cff_service_metrics_variations +#define CFF_SERVICE_CFF_LOAD_GET cff_service_cff_load #define CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec #define CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec #define CFF_FIELD_HANDLERS_GET cff_field_handlers @@ -65,6 +65,7 @@ FT_BEGIN_HEADER FT_Service_PropertiesRec cff_service_properties; FT_Service_MultiMastersRec cff_service_multi_masters; FT_Service_MetricsVariationsRec cff_service_metrics_variations; + FT_Service_CFFLoadRec cff_service_cff_load; FT_CMap_ClassRec cff_cmap_encoding_class_rec; FT_CMap_ClassRec cff_cmap_unicode_class_rec; @@ -92,6 +93,8 @@ FT_BEGIN_HEADER ( GET_PIC( library )->cff_service_multi_masters ) #define CFF_SERVICE_METRICS_VAR_GET \ ( GET_PIC( library )->cff_service_metrics_variations ) +#define CFF_SERVICE_CFF_LOAD_GET \ + ( GET_PIC( library )->cff_service_cff_load ) #define CFF_CMAP_ENCODING_CLASS_REC_GET \ ( GET_PIC( library )->cff_cmap_encoding_class_rec ) #define CFF_CMAP_UNICODE_CLASS_REC_GET \ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h index 3222e933f1d..fec1ca20bde 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h @@ -4,7 +4,7 @@ /* */ /* CFF token definitions (specification only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h deleted file mode 100644 index 74f569f08b8..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h +++ /dev/null @@ -1,405 +0,0 @@ -/***************************************************************************/ -/* */ -/* cfftypes.h */ -/* */ -/* Basic OpenType/CFF type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2017 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CFFTYPES_H_ -#define CFFTYPES_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_TYPE1_TABLES_H -#include FT_INTERNAL_SERVICE_H -#include FT_SERVICE_POSTSCRIPT_CMAPS_H -#include FT_INTERNAL_POSTSCRIPT_HINTS_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CFF_IndexRec */ - /* */ - /* <Description> */ - /* A structure used to model a CFF Index table. */ - /* */ - /* <Fields> */ - /* stream :: The source input stream. */ - /* */ - /* start :: The position of the first index byte in the */ - /* input stream. */ - /* */ - /* count :: The number of elements in the index. */ - /* */ - /* off_size :: The size in bytes of object offsets in index. */ - /* */ - /* data_offset :: The position of first data byte in the index's */ - /* bytes. */ - /* */ - /* data_size :: The size of the data table in this index. */ - /* */ - /* offsets :: A table of element offsets in the index. Must be */ - /* loaded explicitly. */ - /* */ - /* bytes :: If the index is loaded in memory, its bytes. */ - /* */ - typedef struct CFF_IndexRec_ - { - FT_Stream stream; - FT_ULong start; - FT_UInt hdr_size; - FT_UInt count; - FT_Byte off_size; - FT_ULong data_offset; - FT_ULong data_size; - - FT_ULong* offsets; - FT_Byte* bytes; - - } CFF_IndexRec, *CFF_Index; - - - typedef struct CFF_EncodingRec_ - { - FT_UInt format; - FT_ULong offset; - - FT_UInt count; - FT_UShort sids [256]; /* avoid dynamic allocations */ - FT_UShort codes[256]; - - } CFF_EncodingRec, *CFF_Encoding; - - - typedef struct CFF_CharsetRec_ - { - - FT_UInt format; - FT_ULong offset; - - FT_UShort* sids; - FT_UShort* cids; /* the inverse mapping of `sids'; only needed */ - /* for CID-keyed fonts */ - FT_UInt max_cid; - FT_UInt num_glyphs; - - } CFF_CharsetRec, *CFF_Charset; - - - /* cf. similar fields in file `ttgxvar.h' from the `truetype' module */ - - typedef struct CFF_VarData_ - { -#if 0 - FT_UInt itemCount; /* not used; always zero */ - FT_UInt shortDeltaCount; /* not used; always zero */ -#endif - - FT_UInt regionIdxCount; /* number of region indexes */ - FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */ - /* these index `varRegionList' */ - } CFF_VarData; - - - /* contribution of one axis to a region */ - typedef struct CFF_AxisCoords_ - { - FT_Fixed startCoord; - FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */ - FT_Fixed endCoord; - - } CFF_AxisCoords; - - - typedef struct CFF_VarRegion_ - { - CFF_AxisCoords* axisList; /* array of axisCount records */ - - } CFF_VarRegion; - - - typedef struct CFF_VStoreRec_ - { - FT_UInt dataCount; - CFF_VarData* varData; /* array of dataCount records */ - /* vsindex indexes this array */ - FT_UShort axisCount; - FT_UInt regionCount; /* total number of regions defined */ - CFF_VarRegion* varRegionList; - - } CFF_VStoreRec, *CFF_VStore; - - - /* forward reference */ - typedef struct CFF_FontRec_* CFF_Font; - - - /* This object manages one cached blend vector. */ - /* */ - /* There is a BlendRec for Private DICT parsing in each subfont */ - /* and a BlendRec for charstrings in CF2_Font instance data. */ - /* A cached BV may be used across DICTs or Charstrings if inputs */ - /* have not changed. */ - /* */ - /* `usedBV' is reset at the start of each parse or charstring. */ - /* vsindex cannot be changed after a BV is used. */ - /* */ - /* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */ - typedef struct CFF_BlendRec_ - { - FT_Bool builtBV; /* blendV has been built */ - FT_Bool usedBV; /* blendV has been used */ - CFF_Font font; /* top level font struct */ - FT_UInt lastVsindex; /* last vsindex used */ - FT_UInt lenNDV; /* normDV length (aka numAxes) */ - FT_Fixed* lastNDV; /* last NDV used */ - FT_UInt lenBV; /* BlendV length (aka numMasters) */ - FT_Int32* BV; /* current blendV (per DICT/glyph) */ - - } CFF_BlendRec, *CFF_Blend; - - - typedef struct CFF_FontRecDictRec_ - { - FT_UInt version; - FT_UInt notice; - FT_UInt copyright; - FT_UInt full_name; - FT_UInt family_name; - FT_UInt weight; - FT_Bool is_fixed_pitch; - FT_Fixed italic_angle; - FT_Fixed underline_position; - FT_Fixed underline_thickness; - FT_Int paint_type; - FT_Int charstring_type; - FT_Matrix font_matrix; - FT_Bool has_font_matrix; - FT_ULong units_per_em; /* temporarily used as scaling value also */ - FT_Vector font_offset; - FT_ULong unique_id; - FT_BBox font_bbox; - FT_Pos stroke_width; - FT_ULong charset_offset; - FT_ULong encoding_offset; - FT_ULong charstrings_offset; - FT_ULong private_offset; - FT_ULong private_size; - FT_Long synthetic_base; - FT_UInt embedded_postscript; - - /* these should only be used for the top-level font dictionary */ - FT_UInt cid_registry; - FT_UInt cid_ordering; - FT_Long cid_supplement; - - FT_Long cid_font_version; - FT_Long cid_font_revision; - FT_Long cid_font_type; - FT_ULong cid_count; - FT_ULong cid_uid_base; - FT_ULong cid_fd_array_offset; - FT_ULong cid_fd_select_offset; - FT_UInt cid_font_name; - - /* the next fields come from the data of the deprecated */ - /* `MultipleMaster' operator; they are needed to parse the (also */ - /* deprecated) `blend' operator in Type 2 charstrings */ - FT_UShort num_designs; - FT_UShort num_axes; - - /* fields for CFF2 */ - FT_ULong vstore_offset; - FT_UInt maxstack; - - } CFF_FontRecDictRec, *CFF_FontRecDict; - - - /* forward reference */ - typedef struct CFF_SubFontRec_* CFF_SubFont; - - - typedef struct CFF_PrivateRec_ - { - FT_Byte num_blue_values; - FT_Byte num_other_blues; - FT_Byte num_family_blues; - FT_Byte num_family_other_blues; - - FT_Pos blue_values[14]; - FT_Pos other_blues[10]; - FT_Pos family_blues[14]; - FT_Pos family_other_blues[10]; - - FT_Fixed blue_scale; - FT_Pos blue_shift; - FT_Pos blue_fuzz; - FT_Pos standard_width; - FT_Pos standard_height; - - FT_Byte num_snap_widths; - FT_Byte num_snap_heights; - FT_Pos snap_widths[13]; - FT_Pos snap_heights[13]; - FT_Bool force_bold; - FT_Fixed force_bold_threshold; - FT_Int lenIV; - FT_Int language_group; - FT_Fixed expansion_factor; - FT_Long initial_random_seed; - FT_ULong local_subrs_offset; - FT_Pos default_width; - FT_Pos nominal_width; - - /* fields for CFF2 */ - FT_UInt vsindex; - CFF_SubFont subfont; - - } CFF_PrivateRec, *CFF_Private; - - - typedef struct CFF_FDSelectRec_ - { - FT_Byte format; - FT_UInt range_count; - - /* that's the table, taken from the file `as is' */ - FT_Byte* data; - FT_UInt data_size; - - /* small cache for format 3 only */ - FT_UInt cache_first; - FT_UInt cache_count; - FT_Byte cache_fd; - - } CFF_FDSelectRec, *CFF_FDSelect; - - - /* A SubFont packs a font dict and a private dict together. They are */ - /* needed to support CID-keyed CFF fonts. */ - typedef struct CFF_SubFontRec_ - { - CFF_FontRecDictRec font_dict; - CFF_PrivateRec private_dict; - - /* fields for CFF2 */ - CFF_BlendRec blend; /* current blend vector */ - FT_UInt lenNDV; /* current length NDV or zero */ - FT_Fixed* NDV; /* ptr to current NDV or NULL */ - - /* `blend_stack' is a writable buffer to hold blend results. */ - /* This buffer is to the side of the normal cff parser stack; */ - /* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */ - /* The normal stack then points to these values instead of the DICT */ - /* because all other operators in Private DICT clear the stack. */ - /* `blend_stack' could be cleared at each operator other than blend. */ - /* Blended values are stored as 5-byte fixed point values. */ - - FT_Byte* blend_stack; /* base of stack allocation */ - FT_Byte* blend_top; /* first empty slot */ - FT_UInt blend_used; /* number of bytes in use */ - FT_UInt blend_alloc; /* number of bytes allocated */ - - CFF_IndexRec local_subrs_index; - FT_Byte** local_subrs; /* array of pointers */ - /* into Local Subrs INDEX data */ - - FT_UInt32 random; - - } CFF_SubFontRec; - - -#define CFF_MAX_CID_FONTS 256 - - - typedef struct CFF_FontRec_ - { - FT_Library library; - FT_Stream stream; - FT_Memory memory; /* TODO: take this from stream->memory? */ - FT_ULong base_offset; /* offset to start of CFF */ - FT_UInt num_faces; - FT_UInt num_glyphs; - - FT_Byte version_major; - FT_Byte version_minor; - FT_Byte header_size; - - FT_UInt top_dict_length; /* cff2 only */ - - FT_Bool cff2; - - CFF_IndexRec name_index; - CFF_IndexRec top_dict_index; - CFF_IndexRec global_subrs_index; - - CFF_EncodingRec encoding; - CFF_CharsetRec charset; - - CFF_IndexRec charstrings_index; - CFF_IndexRec font_dict_index; - CFF_IndexRec private_index; - CFF_IndexRec local_subrs_index; - - FT_String* font_name; - - /* array of pointers into Global Subrs INDEX data */ - FT_Byte** global_subrs; - - /* array of pointers into String INDEX data stored at string_pool */ - FT_UInt num_strings; - FT_Byte** strings; - FT_Byte* string_pool; - FT_ULong string_pool_size; - - CFF_SubFontRec top_font; - FT_UInt num_subfonts; - CFF_SubFont subfonts[CFF_MAX_CID_FONTS]; - - CFF_FDSelectRec fd_select; - - /* interface to PostScript hinter */ - PSHinter_Service pshinter; - - /* interface to Postscript Names service */ - FT_Service_PsCMaps psnames; - - /* since version 2.3.0 */ - PS_FontInfoRec* font_info; /* font info dictionary */ - - /* since version 2.3.6 */ - FT_String* registry; - FT_String* ordering; - - /* since version 2.4.12 */ - FT_Generic cf2_instance; - - /* since version 2.7.1 */ - CFF_VStoreRec vstore; /* parsed vstore structure */ - - } CFF_FontRec; - - -FT_END_HEADER - -#endif /* CFFTYPES_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/module.mk b/Build/source/libs/freetype2/freetype-src/src/cff/module.mk index 2975aeed8c7..8013d5dcab0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/cff/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk b/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk index 86840bfe3c9..bce672927ec 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -32,27 +32,14 @@ CFF_DRV_SRC := $(CFF_DIR)/cffcmap.c \ $(CFF_DIR)/cffload.c \ $(CFF_DIR)/cffobjs.c \ $(CFF_DIR)/cffparse.c \ - $(CFF_DIR)/cffpic.c \ - $(CFF_DIR)/cf2arrst.c \ - $(CFF_DIR)/cf2blues.c \ - $(CFF_DIR)/cf2error.c \ - $(CFF_DIR)/cf2font.c \ - $(CFF_DIR)/cf2ft.c \ - $(CFF_DIR)/cf2hints.c \ - $(CFF_DIR)/cf2intrp.c \ - $(CFF_DIR)/cf2read.c \ - $(CFF_DIR)/cf2stack.c + $(CFF_DIR)/cffpic.c # CFF driver headers # CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \ $(CFF_DIR)/cfferrs.h \ - $(CFF_DIR)/cfftoken.h \ - $(CFF_DIR)/cfftypes.h \ - $(CFF_DIR)/cf2fixed.h \ - $(CFF_DIR)/cf2glue.h \ - $(CFF_DIR)/cf2types.h + $(CFF_DIR)/cfftoken.h # CFF driver object(s) diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/Jamfile b/Build/source/libs/freetype2/freetype-src/src/cid/Jamfile index 8d3ba6a4725..1c232fda3f7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/cid/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cid Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/ciderrs.h b/Build/source/libs/freetype2/freetype-src/src/cid/ciderrs.h index 709dc8cd1e4..a5a86e3fc68 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/ciderrs.h +++ b/Build/source/libs/freetype2/freetype-src/src/cid/ciderrs.h @@ -4,7 +4,7 @@ /* */ /* CID error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidgload.c b/Build/source/libs/freetype2/freetype-src/src/cid/cidgload.c index b96c33334d6..d14f9a2cc97 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidgload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidgload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -24,6 +24,10 @@ #include FT_OUTLINE_H #include FT_INTERNAL_CALC_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_CFF_TYPES_H +#include FT_DRIVER_H + #include "ciderrs.h" @@ -52,9 +56,11 @@ FT_ULong glyph_length = 0; PSAux_Service psaux = (PSAux_Service)face->psaux; + FT_Bool force_scaling = FALSE; + #ifdef FT_CONFIG_OPTION_INCREMENTAL - FT_Incremental_InterfaceRec *inc = - face->root.internal->incremental_interface; + FT_Incremental_InterfaceRec *inc = + face->root.internal->incremental_interface; #endif @@ -169,9 +175,57 @@ if ( decoder->lenIV >= 0 ) psaux->t1_decrypt( charstring, glyph_length, 4330 ); - error = decoder->funcs.parse_charstrings( - decoder, charstring + cs_offset, - glyph_length - cs_offset ); + /* choose which renderer to use */ +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + if ( ( (PS_Driver)FT_FACE_DRIVER( face ) )->hinting_engine == + FT_HINTING_FREETYPE || + decoder->builder.metrics_only ) + error = psaux->t1_decoder_funcs->parse_charstrings_old( + decoder, + charstring + cs_offset, + glyph_length - cs_offset ); +#else + if ( decoder->builder.metrics_only ) + error = psaux->t1_decoder_funcs->parse_metrics( + decoder, + charstring + cs_offset, + glyph_length - cs_offset ); +#endif + else + { + PS_Decoder psdecoder; + CFF_SubFontRec subfont; + + + psaux->ps_decoder_init( &psdecoder, decoder, TRUE ); + + psaux->t1_make_subfont( FT_FACE( face ), + &dict->private_dict, + &subfont ); + psdecoder.current_subfont = &subfont; + + error = psaux->t1_decoder_funcs->parse_charstrings( + &psdecoder, + charstring + cs_offset, + glyph_length - cs_offset ); + + /* Adobe's engine uses 16.16 numbers everywhere; */ + /* as a consequence, glyphs larger than 2000ppem get rejected */ + if ( FT_ERR_EQ( error, Glyph_Too_Big ) ) + { + /* this time, we retry unhinted and scale up the glyph later on */ + /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */ + /* 0x400 for both `x_scale' and `y_scale' in this case) */ + ((CID_GlyphSlot)decoder->builder.glyph)->hint = FALSE; + + force_scaling = TRUE; + + error = psaux->t1_decoder_funcs->parse_charstrings( + &psdecoder, + charstring + cs_offset, + glyph_length - cs_offset ); + } + } } #ifdef FT_CONFIG_OPTION_INCREMENTAL @@ -200,6 +254,8 @@ Exit: FT_FREE( charstring ); + ((CID_GlyphSlot)decoder->builder.glyph)->scaled = force_scaling; + return error; } @@ -288,10 +344,12 @@ T1_DecoderRec decoder; CID_Face face = (CID_Face)cidglyph->face; FT_Bool hinting; + FT_Bool scaled; PSAux_Service psaux = (PSAux_Service)face->psaux; FT_Matrix font_matrix; FT_Vector font_offset; + FT_Bool must_finish_decoder = FALSE; if ( glyph_index >= (FT_UInt)face->root.num_glyphs ) @@ -311,7 +369,10 @@ hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); + scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ); + glyph->hint = hinting; + glyph->scaled = scaled; cidglyph->format = FT_GLYPH_FORMAT_OUTLINE; error = psaux->t1_decoder_funcs->init( &decoder, @@ -329,6 +390,8 @@ /* TODO: initialize decoder.len_buildchar and decoder.buildchar */ /* if we ever support CID-keyed multiple master fonts */ + must_finish_decoder = TRUE; + /* set up the decoder */ decoder.builder.no_recurse = FT_BOOL( ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) ); @@ -337,12 +400,18 @@ if ( error ) goto Exit; + /* copy flags back for forced scaling */ + hinting = glyph->hint; + scaled = glyph->scaled; + font_matrix = decoder.font_matrix; font_offset = decoder.font_offset; /* save new glyph tables */ psaux->t1_decoder_funcs->done( &decoder ); + must_finish_decoder = FALSE; + /* now set the metrics -- this is rather simple, as */ /* the left side bearing is the xMin, and the top side */ /* bearing the yMax */ @@ -410,7 +479,7 @@ metrics->vertAdvance += font_offset.y; } - if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) + if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || scaled ) { /* scale the outline and the metrics */ FT_Int n; @@ -451,6 +520,10 @@ } Exit: + + if ( must_finish_decoder ) + psaux->t1_decoder_funcs->done( &decoder ); + return error; } diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidgload.h b/Build/source/libs/freetype2/freetype-src/src/cid/cidgload.h index 7f816b5bc7b..4811852ae43 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidgload.h +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidgload.h @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidload.c b/Build/source/libs/freetype2/freetype-src/src/cid/cidload.c index ff0722110db..27cd09b3c35 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 font loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidload.h b/Build/source/libs/freetype2/freetype-src/src/cid/cidload.h index 45a0e6df25b..3f8bd08620a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidload.h +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidload.h @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 font loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidobjs.c b/Build/source/libs/freetype2/freetype-src/src/cid/cidobjs.c index ceda8ff97f0..77afe1c8751 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidobjs.c @@ -4,7 +4,7 @@ /* */ /* CID objects manager (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -26,6 +26,7 @@ #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_INTERNAL_POSTSCRIPT_AUX_H #include FT_INTERNAL_POSTSCRIPT_HINTS_H +#include FT_DRIVER_H #include "ciderrs.h" @@ -463,9 +464,42 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - cid_driver_init( FT_Module driver ) + cid_driver_init( FT_Module module ) { - FT_UNUSED( driver ); + PS_Driver driver = (PS_Driver)module; + + FT_UInt32 seed; + + + /* set default property values, cf. `ftt1drv.h' */ +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + driver->hinting_engine = FT_HINTING_FREETYPE; +#else + driver->hinting_engine = FT_HINTING_ADOBE; +#endif + + driver->no_stem_darkening = TRUE; + + driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1; + driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1; + driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2; + driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2; + driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3; + driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3; + driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4; + driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4; + + /* compute random seed from some memory addresses */ + seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^ + (FT_Offset)(char*)&module ^ + (FT_Offset)(char*)module->memory ); + seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 ); + + driver->random_seed = (FT_Int32)seed; + if ( driver->random_seed < 0 ) + driver->random_seed = -driver->random_seed; + else if ( driver->random_seed == 0 ) + driver->random_seed = 123456789; return FT_Err_Ok; } diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidobjs.h b/Build/source/libs/freetype2/freetype-src/src/cid/cidobjs.h index 8bcf886e10d..0221f017dd2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidobjs.h +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidobjs.h @@ -4,7 +4,7 @@ /* */ /* CID objects manager (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.c b/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.c index 007609bbdfb..b1c7f3cb2c9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.c +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.h b/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.h index 20bebb942ba..61602f76741 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.h +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.h @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidriver.c b/Build/source/libs/freetype2/freetype-src/src/cid/cidriver.c index bb611a961ee..d9faf353ea4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidriver.c +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidriver.c @@ -4,7 +4,7 @@ /* */ /* CID driver interface (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,6 +20,7 @@ #include "cidriver.h" #include "cidgload.h" #include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_POSTSCRIPT_PROPS_H #include "ciderrs.h" @@ -27,6 +28,10 @@ #include FT_SERVICE_FONT_FORMAT_H #include FT_SERVICE_POSTSCRIPT_INFO_H #include FT_SERVICE_CID_H +#include FT_SERVICE_PROPERTIES_H +#include FT_DRIVER_H + +#include FT_INTERNAL_POSTSCRIPT_AUX_H /*************************************************************************/ @@ -168,6 +173,18 @@ /* + * PROPERTY SERVICE + * + */ + + FT_DEFINE_SERVICE_PROPERTIESREC( + cid_service_properties, + + (FT_Properties_SetFunc)ps_property_set, /* set_property */ + (FT_Properties_GetFunc)ps_property_get ) /* get_property */ + + + /* * SERVICE LIST * */ @@ -178,6 +195,7 @@ { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cid_service_ps_name }, { FT_SERVICE_ID_POSTSCRIPT_INFO, &cid_service_ps_info }, { FT_SERVICE_ID_CID, &cid_service_cid_info }, + { FT_SERVICE_ID_PROPERTIES, &cid_service_properties }, { NULL, NULL } }; @@ -200,7 +218,7 @@ FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_SCALABLE | FT_MODULE_DRIVER_HAS_HINTER, - sizeof ( FT_DriverRec ), + sizeof ( PS_DriverRec ), "t1cid", /* module name */ 0x10000L, /* version 1.0 of driver */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidriver.h b/Build/source/libs/freetype2/freetype-src/src/cid/cidriver.h index 76640c57ba5..59d9ded9015 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidriver.h +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidriver.h @@ -4,7 +4,7 @@ /* */ /* High-level CID driver interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidtoken.h b/Build/source/libs/freetype2/freetype-src/src/cid/cidtoken.h index 653cc5586ef..b0e2dac6aaf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidtoken.h +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidtoken.h @@ -4,7 +4,7 @@ /* */ /* CID token definitions (specification only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/module.mk b/Build/source/libs/freetype2/freetype-src/src/cid/module.mk index b30b8679b96..9010e339a46 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/cid/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/rules.mk b/Build/source/libs/freetype2/freetype-src/src/cid/rules.mk index fcddd92eca3..94333bda06e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/cid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/type1cid.c b/Build/source/libs/freetype2/freetype-src/src/cid/type1cid.c index 93e6f810dba..61770e3f1e2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/type1cid.c +++ b/Build/source/libs/freetype2/freetype-src/src/cid/type1cid.c @@ -4,7 +4,7 @@ /* */ /* FreeType OpenType driver component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/Jamfile b/Build/source/libs/freetype2/freetype-src/src/gxvalid/Jamfile index a120128ae57..74f3c51ff0e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/gxvalid Jamfile # -# Copyright 2005-2017 by +# Copyright 2005-2018 by # suzuki toshiya, Masatake YAMATO and Red Hat K.K. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/README b/Build/source/libs/freetype2/freetype-src/src/gxvalid/README index 200f66cb129..af8128e0e79 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/README +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/README @@ -287,11 +287,11 @@ gxvalid: TrueType GX validator 4-5. invalid feature number (117/183) ------------------------------------- - The GX/AAT extension can include 255 different layout features, but - popular layout features are predefined (see - http://developer.apple.com/fonts/Registry/index.html). Some fonts - include feature numbers which are incompatible with the predefined - feature registry. + The GX/AAT extension can include 255 different layout features, + but popular layout features are predefined (see + https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html). + Some fonts include feature numbers which are incompatible with the + predefined feature registry. In our survey, there are 140 fonts including `feat' table. @@ -518,7 +518,7 @@ gxvalid: TrueType GX validator ------------------------------------------------------------------------ -Copyright 2004-2017 by +Copyright 2004-2018 by suzuki toshiya, Masatake YAMATO, Red hat K.K., David Turner, Robert Wilhelm, and Werner Lemberg. diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvalid.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvalid.c index da485141d37..d0577a247eb 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvalid.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvalid.c @@ -4,7 +4,7 @@ /* */ /* FreeType validator for TrueTypeGX/AAT tables (body only). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvalid.h b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvalid.h index 78116ef85a9..19f03799822 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvalid.h +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvalid.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT table validation (specification only). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvbsln.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvbsln.c index 81dff7304dc..c367d384834 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvbsln.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvbsln.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT bsln table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvcommn.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvcommn.c index db0a91ea742..b96601108b6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvcommn.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvcommn.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT common tables validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvcommn.h b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvcommn.h index 10b1c800f02..8e4ff9cafc0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvcommn.h +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvcommn.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT common tables validation (specification). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxverror.h b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxverror.h index 80a2b8a2625..d1151258a97 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxverror.h +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxverror.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT validation module error codes (specification only). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfeat.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfeat.c index 2e3ec6f9bec..2c805d1d119 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfeat.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfeat.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT feat table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfeat.h b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfeat.h index 8c0e847eb7a..2d943806c11 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfeat.h +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfeat.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT feat table validation (specification). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfgen.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfgen.c index 8cc08cd9c3e..840c0f3524a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfgen.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvfgen.c @@ -5,7 +5,7 @@ /* Generate feature registry data for gxv `feat' validator. */ /* This program is derived from gxfeatreg.c in gxlayout. */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* This file may only be used, */ @@ -21,7 +21,7 @@ /* gxfeatreg.c */ /* */ /* Database of font features pre-defined by Apple Computer, Inc. */ -/* http://developer.apple.com/fonts/Registry/ */ +/* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html */ /* (body). */ /* */ /* Copyright 2003 by */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvjust.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvjust.c index c8cfd83eacd..00c4293195b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvjust.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvjust.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT just table validation (body). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvkern.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvkern.c index 9f9037387d2..9c0efd7a4f6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvkern.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvkern.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT kern table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvlcar.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvlcar.c index 775d5229f2f..0f261a9ace3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvlcar.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvlcar.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT lcar table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmod.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmod.c index 84e9275baf2..1a3c862927d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmod.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType's TrueTypeGX/AAT validation module implementation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmod.h b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmod.h index df25e60cb28..745c62e1054 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmod.h +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmod.h @@ -5,7 +5,7 @@ /* FreeType's TrueTypeGX/AAT validation module implementation */ /* (specification). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort.c index 184a6317c0d..b361cb2b9d7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT mort table validation (body). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort.h b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort.h index d0543adcc5f..d8030645e99 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort.h +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT common definition for mort table (specification). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort0.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort0.c index a75fad7768c..95cf53d5ebf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort0.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort0.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type0 (Indic Script Rearrangement) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort1.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort1.c index 361ef2262d0..a7683a17b0b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort1.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort1.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type1 (Contextual Substitution) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort2.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort2.c index c17e51e3236..c23c2775a15 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort2.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort2.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type2 (Ligature Substitution) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort4.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort4.c index 041bab369f7..9d21a5fc29d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort4.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort4.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type4 (Non-Contextual Glyph Substitution) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort5.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort5.c index 4751eceaa07..42cb428aa88 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort5.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmort5.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type5 (Contextual Glyph Insertion) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx.c index 2bb4f3b8b1a..9fd6e6b971e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT morx table validation (body). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx.h b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx.h index 20cec586724..6d9925e92b2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx.h +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT common definition for morx table (specification). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx0.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx0.c index e0a0a92438e..302261b7fa2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx0.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx0.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for type0 (Indic Script Rearrangement) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx1.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx1.c index 9afebdbfa85..890ca74b1d1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx1.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx1.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for type1 (Contextual Substitution) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx2.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx2.c index 3a60cf68a41..3135031d457 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx2.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx2.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for type2 (Ligature Substitution) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx4.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx4.c index 29555685af6..1e2397b0c57 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx4.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx4.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for "morx" type4 (Non-Contextual Glyph Substitution) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx5.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx5.c index 05c11417ef3..db4f9290c8e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx5.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvmorx5.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for type5 (Contextual Glyph Insertion) subtable. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvopbd.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvopbd.c index 11580d8b2a8..e2c167ea599 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvopbd.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvopbd.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT opbd table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvprop.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvprop.c index 7d398b7e665..a67b6bdd009 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvprop.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvprop.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT prop table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvtrak.c b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvtrak.c index dd498255654..d501b5014b5 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvtrak.c +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/gxvtrak.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT trak table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/module.mk b/Build/source/libs/freetype2/freetype-src/src/gxvalid/module.mk index 7f87e108129..b64879dcee7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/module.mk @@ -2,7 +2,7 @@ # FreeType 2 gxvalid module definition # -# Copyright 2004-2017 by +# Copyright 2004-2018 by # suzuki toshiya, Masatake YAMATO, Red Hat K.K., # David Turner, Robert Wilhelm, and Werner Lemberg. # diff --git a/Build/source/libs/freetype2/freetype-src/src/gxvalid/rules.mk b/Build/source/libs/freetype2/freetype-src/src/gxvalid/rules.mk index 10ec08c5b03..3a17c030a60 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gxvalid/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/gxvalid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2017 by +# Copyright 2004-2018 by # suzuki toshiya, Masatake YAMATO, Red Hat K.K., # David Turner, Robert Wilhelm, and Werner Lemberg. # diff --git a/Build/source/libs/freetype2/freetype-src/src/gzip/Jamfile b/Build/source/libs/freetype2/freetype-src/src/gzip/Jamfile index 170c13a4c66..a7b4c8c9506 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gzip/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/gzip/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/gzip Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/gzip/ftgzip.c b/Build/source/libs/freetype2/freetype-src/src/gzip/ftgzip.c index c487786d993..f8011c2dd82 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gzip/ftgzip.c +++ b/Build/source/libs/freetype2/freetype-src/src/gzip/ftgzip.c @@ -8,7 +8,7 @@ /* parse compressed PCF fonts, as found with many X11 server */ /* distributions. */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/gzip/rules.mk b/Build/source/libs/freetype2/freetype-src/src/gzip/rules.mk index bc7d5fa631a..1a2e48bebd9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/gzip/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/gzip/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/lzw/Jamfile b/Build/source/libs/freetype2/freetype-src/src/lzw/Jamfile index 8e61f080a24..cb83aa4a562 100644 --- a/Build/source/libs/freetype2/freetype-src/src/lzw/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/lzw/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/lzw Jamfile # -# Copyright 2004-2017 by +# Copyright 2004-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/lzw/ftlzw.c b/Build/source/libs/freetype2/freetype-src/src/lzw/ftlzw.c index 941f6cef4c9..cb46f93c68e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/lzw/ftlzw.c +++ b/Build/source/libs/freetype2/freetype-src/src/lzw/ftlzw.c @@ -8,7 +8,7 @@ /* be used to parse compressed PCF fonts, as found with many X11 server */ /* distributions. */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* Albert Chin-A-Young. */ /* */ /* based on code in `src/gzip/ftgzip.c' */ diff --git a/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.c b/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.c index 486c546c146..2b868ba9f2d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.c +++ b/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.c @@ -8,7 +8,7 @@ /* be used to parse compressed PCF fonts, as found with many X11 server */ /* distributions. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* David Turner. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.h b/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.h index a108862c0a5..4fd267eb90f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.h +++ b/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.h @@ -8,7 +8,7 @@ /* be used to parse compressed PCF fonts, as found with many X11 server */ /* distributions. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* David Turner. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/lzw/rules.mk b/Build/source/libs/freetype2/freetype-src/src/lzw/rules.mk index e7bf68a0659..18933c41c2e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/lzw/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/lzw/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2017 by +# Copyright 2004-2018 by # Albert Chin-A-Young. # # based on `src/lzw/rules.mk' diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/Jamfile b/Build/source/libs/freetype2/freetype-src/src/otvalid/Jamfile index a755f2bcfe6..21b8e0cb0f6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/otvalid Jamfile # -# Copyright 2004-2017 by +# Copyright 2004-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/module.mk b/Build/source/libs/freetype2/freetype-src/src/otvalid/module.mk index 5ee1265db81..34f3dab32f0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2017 by +# Copyright 2004-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvalid.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvalid.c index 312751a1f48..4423ca10128 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvalid.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvalid.c @@ -4,7 +4,7 @@ /* */ /* FreeType validator for OpenType tables (body only). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvalid.h b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvalid.h index f2969ccccca..d7801abae50 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvalid.h +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvalid.h @@ -4,7 +4,7 @@ /* */ /* OpenType table validation (specification only). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvbase.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvbase.c index 3adad8439c7..a01d45c707a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvbase.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvbase.c @@ -4,7 +4,7 @@ /* */ /* OpenType BASE table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -284,22 +284,41 @@ OTV_Validator otvalid = &otvalidrec; FT_Bytes p = table; FT_UInt table_size; + FT_UShort version; OTV_OPTIONAL_TABLE( HorizAxis ); OTV_OPTIONAL_TABLE( VertAxis ); + OTV_OPTIONAL_TABLE32( itemVarStore ); + otvalid->root = ftvalid; FT_TRACE3(( "validating BASE table\n" )); OTV_INIT; - OTV_LIMIT_CHECK( 6 ); + OTV_LIMIT_CHECK( 4 ); - if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ + if ( FT_NEXT_USHORT( p ) != 1 ) /* majorVersion */ FT_INVALID_FORMAT; - table_size = 6; + version = FT_NEXT_USHORT( p ); /* minorVersion */ + + table_size = 8; + switch ( version ) + { + case 0: + OTV_LIMIT_CHECK( 4 ); + break; + + case 1: + OTV_LIMIT_CHECK( 8 ); + table_size += 4; + break; + + default: + FT_INVALID_FORMAT; + } OTV_OPTIONAL_OFFSET( HorizAxis ); OTV_SIZE_CHECK( HorizAxis ); @@ -311,6 +330,14 @@ if ( VertAxis ) otv_Axis_validate( table + VertAxis, otvalid ); + if ( version > 0 ) + { + OTV_OPTIONAL_OFFSET32( itemVarStore ); + OTV_SIZE_CHECK32( itemVarStore ); + if ( itemVarStore ) + OTV_TRACE(( " [omitting itemVarStore validation]\n" )); /* XXX */ + } + FT_TRACE4(( "\n" )); } diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvcommn.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvcommn.c index 3407d2ad4ab..0ccfb03c08a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvcommn.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvcommn.c @@ -4,7 +4,7 @@ /* */ /* OpenType common tables validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -313,19 +313,26 @@ OTV_NAME_ENTER( "Device" ); - OTV_LIMIT_CHECK( 8 ); + OTV_LIMIT_CHECK( 6 ); StartSize = FT_NEXT_USHORT( p ); EndSize = FT_NEXT_USHORT( p ); DeltaFormat = FT_NEXT_USHORT( p ); - if ( DeltaFormat < 1 || DeltaFormat > 3 ) - FT_INVALID_FORMAT; + if ( DeltaFormat == 0x8000U ) + { + /* VariationIndex, nothing to do */ + } + else + { + if ( DeltaFormat < 1 || DeltaFormat > 3 ) + FT_INVALID_FORMAT; - if ( EndSize < StartSize ) - FT_INVALID_DATA; + if ( EndSize < StartSize ) + FT_INVALID_DATA; - count = EndSize - StartSize + 1; - OTV_LIMIT_CHECK( ( 1 << DeltaFormat ) * count / 8 ); /* DeltaValue */ + count = EndSize - StartSize + 1; + OTV_LIMIT_CHECK( ( 1 << DeltaFormat ) * count / 8 ); /* DeltaValue */ + } OTV_EXIT; } @@ -347,7 +354,7 @@ OTV_Validator otvalid ) { FT_Bytes p = table; - FT_UInt LookupType, SubTableCount; + FT_UInt LookupType, LookupFlag, SubTableCount; OTV_Validate_Func validate; @@ -355,7 +362,7 @@ OTV_LIMIT_CHECK( 6 ); LookupType = FT_NEXT_USHORT( p ); - p += 2; /* skip LookupFlag */ + LookupFlag = FT_NEXT_USHORT( p ); SubTableCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (type %d)\n", LookupType )); @@ -373,6 +380,9 @@ for ( ; SubTableCount > 0; SubTableCount-- ) validate( table + FT_NEXT_USHORT( p ), otvalid ); + if ( LookupFlag & 0x10 ) + OTV_LIMIT_CHECK( 2 ); /* MarkFilteringSet */ + OTV_EXIT; } diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvcommn.h b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvcommn.h index 10a603ebb93..a392784cf19 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvcommn.h +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvcommn.h @@ -4,7 +4,7 @@ /* */ /* OpenType common tables validation (specification). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -67,29 +67,38 @@ FT_BEGIN_HEADER #undef FT_INVALID_ -#define FT_INVALID_( _error ) \ +#define FT_INVALID_( _error ) \ ft_validator_error( otvalid->root, FT_THROW( _error ) ) #define OTV_OPTIONAL_TABLE( _table ) FT_UShort _table; \ FT_Bytes _table ## _p +#define OTV_OPTIONAL_TABLE32( _table ) FT_ULong _table; \ + FT_Bytes _table ## _p + #define OTV_OPTIONAL_OFFSET( _offset ) \ FT_BEGIN_STMNT \ _offset ## _p = p; \ _offset = FT_NEXT_USHORT( p ); \ FT_END_STMNT -#define OTV_LIMIT_CHECK( _count ) \ - FT_BEGIN_STMNT \ +#define OTV_OPTIONAL_OFFSET32( _offset ) \ + FT_BEGIN_STMNT \ + _offset ## _p = p; \ + _offset = FT_NEXT_ULONG( p ); \ + FT_END_STMNT + +#define OTV_LIMIT_CHECK( _count ) \ + FT_BEGIN_STMNT \ if ( p + (_count) > otvalid->root->limit ) \ - FT_INVALID_TOO_SHORT; \ + FT_INVALID_TOO_SHORT; \ FT_END_STMNT #define OTV_SIZE_CHECK( _size ) \ FT_BEGIN_STMNT \ if ( _size > 0 && _size < table_size ) \ { \ - if ( otvalid->root->level == FT_VALIDATE_PARANOID ) \ + if ( otvalid->root->level == FT_VALIDATE_PARANOID ) \ FT_INVALID_OFFSET; \ else \ { \ @@ -102,12 +111,33 @@ FT_BEGIN_HEADER " set to zero.\n" \ "\n", #_size )); \ \ - /* always assume 16bit entities */ \ _size = pp[0] = pp[1] = 0; \ } \ } \ FT_END_STMNT +#define OTV_SIZE_CHECK32( _size ) \ + FT_BEGIN_STMNT \ + if ( _size > 0 && _size < table_size ) \ + { \ + if ( otvalid->root->level == FT_VALIDATE_PARANOID ) \ + FT_INVALID_OFFSET; \ + else \ + { \ + /* strip off `const' */ \ + FT_Byte* pp = (FT_Byte*)_size ## _p; \ + \ + \ + FT_TRACE3(( "\n" \ + "Invalid offset to optional table `%s'" \ + " set to zero.\n" \ + "\n", #_size )); \ + \ + _size = pp[0] = pp[1] = pp[2] = pp[3] = 0; \ + } \ + } \ + FT_END_STMNT + #define OTV_NAME_(x) #x #define OTV_NAME(x) OTV_NAME_(x) @@ -146,11 +176,11 @@ FT_BEGIN_HEADER #define OTV_INIT otvalid->debug_indent = 0 -#define OTV_ENTER \ - FT_BEGIN_STMNT \ - otvalid->debug_indent += 2; \ - FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \ - FT_TRACE4(( "%s table\n", \ +#define OTV_ENTER \ + FT_BEGIN_STMNT \ + otvalid->debug_indent += 2; \ + FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \ + FT_TRACE4(( "%s table\n", \ otvalid->debug_function_name[otvalid->nesting_level] )); \ FT_END_STMNT diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otverror.h b/Build/source/libs/freetype2/freetype-src/src/otvalid/otverror.h index 699903987cc..2fcf42e3875 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otverror.h +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otverror.h @@ -4,7 +4,7 @@ /* */ /* OpenType validation module error codes (specification only). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgdef.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgdef.c index 27b9a69ca88..08f3171541f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgdef.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgdef.c @@ -4,7 +4,7 @@ /* */ /* OpenType GDEF table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -68,7 +68,7 @@ OTV_LIMIT_CHECK( GlyphCount * 2 ); otvalid->nesting_level++; - func = otvalid->func[otvalid->nesting_level]; + func = otvalid->func[otvalid->nesting_level]; otvalid->extra1 = 0; for ( ; GlyphCount > 0; GlyphCount-- ) @@ -136,6 +136,40 @@ /*************************************************************************/ /*************************************************************************/ /***** *****/ + /***** MARK GLYPH SETS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + static void + otv_MarkGlyphSets_validate( FT_Bytes table, + OTV_Validator otvalid ) + { + FT_Bytes p = table; + FT_UInt MarkGlyphSetCount; + + + OTV_NAME_ENTER( "MarkGlyphSets" ); + + p += 2; /* skip Format */ + + OTV_LIMIT_CHECK( 2 ); + MarkGlyphSetCount = FT_NEXT_USHORT( p ); + + OTV_TRACE(( " (MarkGlyphSetCount = %d)\n", MarkGlyphSetCount )); + + OTV_LIMIT_CHECK( MarkGlyphSetCount * 4 ); /* CoverageOffsets */ + + for ( ; MarkGlyphSetCount > 0; MarkGlyphSetCount-- ) + otv_Coverage_validate( table + FT_NEXT_ULONG( p ), otvalid, -1 ); + + OTV_EXIT; + } + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ /***** GDEF TABLE *****/ /***** *****/ /*************************************************************************/ @@ -152,14 +186,18 @@ { OTV_ValidatorRec otvalidrec; OTV_Validator otvalid = &otvalidrec; - FT_Bytes p = table; + FT_Bytes p = table; FT_UInt table_size; - FT_Bool need_MarkAttachClassDef; + FT_UShort version; + FT_Bool need_MarkAttachClassDef = 1; OTV_OPTIONAL_TABLE( GlyphClassDef ); OTV_OPTIONAL_TABLE( AttachListOffset ); OTV_OPTIONAL_TABLE( LigCaretListOffset ); OTV_OPTIONAL_TABLE( MarkAttachClassDef ); + OTV_OPTIONAL_TABLE( MarkGlyphSetsDef ); + + OTV_OPTIONAL_TABLE32( itemVarStore ); otvalid->root = ftvalid; @@ -167,24 +205,49 @@ FT_TRACE3(( "validating GDEF table\n" )); OTV_INIT; - OTV_LIMIT_CHECK( 12 ); + OTV_LIMIT_CHECK( 4 ); - if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ + if ( FT_NEXT_USHORT( p ) != 1 ) /* majorVersion */ FT_INVALID_FORMAT; - /* MarkAttachClassDef has been added to the OpenType */ - /* specification without increasing GDEF's version, */ - /* so we use this ugly hack to find out whether the */ - /* table is needed actually. */ + version = FT_NEXT_USHORT( p ); /* minorVersion */ - need_MarkAttachClassDef = FT_BOOL( - otv_GSUBGPOS_have_MarkAttachmentType_flag( gsub ) || - otv_GSUBGPOS_have_MarkAttachmentType_flag( gpos ) ); + table_size = 10; + switch ( version ) + { + case 0: + /* MarkAttachClassDef has been added to the OpenType */ + /* specification without increasing GDEF's version, */ + /* so we use this ugly hack to find out whether the */ + /* table is needed actually. */ + + need_MarkAttachClassDef = FT_BOOL( + otv_GSUBGPOS_have_MarkAttachmentType_flag( gsub ) || + otv_GSUBGPOS_have_MarkAttachmentType_flag( gpos ) ); + + if ( need_MarkAttachClassDef ) + { + OTV_LIMIT_CHECK( 8 ); + table_size += 2; + } + else + OTV_LIMIT_CHECK( 6 ); /* OpenType < 1.2 */ - if ( need_MarkAttachClassDef ) - table_size = 12; /* OpenType >= 1.2 */ - else - table_size = 10; /* OpenType < 1.2 */ + break; + + case 2: + OTV_LIMIT_CHECK( 10 ); + table_size += 4; + break; + + case 3: + OTV_LIMIT_CHECK( 14 ); + table_size += 8; + break; + + default: + FT_INVALID_FORMAT; + } otvalid->glyph_count = glyph_count; @@ -217,6 +280,22 @@ otv_ClassDef_validate( table + MarkAttachClassDef, otvalid ); } + if ( version > 0 ) + { + OTV_OPTIONAL_OFFSET( MarkGlyphSetsDef ); + OTV_SIZE_CHECK( MarkGlyphSetsDef ); + if ( MarkGlyphSetsDef ) + otv_MarkGlyphSets_validate( table + MarkGlyphSetsDef, otvalid ); + } + + if ( version > 2 ) + { + OTV_OPTIONAL_OFFSET32( itemVarStore ); + OTV_SIZE_CHECK32( itemVarStore ); + if ( itemVarStore ) + OTV_TRACE(( " [omitting itemVarStore validation]\n" )); /* XXX */ + } + FT_TRACE4(( "\n" )); } diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgpos.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgpos.c index 0fbcc2077cb..696b35cae62 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgpos.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgpos.c @@ -4,7 +4,7 @@ /* */ /* OpenType GPOS table validation (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -130,7 +130,7 @@ otv_MarkArray_validate( table + Array1, otvalid ); otvalid->nesting_level++; - func = otvalid->func[otvalid->nesting_level]; + func = otvalid->func[otvalid->nesting_level]; otvalid->extra1 = ClassCount; func( table + Array2, otvalid ); @@ -218,10 +218,6 @@ OTV_LIMIT_CHECK( 2 ); OTV_OPTIONAL_OFFSET( device ); - /* XXX: this value is usually too small, especially if the current */ - /* ValueRecord is part of an array -- getting the correct table */ - /* size is probably not worth the trouble */ - table_size = p - otvalid->extra3; OTV_SIZE_CHECK( device ); @@ -271,7 +267,7 @@ case 3: { - FT_UInt table_size; + FT_UInt table_size; OTV_OPTIONAL_TABLE( XDeviceTable ); OTV_OPTIONAL_TABLE( YDeviceTable ); @@ -426,6 +422,8 @@ /*************************************************************************/ /*************************************************************************/ + /* sets otvalid->extra3 (pointer to base table) */ + static void otv_PairSet_validate( FT_Bytes table, FT_UInt format1, @@ -438,6 +436,8 @@ OTV_NAME_ENTER( "PairSet" ); + otvalid->extra3 = table; + OTV_LIMIT_CHECK( 2 ); PairValueCount = FT_NEXT_USHORT( p ); @@ -483,8 +483,6 @@ OTV_TRACE(( " (format %d)\n", PosFormat )); - otvalid->extra3 = table; - switch ( PosFormat ) { case 1: /* PairPosFormat1 */ @@ -537,7 +535,9 @@ otv_ClassDef_validate( table + ClassDef2, otvalid ); OTV_LIMIT_CHECK( ClassCount1 * ClassCount2 * - ( len_value1 + len_value2 ) ); + ( len_value1 + len_value2 ) ); + + otvalid->extra3 = table; /* Class1Record */ for ( ; ClassCount1 > 0; ClassCount1-- ) @@ -985,20 +985,42 @@ { OTV_ValidatorRec validrec; OTV_Validator otvalid = &validrec; - FT_Bytes p = table; + FT_Bytes p = table; + FT_UInt table_size; + FT_UShort version; FT_UInt ScriptList, FeatureList, LookupList; + OTV_OPTIONAL_TABLE32( featureVariations ); + otvalid->root = ftvalid; FT_TRACE3(( "validating GPOS table\n" )); OTV_INIT; - OTV_LIMIT_CHECK( 10 ); + OTV_LIMIT_CHECK( 4 ); - if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ + if ( FT_NEXT_USHORT( p ) != 1 ) /* majorVersion */ FT_INVALID_FORMAT; + version = FT_NEXT_USHORT( p ); /* minorVersion */ + + table_size = 10; + switch ( version ) + { + case 0: + OTV_LIMIT_CHECK( 6 ); + break; + + case 1: + OTV_LIMIT_CHECK( 10 ); + table_size += 4; + break; + + default: + FT_INVALID_FORMAT; + } + ScriptList = FT_NEXT_USHORT( p ); FeatureList = FT_NEXT_USHORT( p ); LookupList = FT_NEXT_USHORT( p ); @@ -1014,6 +1036,14 @@ otv_ScriptList_validate( table + ScriptList, table + FeatureList, otvalid ); + if ( version > 0 ) + { + OTV_OPTIONAL_OFFSET32( featureVariations ); + OTV_SIZE_CHECK32( featureVariations ); + if ( featureVariations ) + OTV_TRACE(( " [omitting featureVariations validation]\n" )); /* XXX */ + } + FT_TRACE4(( "\n" )); } diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgpos.h b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgpos.h index 99b0ad39159..95f9ac3ee85 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgpos.h +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgpos.h @@ -4,7 +4,7 @@ /* */ /* OpenType GPOS table validator (specification). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgsub.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgsub.c index f9bd8dc5d80..d35ea67f309 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgsub.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvgsub.c @@ -4,7 +4,7 @@ /* */ /* OpenType GSUB table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -552,18 +552,40 @@ OTV_ValidatorRec otvalidrec; OTV_Validator otvalid = &otvalidrec; FT_Bytes p = table; + FT_UInt table_size; + FT_UShort version; FT_UInt ScriptList, FeatureList, LookupList; + OTV_OPTIONAL_TABLE32( featureVariations ); + otvalid->root = ftvalid; FT_TRACE3(( "validating GSUB table\n" )); OTV_INIT; - OTV_LIMIT_CHECK( 10 ); + OTV_LIMIT_CHECK( 4 ); + + if ( FT_NEXT_USHORT( p ) != 1 ) /* majorVersion */ + FT_INVALID_FORMAT; + + version = FT_NEXT_USHORT( p ); /* minorVersion */ + + table_size = 10; + switch ( version ) + { + case 0: + OTV_LIMIT_CHECK( 6 ); + break; + + case 1: + OTV_LIMIT_CHECK( 10 ); + table_size += 4; + break; - if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ + default: FT_INVALID_FORMAT; + } ScriptList = FT_NEXT_USHORT( p ); FeatureList = FT_NEXT_USHORT( p ); @@ -580,6 +602,14 @@ otv_ScriptList_validate( table + ScriptList, table + FeatureList, otvalid ); + if ( version > 0 ) + { + OTV_OPTIONAL_OFFSET32( featureVariations ); + OTV_SIZE_CHECK32( featureVariations ); + if ( featureVariations ) + OTV_TRACE(( " [omitting featureVariations validation]\n" )); /* XXX */ + } + FT_TRACE4(( "\n" )); } diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvjstf.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvjstf.c index 57a38f95c9e..94d4af90f6f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvjstf.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvjstf.c @@ -4,7 +4,7 @@ /* */ /* OpenType JSTF table validation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmath.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmath.c index a14d3697008..b9800f60a26 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmath.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmath.c @@ -4,7 +4,7 @@ /* */ /* OpenType MATH table validation (body). */ /* */ -/* Copyright 2007-2017 by */ +/* Copyright 2007-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* Written by George Williams. */ diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmod.c b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmod.c index 35ffc43d3a5..89ee449d16d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmod.c +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType's OpenType validation module implementation (body). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmod.h b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmod.h index 30d401ddca3..6917bccee5d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmod.h +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/otvmod.h @@ -5,7 +5,7 @@ /* FreeType's OpenType validation module implementation */ /* (specification). */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/otvalid/rules.mk b/Build/source/libs/freetype2/freetype-src/src/otvalid/rules.mk index 10329a96ea0..d4fc7237405 100644 --- a/Build/source/libs/freetype2/freetype-src/src/otvalid/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/otvalid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2017 by +# Copyright 2004-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/pcf/Jamfile b/Build/source/libs/freetype2/freetype-src/src/pcf/Jamfile index 794f27dfb03..7b92b12ddcf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pcf/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/pcf/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/pcf Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/pcf/pcfdrivr.c b/Build/source/libs/freetype2/freetype-src/src/pcf/pcfdrivr.c index 169f75e9506..0119d94853a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pcf/pcfdrivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/pcf/pcfdrivr.c @@ -50,7 +50,7 @@ THE SOFTWARE. #include FT_SERVICE_BDF_H #include FT_SERVICE_FONT_FORMAT_H #include FT_SERVICE_PROPERTIES_H -#include FT_PCF_DRIVER_H +#include FT_DRIVER_H /*************************************************************************/ diff --git a/Build/source/libs/freetype2/freetype-src/src/pcf/pcfread.c b/Build/source/libs/freetype2/freetype-src/src/pcf/pcfread.c index da216b05f4b..537da0dc79b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pcf/pcfread.c +++ b/Build/source/libs/freetype2/freetype-src/src/pcf/pcfread.c @@ -840,7 +840,7 @@ THE SOFTWARE. FT_TRACE4(( "pcf_get_bitmaps:\n" " format: 0x%lX\n" " (%s, %s,\n" - " padding=%d bits, scanning=%d bits)\n", + " padding=%d bit%s, scanning=%d bit%s)\n", format, PCF_BYTE_ORDER( format ) == MSBFirst ? "most significant byte first" @@ -849,7 +849,9 @@ THE SOFTWARE. ? "most significant bit first" : "least significant bit first", 8 << PCF_GLYPH_PAD_INDEX( format ), - 8 << PCF_SCAN_UNIT_INDEX( format ) )); + ( 8 << PCF_GLYPH_PAD_INDEX( format ) ) == 1 ? "" : "s", + 8 << PCF_SCAN_UNIT_INDEX( format ), + ( 8 << PCF_SCAN_UNIT_INDEX( format ) ) == 1 ? "" : "s" )); if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) return FT_THROW( Invalid_File_Format ); diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/Jamfile b/Build/source/libs/freetype2/freetype-src/src/pfr/Jamfile index 17831716246..cb55a7ee89a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/pfr Jamfile # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/module.mk b/Build/source/libs/freetype2/freetype-src/src/pfr/module.mk index 7b84da97083..27fec8e5f61 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfr.c b/Build/source/libs/freetype2/freetype-src/src/pfr/pfr.c index 4f31f5d9bc0..1760882fcdb 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfr.c +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfr.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR driver component. */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrcmap.c b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrcmap.c index 1d6b15be484..60643780a16 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrcmap.c +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrcmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR cmap handling (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrcmap.h b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrcmap.h index 957bf65b4c3..c70a0c83c50 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrcmap.h +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrcmap.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR cmap handling (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrdrivr.c b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrdrivr.c index 195cdb76acb..6c7e50128a2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrdrivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrdrivr.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR driver interface (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrdrivr.h b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrdrivr.h index b81d56017e0..cab852789b9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrdrivr.h +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrdrivr.h @@ -4,7 +4,7 @@ /* */ /* High-level Type PFR driver interface (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrerror.h b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrerror.h index ef044e32c9e..7027c818e89 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrerror.h +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrerror.h @@ -4,7 +4,7 @@ /* */ /* PFR error codes (specification only). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrgload.c b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrgload.c index 93f5fc70908..b7990196b6e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrgload.c +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrgload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR glyph loader (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -756,8 +756,10 @@ count = glyph->num_subs - old_count; - FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n", - count, offset )); + FT_TRACE4(( "compound glyph with %d element%s (offset %lu):\n", + count, + count == 1 ? "" : "s", + offset )); /* now, load each individual glyph */ for ( n = 0; n < count; n++ ) @@ -810,7 +812,9 @@ /* proceed to next sub-glyph */ } - FT_TRACE4(( "end compound glyph with %d elements\n", count )); + FT_TRACE4(( "end compound glyph with %d element%s\n", + count, + count == 1 ? "" : "s" )); } else { diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrgload.h b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrgload.h index 66123238717..01f48d7706a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrgload.h +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrgload.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR glyph loader (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrload.c b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrload.c index 4f841658285..2776da462a8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrload.c +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR loader (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrload.h b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrload.h index f9475ae0629..36e809a762c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrload.h +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrload.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR loader (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrobjs.c b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrobjs.c index 514af8050d2..737b97b5ff2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrobjs.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR object methods (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrobjs.h b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrobjs.h index d6ad6562dfc..59c709f58d0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrobjs.h +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrobjs.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR object methods (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrsbit.c b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrsbit.c index 54e7d0e6cc5..ba909ddca75 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrsbit.c +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrsbit.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR bitmap loader (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrsbit.h b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrsbit.h index fc270f50a8f..07b27bc06cc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrsbit.h +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrsbit.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR bitmap loader (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrtypes.h b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrtypes.h index c3d542c2094..058d6aadc9a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/pfrtypes.h +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/pfrtypes.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR data structures (specification only). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pfr/rules.mk b/Build/source/libs/freetype2/freetype-src/src/pfr/rules.mk index 9940f622862..3acb7956969 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pfr/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/pfr/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/Jamfile b/Build/source/libs/freetype2/freetype-src/src/psaux/Jamfile index 798b73d1cdd..a231d5974f5 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/psaux Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -22,6 +22,16 @@ SubDir FT2_TOP $(FT2_SRC_DIR) psaux ; psobjs t1cmap t1decode + cffdecode + psarrst + psblues + pserror + psfont + psft + pshints + psintrp + psread + psstack ; } else diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/afmparse.c b/Build/source/libs/freetype2/freetype-src/src/psaux/afmparse.c index ff2cc8cf082..0c33d5949bc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/afmparse.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/afmparse.c @@ -4,7 +4,7 @@ /* */ /* AFM parser (body). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/afmparse.h b/Build/source/libs/freetype2/freetype-src/src/psaux/afmparse.h index cd2beb7804d..86f852a2477 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/afmparse.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/afmparse.h @@ -4,7 +4,7 @@ /* */ /* AFM parser (specification). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/cffdecode.c b/Build/source/libs/freetype2/freetype-src/src/psaux/cffdecode.c new file mode 100644 index 00000000000..80d622c0e1b --- /dev/null +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/cffdecode.c @@ -0,0 +1,2370 @@ +/***************************************************************************/ +/* */ +/* cffdecode.c */ +/* */ +/* PostScript CFF (Type 2) decoding routines (body). */ +/* */ +/* Copyright 2017-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_SERVICE_H +#include FT_SERVICE_CFF_TABLE_LOAD_H + +#include "cffdecode.h" +#include "psobjs.h" + +#include "psauxerr.h" + + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_cffdecode + + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + + typedef enum CFF_Operator_ + { + cff_op_unknown = 0, + + cff_op_rmoveto, + cff_op_hmoveto, + cff_op_vmoveto, + + cff_op_rlineto, + cff_op_hlineto, + cff_op_vlineto, + + cff_op_rrcurveto, + cff_op_hhcurveto, + cff_op_hvcurveto, + cff_op_rcurveline, + cff_op_rlinecurve, + cff_op_vhcurveto, + cff_op_vvcurveto, + + cff_op_flex, + cff_op_hflex, + cff_op_hflex1, + cff_op_flex1, + + cff_op_endchar, + + cff_op_hstem, + cff_op_vstem, + cff_op_hstemhm, + cff_op_vstemhm, + + cff_op_hintmask, + cff_op_cntrmask, + cff_op_dotsection, /* deprecated, acts as no-op */ + + cff_op_abs, + cff_op_add, + cff_op_sub, + cff_op_div, + cff_op_neg, + cff_op_random, + cff_op_mul, + cff_op_sqrt, + + cff_op_blend, + + cff_op_drop, + cff_op_exch, + cff_op_index, + cff_op_roll, + cff_op_dup, + + cff_op_put, + cff_op_get, + cff_op_store, + cff_op_load, + + cff_op_and, + cff_op_or, + cff_op_not, + cff_op_eq, + cff_op_ifelse, + + cff_op_callsubr, + cff_op_callgsubr, + cff_op_return, + + /* Type 1 opcodes: invalid but seen in real life */ + cff_op_hsbw, + cff_op_closepath, + cff_op_callothersubr, + cff_op_pop, + cff_op_seac, + cff_op_sbw, + cff_op_setcurrentpoint, + + /* do not remove */ + cff_op_max + + } CFF_Operator; + + +#define CFF_COUNT_CHECK_WIDTH 0x80 +#define CFF_COUNT_EXACT 0x40 +#define CFF_COUNT_CLEAR_STACK 0x20 + + /* count values which have the `CFF_COUNT_CHECK_WIDTH' flag set are */ + /* used for checking the width and requested numbers of arguments */ + /* only; they are set to zero afterwards */ + + /* the other two flags are informative only and unused currently */ + + static const FT_Byte cff_argument_counts[] = + { + 0, /* unknown */ + + 2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, /* rmoveto */ + 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, + 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, + + 0 | CFF_COUNT_CLEAR_STACK, /* rlineto */ + 0 | CFF_COUNT_CLEAR_STACK, + 0 | CFF_COUNT_CLEAR_STACK, + + 0 | CFF_COUNT_CLEAR_STACK, /* rrcurveto */ + 0 | CFF_COUNT_CLEAR_STACK, + 0 | CFF_COUNT_CLEAR_STACK, + 0 | CFF_COUNT_CLEAR_STACK, + 0 | CFF_COUNT_CLEAR_STACK, + 0 | CFF_COUNT_CLEAR_STACK, + 0 | CFF_COUNT_CLEAR_STACK, + + 13, /* flex */ + 7, + 9, + 11, + + 0 | CFF_COUNT_CHECK_WIDTH, /* endchar */ + + 2 | CFF_COUNT_CHECK_WIDTH, /* hstem */ + 2 | CFF_COUNT_CHECK_WIDTH, + 2 | CFF_COUNT_CHECK_WIDTH, + 2 | CFF_COUNT_CHECK_WIDTH, + + 0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */ + 0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */ + 0, /* dotsection */ + + 1, /* abs */ + 2, + 2, + 2, + 1, + 0, + 2, + 1, + + 1, /* blend */ + + 1, /* drop */ + 2, + 1, + 2, + 1, + + 2, /* put */ + 1, + 4, + 3, + + 2, /* and */ + 2, + 1, + 2, + 4, + + 1, /* callsubr */ + 1, + 0, + + 2, /* hsbw */ + 0, + 0, + 0, + 5, /* seac */ + 4, /* sbw */ + 2 /* setcurrentpoint */ + }; + + + static FT_Error + cff_operator_seac( CFF_Decoder* decoder, + FT_Pos asb, + FT_Pos adx, + FT_Pos ady, + FT_Int bchar, + FT_Int achar ) + { + FT_Error error; + CFF_Builder* builder = &decoder->builder; + FT_Int bchar_index, achar_index; + TT_Face face = decoder->builder.face; + FT_Vector left_bearing, advance; + FT_Byte* charstring; + FT_ULong charstring_len; + FT_Pos glyph_width; + + + if ( decoder->seac ) + { + FT_ERROR(( "cff_operator_seac: invalid nested seac\n" )); + return FT_THROW( Syntax_Error ); + } + + adx += decoder->builder.left_bearing.x; + ady += decoder->builder.left_bearing.y; + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* Incremental fonts don't necessarily have valid charsets. */ + /* They use the character code, not the glyph index, in this case. */ + if ( face->root.internal->incremental_interface ) + { + bchar_index = bchar; + achar_index = achar; + } + else +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + { + CFF_Font cff = (CFF_Font)(face->extra.data); + + + bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar ); + achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar ); + } + + if ( bchar_index < 0 || achar_index < 0 ) + { + FT_ERROR(( "cff_operator_seac:" + " invalid seac character code arguments\n" )); + return FT_THROW( Syntax_Error ); + } + + /* If we are trying to load a composite glyph, do not load the */ + /* accent character and return the array of subglyphs. */ + if ( builder->no_recurse ) + { + FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph; + FT_GlyphLoader loader = glyph->internal->loader; + FT_SubGlyph subg; + + + /* reallocate subglyph array if necessary */ + error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 ); + if ( error ) + goto Exit; + + subg = loader->current.subglyphs; + + /* subglyph 0 = base character */ + subg->index = bchar_index; + subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES | + FT_SUBGLYPH_FLAG_USE_MY_METRICS; + subg->arg1 = 0; + subg->arg2 = 0; + subg++; + + /* subglyph 1 = accent character */ + subg->index = achar_index; + subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; + subg->arg1 = (FT_Int)( adx >> 16 ); + subg->arg2 = (FT_Int)( ady >> 16 ); + + /* set up remaining glyph fields */ + glyph->num_subglyphs = 2; + glyph->subglyphs = loader->base.subglyphs; + glyph->format = FT_GLYPH_FORMAT_COMPOSITE; + + loader->current.num_subglyphs = 2; + } + + FT_GlyphLoader_Prepare( builder->loader ); + + /* First load `bchar' in builder */ + error = decoder->get_glyph_callback( face, (FT_UInt)bchar_index, + &charstring, &charstring_len ); + if ( !error ) + { + /* the seac operator must not be nested */ + decoder->seac = TRUE; + error = cff_decoder_parse_charstrings( decoder, charstring, + charstring_len, 0 ); + decoder->seac = FALSE; + + decoder->free_glyph_callback( face, &charstring, charstring_len ); + + if ( error ) + goto Exit; + } + + /* Save the left bearing, advance and glyph width of the base */ + /* character as they will be erased by the next load. */ + + left_bearing = builder->left_bearing; + advance = builder->advance; + glyph_width = decoder->glyph_width; + + builder->left_bearing.x = 0; + builder->left_bearing.y = 0; + + builder->pos_x = adx - asb; + builder->pos_y = ady; + + /* Now load `achar' on top of the base outline. */ + error = decoder->get_glyph_callback( face, (FT_UInt)achar_index, + &charstring, &charstring_len ); + if ( !error ) + { + /* the seac operator must not be nested */ + decoder->seac = TRUE; + error = cff_decoder_parse_charstrings( decoder, charstring, + charstring_len, 0 ); + decoder->seac = FALSE; + + decoder->free_glyph_callback( face, &charstring, charstring_len ); + + if ( error ) + goto Exit; + } + + /* Restore the left side bearing, advance and glyph width */ + /* of the base character. */ + builder->left_bearing = left_bearing; + builder->advance = advance; + decoder->glyph_width = glyph_width; + + builder->pos_x = 0; + builder->pos_y = 0; + + Exit: + return error; + } + +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********** *********/ + /********** *********/ + /********** GENERIC CHARSTRING PARSING *********/ + /********** *********/ + /********** *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Function> */ + /* cff_compute_bias */ + /* */ + /* <Description> */ + /* Computes the bias value in dependence of the number of glyph */ + /* subroutines. */ + /* */ + /* <Input> */ + /* in_charstring_type :: The `CharstringType' value of the top DICT */ + /* dictionary. */ + /* */ + /* num_subrs :: The number of glyph subroutines. */ + /* */ + /* <Return> */ + /* The bias value. */ + static FT_Int + cff_compute_bias( FT_Int in_charstring_type, + FT_UInt num_subrs ) + { + FT_Int result; + + + if ( in_charstring_type == 1 ) + result = 0; + else if ( num_subrs < 1240 ) + result = 107; + else if ( num_subrs < 33900U ) + result = 1131; + else + result = 32768U; + + return result; + } + + + FT_LOCAL_DEF( FT_Int ) + cff_lookup_glyph_by_stdcharcode( CFF_Font cff, + FT_Int charcode ) + { + FT_UInt n; + FT_UShort glyph_sid; + + FT_Service_CFFLoad cffload; + + + /* CID-keyed fonts don't have glyph names */ + if ( !cff->charset.sids ) + return -1; + + /* check range of standard char code */ + if ( charcode < 0 || charcode > 255 ) + return -1; + +#if 0 + /* retrieve cffload from list of current modules */ + FT_Service_CFFLoad cffload; + + + FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD ); + if ( !cffload ) + { + FT_ERROR(( "cff_lookup_glyph_by_stdcharcode:" + " the `cffload' module is not available\n" )); + return FT_THROW( Unimplemented_Feature ); + } +#endif + + cffload = (FT_Service_CFFLoad)cff->cffload; + + /* Get code to SID mapping from `cff_standard_encoding'. */ + glyph_sid = cffload->get_standard_encoding( (FT_UInt)charcode ); + + for ( n = 0; n < cff->num_glyphs; n++ ) + { + if ( cff->charset.sids[n] == glyph_sid ) + return (FT_Int)n; + } + + return -1; + } + + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + + /*************************************************************************/ + /* */ + /* <Function> */ + /* cff_decoder_parse_charstrings */ + /* */ + /* <Description> */ + /* Parses a given Type 2 charstrings program. */ + /* */ + /* <InOut> */ + /* decoder :: The current Type 1 decoder. */ + /* */ + /* <Input> */ + /* charstring_base :: The base of the charstring stream. */ + /* */ + /* charstring_len :: The length in bytes of the charstring stream. */ + /* */ + /* in_dict :: Set to 1 if function is called from top or */ + /* private DICT (needed for Multiple Master CFFs). */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + cff_decoder_parse_charstrings( CFF_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len, + FT_Bool in_dict ) + { + FT_Error error; + CFF_Decoder_Zone* zone; + FT_Byte* ip; + FT_Byte* limit; + CFF_Builder* builder = &decoder->builder; + FT_Pos x, y; + FT_Fixed* stack; + FT_Int charstring_type = + decoder->cff->top_font.font_dict.charstring_type; + FT_UShort num_designs = + decoder->cff->top_font.font_dict.num_designs; + FT_UShort num_axes = + decoder->cff->top_font.font_dict.num_axes; + + T2_Hints_Funcs hinter; + + + /* set default width */ + decoder->num_hints = 0; + decoder->read_width = 1; + + /* initialize the decoder */ + decoder->top = decoder->stack; + decoder->zone = decoder->zones; + zone = decoder->zones; + stack = decoder->top; + + hinter = (T2_Hints_Funcs)builder->hints_funcs; + + builder->path_begun = 0; + + zone->base = charstring_base; + limit = zone->limit = charstring_base + charstring_len; + ip = zone->cursor = zone->base; + + error = FT_Err_Ok; + + x = builder->pos_x; + y = builder->pos_y; + + /* begin hints recording session, if any */ + if ( hinter ) + hinter->open( hinter->hints ); + + /* now execute loop */ + while ( ip < limit ) + { + CFF_Operator op; + FT_Byte v; + + + /********************************************************************/ + /* */ + /* Decode operator or operand */ + /* */ + v = *ip++; + if ( v >= 32 || v == 28 ) + { + FT_Int shift = 16; + FT_Int32 val; + + + /* this is an operand, push it on the stack */ + + /* if we use shifts, all computations are done with unsigned */ + /* values; the conversion to a signed value is the last step */ + if ( v == 28 ) + { + if ( ip + 1 >= limit ) + goto Syntax_Error; + val = (FT_Short)( ( (FT_UShort)ip[0] << 8 ) | ip[1] ); + ip += 2; + } + else if ( v < 247 ) + val = (FT_Int32)v - 139; + else if ( v < 251 ) + { + if ( ip >= limit ) + goto Syntax_Error; + val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108; + } + else if ( v < 255 ) + { + if ( ip >= limit ) + goto Syntax_Error; + val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108; + } + else + { + if ( ip + 3 >= limit ) + goto Syntax_Error; + val = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) | + ( (FT_UInt32)ip[1] << 16 ) | + ( (FT_UInt32)ip[2] << 8 ) | + (FT_UInt32)ip[3] ); + ip += 4; + if ( charstring_type == 2 ) + shift = 0; + } + if ( decoder->top - stack >= CFF_MAX_OPERANDS ) + goto Stack_Overflow; + + val = (FT_Int32)( (FT_UInt32)val << shift ); + *decoder->top++ = val; + +#ifdef FT_DEBUG_LEVEL_TRACE + if ( !( val & 0xFFFFL ) ) + FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) )); + else + FT_TRACE4(( " %.5f", val / 65536.0 )); +#endif + + } + else + { + /* The specification says that normally arguments are to be taken */ + /* from the bottom of the stack. However, this seems not to be */ + /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */ + /* arguments similar to a PS interpreter. */ + + FT_Fixed* args = decoder->top; + FT_Int num_args = (FT_Int)( args - decoder->stack ); + FT_Int req_args; + + + /* find operator */ + op = cff_op_unknown; + + switch ( v ) + { + case 1: + op = cff_op_hstem; + break; + case 3: + op = cff_op_vstem; + break; + case 4: + op = cff_op_vmoveto; + break; + case 5: + op = cff_op_rlineto; + break; + case 6: + op = cff_op_hlineto; + break; + case 7: + op = cff_op_vlineto; + break; + case 8: + op = cff_op_rrcurveto; + break; + case 9: + op = cff_op_closepath; + break; + case 10: + op = cff_op_callsubr; + break; + case 11: + op = cff_op_return; + break; + case 12: + if ( ip >= limit ) + goto Syntax_Error; + v = *ip++; + + switch ( v ) + { + case 0: + op = cff_op_dotsection; + break; + case 1: /* this is actually the Type1 vstem3 operator */ + op = cff_op_vstem; + break; + case 2: /* this is actually the Type1 hstem3 operator */ + op = cff_op_hstem; + break; + case 3: + op = cff_op_and; + break; + case 4: + op = cff_op_or; + break; + case 5: + op = cff_op_not; + break; + case 6: + op = cff_op_seac; + break; + case 7: + op = cff_op_sbw; + break; + case 8: + op = cff_op_store; + break; + case 9: + op = cff_op_abs; + break; + case 10: + op = cff_op_add; + break; + case 11: + op = cff_op_sub; + break; + case 12: + op = cff_op_div; + break; + case 13: + op = cff_op_load; + break; + case 14: + op = cff_op_neg; + break; + case 15: + op = cff_op_eq; + break; + case 16: + op = cff_op_callothersubr; + break; + case 17: + op = cff_op_pop; + break; + case 18: + op = cff_op_drop; + break; + case 20: + op = cff_op_put; + break; + case 21: + op = cff_op_get; + break; + case 22: + op = cff_op_ifelse; + break; + case 23: + op = cff_op_random; + break; + case 24: + op = cff_op_mul; + break; + case 26: + op = cff_op_sqrt; + break; + case 27: + op = cff_op_dup; + break; + case 28: + op = cff_op_exch; + break; + case 29: + op = cff_op_index; + break; + case 30: + op = cff_op_roll; + break; + case 33: + op = cff_op_setcurrentpoint; + break; + case 34: + op = cff_op_hflex; + break; + case 35: + op = cff_op_flex; + break; + case 36: + op = cff_op_hflex1; + break; + case 37: + op = cff_op_flex1; + break; + default: + FT_TRACE4(( " unknown op (12, %d)\n", v )); + break; + } + break; + case 13: + op = cff_op_hsbw; + break; + case 14: + op = cff_op_endchar; + break; + case 16: + op = cff_op_blend; + break; + case 18: + op = cff_op_hstemhm; + break; + case 19: + op = cff_op_hintmask; + break; + case 20: + op = cff_op_cntrmask; + break; + case 21: + op = cff_op_rmoveto; + break; + case 22: + op = cff_op_hmoveto; + break; + case 23: + op = cff_op_vstemhm; + break; + case 24: + op = cff_op_rcurveline; + break; + case 25: + op = cff_op_rlinecurve; + break; + case 26: + op = cff_op_vvcurveto; + break; + case 27: + op = cff_op_hhcurveto; + break; + case 29: + op = cff_op_callgsubr; + break; + case 30: + op = cff_op_vhcurveto; + break; + case 31: + op = cff_op_hvcurveto; + break; + default: + FT_TRACE4(( " unknown op (%d)\n", v )); + break; + } + + if ( op == cff_op_unknown ) + continue; + + /* in Multiple Master CFFs, T2 charstrings can appear in */ + /* dictionaries, but some operators are prohibited */ + if ( in_dict ) + { + switch ( op ) + { + case cff_op_hstem: + case cff_op_vstem: + case cff_op_vmoveto: + case cff_op_rlineto: + case cff_op_hlineto: + case cff_op_vlineto: + case cff_op_rrcurveto: + case cff_op_hstemhm: + case cff_op_hintmask: + case cff_op_cntrmask: + case cff_op_rmoveto: + case cff_op_hmoveto: + case cff_op_vstemhm: + case cff_op_rcurveline: + case cff_op_rlinecurve: + case cff_op_vvcurveto: + case cff_op_hhcurveto: + case cff_op_vhcurveto: + case cff_op_hvcurveto: + case cff_op_hflex: + case cff_op_flex: + case cff_op_hflex1: + case cff_op_flex1: + case cff_op_callsubr: + case cff_op_callgsubr: + goto MM_Error; + + default: + break; + } + } + + /* check arguments */ + req_args = cff_argument_counts[op]; + if ( req_args & CFF_COUNT_CHECK_WIDTH ) + { + if ( num_args > 0 && decoder->read_width ) + { + /* If `nominal_width' is non-zero, the number is really a */ + /* difference against `nominal_width'. Else, the number here */ + /* is truly a width, not a difference against `nominal_width'. */ + /* If the font does not set `nominal_width', then */ + /* `nominal_width' defaults to zero, and so we can set */ + /* `glyph_width' to `nominal_width' plus number on the stack */ + /* -- for either case. */ + + FT_Int set_width_ok; + + + switch ( op ) + { + case cff_op_hmoveto: + case cff_op_vmoveto: + set_width_ok = num_args & 2; + break; + + case cff_op_hstem: + case cff_op_vstem: + case cff_op_hstemhm: + case cff_op_vstemhm: + case cff_op_rmoveto: + case cff_op_hintmask: + case cff_op_cntrmask: + set_width_ok = num_args & 1; + break; + + case cff_op_endchar: + /* If there is a width specified for endchar, we either have */ + /* 1 argument or 5 arguments. We like to argue. */ + set_width_ok = in_dict + ? 0 + : ( ( num_args == 5 ) || ( num_args == 1 ) ); + break; + + default: + set_width_ok = 0; + break; + } + + if ( set_width_ok ) + { + decoder->glyph_width = decoder->nominal_width + + ( stack[0] >> 16 ); + + if ( decoder->width_only ) + { + /* we only want the advance width; stop here */ + break; + } + + /* Consumed an argument. */ + num_args--; + } + } + + decoder->read_width = 0; + req_args = 0; + } + + req_args &= 0x000F; + if ( num_args < req_args ) + goto Stack_Underflow; + args -= req_args; + num_args -= req_args; + + /* At this point, `args' points to the first argument of the */ + /* operand in case `req_args' isn't zero. Otherwise, we have */ + /* to adjust `args' manually. */ + + /* Note that we only pop arguments from the stack which we */ + /* really need and can digest so that we can continue in case */ + /* of superfluous stack elements. */ + + switch ( op ) + { + case cff_op_hstem: + case cff_op_vstem: + case cff_op_hstemhm: + case cff_op_vstemhm: + /* the number of arguments is always even here */ + FT_TRACE4(( + op == cff_op_hstem ? " hstem\n" : + ( op == cff_op_vstem ? " vstem\n" : + ( op == cff_op_hstemhm ? " hstemhm\n" : " vstemhm\n" ) ) )); + + if ( hinter ) + hinter->stems( hinter->hints, + ( op == cff_op_hstem || op == cff_op_hstemhm ), + num_args / 2, + args - ( num_args & ~1 ) ); + + decoder->num_hints += num_args / 2; + args = stack; + break; + + case cff_op_hintmask: + case cff_op_cntrmask: + FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" )); + + /* implement vstem when needed -- */ + /* the specification doesn't say it, but this also works */ + /* with the 'cntrmask' operator */ + /* */ + if ( num_args > 0 ) + { + if ( hinter ) + hinter->stems( hinter->hints, + 0, + num_args / 2, + args - ( num_args & ~1 ) ); + + decoder->num_hints += num_args / 2; + } + + /* In a valid charstring there must be at least one byte */ + /* after `hintmask' or `cntrmask' (e.g., for a `return' */ + /* instruction). Additionally, there must be space for */ + /* `num_hints' bits. */ + + if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit ) + goto Syntax_Error; + + if ( hinter ) + { + if ( op == cff_op_hintmask ) + hinter->hintmask( hinter->hints, + (FT_UInt)builder->current->n_points, + (FT_UInt)decoder->num_hints, + ip ); + else + hinter->counter( hinter->hints, + (FT_UInt)decoder->num_hints, + ip ); + } + +#ifdef FT_DEBUG_LEVEL_TRACE + { + FT_UInt maskbyte; + + + FT_TRACE4(( " (maskbytes:" )); + + for ( maskbyte = 0; + maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 ); + maskbyte++, ip++ ) + FT_TRACE4(( " 0x%02X", *ip )); + + FT_TRACE4(( ")\n" )); + } +#else + ip += ( decoder->num_hints + 7 ) >> 3; +#endif + args = stack; + break; + + case cff_op_rmoveto: + FT_TRACE4(( " rmoveto\n" )); + + cff_builder_close_contour( builder ); + builder->path_begun = 0; + x = ADD_LONG( x, args[-2] ); + y = ADD_LONG( y, args[-1] ); + args = stack; + break; + + case cff_op_vmoveto: + FT_TRACE4(( " vmoveto\n" )); + + cff_builder_close_contour( builder ); + builder->path_begun = 0; + y = ADD_LONG( y, args[-1] ); + args = stack; + break; + + case cff_op_hmoveto: + FT_TRACE4(( " hmoveto\n" )); + + cff_builder_close_contour( builder ); + builder->path_begun = 0; + x = ADD_LONG( x, args[-1] ); + args = stack; + break; + + case cff_op_rlineto: + FT_TRACE4(( " rlineto\n" )); + + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, num_args / 2 ) ) + goto Fail; + + if ( num_args < 2 ) + goto Stack_Underflow; + + args -= num_args & ~1; + while ( args < decoder->top ) + { + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, 1 ); + args += 2; + } + args = stack; + break; + + case cff_op_hlineto: + case cff_op_vlineto: + { + FT_Int phase = ( op == cff_op_hlineto ); + + + FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n" + : " vlineto\n" )); + + if ( num_args < 0 ) + goto Stack_Underflow; + + /* there exist subsetted fonts (found in PDFs) */ + /* which call `hlineto' without arguments */ + if ( num_args == 0 ) + break; + + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, num_args ) ) + goto Fail; + + args = stack; + while ( args < decoder->top ) + { + if ( phase ) + x = ADD_LONG( x, args[0] ); + else + y = ADD_LONG( y, args[0] ); + + if ( cff_builder_add_point1( builder, x, y ) ) + goto Fail; + + args++; + phase ^= 1; + } + args = stack; + } + break; + + case cff_op_rrcurveto: + { + FT_Int nargs; + + + FT_TRACE4(( " rrcurveto\n" )); + + if ( num_args < 6 ) + goto Stack_Underflow; + + nargs = num_args - num_args % 6; + + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, nargs / 2 ) ) + goto Fail; + + args -= nargs; + while ( args < decoder->top ) + { + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[2] ); + y = ADD_LONG( y, args[3] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[4] ); + y = ADD_LONG( y, args[5] ); + cff_builder_add_point( builder, x, y, 1 ); + + args += 6; + } + args = stack; + } + break; + + case cff_op_vvcurveto: + { + FT_Int nargs; + + + FT_TRACE4(( " vvcurveto\n" )); + + if ( num_args < 4 ) + goto Stack_Underflow; + + /* if num_args isn't of the form 4n or 4n+1, */ + /* we enforce it by clearing the second bit */ + + nargs = num_args & ~2; + + if ( cff_builder_start_point( builder, x, y ) ) + goto Fail; + + args -= nargs; + + if ( nargs & 1 ) + { + x = ADD_LONG( x, args[0] ); + args++; + nargs--; + } + + if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) ) + goto Fail; + + while ( args < decoder->top ) + { + y = ADD_LONG( y, args[0] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); + cff_builder_add_point( builder, x, y, 0 ); + + y = ADD_LONG( y, args[3] ); + cff_builder_add_point( builder, x, y, 1 ); + + args += 4; + } + args = stack; + } + break; + + case cff_op_hhcurveto: + { + FT_Int nargs; + + + FT_TRACE4(( " hhcurveto\n" )); + + if ( num_args < 4 ) + goto Stack_Underflow; + + /* if num_args isn't of the form 4n or 4n+1, */ + /* we enforce it by clearing the second bit */ + + nargs = num_args & ~2; + + if ( cff_builder_start_point( builder, x, y ) ) + goto Fail; + + args -= nargs; + if ( nargs & 1 ) + { + y = ADD_LONG( y, args[0] ); + args++; + nargs--; + } + + if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) ) + goto Fail; + + while ( args < decoder->top ) + { + x = ADD_LONG( x, args[0] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[3] ); + cff_builder_add_point( builder, x, y, 1 ); + + args += 4; + } + args = stack; + } + break; + + case cff_op_vhcurveto: + case cff_op_hvcurveto: + { + FT_Int phase; + FT_Int nargs; + + + FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto\n" + : " hvcurveto\n" )); + + if ( cff_builder_start_point( builder, x, y ) ) + goto Fail; + + if ( num_args < 4 ) + goto Stack_Underflow; + + /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */ + /* we enforce it by clearing the second bit */ + + nargs = num_args & ~2; + + args -= nargs; + if ( cff_check_points( builder, ( nargs / 4 ) * 3 ) ) + goto Stack_Underflow; + + phase = ( op == cff_op_hvcurveto ); + + while ( nargs >= 4 ) + { + nargs -= 4; + if ( phase ) + { + x = ADD_LONG( x, args[0] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); + cff_builder_add_point( builder, x, y, 0 ); + + y = ADD_LONG( y, args[3] ); + if ( nargs == 1 ) + x = ADD_LONG( x, args[4] ); + cff_builder_add_point( builder, x, y, 1 ); + } + else + { + y = ADD_LONG( y, args[0] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[3] ); + if ( nargs == 1 ) + y = ADD_LONG( y, args[4] ); + cff_builder_add_point( builder, x, y, 1 ); + } + args += 4; + phase ^= 1; + } + args = stack; + } + break; + + case cff_op_rlinecurve: + { + FT_Int num_lines; + FT_Int nargs; + + + FT_TRACE4(( " rlinecurve\n" )); + + if ( num_args < 8 ) + goto Stack_Underflow; + + nargs = num_args & ~1; + num_lines = ( nargs - 6 ) / 2; + + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, num_lines + 3 ) ) + goto Fail; + + args -= nargs; + + /* first, add the line segments */ + while ( num_lines > 0 ) + { + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, 1 ); + + args += 2; + num_lines--; + } + + /* then the curve */ + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[2] ); + y = ADD_LONG( y, args[3] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[4] ); + y = ADD_LONG( y, args[5] ); + cff_builder_add_point( builder, x, y, 1 ); + + args = stack; + } + break; + + case cff_op_rcurveline: + { + FT_Int num_curves; + FT_Int nargs; + + + FT_TRACE4(( " rcurveline\n" )); + + if ( num_args < 8 ) + goto Stack_Underflow; + + nargs = num_args - 2; + nargs = nargs - nargs % 6 + 2; + num_curves = ( nargs - 2 ) / 6; + + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, num_curves * 3 + 2 ) ) + goto Fail; + + args -= nargs; + + /* first, add the curves */ + while ( num_curves > 0 ) + { + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[2] ); + y = ADD_LONG( y, args[3] ); + cff_builder_add_point( builder, x, y, 0 ); + + x = ADD_LONG( x, args[4] ); + y = ADD_LONG( y, args[5] ); + cff_builder_add_point( builder, x, y, 1 ); + + args += 6; + num_curves--; + } + + /* then the final line */ + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, 1 ); + + args = stack; + } + break; + + case cff_op_hflex1: + { + FT_Pos start_y; + + + FT_TRACE4(( " hflex1\n" )); + + /* adding five more points: 4 control points, 1 on-curve point */ + /* -- make sure we have enough space for the start point if it */ + /* needs to be added */ + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, 6 ) ) + goto Fail; + + /* record the starting point's y position for later use */ + start_y = y; + + /* first control point */ + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, 0 ); + + /* second control point */ + x = ADD_LONG( x, args[2] ); + y = ADD_LONG( y, args[3] ); + cff_builder_add_point( builder, x, y, 0 ); + + /* join point; on curve, with y-value the same as the last */ + /* control point's y-value */ + x = ADD_LONG( x, args[4] ); + cff_builder_add_point( builder, x, y, 1 ); + + /* third control point, with y-value the same as the join */ + /* point's y-value */ + x = ADD_LONG( x, args[5] ); + cff_builder_add_point( builder, x, y, 0 ); + + /* fourth control point */ + x = ADD_LONG( x, args[6] ); + y = ADD_LONG( y, args[7] ); + cff_builder_add_point( builder, x, y, 0 ); + + /* ending point, with y-value the same as the start */ + x = ADD_LONG( x, args[8] ); + y = start_y; + cff_builder_add_point( builder, x, y, 1 ); + + args = stack; + break; + } + + case cff_op_hflex: + { + FT_Pos start_y; + + + FT_TRACE4(( " hflex\n" )); + + /* adding six more points; 4 control points, 2 on-curve points */ + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, 6 ) ) + goto Fail; + + /* record the starting point's y-position for later use */ + start_y = y; + + /* first control point */ + x = ADD_LONG( x, args[0] ); + cff_builder_add_point( builder, x, y, 0 ); + + /* second control point */ + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); + cff_builder_add_point( builder, x, y, 0 ); + + /* join point; on curve, with y-value the same as the last */ + /* control point's y-value */ + x = ADD_LONG( x, args[3] ); + cff_builder_add_point( builder, x, y, 1 ); + + /* third control point, with y-value the same as the join */ + /* point's y-value */ + x = ADD_LONG( x, args[4] ); + cff_builder_add_point( builder, x, y, 0 ); + + /* fourth control point */ + x = ADD_LONG( x, args[5] ); + y = start_y; + cff_builder_add_point( builder, x, y, 0 ); + + /* ending point, with y-value the same as the start point's */ + /* y-value -- we don't add this point, though */ + x = ADD_LONG( x, args[6] ); + cff_builder_add_point( builder, x, y, 1 ); + + args = stack; + break; + } + + case cff_op_flex1: + { + FT_Pos start_x, start_y; /* record start x, y values for */ + /* alter use */ + FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */ + /* algorithm below */ + FT_Int horizontal, count; + FT_Fixed* temp; + + + FT_TRACE4(( " flex1\n" )); + + /* adding six more points; 4 control points, 2 on-curve points */ + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, 6 ) ) + goto Fail; + + /* record the starting point's x, y position for later use */ + start_x = x; + start_y = y; + + /* XXX: figure out whether this is supposed to be a horizontal */ + /* or vertical flex; the Type 2 specification is vague... */ + + temp = args; + + /* grab up to the last argument */ + for ( count = 5; count > 0; count-- ) + { + dx = ADD_LONG( dx, temp[0] ); + dy = ADD_LONG( dy, temp[1] ); + temp += 2; + } + + if ( dx < 0 ) + dx = -dx; + if ( dy < 0 ) + dy = -dy; + + /* strange test, but here it is... */ + horizontal = ( dx > dy ); + + for ( count = 5; count > 0; count-- ) + { + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, + (FT_Bool)( count == 3 ) ); + args += 2; + } + + /* is last operand an x- or y-delta? */ + if ( horizontal ) + { + x = ADD_LONG( x, args[0] ); + y = start_y; + } + else + { + x = start_x; + y = ADD_LONG( y, args[0] ); + } + + cff_builder_add_point( builder, x, y, 1 ); + + args = stack; + break; + } + + case cff_op_flex: + { + FT_UInt count; + + + FT_TRACE4(( " flex\n" )); + + if ( cff_builder_start_point( builder, x, y ) || + cff_check_points( builder, 6 ) ) + goto Fail; + + for ( count = 6; count > 0; count-- ) + { + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); + cff_builder_add_point( builder, x, y, + (FT_Bool)( count == 4 || count == 1 ) ); + args += 2; + } + + args = stack; + } + break; + + case cff_op_seac: + FT_TRACE4(( " seac\n" )); + + error = cff_operator_seac( decoder, + args[0], args[1], args[2], + (FT_Int)( args[3] >> 16 ), + (FT_Int)( args[4] >> 16 ) ); + + /* add current outline to the glyph slot */ + FT_GlyphLoader_Add( builder->loader ); + + /* return now! */ + FT_TRACE4(( "\n" )); + return error; + + case cff_op_endchar: + /* in dictionaries, `endchar' simply indicates end of data */ + if ( in_dict ) + return error; + + FT_TRACE4(( " endchar\n" )); + + /* We are going to emulate the seac operator. */ + if ( num_args >= 4 ) + { + /* Save glyph width so that the subglyphs don't overwrite it. */ + FT_Pos glyph_width = decoder->glyph_width; + + + error = cff_operator_seac( decoder, + 0L, args[-4], args[-3], + (FT_Int)( args[-2] >> 16 ), + (FT_Int)( args[-1] >> 16 ) ); + + decoder->glyph_width = glyph_width; + } + else + { + cff_builder_close_contour( builder ); + + /* close hints recording session */ + if ( hinter ) + { + if ( hinter->close( hinter->hints, + (FT_UInt)builder->current->n_points ) ) + goto Syntax_Error; + + /* apply hints to the loaded glyph outline now */ + error = hinter->apply( hinter->hints, + builder->current, + (PSH_Globals)builder->hints_globals, + decoder->hint_mode ); + if ( error ) + goto Fail; + } + + /* add current outline to the glyph slot */ + FT_GlyphLoader_Add( builder->loader ); + } + + /* return now! */ + FT_TRACE4(( "\n" )); + return error; + + case cff_op_abs: + FT_TRACE4(( " abs\n" )); + + if ( args[0] < 0 ) + { + if ( args[0] == FT_LONG_MIN ) + args[0] = FT_LONG_MAX; + else + args[0] = -args[0]; + } + args++; + break; + + case cff_op_add: + FT_TRACE4(( " add\n" )); + + args[0] = ADD_LONG( args[0], args[1] ); + args++; + break; + + case cff_op_sub: + FT_TRACE4(( " sub\n" )); + + args[0] = SUB_LONG( args[0], args[1] ); + args++; + break; + + case cff_op_div: + FT_TRACE4(( " div\n" )); + + args[0] = FT_DivFix( args[0], args[1] ); + args++; + break; + + case cff_op_neg: + FT_TRACE4(( " neg\n" )); + + if ( args[0] == FT_LONG_MIN ) + args[0] = FT_LONG_MAX; + args[0] = -args[0]; + args++; + break; + + case cff_op_random: + FT_TRACE4(( " random\n" )); + + /* only use the lower 16 bits of `random' */ + /* to generate a number in the range (0;1] */ + args[0] = (FT_Fixed) + ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); + args++; + + decoder->current_subfont->random = + cff_random( decoder->current_subfont->random ); + break; + + case cff_op_mul: + FT_TRACE4(( " mul\n" )); + + args[0] = FT_MulFix( args[0], args[1] ); + args++; + break; + + case cff_op_sqrt: + FT_TRACE4(( " sqrt\n" )); + + if ( args[0] > 0 ) + { + FT_Fixed root = args[0]; + FT_Fixed new_root; + + + for (;;) + { + new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1; + if ( new_root == root ) + break; + root = new_root; + } + args[0] = new_root; + } + else + args[0] = 0; + args++; + break; + + case cff_op_drop: + /* nothing */ + FT_TRACE4(( " drop\n" )); + + break; + + case cff_op_exch: + { + FT_Fixed tmp; + + + FT_TRACE4(( " exch\n" )); + + tmp = args[0]; + args[0] = args[1]; + args[1] = tmp; + args += 2; + } + break; + + case cff_op_index: + { + FT_Int idx = (FT_Int)( args[0] >> 16 ); + + + FT_TRACE4(( " index\n" )); + + if ( idx < 0 ) + idx = 0; + else if ( idx > num_args - 2 ) + idx = num_args - 2; + args[0] = args[-( idx + 1 )]; + args++; + } + break; + + case cff_op_roll: + { + FT_Int count = (FT_Int)( args[0] >> 16 ); + FT_Int idx = (FT_Int)( args[1] >> 16 ); + + + FT_TRACE4(( " roll\n" )); + + if ( count <= 0 ) + count = 1; + + args -= count; + if ( args < stack ) + goto Stack_Underflow; + + if ( idx >= 0 ) + { + while ( idx > 0 ) + { + FT_Fixed tmp = args[count - 1]; + FT_Int i; + + + for ( i = count - 2; i >= 0; i-- ) + args[i + 1] = args[i]; + args[0] = tmp; + idx--; + } + } + else + { + while ( idx < 0 ) + { + FT_Fixed tmp = args[0]; + FT_Int i; + + + for ( i = 0; i < count - 1; i++ ) + args[i] = args[i + 1]; + args[count - 1] = tmp; + idx++; + } + } + args += count; + } + break; + + case cff_op_dup: + FT_TRACE4(( " dup\n" )); + + args[1] = args[0]; + args += 2; + break; + + case cff_op_put: + { + FT_Fixed val = args[0]; + FT_Int idx = (FT_Int)( args[1] >> 16 ); + + + FT_TRACE4(( " put\n" )); + + /* the Type2 specification before version 16-March-2000 */ + /* didn't give a hard-coded size limit of the temporary */ + /* storage array; instead, an argument of the */ + /* `MultipleMaster' operator set the size */ + if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS ) + decoder->buildchar[idx] = val; + } + break; + + case cff_op_get: + { + FT_Int idx = (FT_Int)( args[0] >> 16 ); + FT_Fixed val = 0; + + + FT_TRACE4(( " get\n" )); + + if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS ) + val = decoder->buildchar[idx]; + + args[0] = val; + args++; + } + break; + + case cff_op_store: + /* this operator was removed from the Type2 specification */ + /* in version 16-March-2000 */ + + /* since we currently don't handle interpolation of multiple */ + /* master fonts, this is a no-op */ + FT_TRACE4(( " store\n" )); + break; + + case cff_op_load: + /* this operator was removed from the Type2 specification */ + /* in version 16-March-2000 */ + { + FT_Int reg_idx = (FT_Int)args[0]; + FT_Int idx = (FT_Int)args[1]; + FT_Int count = (FT_Int)args[2]; + + + FT_TRACE4(( " load\n" )); + + /* since we currently don't handle interpolation of multiple */ + /* master fonts, we store a vector [1 0 0 ...] in the */ + /* temporary storage array regardless of the Registry index */ + if ( reg_idx >= 0 && reg_idx <= 2 && + idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS && + count >= 0 && count <= num_axes ) + { + FT_Int end, i; + + + end = FT_MIN( idx + count, CFF_MAX_TRANS_ELEMENTS ); + + if ( idx < end ) + decoder->buildchar[idx] = 1 << 16; + + for ( i = idx + 1; i < end; i++ ) + decoder->buildchar[i] = 0; + } + } + break; + + case cff_op_blend: + /* this operator was removed from the Type2 specification */ + /* in version 16-March-2000 */ + { + FT_Int num_results = (FT_Int)( args[0] >> 16 ); + + + FT_TRACE4(( " blend\n" )); + + if ( num_results < 0 ) + goto Syntax_Error; + + if ( num_results * (FT_Int)num_designs > num_args ) + goto Stack_Underflow; + + /* since we currently don't handle interpolation of multiple */ + /* master fonts, return the `num_results' values of the */ + /* first master */ + args -= num_results * ( num_designs - 1 ); + num_args -= num_results * ( num_designs - 1 ); + } + break; + + case cff_op_dotsection: + /* this operator is deprecated and ignored by the parser */ + FT_TRACE4(( " dotsection\n" )); + break; + + case cff_op_closepath: + /* this is an invalid Type 2 operator; however, there */ + /* exist fonts which are incorrectly converted from probably */ + /* Type 1 to CFF, and some parsers seem to accept it */ + + FT_TRACE4(( " closepath (invalid op)\n" )); + + args = stack; + break; + + case cff_op_hsbw: + /* this is an invalid Type 2 operator; however, there */ + /* exist fonts which are incorrectly converted from probably */ + /* Type 1 to CFF, and some parsers seem to accept it */ + + FT_TRACE4(( " hsbw (invalid op)\n" )); + + decoder->glyph_width = + ADD_LONG( decoder->nominal_width, ( args[1] >> 16 ) ); + + decoder->builder.left_bearing.x = args[0]; + decoder->builder.left_bearing.y = 0; + + x = ADD_LONG( decoder->builder.pos_x, args[0] ); + y = decoder->builder.pos_y; + args = stack; + break; + + case cff_op_sbw: + /* this is an invalid Type 2 operator; however, there */ + /* exist fonts which are incorrectly converted from probably */ + /* Type 1 to CFF, and some parsers seem to accept it */ + + FT_TRACE4(( " sbw (invalid op)\n" )); + + decoder->glyph_width = + ADD_LONG( decoder->nominal_width, ( args[2] >> 16 ) ); + + decoder->builder.left_bearing.x = args[0]; + decoder->builder.left_bearing.y = args[1]; + + x = ADD_LONG( decoder->builder.pos_x, args[0] ); + y = ADD_LONG( decoder->builder.pos_y, args[1] ); + args = stack; + break; + + case cff_op_setcurrentpoint: + /* this is an invalid Type 2 operator; however, there */ + /* exist fonts which are incorrectly converted from probably */ + /* Type 1 to CFF, and some parsers seem to accept it */ + + FT_TRACE4(( " setcurrentpoint (invalid op)\n" )); + + x = ADD_LONG( decoder->builder.pos_x, args[0] ); + y = ADD_LONG( decoder->builder.pos_y, args[1] ); + args = stack; + break; + + case cff_op_callothersubr: + /* this is an invalid Type 2 operator; however, there */ + /* exist fonts which are incorrectly converted from probably */ + /* Type 1 to CFF, and some parsers seem to accept it */ + + FT_TRACE4(( " callothersubr (invalid op)\n" )); + + /* subsequent `pop' operands should add the arguments, */ + /* this is the implementation described for `unknown' other */ + /* subroutines in the Type1 spec. */ + /* */ + /* XXX Fix return arguments (see discussion below). */ + args -= 2 + ( args[-2] >> 16 ); + if ( args < stack ) + goto Stack_Underflow; + break; + + case cff_op_pop: + /* this is an invalid Type 2 operator; however, there */ + /* exist fonts which are incorrectly converted from probably */ + /* Type 1 to CFF, and some parsers seem to accept it */ + + FT_TRACE4(( " pop (invalid op)\n" )); + + /* XXX Increasing `args' is wrong: After a certain number of */ + /* `pop's we get a stack overflow. Reason for doing it is */ + /* code like this (actually found in a CFF font): */ + /* */ + /* 17 1 3 callothersubr */ + /* pop */ + /* callsubr */ + /* */ + /* Since we handle `callothersubr' as a no-op, and */ + /* `callsubr' needs at least one argument, `pop' can't be a */ + /* no-op too as it basically should be. */ + /* */ + /* The right solution would be to provide real support for */ + /* `callothersubr' as done in `t1decode.c', however, given */ + /* the fact that CFF fonts with `pop' are invalid, it is */ + /* questionable whether it is worth the time. */ + args++; + break; + + case cff_op_and: + { + FT_Fixed cond = ( args[0] && args[1] ); + + + FT_TRACE4(( " and\n" )); + + args[0] = cond ? 0x10000L : 0; + args++; + } + break; + + case cff_op_or: + { + FT_Fixed cond = ( args[0] || args[1] ); + + + FT_TRACE4(( " or\n" )); + + args[0] = cond ? 0x10000L : 0; + args++; + } + break; + + case cff_op_not: + { + FT_Fixed cond = !args[0]; + + + FT_TRACE4(( " not\n" )); + + args[0] = cond ? 0x10000L : 0; + args++; + } + break; + + case cff_op_eq: + { + FT_Fixed cond = ( args[0] == args[1] ); + + + FT_TRACE4(( " eq\n" )); + + args[0] = cond ? 0x10000L : 0; + args++; + } + break; + + case cff_op_ifelse: + { + FT_Fixed cond = ( args[2] <= args[3] ); + + + FT_TRACE4(( " ifelse\n" )); + + if ( !cond ) + args[0] = args[1]; + args++; + } + break; + + case cff_op_callsubr: + { + FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + + decoder->locals_bias ); + + + FT_TRACE4(( " callsubr (idx %d, entering level %d)\n", + idx, + zone - decoder->zones + 1 )); + + if ( idx >= decoder->num_locals ) + { + FT_ERROR(( "cff_decoder_parse_charstrings:" + " invalid local subr index\n" )); + goto Syntax_Error; + } + + if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) + { + FT_ERROR(( "cff_decoder_parse_charstrings:" + " too many nested subrs\n" )); + goto Syntax_Error; + } + + zone->cursor = ip; /* save current instruction pointer */ + + zone++; + zone->base = decoder->locals[idx]; + zone->limit = decoder->locals[idx + 1]; + zone->cursor = zone->base; + + if ( !zone->base || zone->limit == zone->base ) + { + FT_ERROR(( "cff_decoder_parse_charstrings:" + " invoking empty subrs\n" )); + goto Syntax_Error; + } + + decoder->zone = zone; + ip = zone->base; + limit = zone->limit; + } + break; + + case cff_op_callgsubr: + { + FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + + decoder->globals_bias ); + + + FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n", + idx, + zone - decoder->zones + 1 )); + + if ( idx >= decoder->num_globals ) + { + FT_ERROR(( "cff_decoder_parse_charstrings:" + " invalid global subr index\n" )); + goto Syntax_Error; + } + + if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) + { + FT_ERROR(( "cff_decoder_parse_charstrings:" + " too many nested subrs\n" )); + goto Syntax_Error; + } + + zone->cursor = ip; /* save current instruction pointer */ + + zone++; + zone->base = decoder->globals[idx]; + zone->limit = decoder->globals[idx + 1]; + zone->cursor = zone->base; + + if ( !zone->base || zone->limit == zone->base ) + { + FT_ERROR(( "cff_decoder_parse_charstrings:" + " invoking empty subrs\n" )); + goto Syntax_Error; + } + + decoder->zone = zone; + ip = zone->base; + limit = zone->limit; + } + break; + + case cff_op_return: + FT_TRACE4(( " return (leaving level %d)\n", + decoder->zone - decoder->zones )); + + if ( decoder->zone <= decoder->zones ) + { + FT_ERROR(( "cff_decoder_parse_charstrings:" + " unexpected return\n" )); + goto Syntax_Error; + } + + decoder->zone--; + zone = decoder->zone; + ip = zone->cursor; + limit = zone->limit; + break; + + default: + FT_ERROR(( "Unimplemented opcode: %d", ip[-1] )); + + if ( ip[-1] == 12 ) + FT_ERROR(( " %d", ip[0] )); + FT_ERROR(( "\n" )); + + return FT_THROW( Unimplemented_Feature ); + } + + decoder->top = args; + + if ( decoder->top - stack >= CFF_MAX_OPERANDS ) + goto Stack_Overflow; + + } /* general operator processing */ + + } /* while ip < limit */ + + FT_TRACE4(( "..end..\n\n" )); + + Fail: + return error; + + MM_Error: + FT_TRACE4(( "cff_decoder_parse_charstrings:" + " invalid opcode found in top DICT charstring\n")); + return FT_THROW( Invalid_File_Format ); + + Syntax_Error: + FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" )); + return FT_THROW( Invalid_File_Format ); + + Stack_Underflow: + FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" )); + return FT_THROW( Too_Few_Arguments ); + + Stack_Overflow: + FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" )); + return FT_THROW( Stack_Overflow ); + } + +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* cff_decoder_init */ + /* */ + /* <Description> */ + /* Initializes a given glyph decoder. */ + /* */ + /* <InOut> */ + /* decoder :: A pointer to the glyph builder to initialize. */ + /* */ + /* <Input> */ + /* face :: The current face object. */ + /* */ + /* size :: The current size object. */ + /* */ + /* slot :: The current glyph object. */ + /* */ + /* hinting :: Whether hinting is active. */ + /* */ + /* hint_mode :: The hinting mode. */ + /* */ + FT_LOCAL_DEF( void ) + cff_decoder_init( CFF_Decoder* decoder, + TT_Face face, + CFF_Size size, + CFF_GlyphSlot slot, + FT_Bool hinting, + FT_Render_Mode hint_mode, + CFF_Decoder_Get_Glyph_Callback get_callback, + CFF_Decoder_Free_Glyph_Callback free_callback ) + { + CFF_Font cff = (CFF_Font)face->extra.data; + + + /* clear everything */ + FT_ZERO( decoder ); + + /* initialize builder */ + cff_builder_init( &decoder->builder, face, size, slot, hinting ); + + /* initialize Type2 decoder */ + decoder->cff = cff; + decoder->num_globals = cff->global_subrs_index.count; + decoder->globals = cff->global_subrs; + decoder->globals_bias = cff_compute_bias( + cff->top_font.font_dict.charstring_type, + decoder->num_globals ); + + decoder->hint_mode = hint_mode; + + decoder->get_glyph_callback = get_callback; + decoder->free_glyph_callback = free_callback; + } + + + /* this function is used to select the subfont */ + /* and the locals subrs array */ + FT_LOCAL_DEF( FT_Error ) + cff_decoder_prepare( CFF_Decoder* decoder, + CFF_Size size, + FT_UInt glyph_index ) + { + CFF_Builder *builder = &decoder->builder; + CFF_Font cff = (CFF_Font)builder->face->extra.data; + CFF_SubFont sub = &cff->top_font; + FT_Error error = FT_Err_Ok; + + FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)cff->cffload; + + + /* manage CID fonts */ + if ( cff->num_subfonts ) + { + FT_Byte fd_index = cffload->fd_select_get( &cff->fd_select, + glyph_index ); + + + if ( fd_index >= cff->num_subfonts ) + { + FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + FT_TRACE3(( " in subfont %d:\n", fd_index )); + + sub = cff->subfonts[fd_index]; + + if ( builder->hints_funcs && size ) + { + FT_Size ftsize = FT_SIZE( size ); + CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data; + + + /* for CFFs without subfonts, this value has already been set */ + builder->hints_globals = (void *)internal->subfonts[fd_index]; + } + } + + decoder->num_locals = sub->local_subrs_index.count; + decoder->locals = sub->local_subrs; + decoder->locals_bias = cff_compute_bias( + decoder->cff->top_font.font_dict.charstring_type, + decoder->num_locals ); + + decoder->glyph_width = sub->private_dict.default_width; + decoder->nominal_width = sub->private_dict.nominal_width; + + decoder->current_subfont = sub; + + Exit: + return error; + } + + +/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/cffdecode.h b/Build/source/libs/freetype2/freetype-src/src/psaux/cffdecode.h new file mode 100644 index 00000000000..0d4f5fef631 --- /dev/null +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/cffdecode.h @@ -0,0 +1,64 @@ +/***************************************************************************/ +/* */ +/* cffdecode.h */ +/* */ +/* PostScript CFF (Type 2) decoding routines (specification). */ +/* */ +/* Copyright 2017-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef CFFDECODE_H_ +#define CFFDECODE_H_ + + +#include <ft2build.h> +#include FT_INTERNAL_POSTSCRIPT_AUX_H + + +FT_BEGIN_HEADER + + FT_LOCAL( void ) + cff_decoder_init( CFF_Decoder* decoder, + TT_Face face, + CFF_Size size, + CFF_GlyphSlot slot, + FT_Bool hinting, + FT_Render_Mode hint_mode, + CFF_Decoder_Get_Glyph_Callback get_callback, + CFF_Decoder_Free_Glyph_Callback free_callback ); + + FT_LOCAL( FT_Error ) + cff_decoder_prepare( CFF_Decoder* decoder, + CFF_Size size, + FT_UInt glyph_index ); + + + FT_LOCAL( FT_Int ) + cff_lookup_glyph_by_stdcharcode( CFF_Font cff, + FT_Int charcode ); + + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + FT_LOCAL( FT_Error ) + cff_decoder_parse_charstrings( CFF_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len, + FT_Bool in_dict ); +#endif + + +FT_END_HEADER + +#endif + + +/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/module.mk b/Build/source/libs/freetype2/freetype-src/src/psaux/module.mk index c70a227166d..6584d075a29 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psarrst.c index 6796450fe10..a8780947f9d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psarrst.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2arrst.c */ +/* psarrst.c */ /* */ /* Adobe's code for Array Stacks (body). */ /* */ @@ -36,13 +36,13 @@ /***************************************************************************/ -#include "cf2ft.h" +#include "psft.h" #include FT_INTERNAL_DEBUG_H -#include "cf2glue.h" -#include "cf2arrst.h" +#include "psglue.h" +#include "psarrst.h" -#include "cf2error.h" +#include "pserror.h" /* diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psarrst.h index 3c21a3b6727..b3568eb61fc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psarrst.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2arrst.h */ +/* psarrst.h */ /* */ /* Adobe's code for Array Stacks (specification). */ /* */ @@ -36,11 +36,11 @@ /***************************************************************************/ -#ifndef CF2ARRST_H_ -#define CF2ARRST_H_ +#ifndef PSARRST_H_ +#define PSARRST_H_ -#include "cf2error.h" +#include "pserror.h" FT_BEGIN_HEADER @@ -94,7 +94,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2ARRST_H_ */ +#endif /* PSARRST_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/psaux.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psaux.c index c373aa7d5b7..fb447fcdbbc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/psaux.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psaux.c @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript driver component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -25,6 +25,17 @@ #include "psobjs.c" #include "t1cmap.c" #include "t1decode.c" +#include "cffdecode.c" + +#include "psarrst.c" +#include "psblues.c" +#include "pserror.c" +#include "psfont.c" +#include "psft.c" +#include "pshints.c" +#include "psintrp.c" +#include "psread.c" +#include "psstack.c" /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/psauxerr.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psauxerr.h index 1d7ac6001b1..cc33fd2eeac 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/psauxerr.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psauxerr.h @@ -4,7 +4,7 @@ /* */ /* PS auxiliary module error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/psauxmod.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psauxmod.c index 1f589cefc21..ee497085cc2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/psauxmod.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psauxmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript module implementation (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,6 +21,8 @@ #include "psobjs.h" #include "t1decode.h" #include "t1cmap.h" +#include "psft.h" +#include "cffdecode.h" #ifndef T1_CONFIG_OPTION_NO_AFM #include "afmparse.h" @@ -60,6 +62,14 @@ FT_CALLBACK_TABLE_DEF + const PS_Builder_FuncsRec ps_builder_funcs = + { + ps_builder_init, /* init */ + ps_builder_done /* done */ + }; + + + FT_CALLBACK_TABLE_DEF const T1_Builder_FuncsRec t1_builder_funcs = { t1_builder_init, /* init */ @@ -77,9 +87,14 @@ FT_CALLBACK_TABLE_DEF const T1_Decoder_FuncsRec t1_decoder_funcs = { - t1_decoder_init, /* init */ - t1_decoder_done, /* done */ - t1_decoder_parse_charstrings /* parse_charstrings */ + t1_decoder_init, /* init */ + t1_decoder_done, /* done */ +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + t1_decoder_parse_charstrings, /* parse_charstrings_old */ +#else + t1_decoder_parse_metrics, /* parse_metrics */ +#endif + cf2_decoder_parse_charstrings /* parse_charstrings */ }; @@ -104,6 +119,34 @@ }; + FT_CALLBACK_TABLE_DEF + const CFF_Builder_FuncsRec cff_builder_funcs = + { + cff_builder_init, /* init */ + cff_builder_done, /* done */ + + cff_check_points, /* check_points */ + cff_builder_add_point, /* add_point */ + cff_builder_add_point1, /* add_point1 */ + cff_builder_add_contour, /* add_contour */ + cff_builder_start_point, /* start_point */ + cff_builder_close_contour /* close_contour */ + }; + + + FT_CALLBACK_TABLE_DEF + const CFF_Decoder_FuncsRec cff_decoder_funcs = + { + cff_decoder_init, /* init */ + cff_decoder_prepare, /* prepare */ + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + cff_decoder_parse_charstrings, /* parse_charstrings_old */ +#endif + cf2_decoder_parse_charstrings /* parse_charstrings */ + }; + + static const PSAux_Interface psaux_interface = { @@ -112,6 +155,9 @@ &t1_builder_funcs, &t1_decoder_funcs, t1_decrypt, + cff_random, + ps_decoder_init, + t1_make_subfont, (const T1_CMap_ClassesRec*) &t1_cmap_classes, @@ -120,6 +166,8 @@ #else 0, #endif + + &cff_decoder_funcs, }; diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/psauxmod.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psauxmod.h index 926f37eba5d..f30978f0220 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/psauxmod.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psauxmod.h @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript module implementation (specification). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -23,6 +23,8 @@ #include <ft2build.h> #include FT_MODULE_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H + FT_BEGIN_HEADER @@ -31,6 +33,13 @@ FT_BEGIN_HEADER #endif + FT_CALLBACK_TABLE + const CFF_Builder_FuncsRec cff_builder_funcs; + + FT_CALLBACK_TABLE + const PS_Builder_FuncsRec ps_builder_funcs; + + FT_EXPORT_VAR( const FT_Module_Class ) psaux_driver_class; diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psblues.c index c491f2f9e5c..ae39d03c777 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psblues.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2blues.c */ +/* psblues.c */ /* */ /* Adobe's code for handling Blue Zones (body). */ /* */ @@ -36,12 +36,12 @@ /***************************************************************************/ -#include "cf2ft.h" +#include "psft.h" #include FT_INTERNAL_DEBUG_H -#include "cf2blues.h" -#include "cf2hints.h" -#include "cf2font.h" +#include "psblues.h" +#include "pshints.h" +#include "psfont.h" /*************************************************************************/ @@ -67,7 +67,7 @@ CF2_Font font ) { /* pointer to parsed font object */ - CFF_Decoder* decoder = font->decoder; + PS_Decoder* decoder = font->decoder; CF2_Fixed zoneHeight; CF2_Fixed maxZoneHeight = 0; diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psblues.h index a6bcd9de578..25ef6849c77 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psblues.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2blues.h */ +/* psblues.h */ /* */ /* Adobe's code for handling Blue Zones (specification). */ /* */ @@ -65,11 +65,11 @@ */ -#ifndef CF2BLUES_H_ -#define CF2BLUES_H_ +#ifndef PSBLUES_H_ +#define PSBLUES_H_ -#include "cf2glue.h" +#include "psglue.h" FT_BEGIN_HEADER @@ -179,7 +179,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2BLUES_H_ */ +#endif /* PSBLUES_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/psconv.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psconv.c index d125b0834a4..a03385000df 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/psconv.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psconv.c @@ -4,7 +4,7 @@ /* */ /* Some convenience conversions (body). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/psconv.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psconv.h index cab254ac5a1..d643ffcfc2c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/psconv.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psconv.h @@ -4,7 +4,7 @@ /* */ /* Some convenience conversions (specification). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.c b/Build/source/libs/freetype2/freetype-src/src/psaux/pserror.c index e3dd69f50d1..9169e5222d0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/pserror.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2error.c */ +/* pserror.c */ /* */ /* Adobe's code for error handling (body). */ /* */ @@ -36,8 +36,8 @@ /***************************************************************************/ -#include "cf2ft.h" -#include "cf2error.h" +#include "psft.h" +#include "pserror.h" FT_LOCAL_DEF( void ) diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h b/Build/source/libs/freetype2/freetype-src/src/psaux/pserror.h index d2c770d2974..13d52062bf3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/pserror.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2error.h */ +/* pserror.h */ /* */ /* Adobe's code for error handling (specification). */ /* */ @@ -36,8 +36,8 @@ /***************************************************************************/ -#ifndef CF2ERROR_H_ -#define CF2ERROR_H_ +#ifndef PSERROR_H_ +#define PSERROR_H_ #include FT_MODULE_ERRORS_H @@ -50,7 +50,7 @@ #include FT_ERRORS_H -#include "cf2ft.h" +#include "psft.h" FT_BEGIN_HEADER @@ -113,7 +113,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2ERROR_H_ */ +#endif /* PSERROR_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2fixed.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psfixed.h index a041184bda8..219589e7fc7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2fixed.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psfixed.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2fixed.h */ +/* psfixed.h */ /* */ /* Adobe's code for Fixed Point Mathematics (specification only). */ /* */ @@ -36,8 +36,8 @@ /***************************************************************************/ -#ifndef CF2FIXED_H_ -#define CF2FIXED_H_ +#ifndef PSFIXED_H_ +#define PSFIXED_H_ FT_BEGIN_HEADER @@ -89,7 +89,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2FIXED_H_ */ +#endif /* PSFIXED_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psfont.c index 4ac71a8d715..dde67a739d6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psfont.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2font.c */ +/* psfont.c */ /* */ /* Adobe's code for font instances (body). */ /* */ @@ -39,12 +39,12 @@ #include <ft2build.h> #include FT_INTERNAL_CALC_H -#include "cf2ft.h" +#include "psft.h" -#include "cf2glue.h" -#include "cf2font.h" -#include "cf2error.h" -#include "cf2intrp.h" +#include "psglue.h" +#include "psfont.h" +#include "pserror.h" +#include "psintrp.h" /* Compute a stem darkening amount in character space. */ @@ -243,7 +243,7 @@ const CF2_Matrix* transform ) { /* pointer to parsed font object */ - CFF_Decoder* decoder = font->decoder; + PS_Decoder* decoder = font->decoder; FT_Bool needExtraSetup = FALSE; @@ -260,7 +260,6 @@ CF2_UInt lenNormalizedV = 0; FT_Fixed* normalizedV = NULL; - /* clear previous error */ font->error = FT_Err_Ok; @@ -273,46 +272,52 @@ needExtraSetup = TRUE; } - /* check for variation vectors */ - vstore = cf2_getVStore( decoder ); - hasVariations = ( vstore->dataCount != 0 ); - - if ( hasVariations ) + if ( !font->isT1 ) { -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /* check whether Private DICT in this subfont needs to be reparsed */ - font->error = cf2_getNormalizedVector( decoder, - &lenNormalizedV, - &normalizedV ); - if ( font->error ) - return; + FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)font->cffload; + + + /* check for variation vectors */ + vstore = cf2_getVStore( decoder ); + hasVariations = ( vstore->dataCount != 0 ); - if ( cff_blend_check_vector( &subFont->blend, - subFont->private_dict.vsindex, - lenNormalizedV, - normalizedV ) ) + if ( hasVariations ) { - /* blend has changed, reparse */ - cff_load_private_dict( decoder->cff, - subFont, - lenNormalizedV, - normalizedV ); - needExtraSetup = TRUE; - } +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* check whether Private DICT in this subfont needs to be reparsed */ + font->error = cf2_getNormalizedVector( decoder, + &lenNormalizedV, + &normalizedV ); + if ( font->error ) + return; + + if ( cffload->blend_check_vector( &subFont->blend, + subFont->private_dict.vsindex, + lenNormalizedV, + normalizedV ) ) + { + /* blend has changed, reparse */ + cffload->load_private_dict( decoder->cff, + subFont, + lenNormalizedV, + normalizedV ); + needExtraSetup = TRUE; + } #endif - /* copy from subfont */ - font->blend.font = subFont->blend.font; + /* copy from subfont */ + font->blend.font = subFont->blend.font; - /* clear state of charstring blend */ - font->blend.usedBV = FALSE; + /* clear state of charstring blend */ + font->blend.usedBV = FALSE; - /* initialize value for charstring */ - font->vsindex = subFont->private_dict.vsindex; + /* initialize value for charstring */ + font->vsindex = subFont->private_dict.vsindex; - /* store vector inputs for blends in charstring */ - font->lenNDV = lenNormalizedV; - font->NDV = normalizedV; + /* store vector inputs for blends in charstring */ + font->lenNDV = lenNormalizedV; + font->NDV = normalizedV; + } } /* if ppem has changed, we need to recompute some cached data */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psfont.h index 17ecd17bbb6..e611ac4bdc8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psfont.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2font.h */ +/* psfont.h */ /* */ /* Adobe's code for font instances (specification). */ /* */ @@ -36,13 +36,14 @@ /***************************************************************************/ -#ifndef CF2FONT_H_ -#define CF2FONT_H_ +#ifndef PSFONT_H_ +#define PSFONT_H_ -#include "cf2ft.h" -#include "cf2blues.h" -#include "cffload.h" +#include FT_SERVICE_CFF_TABLE_LOAD_H + +#include "psft.h" +#include "psblues.h" FT_BEGIN_HEADER @@ -64,6 +65,7 @@ FT_BEGIN_HEADER FT_Memory memory; FT_Error error; /* shared error for this instance */ + FT_Bool isT1; FT_Bool isCFF2; CF2_RenderingFlags renderingFlags; @@ -89,7 +91,7 @@ FT_BEGIN_HEADER /* FreeType related members */ CF2_OutlineRec outline; /* freetype glyph outline functions */ - CFF_Decoder* decoder; + PS_Decoder* decoder; CFF_SubFont lastSubfont; /* FreeType parsed data; */ /* top font or subfont */ @@ -111,6 +113,8 @@ FT_BEGIN_HEADER /* counterclockwise winding */ CF2_BluesRec blues; /* computed zone data */ + + FT_Service_CFFLoad cffload; /* pointer to cff functions */ }; @@ -124,7 +128,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2FONT_H_ */ +#endif /* PSFONT_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psft.c index c6c00d16239..1f750174a1c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psft.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2ft.c */ +/* psft.c */ /* */ /* FreeType Glue Component to Adobe's Interpreter (body). */ /* */ @@ -36,11 +36,20 @@ /***************************************************************************/ -#include "cf2ft.h" +#include "psft.h" #include FT_INTERNAL_DEBUG_H -#include "cf2font.h" -#include "cf2error.h" +#include "psfont.h" +#include "pserror.h" +#include "psobjs.h" +#include "cffdecode.h" + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_MULTIPLE_MASTERS_H +#include FT_SERVICE_MULTIPLE_MASTERS_H +#endif + +#include FT_SERVICE_CFF_TABLE_LOAD_H #define CF2_MAX_SIZE cf2_intToFixed( 2000 ) /* max ppem */ @@ -83,12 +92,13 @@ cf2_setGlyphWidth( CF2_Outline outline, CF2_Fixed width ) { - CFF_Decoder* decoder = outline->decoder; + PS_Decoder* decoder = outline->decoder; FT_ASSERT( decoder ); - decoder->glyph_width = cf2_fixedToInt( width ); + if ( !decoder->builder.is_t1 ) + *decoder->glyph_width = cf2_fixedToInt( width ); } @@ -122,8 +132,8 @@ const CF2_CallbackParams params ) { /* downcast the object pointer */ - CF2_Outline outline = (CF2_Outline)callbacks; - CFF_Builder* builder; + CF2_Outline outline = (CF2_Outline)callbacks; + PS_Builder* builder; (void)params; /* only used in debug mode */ @@ -134,7 +144,7 @@ builder = &outline->decoder->builder; /* note: two successive moves simply close the contour twice */ - cff_builder_close_contour( builder ); + ps_builder_close_contour( builder ); builder->path_begun = 0; } @@ -146,8 +156,8 @@ FT_Error error; /* downcast the object pointer */ - CF2_Outline outline = (CF2_Outline)callbacks; - CFF_Builder* builder; + CF2_Outline outline = (CF2_Outline)callbacks; + PS_Builder* builder; FT_ASSERT( outline && outline->decoder ); @@ -159,9 +169,9 @@ { /* record the move before the line; also check points and set */ /* `path_begun' */ - error = cff_builder_start_point( builder, - params->pt0.x, - params->pt0.y ); + error = ps_builder_start_point( builder, + params->pt0.x, + params->pt0.y ); if ( error ) { if ( !*callbacks->error ) @@ -170,10 +180,10 @@ } } - /* `cff_builder_add_point1' includes a check_points call for one point */ - error = cff_builder_add_point1( builder, - params->pt1.x, - params->pt1.y ); + /* `ps_builder_add_point1' includes a check_points call for one point */ + error = ps_builder_add_point1( builder, + params->pt1.x, + params->pt1.y ); if ( error ) { if ( !*callbacks->error ) @@ -190,8 +200,8 @@ FT_Error error; /* downcast the object pointer */ - CF2_Outline outline = (CF2_Outline)callbacks; - CFF_Builder* builder; + CF2_Outline outline = (CF2_Outline)callbacks; + PS_Builder* builder; FT_ASSERT( outline && outline->decoder ); @@ -203,9 +213,9 @@ { /* record the move before the line; also check points and set */ /* `path_begun' */ - error = cff_builder_start_point( builder, - params->pt0.x, - params->pt0.y ); + error = ps_builder_start_point( builder, + params->pt0.x, + params->pt0.y ); if ( error ) { if ( !*callbacks->error ) @@ -215,7 +225,7 @@ } /* prepare room for 3 points: 2 off-curve, 1 on-curve */ - error = cff_check_points( builder, 3 ); + error = ps_builder_check_points( builder, 3 ); if ( error ) { if ( !*callbacks->error ) @@ -223,15 +233,15 @@ return; } - cff_builder_add_point( builder, - params->pt1.x, - params->pt1.y, 0 ); - cff_builder_add_point( builder, - params->pt2.x, - params->pt2.y, 0 ); - cff_builder_add_point( builder, - params->pt3.x, - params->pt3.y, 1 ); + ps_builder_add_point( builder, + params->pt1.x, + params->pt1.y, 0 ); + ps_builder_add_point( builder, + params->pt2.x, + params->pt2.y, 0 ); + ps_builder_add_point( builder, + params->pt3.x, + params->pt3.y, 1 ); } @@ -253,11 +263,11 @@ /* get scaling and hint flag from GlyphSlot */ static void - cf2_getScaleAndHintFlag( CFF_Decoder* decoder, - CF2_Fixed* x_scale, - CF2_Fixed* y_scale, - FT_Bool* hinted, - FT_Bool* scaled ) + cf2_getScaleAndHintFlag( PS_Decoder* decoder, + CF2_Fixed* x_scale, + CF2_Fixed* y_scale, + FT_Bool* hinted, + FT_Bool* scaled ) { FT_ASSERT( decoder && decoder->builder.glyph ); @@ -284,47 +294,60 @@ /* get units per em from `FT_Face' */ /* TODO: should handle font matrix concatenation? */ static FT_UShort - cf2_getUnitsPerEm( CFF_Decoder* decoder ) + cf2_getUnitsPerEm( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->builder.face ); - FT_ASSERT( decoder->builder.face->root.units_per_EM ); + FT_ASSERT( decoder->builder.face->units_per_EM ); - return decoder->builder.face->root.units_per_EM; + return decoder->builder.face->units_per_EM; } /* Main entry point: Render one glyph. */ FT_LOCAL_DEF( FT_Error ) - cf2_decoder_parse_charstrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_ULong charstring_len ) + cf2_decoder_parse_charstrings( PS_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len ) { FT_Memory memory; FT_Error error = FT_Err_Ok; CF2_Font font; + FT_Bool is_t1 = decoder->builder.is_t1; - FT_ASSERT( decoder && decoder->cff ); + + FT_ASSERT( decoder && + ( is_t1 || decoder->cff ) ); + + if ( is_t1 && !decoder->current_subfont ) + { + FT_ERROR(( "cf2_decoder_parse_charstrings (Type 1): " + "SubFont missing. Use `t1_make_subfont' first\n" )); + return FT_THROW( Invalid_Table ); + } memory = decoder->builder.memory; /* CF2 data is saved here across glyphs */ - font = (CF2_Font)decoder->cff->cf2_instance.data; + font = (CF2_Font)decoder->cf2_instance->data; /* on first glyph, allocate instance structure */ - if ( !decoder->cff->cf2_instance.data ) + if ( !decoder->cf2_instance->data ) { - decoder->cff->cf2_instance.finalizer = + decoder->cf2_instance->finalizer = (FT_Generic_Finalizer)cf2_free_instance; - if ( FT_ALLOC( decoder->cff->cf2_instance.data, + if ( FT_ALLOC( decoder->cf2_instance->data, sizeof ( CF2_FontRec ) ) ) return FT_THROW( Out_Of_Memory ); - font = (CF2_Font)decoder->cff->cf2_instance.data; + font = (CF2_Font)decoder->cf2_instance->data; font->memory = memory; + if ( !is_t1 ) + font->cffload = (FT_Service_CFFLoad)decoder->cff->cffload; + /* initialize a client outline, to be shared by each glyph rendered */ cf2_outline_init( &font->outline, font->memory, &font->error ); } @@ -337,13 +360,13 @@ { /* build parameters for Adobe engine */ - CFF_Builder* builder = &decoder->builder; - CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face ); + PS_Builder* builder = &decoder->builder; + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face ); FT_Bool no_stem_darkening_driver = driver->no_stem_darkening; FT_Char no_stem_darkening_font = - builder->face->root.internal->no_stem_darkening; + builder->face->internal->no_stem_darkening; /* local error */ FT_Error error2 = FT_Err_Ok; @@ -372,8 +395,14 @@ &hinted, &scaled ); - /* copy isCFF2 boolean from TT_Face to CF2_Font */ - font->isCFF2 = builder->face->is_cff2; + if ( is_t1 ) + font->isCFF2 = FALSE; + else + { + /* copy isCFF2 boolean from TT_Face to CF2_Font */ + font->isCFF2 = ((TT_Face)builder->face)->is_cff2; + } + font->isT1 = is_t1; font->renderingFlags = 0; if ( hinted ) @@ -416,7 +445,7 @@ /* get pointer to current FreeType subfont (based on current glyphID) */ FT_LOCAL_DEF( CFF_SubFont ) - cf2_getSubfont( CFF_Decoder* decoder ) + cf2_getSubfont( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -426,7 +455,7 @@ /* get pointer to VStore structure */ FT_LOCAL_DEF( CFF_VStore ) - cf2_getVStore( CFF_Decoder* decoder ) + cf2_getVStore( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->cff ); @@ -436,7 +465,7 @@ /* get maxstack value from CFF2 Top DICT */ FT_LOCAL_DEF( FT_UInt ) - cf2_getMaxstack( CFF_Decoder* decoder ) + cf2_getMaxstack( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->cff ); @@ -450,25 +479,33 @@ /* */ /* Note: Uses FT_Fixed not CF2_Fixed for the vector. */ FT_LOCAL_DEF( FT_Error ) - cf2_getNormalizedVector( CFF_Decoder* decoder, + cf2_getNormalizedVector( PS_Decoder* decoder, CF2_UInt *len, FT_Fixed* *vec ) { + TT_Face face; + FT_Service_MultiMasters mm; + + FT_ASSERT( decoder && decoder->builder.face ); FT_ASSERT( vec && len ); + FT_ASSERT( !decoder->builder.is_t1 ); - return cff_get_var_blend( decoder->builder.face, len, NULL, vec, NULL ); + face = (TT_Face)decoder->builder.face; + mm = (FT_Service_MultiMasters)face->mm; + + return mm->get_var_blend( FT_FACE( face ), len, NULL, vec, NULL ); } #endif /* get `y_ppem' from `CFF_Size' */ FT_LOCAL_DEF( CF2_Fixed ) - cf2_getPpemY( CFF_Decoder* decoder ) + cf2_getPpemY( PS_Decoder* decoder ) { - FT_ASSERT( decoder && - decoder->builder.face && - decoder->builder.face->root.size ); + FT_ASSERT( decoder && + decoder->builder.face && + decoder->builder.face->size ); /* * Note that `y_ppem' can be zero if there wasn't a call to @@ -480,7 +517,7 @@ * */ return cf2_intToFixed( - decoder->builder.face->root.size->metrics.y_ppem ); + decoder->builder.face->size->metrics.y_ppem ); } @@ -488,7 +525,7 @@ /* FreeType stores these as integer font units */ /* (note: variable names seem swapped) */ FT_LOCAL_DEF( CF2_Fixed ) - cf2_getStdVW( CFF_Decoder* decoder ) + cf2_getStdVW( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -498,7 +535,7 @@ FT_LOCAL_DEF( CF2_Fixed ) - cf2_getStdHW( CFF_Decoder* decoder ) + cf2_getStdHW( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -509,10 +546,10 @@ /* note: FreeType stores 1000 times the actual value for `BlueScale' */ FT_LOCAL_DEF( void ) - cf2_getBlueMetrics( CFF_Decoder* decoder, - CF2_Fixed* blueScale, - CF2_Fixed* blueShift, - CF2_Fixed* blueFuzz ) + cf2_getBlueMetrics( PS_Decoder* decoder, + CF2_Fixed* blueScale, + CF2_Fixed* blueShift, + CF2_Fixed* blueFuzz ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -529,9 +566,9 @@ /* get blue values counts and arrays; the FreeType parser has validated */ /* the counts and verified that each is an even number */ FT_LOCAL_DEF( void ) - cf2_getBlueValues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ) + cf2_getBlueValues( PS_Decoder* decoder, + size_t* count, + FT_Pos* *data ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -542,9 +579,9 @@ FT_LOCAL_DEF( void ) - cf2_getOtherBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ) + cf2_getOtherBlues( PS_Decoder* decoder, + size_t* count, + FT_Pos* *data ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -555,9 +592,9 @@ FT_LOCAL_DEF( void ) - cf2_getFamilyBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ) + cf2_getFamilyBlues( PS_Decoder* decoder, + size_t* count, + FT_Pos* *data ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -568,9 +605,9 @@ FT_LOCAL_DEF( void ) - cf2_getFamilyOtherBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ) + cf2_getFamilyOtherBlues( PS_Decoder* decoder, + size_t* count, + FT_Pos* *data ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -581,7 +618,7 @@ FT_LOCAL_DEF( CF2_Int ) - cf2_getLanguageGroup( CFF_Decoder* decoder ) + cf2_getLanguageGroup( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -592,9 +629,9 @@ /* convert unbiased subroutine index to `CF2_Buffer' and */ /* return 0 on success */ FT_LOCAL_DEF( CF2_Int ) - cf2_initGlobalRegionBuffer( CFF_Decoder* decoder, - CF2_Int subrNum, - CF2_Buffer buf ) + cf2_initGlobalRegionBuffer( PS_Decoder* decoder, + CF2_Int subrNum, + CF2_Buffer buf ) { CF2_UInt idx; @@ -620,9 +657,9 @@ /* convert AdobeStandardEncoding code to CF2_Buffer; */ /* used for seac component */ FT_LOCAL_DEF( FT_Error ) - cf2_getSeacComponent( CFF_Decoder* decoder, - CF2_Int code, - CF2_Buffer buf ) + cf2_getSeacComponent( PS_Decoder* decoder, + CF2_Int code, + CF2_Buffer buf ) { CF2_Int gid; FT_Byte* charstring; @@ -631,13 +668,14 @@ FT_ASSERT( decoder ); + FT_ASSERT( !decoder->builder.is_t1 ); FT_ZERO( buf ); #ifdef FT_CONFIG_OPTION_INCREMENTAL /* Incremental fonts don't necessarily have valid charsets. */ /* They use the character code, not the glyph index, in this case. */ - if ( decoder->builder.face->root.internal->incremental_interface ) + if ( decoder->builder.face->internal->incremental_interface ) gid = code; else #endif /* FT_CONFIG_OPTION_INCREMENTAL */ @@ -647,10 +685,10 @@ return FT_THROW( Invalid_Glyph_Format ); } - error = cff_get_glyph_data( decoder->builder.face, - (CF2_UInt)gid, - &charstring, - &len ); + error = decoder->get_glyph_callback( (TT_Face)decoder->builder.face, + (CF2_UInt)gid, + &charstring, + &len ); /* TODO: for now, just pass the FreeType error through */ if ( error ) return error; @@ -667,21 +705,92 @@ FT_LOCAL_DEF( void ) - cf2_freeSeacComponent( CFF_Decoder* decoder, - CF2_Buffer buf ) + cf2_freeSeacComponent( PS_Decoder* decoder, + CF2_Buffer buf ) + { + FT_ASSERT( decoder ); + FT_ASSERT( !decoder->builder.is_t1 ); + + decoder->free_glyph_callback( (TT_Face)decoder->builder.face, + (FT_Byte**)&buf->start, + (FT_ULong)( buf->end - buf->start ) ); + } + + + FT_LOCAL_DEF( FT_Error ) + cf2_getT1SeacComponent( PS_Decoder* decoder, + FT_UInt glyph_index, + CF2_Buffer buf ) + { + FT_Data glyph_data; + FT_Error error = FT_Err_Ok; + T1_Face face = (T1_Face)decoder->builder.face; + T1_Font type1 = &face->type1; + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + FT_Incremental_InterfaceRec *inc = + face->root.internal->incremental_interface; + + + /* For incremental fonts get the character data using the */ + /* callback function. */ + if ( inc ) + error = inc->funcs->get_glyph_data( inc->object, + glyph_index, &glyph_data ); + else +#endif + /* For ordinary fonts get the character data stored in the face record. */ + { + glyph_data.pointer = type1->charstrings[glyph_index]; + glyph_data.length = (FT_Int)type1->charstrings_len[glyph_index]; + } + + if ( !error ) + { + FT_Byte* charstring_base = (FT_Byte*)glyph_data.pointer; + FT_ULong charstring_len = (FT_ULong)glyph_data.length; + + + FT_ASSERT( charstring_base + charstring_len >= charstring_base ); + + FT_ZERO( buf ); + buf->start = + buf->ptr = charstring_base; + buf->end = charstring_base + charstring_len; + } + + return error; + } + + + FT_LOCAL_DEF( void ) + cf2_freeT1SeacComponent( PS_Decoder* decoder, + CF2_Buffer buf ) { + T1_Face face; + FT_Data data; + + FT_ASSERT( decoder ); - cff_free_glyph_data( decoder->builder.face, - (FT_Byte**)&buf->start, - (FT_ULong)( buf->end - buf->start ) ); +#ifdef FT_CONFIG_OPTION_INCREMENTAL + face = (T1_Face)decoder->builder.face; + + data.pointer = buf->start; + data.length = (FT_Int)( buf->end - buf->start ); + + if ( face->root.internal->incremental_interface ) + face->root.internal->incremental_interface->funcs->free_glyph_data( + face->root.internal->incremental_interface->object, + &data ); +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ } FT_LOCAL_DEF( CF2_Int ) - cf2_initLocalRegionBuffer( CFF_Decoder* decoder, - CF2_Int subrNum, - CF2_Buffer buf ) + cf2_initLocalRegionBuffer( PS_Decoder* decoder, + CF2_Int subrNum, + CF2_Buffer buf ) { CF2_UInt idx; @@ -696,16 +805,42 @@ FT_ASSERT( decoder->locals ); - buf->start = - buf->ptr = decoder->locals[idx]; - buf->end = decoder->locals[idx + 1]; + buf->start = decoder->locals[idx]; + + if ( decoder->builder.is_t1 ) + { + /* The Type 1 driver stores subroutines without the seed bytes. */ + /* The CID driver stores subroutines with seed bytes. This */ + /* case is taken care of when decoder->subrs_len == 0. */ + if ( decoder->locals_len ) + buf->end = buf->start + decoder->locals_len[idx]; + else + { + /* We are using subroutines from a CID font. We must adjust */ + /* for the seed bytes. */ + buf->start += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 ); + buf->end = decoder->locals[idx + 1]; + } + + if ( !buf->start ) + { + FT_ERROR(( "cf2_initLocalRegionBuffer (Type 1 mode):" + " invoking empty subrs\n" )); + } + } + else + { + buf->end = decoder->locals[idx + 1]; + } + + buf->ptr = buf->start; return FALSE; /* success */ } FT_LOCAL_DEF( CF2_Fixed ) - cf2_getDefaultWidthX( CFF_Decoder* decoder ) + cf2_getDefaultWidthX( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -715,7 +850,7 @@ FT_LOCAL_DEF( CF2_Fixed ) - cf2_getNominalWidthX( CFF_Decoder* decoder ) + cf2_getNominalWidthX( PS_Decoder* decoder ) { FT_ASSERT( decoder && decoder->current_subfont ); @@ -727,7 +862,7 @@ FT_LOCAL_DEF( void ) cf2_outline_reset( CF2_Outline outline ) { - CFF_Decoder* decoder = outline->decoder; + PS_Decoder* decoder = outline->decoder; FT_ASSERT( decoder ); @@ -741,12 +876,12 @@ FT_LOCAL_DEF( void ) cf2_outline_close( CF2_Outline outline ) { - CFF_Decoder* decoder = outline->decoder; + PS_Decoder* decoder = outline->decoder; FT_ASSERT( decoder ); - cff_builder_close_contour( &decoder->builder ); + ps_builder_close_contour( &decoder->builder ); FT_GlyphLoader_Add( decoder->builder.loader ); } diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psft.h index b054a6e950c..ab172110bb6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psft.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2ft.h */ +/* psft.h */ /* */ /* FreeType Glue Component to Adobe's Interpreter (specification). */ /* */ @@ -36,11 +36,11 @@ /***************************************************************************/ -#ifndef CF2FT_H_ -#define CF2FT_H_ +#ifndef PSFT_H_ +#define PSFT_H_ -#include "cf2types.h" +#include "pstypes.h" /* TODO: disable asserts for now */ @@ -49,88 +49,96 @@ #include FT_SYSTEM_H -#include "cf2glue.h" -#include "cffgload.h" /* for CFF_Decoder */ +#include "psglue.h" +#include FT_INTERNAL_POSTSCRIPT_AUX_H /* for PS_Decoder */ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - cf2_decoder_parse_charstrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_ULong charstring_len ); + cf2_decoder_parse_charstrings( PS_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len ); FT_LOCAL( CFF_SubFont ) - cf2_getSubfont( CFF_Decoder* decoder ); + cf2_getSubfont( PS_Decoder* decoder ); FT_LOCAL( CFF_VStore ) - cf2_getVStore( CFF_Decoder* decoder ); + cf2_getVStore( PS_Decoder* decoder ); FT_LOCAL( FT_UInt ) - cf2_getMaxstack( CFF_Decoder* decoder ); + cf2_getMaxstack( PS_Decoder* decoder ); #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_LOCAL( FT_Error ) - cf2_getNormalizedVector( CFF_Decoder* decoder, - CF2_UInt *len, - FT_Fixed* *vec ); + cf2_getNormalizedVector( PS_Decoder* decoder, + CF2_UInt *len, + FT_Fixed* *vec ); #endif FT_LOCAL( CF2_Fixed ) - cf2_getPpemY( CFF_Decoder* decoder ); + cf2_getPpemY( PS_Decoder* decoder ); FT_LOCAL( CF2_Fixed ) - cf2_getStdVW( CFF_Decoder* decoder ); + cf2_getStdVW( PS_Decoder* decoder ); FT_LOCAL( CF2_Fixed ) - cf2_getStdHW( CFF_Decoder* decoder ); + cf2_getStdHW( PS_Decoder* decoder ); FT_LOCAL( void ) - cf2_getBlueMetrics( CFF_Decoder* decoder, - CF2_Fixed* blueScale, - CF2_Fixed* blueShift, - CF2_Fixed* blueFuzz ); + cf2_getBlueMetrics( PS_Decoder* decoder, + CF2_Fixed* blueScale, + CF2_Fixed* blueShift, + CF2_Fixed* blueFuzz ); FT_LOCAL( void ) - cf2_getBlueValues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ); + cf2_getBlueValues( PS_Decoder* decoder, + size_t* count, + FT_Pos* *data ); FT_LOCAL( void ) - cf2_getOtherBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ); + cf2_getOtherBlues( PS_Decoder* decoder, + size_t* count, + FT_Pos* *data ); FT_LOCAL( void ) - cf2_getFamilyBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ); + cf2_getFamilyBlues( PS_Decoder* decoder, + size_t* count, + FT_Pos* *data ); FT_LOCAL( void ) - cf2_getFamilyOtherBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ); + cf2_getFamilyOtherBlues( PS_Decoder* decoder, + size_t* count, + FT_Pos* *data ); FT_LOCAL( CF2_Int ) - cf2_getLanguageGroup( CFF_Decoder* decoder ); + cf2_getLanguageGroup( PS_Decoder* decoder ); FT_LOCAL( CF2_Int ) - cf2_initGlobalRegionBuffer( CFF_Decoder* decoder, - CF2_Int subrNum, - CF2_Buffer buf ); + cf2_initGlobalRegionBuffer( PS_Decoder* decoder, + CF2_Int subrNum, + CF2_Buffer buf ); FT_LOCAL( FT_Error ) - cf2_getSeacComponent( CFF_Decoder* decoder, - CF2_Int code, - CF2_Buffer buf ); + cf2_getSeacComponent( PS_Decoder* decoder, + CF2_Int code, + CF2_Buffer buf ); FT_LOCAL( void ) - cf2_freeSeacComponent( CFF_Decoder* decoder, - CF2_Buffer buf ); + cf2_freeSeacComponent( PS_Decoder* decoder, + CF2_Buffer buf ); FT_LOCAL( CF2_Int ) - cf2_initLocalRegionBuffer( CFF_Decoder* decoder, - CF2_Int subrNum, - CF2_Buffer buf ); + cf2_initLocalRegionBuffer( PS_Decoder* decoder, + CF2_Int subrNum, + CF2_Buffer buf ); FT_LOCAL( CF2_Fixed ) - cf2_getDefaultWidthX( CFF_Decoder* decoder ); + cf2_getDefaultWidthX( PS_Decoder* decoder ); FT_LOCAL( CF2_Fixed ) - cf2_getNominalWidthX( CFF_Decoder* decoder ); + cf2_getNominalWidthX( PS_Decoder* decoder ); + FT_LOCAL( FT_Error ) + cf2_getT1SeacComponent( PS_Decoder* decoder, + FT_UInt glyph_index, + CF2_Buffer buf ); + FT_LOCAL( void ) + cf2_freeT1SeacComponent( PS_Decoder* decoder, + CF2_Buffer buf ); + /* * FreeType client outline * @@ -139,7 +147,7 @@ FT_BEGIN_HEADER typedef struct CF2_OutlineRec_ { CF2_OutlineCallbacksRec root; /* base class must be first */ - CFF_Decoder* decoder; + PS_Decoder* decoder; } CF2_OutlineRec, *CF2_Outline; @@ -153,7 +161,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2FT_H_ */ +#endif /* PSFT_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2glue.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psglue.h index 56a7c248f4e..5545e12a5bf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2glue.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psglue.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2glue.h */ +/* psglue.h */ /* */ /* Adobe's code for shared stuff (specification only). */ /* */ @@ -36,15 +36,15 @@ /***************************************************************************/ -#ifndef CF2GLUE_H_ -#define CF2GLUE_H_ +#ifndef PSGLUE_H_ +#define PSGLUE_H_ /* common includes for other modules */ -#include "cf2error.h" -#include "cf2fixed.h" -#include "cf2arrst.h" -#include "cf2read.h" +#include "pserror.h" +#include "psfixed.h" +#include "psarrst.h" +#include "psread.h" FT_BEGIN_HEADER @@ -138,7 +138,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2GLUE_H_ */ +#endif /* PSGLUE_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.c b/Build/source/libs/freetype2/freetype-src/src/psaux/pshints.c index 656eb2cff17..36151964253 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/pshints.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2hints.c */ +/* pshints.c */ /* */ /* Adobe's code for handling CFF hints (body). */ /* */ @@ -36,13 +36,13 @@ /***************************************************************************/ -#include "cf2ft.h" +#include "psft.h" #include FT_INTERNAL_DEBUG_H -#include "cf2glue.h" -#include "cf2font.h" -#include "cf2hints.h" -#include "cf2intrp.h" +#include "psglue.h" +#include "psfont.h" +#include "pshints.h" +#include "psintrp.h" /*************************************************************************/ @@ -299,6 +299,36 @@ } + static void + cf2_hintmap_dump( CF2_HintMap hintmap ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + CF2_UInt i; + + + FT_TRACE6(( " index csCoord dsCoord scale flags\n" )); + + for ( i = 0; i < hintmap->count; i++ ) + { + CF2_Hint hint = &hintmap->edge[i]; + + + FT_TRACE6(( " %3d %7.2f %7.2f %5d %s%s%s%s\n", + hint->index, + hint->csCoord / 65536.0, + hint->dsCoord / ( hint->scale * 1.0 ), + hint->scale, + ( cf2_hint_isPair( hint ) ? "p" : "g" ), + ( cf2_hint_isTop( hint ) ? "t" : "b" ), + ( cf2_hint_isLocked( hint ) ? "L" : ""), + ( cf2_hint_isSynthetic( hint ) ? "S" : "" ) )); + } +#else + FT_UNUSED( hintmap ); +#endif + } + + /* transform character space coordinate to device space using hint map */ static CF2_Fixed cf2_hintmap_map( CF2_HintMap hintmap, @@ -612,6 +642,14 @@ break; } + FT_TRACE7(( " Got hint at %.2f (%.2f)\n", + firstHintEdge->csCoord / 65536.0, + firstHintEdge->dsCoord / 65536.0 )); + if ( isPair ) + FT_TRACE7(( " Got hint at %.2f (%.2f)\n", + secondHintEdge->csCoord / 65536.0, + secondHintEdge->dsCoord / 65536.0 )); + /* * Discard any hints that overlap in character space. Most often, this * is while building the initial map, where captured hints from all @@ -731,11 +769,20 @@ hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */ hintmap->count += 1; + FT_TRACE7(( " Inserting hint %.2f (%.2f)\n", + firstHintEdge->csCoord / 65536.0, + firstHintEdge->dsCoord / 65536.0 )); + if ( isPair ) { /* insert second edge */ hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */ hintmap->count += 1; + + FT_TRACE7(( " Inserting hint %.2f (%.2f)\n", + secondHintEdge->csCoord / 65536.0, + secondHintEdge->dsCoord / 65536.0 )); + } } @@ -795,7 +842,15 @@ cf2_arrstack_size( hStemHintArray ) + cf2_arrstack_size( vStemHintArray ) ); if ( !cf2_hintmask_isValid( hintMask ) ) + { + if ( font->isT1 ) + { + /* no error, just continue unhinted */ + *hintMask->error = FT_Err_Ok; + hintmap->hinted = FALSE; + } return; /* too many stem hints */ + } } /* begin by clearing the map */ @@ -970,6 +1025,12 @@ } } + FT_TRACE6(( initialMap ? "flags: [p]air [g]host [t]op " + "[b]ottom [L]ocked [S]ynthetic\n" + "Initial hintmap\n" + : "Hints:\n" )); + cf2_hintmap_dump( hintmap ); + /* * Note: The following line is a convenient place to break when * debugging hinting. Examine `hintmap->edge' for the list of @@ -982,6 +1043,9 @@ /* adjust positions of hint edges that are not locked to blue zones */ cf2_hintmap_adjustHints( hintmap ); + FT_TRACE6(( "(adjusted)\n" )); + cf2_hintmap_dump( hintmap ); + /* save the position of all hints that were used in this hint map; */ /* if we use them again, we'll locate them in the same position */ if ( !initialMap ) @@ -1146,7 +1210,7 @@ * second segment. * Let `w 'be the zero-based vector from `u1' to `v1'. * `perp' is the `perpendicular dot product'; see - * http://mathworld.wolfram.com/PerpDotProduct.html. + * https://mathworld.wolfram.com/PerpDotProduct.html. * `s' is the parameter for the parametric line for the first segment * (`u'). * diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.h b/Build/source/libs/freetype2/freetype-src/src/psaux/pshints.h index a8984542a01..92e37e98aef 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/pshints.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2hints.h */ +/* pshints.h */ /* */ /* Adobe's code for handling CFF hints (body). */ /* */ @@ -36,9 +36,8 @@ /***************************************************************************/ -#ifndef CF2HINTS_H_ -#define CF2HINTS_H_ - +#ifndef PSHINT_H_ +#define PSHINT_H_ FT_BEGIN_HEADER @@ -283,7 +282,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2HINTS_H_ */ +#endif /* PSHINT_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psintrp.c index a8162807485..5c0ee784924 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psintrp.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2intrp.c */ +/* psintrp.c */ /* */ /* Adobe's CFF Interpreter (body). */ /* */ @@ -36,18 +36,20 @@ /***************************************************************************/ -#include "cf2ft.h" +#include "psft.h" #include FT_INTERNAL_DEBUG_H +#include FT_SERVICE_CFF_TABLE_LOAD_H -#include "cf2glue.h" -#include "cf2font.h" -#include "cf2stack.h" -#include "cf2hints.h" -#include "cf2intrp.h" +#include "psglue.h" +#include "psfont.h" +#include "psstack.h" +#include "pshints.h" +#include "psintrp.h" -#include "cf2error.h" +#include "pserror.h" -#include "cffload.h" +#include "psobjs.h" /* for cff_random */ +#include "t1decode.h" /* for t1 seac */ /*************************************************************************/ @@ -205,11 +207,11 @@ cf2_cmdHLINETO, /* 6 */ cf2_cmdVLINETO, /* 7 */ cf2_cmdRRCURVETO, /* 8 */ - cf2_cmdRESERVED_9, /* 9 */ + cf2_cmdCLOSEPATH, /* 9 T1 only */ cf2_cmdCALLSUBR, /* 10 */ cf2_cmdRETURN, /* 11 */ cf2_cmdESC, /* 12 */ - cf2_cmdRESERVED_13, /* 13 */ + cf2_cmdHSBW, /* 13 T1 only */ cf2_cmdENDCHAR, /* 14 */ cf2_cmdVSINDEX, /* 15 */ cf2_cmdBLEND, /* 16 */ @@ -233,13 +235,13 @@ enum { cf2_escDOTSECTION, /* 0 */ - cf2_escRESERVED_1, /* 1 */ - cf2_escRESERVED_2, /* 2 */ + cf2_escVSTEM3, /* 1 T1 only */ + cf2_escHSTEM3, /* 2 T1 only */ cf2_escAND, /* 3 */ cf2_escOR, /* 4 */ cf2_escNOT, /* 5 */ - cf2_escRESERVED_6, /* 6 */ - cf2_escRESERVED_7, /* 7 */ + cf2_escSEAC, /* 6 T1 only */ + cf2_escSBW, /* 7 T1 only */ cf2_escRESERVED_8, /* 8 */ cf2_escABS, /* 9 */ cf2_escADD, /* 10 like otherADD */ @@ -248,8 +250,8 @@ cf2_escRESERVED_13, /* 13 */ cf2_escNEG, /* 14 */ cf2_escEQ, /* 15 */ - cf2_escRESERVED_16, /* 16 */ - cf2_escRESERVED_17, /* 17 */ + cf2_escCALLOTHERSUBR,/* 16 T1 only */ + cf2_escPOP, /* 17 T1 only */ cf2_escDROP, /* 18 */ cf2_escRESERVED_19, /* 19 */ cf2_escPUT, /* 20 like otherPUT */ @@ -265,7 +267,7 @@ cf2_escROLL, /* 30 */ cf2_escRESERVED_31, /* 31 */ cf2_escRESERVED_32, /* 32 */ - cf2_escRESERVED_33, /* 33 */ + cf2_escSETCURRENTPT, /* 33 T1 only */ cf2_escHFLEX, /* 34 */ cf2_escFLEX, /* 35 */ cf2_escHFLEX1, /* 36 */ @@ -290,10 +292,13 @@ /* variable accumulates delta values from operand stack */ CF2_Fixed position = hintOffset; + if ( font->isT1 && !font->decoder->flex_state && !*haveWidth ) + FT_ERROR(( "cf2_doStems (Type 1 mode):" + " No width. Use hsbw/sbw as first op\n" )); - if ( hasWidthArg && !*haveWidth ) - *width = cf2_stack_getReal( opStack, 0 ) + - cf2_getNominalWidthX( font->decoder ); + if ( !font->isT1 && hasWidthArg && !*haveWidth ) + *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), + cf2_getNominalWidthX( font->decoder ) ); if ( font->decoder->width_only ) goto exit; @@ -476,7 +481,7 @@ FT_Error lastError = FT_Err_Ok; /* pointer to parsed font object */ - CFF_Decoder* decoder = font->decoder; + PS_Decoder* decoder = font->decoder; FT_Error* error = &font->error; FT_Memory memory = font->memory; @@ -484,6 +489,15 @@ CF2_Fixed scaleY = font->innerTransform.d; CF2_Fixed nominalWidthX = cf2_getNominalWidthX( decoder ); + /* stuff for Type 1 */ + FT_Int known_othersubr_result_cnt = 0; + FT_Bool large_int = FALSE; + FT_Bool initial_map_ready = FALSE; + +#define PS_STORAGE_SIZE 3 + CF2_F16Dot16 results[PS_STORAGE_SIZE]; /* for othersubr results */ + FT_Int result_cnt = 0; + /* save this for hinting seac accents */ CF2_Fixed hintOriginY = curY; @@ -492,6 +506,7 @@ FT_Byte op1; /* first opcode byte */ CF2_F16Dot16 storage[CF2_STORAGE_SIZE]; /* for `put' and `get' */ + CF2_F16Dot16 flexStore[6]; /* for Type 1 flex */ /* instruction limit; 20,000,000 matches Avalon */ FT_UInt32 instructionLimit = 20000000UL; @@ -514,6 +529,8 @@ FT_ZERO( &storage ); + FT_ZERO( &results ); + FT_ZERO( &flexStore ); /* initialize the remaining objects */ cf2_arrstack_init( &subrStack, @@ -606,6 +623,10 @@ /* main interpreter loop */ while ( 1 ) { + if ( font->isT1 ) + FT_ASSERT( known_othersubr_result_cnt == 0 || + result_cnt == 0 ); + if ( cf2_buf_isEnd( charstring ) ) { /* If we've reached the end of the charstring, simulate a */ @@ -627,6 +648,44 @@ op1 = cf2_cmdRESERVED_0; } + if ( font->isT1 ) + { + if ( !initial_map_ready && + !( op1 == cf2_cmdHSTEM || + op1 == cf2_cmdVSTEM || + op1 == cf2_cmdHSBW || + op1 == cf2_cmdCALLSUBR || + op1 == cf2_cmdRETURN || + op1 == cf2_cmdESC || + op1 == cf2_cmdENDCHAR || + op1 >= 32 /* Numbers */ ) ) + { + /* Skip outline commands first time round. */ + /* `endchar' will trigger initial hintmap build */ + /* and rewind the charstring. */ + cf2_stack_clear( opStack ); + continue; + } + + if ( result_cnt > 0 && + !( op1 == cf2_cmdCALLSUBR || + op1 == cf2_cmdRETURN || + op1 == cf2_cmdESC || + op1 >= 32 /* Numbers */ ) ) + { + /* all operands have been transferred by previous pops */ + result_cnt = 0; + } + + if ( large_int && !( op1 >= 32 || op1 == cf2_escDIV ) ) + { + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " no `div' after large integer\n" )); + + large_int = FALSE; + } + } + /* check for errors once per loop */ if ( *error ) goto exit; @@ -642,8 +701,6 @@ { case cf2_cmdRESERVED_0: case cf2_cmdRESERVED_2: - case cf2_cmdRESERVED_9: - case cf2_cmdRESERVED_13: case cf2_cmdRESERVED_17: /* we may get here if we have a prior error */ FT_TRACE4(( " unknown op (%d)\n", op1 )); @@ -689,15 +746,15 @@ } /* check cached blend vector */ - if ( cff_blend_check_vector( &font->blend, - font->vsindex, - font->lenNDV, - font->NDV ) ) + if ( font->cffload->blend_check_vector( &font->blend, + font->vsindex, + font->lenNDV, + font->NDV ) ) { - lastError = cff_blend_build_vector( &font->blend, - font->vsindex, - font->lenNDV, - font->NDV ); + lastError = font->cffload->blend_build_vector( &font->blend, + font->vsindex, + font->lenNDV, + font->NDV ); if ( lastError ) goto exit; } @@ -720,22 +777,28 @@ case cf2_cmdHSTEM: FT_TRACE4(( op1 == cf2_cmdHSTEMHM ? " hstemhm\n" : " hstem\n" )); - /* never add hints after the mask is computed */ - if ( cf2_hintmask_isValid( &hintMask ) ) + if ( !font->isT1 ) { - FT_TRACE4(( "cf2_interpT2CharString:" - " invalid horizontal hint mask\n" )); - break; + /* never add hints after the mask is computed */ + /* except if in Type 1 mode (no hintmask op) */ + if ( cf2_hintmask_isValid( &hintMask ) ) + { + FT_TRACE4(( "cf2_interpT2CharString:" + " invalid horizontal hint mask\n" )); + break; + } } + /* add left-sidebearing correction in Type 1 mode */ cf2_doStems( font, opStack, &hStemHintArray, width, &haveWidth, - 0 ); + font->isT1 ? decoder->builder.left_bearing->y + : 0 ); - if ( font->decoder->width_only ) + if ( decoder->width_only ) goto exit; break; @@ -744,22 +807,28 @@ case cf2_cmdVSTEM: FT_TRACE4(( op1 == cf2_cmdVSTEMHM ? " vstemhm\n" : " vstem\n" )); - /* never add hints after the mask is computed */ - if ( cf2_hintmask_isValid( &hintMask ) ) + if ( !font->isT1 ) { - FT_TRACE4(( "cf2_interpT2CharString:" - " invalid vertical hint mask\n" )); - break; + /* never add hints after the mask is computed */ + /* except if in Type 1 mode (no hintmask op) */ + if ( cf2_hintmask_isValid( &hintMask ) ) + { + FT_TRACE4(( "cf2_interpT2CharString:" + " invalid vertical hint mask\n" )); + break; + } } + /* add left-sidebearing correction in Type 1 mode */ cf2_doStems( font, opStack, &vStemHintArray, width, &haveWidth, - 0 ); + font->isT1 ? decoder->builder.left_bearing->x + : 0 ); - if ( font->decoder->width_only ) + if ( decoder->width_only ) goto exit; break; @@ -767,6 +836,10 @@ case cf2_cmdVMOVETO: FT_TRACE4(( " vmoveto\n" )); + if ( font->isT1 && !decoder->flex_state && !haveWidth ) + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " No width. Use hsbw/sbw as first op\n" )); + if ( cf2_stack_count( opStack ) > 1 && !haveWidth ) *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), nominalWidthX ); @@ -774,7 +847,7 @@ /* width is defined or default after this */ haveWidth = TRUE; - if ( font->decoder->width_only ) + if ( decoder->width_only ) goto exit; curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) ); @@ -878,6 +951,20 @@ } continue; /* no need to clear stack again */ + case cf2_cmdCLOSEPATH: + if ( !font->isT1 ) + FT_TRACE4(( " unknown op (%d)\n", op1 )); + else + { + FT_TRACE4(( " closepath" )); + + /* if there is no path, `closepath' is a no-op */ + ps_builder_close_contour( &decoder->builder ); + + haveWidth = TRUE; + } + break; + case cf2_cmdCALLGSUBR: case cf2_cmdCALLSUBR: { @@ -887,7 +974,8 @@ FT_TRACE4(( op1 == cf2_cmdCALLGSUBR ? " callgsubr" : " callsubr" )); - if ( charstringIndex > CF2_MAX_SUBR ) + if ( ( !font->isT1 && charstringIndex > CF2_MAX_SUBR ) || + ( font->isT1 && charstringIndex > T1_MAX_SUBRS_CALLS ) ) { /* max subr plus one for charstring */ lastError = FT_THROW( Invalid_Glyph_Format ); @@ -903,6 +991,18 @@ /* set up the new CFF region and pointer */ subrNum = cf2_stack_popInt( opStack ); + if ( font->isT1 && decoder->locals_hash ) + { + size_t* val = ft_hash_num_lookup( subrNum, + decoder->locals_hash ); + + + if ( val ) + subrNum = *val; + else + subrNum = -1; + } + switch ( op1 ) { case cf2_cmdCALLGSUBR: @@ -1060,20 +1160,13 @@ } continue; - /* these opcodes are reserved in both CFF & CFF2 */ - case cf2_escRESERVED_1: - case cf2_escRESERVED_2: - case cf2_escRESERVED_6: - case cf2_escRESERVED_7: + /* these opcodes are always reserved */ case cf2_escRESERVED_8: case cf2_escRESERVED_13: - case cf2_escRESERVED_16: - case cf2_escRESERVED_17: case cf2_escRESERVED_19: case cf2_escRESERVED_25: case cf2_escRESERVED_31: case cf2_escRESERVED_32: - case cf2_escRESERVED_33: FT_TRACE4(( " unknown op (12, %d)\n", op2 )); break; @@ -1081,9 +1174,15 @@ { if ( font->isCFF2 || op2 >= cf2_escRESERVED_38 ) FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + else if ( font->isT1 && result_cnt > 0 && op2 != cf2_escPOP ) + { + /* all operands have been transferred by previous pops */ + result_cnt = 0; + } else { - /* second switch for 2-byte operators handles just CFF */ + /* second switch for 2-byte operators handles */ + /* CFF and Type 1 */ switch ( op2 ) { @@ -1093,6 +1192,58 @@ break; + case cf2_escVSTEM3: + case cf2_escHSTEM3: + /* + * Type 1: Type 2: + * x0 dx0 x1 dx1 x2 dx2 vstem3 x dx {dxa dxb}* vstem + * y0 dy0 y1 dy1 y2 dy2 hstem3 y dy {dya dyb}* hstem + * relative to lsb point relative to zero + * + */ + { + if ( !font->isT1 ) + FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + else + { + CF2_F16Dot16 v0, v1, v2; + + FT_Bool isV = FT_BOOL( op2 == cf2_escVSTEM3 ); + + + FT_TRACE4(( isV ? " vstem3\n" + : " hstem3\n" )); + + FT_ASSERT( cf2_stack_count( opStack ) == 6 ); + + v0 = cf2_stack_getReal( opStack, 0 ); + v1 = cf2_stack_getReal( opStack, 2 ); + v2 = cf2_stack_getReal( opStack, 4 ); + + cf2_stack_setReal( + opStack, 2, + SUB_INT32( SUB_INT32( v1, v0 ), + cf2_stack_getReal( opStack, 1 ) ) ); + cf2_stack_setReal( + opStack, 4, + SUB_INT32( SUB_INT32( v2, v1 ), + cf2_stack_getReal( opStack, 3 ) ) ); + + /* add left-sidebearing correction */ + cf2_doStems( font, + opStack, + isV ? &vStemHintArray : &hStemHintArray, + width, + &haveWidth, + isV ? decoder->builder.left_bearing->x + : decoder->builder.left_bearing->y ); + + if ( decoder->width_only ) + goto exit; + } + } + break; + case cf2_escAND: { CF2_F16Dot16 arg1; @@ -1136,6 +1287,239 @@ } continue; /* do not clear the stack */ + case cf2_escSEAC: + if ( !font->isT1 ) + FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + else + { + FT_Error error2; + CF2_Int bchar_index, achar_index; + FT_Vector left_bearing, advance; + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + T1_Face face = (T1_Face)decoder->builder.face; +#endif + CF2_BufferRec component; + CF2_Fixed dummyWidth; + + CF2_Int achar = cf2_stack_popInt( opStack ); + CF2_Int bchar = cf2_stack_popInt( opStack ); + + FT_Pos ady = cf2_stack_popFixed ( opStack ); + FT_Pos adx = cf2_stack_popFixed ( opStack ); + FT_Pos asb = cf2_stack_popFixed ( opStack ); + + + FT_TRACE4(( " seac\n" )); + + if ( doingSeac ) + { + FT_ERROR(( " nested seac\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; /* nested seac */ + } + + if ( decoder->builder.metrics_only ) + { + FT_ERROR(( " unexpected seac\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; /* unexpected seac */ + } + + /* `glyph_names' is set to 0 for CID fonts which do */ + /* not include an encoding. How can we deal with */ + /* these? */ +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( decoder->glyph_names == 0 && + !face->root.internal->incremental_interface ) +#else + if ( decoder->glyph_names == 0 ) +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + { + FT_ERROR(( + "cf2_interpT2CharString: (Type 1 seac)" + " glyph names table not available in this font\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + /* seac weirdness */ + adx += decoder->builder.left_bearing->x; + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( face->root.internal->incremental_interface ) + { + /* the caller must handle the font encoding also */ + bchar_index = bchar; + achar_index = achar; + } + else +#endif + { + bchar_index = t1_lookup_glyph_by_stdcharcode_ps( + decoder, bchar ); + achar_index = t1_lookup_glyph_by_stdcharcode_ps( + decoder, achar ); + } + + if ( bchar_index < 0 || achar_index < 0 ) + { + FT_ERROR(( + "cf2_interpT2CharString: (Type 1 seac)" + " invalid seac character code arguments\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + /* if we are trying to load a composite glyph, */ + /* do not load the accent character and return */ + /* the array of subglyphs. */ + if ( decoder->builder.no_recurse ) + { + FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph; + FT_GlyphLoader loader = glyph->internal->loader; + FT_SubGlyph subg; + + + /* reallocate subglyph array if necessary */ + error2 = FT_GlyphLoader_CheckSubGlyphs( loader, 2 ); + if ( error2 ) + { + lastError = error2; /* pass FreeType error through */ + goto exit; + } + + subg = loader->current.subglyphs; + + /* subglyph 0 = base character */ + subg->index = bchar_index; + subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES | + FT_SUBGLYPH_FLAG_USE_MY_METRICS; + subg->arg1 = 0; + subg->arg2 = 0; + subg++; + + /* subglyph 1 = accent character */ + subg->index = achar_index; + subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; + subg->arg1 = (FT_Int)FIXED_TO_INT( adx - asb ); + subg->arg2 = (FT_Int)FIXED_TO_INT( ady ); + + /* set up remaining glyph fields */ + glyph->num_subglyphs = 2; + glyph->subglyphs = loader->base.subglyphs; + glyph->format = FT_GLYPH_FORMAT_COMPOSITE; + + loader->current.num_subglyphs = 2; + + goto exit; + } + + /* First load `bchar' in builder */ + /* now load the unscaled outline */ + + /* prepare loader */ + FT_GlyphLoader_Prepare( decoder->builder.loader ); + + error2 = cf2_getT1SeacComponent( decoder, + (FT_UInt)bchar_index, + &component ); + if ( error2 ) + { + lastError = error2; /* pass FreeType error through */ + goto exit; + } + cf2_interpT2CharString( font, + &component, + callbacks, + translation, + TRUE, + 0, + 0, + &dummyWidth ); + cf2_freeT1SeacComponent( decoder, &component ); + + /* save the left bearing and width of the base */ + /* character as they will be erased by the next load */ + + left_bearing = *decoder->builder.left_bearing; + advance = *decoder->builder.advance; + + decoder->builder.left_bearing->x = 0; + decoder->builder.left_bearing->y = 0; + + /* Now load `achar' on top of */ + /* the base outline */ + + error2 = cf2_getT1SeacComponent( decoder, + (FT_UInt)achar_index, + &component ); + if ( error2 ) + { + lastError = error2; /* pass FreeType error through */ + goto exit; + } + cf2_interpT2CharString( font, + &component, + callbacks, + translation, + TRUE, + adx - asb, + ady, + &dummyWidth ); + cf2_freeT1SeacComponent( decoder, &component ); + + /* restore the left side bearing and */ + /* advance width of the base character */ + + *decoder->builder.left_bearing = left_bearing; + *decoder->builder.advance = advance; + + goto exit; + } + break; + + case cf2_escSBW: + if ( !font->isT1 ) + FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + else + { + CF2_Fixed lsb_x, lsb_y; + PS_Builder* builder; + + + FT_TRACE4(( " sbw" )); + + builder = &decoder->builder; + + builder->advance->y = cf2_stack_popFixed( opStack ); + builder->advance->x = cf2_stack_popFixed( opStack ); + + lsb_y = cf2_stack_popFixed( opStack ); + lsb_x = cf2_stack_popFixed( opStack ); + + builder->left_bearing->x = + ADD_INT32( builder->left_bearing->x, lsb_x ); + builder->left_bearing->y = + ADD_INT32( builder->left_bearing->y, lsb_y ); + + haveWidth = TRUE; + + /* the `metrics_only' indicates that we only want */ + /* to compute the glyph's metrics (lsb + advance */ + /* width), not load the rest of it; so exit */ + /* immediately */ + if ( builder->metrics_only ) + goto exit; + + if ( initial_map_ready ) + { + curX = ADD_INT32( curX, lsb_x ); + curY = ADD_INT32( curY, lsb_y ); + } + } + break; + case cf2_escABS: { CF2_F16Dot16 arg; @@ -1193,11 +1577,22 @@ FT_TRACE4(( " div\n" )); - divisor = cf2_stack_popFixed( opStack ); - dividend = cf2_stack_popFixed( opStack ); + if ( font->isT1 && large_int ) + { + divisor = (CF2_F16Dot16)cf2_stack_popInt( opStack ); + dividend = (CF2_F16Dot16)cf2_stack_popInt( opStack ); + + large_int = FALSE; + } + else + { + divisor = cf2_stack_popFixed( opStack ); + dividend = cf2_stack_popFixed( opStack ); + } cf2_stack_pushFixed( opStack, FT_DivFix( dividend, divisor ) ); + } continue; /* do not clear the stack */ @@ -1232,6 +1627,534 @@ } continue; /* do not clear the stack */ + case cf2_escCALLOTHERSUBR: + if ( !font->isT1 ) + FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + else + { + CF2_Int subr_no; + CF2_Int arg_cnt; + CF2_UInt count; + CF2_UInt opIdx = 0; + + + FT_TRACE4(( " callothersubr\n" )); + + subr_no = cf2_stack_popInt( opStack ); + arg_cnt = cf2_stack_popInt( opStack ); + + /*******************************************************/ + /* */ + /* remove all operands to callothersubr from the stack */ + /* */ + /* for handled othersubrs, where we know the number of */ + /* arguments, we increase the stack by the value of */ + /* known_othersubr_result_cnt */ + /* */ + /* for unhandled othersubrs the following pops adjust */ + /* the stack pointer as necessary */ + + count = cf2_stack_count( opStack ); + FT_ASSERT( (CF2_UInt)arg_cnt <= count ); + + opIdx += count - (CF2_UInt)arg_cnt; + + known_othersubr_result_cnt = 0; + result_cnt = 0; + + /* XXX TODO: The checks to `arg_count == <whatever>' */ + /* might not be correct; an othersubr expects a */ + /* certain number of operands on the PostScript stack */ + /* (as opposed to the T1 stack) but it doesn't have to */ + /* put them there by itself; previous othersubrs might */ + /* have left the operands there if they were not */ + /* followed by an appropriate number of pops */ + /* */ + /* On the other hand, Adobe Reader 7.0.8 for Linux */ + /* doesn't accept a font that contains charstrings */ + /* like */ + /* */ + /* 100 200 2 20 callothersubr */ + /* 300 1 20 callothersubr pop */ + /* */ + /* Perhaps this is the reason why BuildCharArray */ + /* exists. */ + + switch ( subr_no ) + { + case 0: /* end flex feature */ + if ( arg_cnt != 3 ) + goto Unexpected_OtherSubr; + + if ( initial_map_ready && + ( !decoder->flex_state || + decoder->num_flex_vectors != 7 ) ) + { + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " unexpected flex end\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + /* the two `results' are popped */ + /* by the following setcurrentpoint */ + cf2_stack_pushFixed( opStack, curX ); + cf2_stack_pushFixed( opStack, curY ); + known_othersubr_result_cnt = 2; + break; + + case 1: /* start flex feature */ + if ( arg_cnt != 0 ) + goto Unexpected_OtherSubr; + + if ( !initial_map_ready ) + break; + + if ( ps_builder_check_points( &decoder->builder, 6 ) ) + goto exit; + + decoder->flex_state = 1; + decoder->num_flex_vectors = 0; + break; + + case 2: /* add flex vectors */ + { + FT_Int idx; + FT_Int idx2; + + + if ( arg_cnt != 0 ) + goto Unexpected_OtherSubr; + + if ( !initial_map_ready ) + break; + + if ( !decoder->flex_state ) + { + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " missing flex start\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + /* note that we should not add a point for */ + /* index 0; this will move our current position */ + /* to the flex point without adding any point */ + /* to the outline */ + idx = decoder->num_flex_vectors++; + if ( idx > 0 && idx < 7 ) + { + /* in malformed fonts it is possible to have */ + /* other opcodes in the middle of a flex (which */ + /* don't increase `num_flex_vectors'); we thus */ + /* have to check whether we can add a point */ + + if ( ps_builder_check_points( &decoder->builder, + 1 ) ) + { + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + /* map: 1->2 2->4 3->6 4->2 5->4 6->6 */ + idx2 = ( idx > 3 ? idx - 3 : idx ) * 2; + + flexStore[idx2 - 2] = curX; + flexStore[idx2 - 1] = curY; + + if ( idx == 3 || idx == 6 ) + cf2_glyphpath_curveTo( &glyphPath, + flexStore[0], + flexStore[1], + flexStore[2], + flexStore[3], + flexStore[4], + flexStore[5] ); + } + } + break; + + case 3: /* change hints */ + if ( arg_cnt != 1 ) + goto Unexpected_OtherSubr; + + if ( initial_map_ready ) + { + /* do not clear hints if initial hintmap */ + /* is not ready - we need to collate all */ + cf2_arrstack_clear( &vStemHintArray ); + cf2_arrstack_clear( &hStemHintArray ); + + cf2_hintmask_init( &hintMask, error ); + hintMask.isValid = FALSE; + hintMask.isNew = TRUE; + } + + known_othersubr_result_cnt = 1; + break; + + case 12: + case 13: + /* counter control hints, clear stack */ + cf2_stack_clear( opStack ); + break; + + case 14: + case 15: + case 16: + case 17: + case 18: /* multiple masters */ + { + PS_Blend blend = decoder->blend; + FT_UInt num_points, nn, mm; + CF2_UInt delta; + CF2_UInt values; + + + if ( !blend ) + { + FT_ERROR(( + "cf2_interpT2CharString:" + " unexpected multiple masters operator\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + num_points = (FT_UInt)subr_no - 13 + + ( subr_no == 18 ); + if ( arg_cnt != (FT_Int)( num_points * + blend->num_designs ) ) + { + FT_ERROR(( + "cf2_interpT2CharString:" + " incorrect number of multiple masters arguments\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + /* We want to compute */ + /* */ + /* a0*w0 + a1*w1 + ... + ak*wk */ + /* */ + /* but we only have a0, a1-a0, a2-a0, ..., ak-a0. */ + /* */ + /* However, given that w0 + w1 + ... + wk == 1, we */ + /* can rewrite it easily as */ + /* */ + /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + ... + (ak-a0)*wk */ + /* */ + /* where k == num_designs-1. */ + /* */ + /* I guess that's why it's written in this `compact' */ + /* form. */ + /* */ + delta = opIdx + num_points; + values = opIdx; + for ( nn = 0; nn < num_points; nn++ ) + { + CF2_Fixed tmp = cf2_stack_getReal( opStack, + values ); + + + for ( mm = 1; mm < blend->num_designs; mm++ ) + tmp = ADD_INT32( tmp, + FT_MulFix( + cf2_stack_getReal( opStack, + delta++ ), + blend->weight_vector[mm] ) ); + + cf2_stack_setReal( opStack, values++, tmp ); + } + cf2_stack_pop( opStack, + (CF2_UInt)arg_cnt - num_points ); + + known_othersubr_result_cnt = (FT_Int)num_points; + break; + } + + case 19: + /* <idx> 1 19 callothersubr */ + /* ==> replace elements starting from index */ + /* cvi( <idx> ) of BuildCharArray with */ + /* WeightVector */ + { + FT_Int idx; + PS_Blend blend = decoder->blend; + + + if ( arg_cnt != 1 || !blend ) + goto Unexpected_OtherSubr; + + idx = cf2_stack_popInt( opStack ); + + if ( idx < 0 || + (FT_UInt)idx + blend->num_designs > + decoder->len_buildchar ) + goto Unexpected_OtherSubr; + + ft_memcpy( &decoder->buildchar[idx], + blend->weight_vector, + blend->num_designs * + sizeof ( blend->weight_vector[0] ) ); + } + break; + + case 20: + /* <arg1> <arg2> 2 20 callothersubr pop */ + /* ==> push <arg1> + <arg2> onto T1 stack */ + { + CF2_F16Dot16 summand1; + CF2_F16Dot16 summand2; + + + if ( arg_cnt != 2 ) + goto Unexpected_OtherSubr; + + summand2 = cf2_stack_popFixed( opStack ); + summand1 = cf2_stack_popFixed( opStack ); + + cf2_stack_pushFixed( opStack, + ADD_INT32( summand1, + summand2 ) ); + known_othersubr_result_cnt = 1; + } + break; + + case 21: + /* <arg1> <arg2> 2 21 callothersubr pop */ + /* ==> push <arg1> - <arg2> onto T1 stack */ + { + CF2_F16Dot16 minuend; + CF2_F16Dot16 subtrahend; + + + if ( arg_cnt != 2 ) + goto Unexpected_OtherSubr; + + subtrahend = cf2_stack_popFixed( opStack ); + minuend = cf2_stack_popFixed( opStack ); + + cf2_stack_pushFixed( opStack, + SUB_INT32( minuend, + subtrahend ) ); + known_othersubr_result_cnt = 1; + } + break; + + case 22: + /* <arg1> <arg2> 2 22 callothersubr pop */ + /* ==> push <arg1> * <arg2> onto T1 stack */ + { + CF2_F16Dot16 factor1; + CF2_F16Dot16 factor2; + + + if ( arg_cnt != 2 ) + goto Unexpected_OtherSubr; + + factor2 = cf2_stack_popFixed( opStack ); + factor1 = cf2_stack_popFixed( opStack ); + + cf2_stack_pushFixed( opStack, + FT_MulFix( factor1, factor2 ) ); + known_othersubr_result_cnt = 1; + } + break; + + case 23: + /* <arg1> <arg2> 2 23 callothersubr pop */ + /* ==> push <arg1> / <arg2> onto T1 stack */ + { + CF2_F16Dot16 dividend; + CF2_F16Dot16 divisor; + + + if ( arg_cnt != 2 ) + goto Unexpected_OtherSubr; + + divisor = cf2_stack_popFixed( opStack ); + dividend = cf2_stack_popFixed( opStack ); + + if ( divisor == 0 ) + goto Unexpected_OtherSubr; + + cf2_stack_pushFixed( opStack, + FT_DivFix( dividend, + divisor ) ); + known_othersubr_result_cnt = 1; + } + break; + + case 24: + /* <val> <idx> 2 24 callothersubr */ + /* ==> set BuildCharArray[cvi( <idx> )] = <val> */ + { + CF2_Int idx; + PS_Blend blend = decoder->blend; + + + if ( arg_cnt != 2 || !blend ) + goto Unexpected_OtherSubr; + + idx = cf2_stack_popInt( opStack ); + + if ( idx < 0 || + (FT_UInt)idx >= decoder->len_buildchar ) + goto Unexpected_OtherSubr; + + decoder->buildchar[idx] = + cf2_stack_popFixed( opStack ); + } + break; + + case 25: + /* <idx> 1 25 callothersubr pop */ + /* ==> push BuildCharArray[cvi( idx )] */ + /* onto T1 stack */ + { + CF2_Int idx; + PS_Blend blend = decoder->blend; + + + if ( arg_cnt != 1 || !blend ) + goto Unexpected_OtherSubr; + + idx = cf2_stack_popInt( opStack ); + + if ( idx < 0 || + (FT_UInt)idx >= decoder->len_buildchar ) + goto Unexpected_OtherSubr; + + cf2_stack_pushFixed( opStack, + decoder->buildchar[idx] ); + known_othersubr_result_cnt = 1; + } + break; + +#if 0 + case 26: + /* <val> mark <idx> */ + /* ==> set BuildCharArray[cvi( <idx> )] = <val>, */ + /* leave mark on T1 stack */ + /* <val> <idx> */ + /* ==> set BuildCharArray[cvi( <idx> )] = <val> */ + XXX which routine has left its mark on the + XXX (PostScript) stack?; + break; +#endif + + case 27: + /* <res1> <res2> <val1> <val2> 4 27 callothersubr pop */ + /* ==> push <res1> onto T1 stack if <val1> <= <val2>, */ + /* otherwise push <res2> */ + { + CF2_F16Dot16 arg1; + CF2_F16Dot16 arg2; + CF2_F16Dot16 cond1; + CF2_F16Dot16 cond2; + + + if ( arg_cnt != 4 ) + goto Unexpected_OtherSubr; + + cond2 = cf2_stack_popFixed( opStack ); + cond1 = cf2_stack_popFixed( opStack ); + arg2 = cf2_stack_popFixed( opStack ); + arg1 = cf2_stack_popFixed( opStack ); + + cf2_stack_pushFixed( opStack, + cond1 <= cond2 ? arg1 : arg2 ); + known_othersubr_result_cnt = 1; + } + break; + + case 28: + /* 0 28 callothersubr pop */ + /* ==> push random value from interval [0, 1) */ + /* onto stack */ + { + CF2_F16Dot16 r; + + + if ( arg_cnt != 0 ) + goto Unexpected_OtherSubr; + + /* only use the lower 16 bits of `random' */ + /* to generate a number in the range (0;1] */ + r = (CF2_F16Dot16) + ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); + + decoder->current_subfont->random = + cff_random( decoder->current_subfont->random ); + + cf2_stack_pushFixed( opStack, r ); + known_othersubr_result_cnt = 1; + } + break; + + default: + if ( arg_cnt >= 0 && subr_no >= 0 ) + { + FT_Int i; + + + FT_ERROR(( + "cf2_interpT2CharString (Type 1 mode):" + " unknown othersubr [%d %d], wish me luck\n", + arg_cnt, subr_no )); + + /* store the unused args */ + /* for this unhandled OtherSubr */ + + if ( arg_cnt > PS_STORAGE_SIZE ) + arg_cnt = PS_STORAGE_SIZE; + result_cnt = arg_cnt; + + for ( i = 1; i <= arg_cnt; i++ ) + results[result_cnt - i] = + cf2_stack_popFixed( opStack ); + + break; + } + /* fall through */ + + Unexpected_OtherSubr: + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " invalid othersubr [%d %d]\n", + arg_cnt, subr_no )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + } + continue; /* do not clear the stack */ + + case cf2_escPOP: + if ( !font->isT1 ) + FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + else + { + FT_TRACE4(( " pop" )); + + if ( known_othersubr_result_cnt > 0 ) + { + known_othersubr_result_cnt--; + /* ignore, we pushed the operands ourselves */ + continue; + } + + if ( result_cnt == 0 ) + { + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " no more operands for othersubr\n" )); + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + result_cnt--; + cf2_stack_pushFixed( opStack, results[result_cnt] ); + } + continue; /* do not clear the stack */ + case cf2_escDROP: FT_TRACE4(( " drop\n" )); @@ -1433,6 +2356,48 @@ } continue; /* do not clear the stack */ + case cf2_escSETCURRENTPT: + if ( !font->isT1 ) + FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + else + { + FT_TRACE4(( " setcurrentpoint" )); + + if ( !initial_map_ready ) + break; + + /* From the T1 specification, section 6.4: */ + /* */ + /* The setcurrentpoint command is used only in */ + /* conjunction with results from OtherSubrs */ + /* procedures. */ + + /* known_othersubr_result_cnt != 0 is already handled */ + /* above. */ + + /* Note, however, that both Ghostscript and Adobe */ + /* Distiller handle this situation by silently */ + /* ignoring the inappropriate `setcurrentpoint' */ + /* instruction. So we do the same. */ +#if 0 + + if ( decoder->flex_state != 1 ) + { + FT_ERROR(( "cf2_interpT2CharString:" + " unexpected `setcurrentpoint'\n" )); + goto Syntax_Error; + } + else + ... +#endif + + curY = cf2_stack_popFixed( opStack ); + curX = cf2_stack_popFixed( opStack ); + + decoder->flex_state = 0; + } + break; + } /* end of 2nd switch checking op2 */ } } @@ -1441,9 +2406,80 @@ break; + case cf2_cmdHSBW: + if ( !font->isT1 ) + FT_TRACE4(( " unknown op (%d)\n", op1 )); + else + { + CF2_Fixed lsb_x; + PS_Builder* builder; + + + FT_TRACE4(( " hsbw" )); + + builder = &decoder->builder; + + builder->advance->x = cf2_stack_popFixed( opStack ); + builder->advance->y = 0; + + lsb_x = cf2_stack_popFixed( opStack ); + + builder->left_bearing->x = ADD_INT32( builder->left_bearing->x, + lsb_x ); + + haveWidth = TRUE; + + /* the `metrics_only' indicates that we only want to compute */ + /* the glyph's metrics (lsb + advance width), not load the */ + /* rest of it; so exit immediately */ + if ( builder->metrics_only ) + goto exit; + + if ( initial_map_ready ) + curX = ADD_INT32( curX, lsb_x ); + } + break; + case cf2_cmdENDCHAR: FT_TRACE4(( " endchar\n" )); + if ( font->isT1 && !initial_map_ready ) + { + FT_TRACE5(( "cf2_interpT2CharString (Type 1 mode): " + "Build initial hintmap, rewinding...\n" )); + + /* trigger initial hintmap build */ + cf2_glyphpath_moveTo( &glyphPath, curX, curY ); + + initial_map_ready = TRUE; + + /* change hints routine - clear for rewind */ + cf2_arrstack_clear( &vStemHintArray ); + cf2_arrstack_clear( &hStemHintArray ); + + cf2_hintmask_init( &hintMask, error ); + hintMask.isValid = FALSE; + hintMask.isNew = TRUE; + + /* rewind charstring */ + /* some charstrings use endchar from a final subroutine call */ + /* without returning, detect these and exit to the top level */ + /* charstring */ + while ( charstringIndex > 0 ) + { + FT_TRACE4(( " return (leaving level %d)\n", charstringIndex )); + + /* restore position in previous charstring */ + charstring = (CF2_Buffer) + cf2_arrstack_getPointer( + &subrStack, + (CF2_UInt)--charstringIndex ); + } + charstring->ptr = charstring->start; + + break; + } + if ( cf2_stack_count( opStack ) == 1 || cf2_stack_count( opStack ) == 5 ) { @@ -1455,14 +2491,15 @@ /* width is defined or default after this */ haveWidth = TRUE; - if ( font->decoder->width_only ) + if ( decoder->width_only ) goto exit; /* close path if still open */ cf2_glyphpath_closeOpenPath( &glyphPath ); - /* disable seac for CFF2 (charstring ending with args on stack) */ - if ( !font->isCFF2 && cf2_stack_count( opStack ) > 1 ) + /* disable seac for CFF2 and Type1 */ + /* (charstring ending with args on stack) */ + if ( !font->isCFF2 && !font->isT1 && cf2_stack_count( opStack ) > 1 ) { /* must be either 4 or 5 -- */ /* this is a (deprecated) implied `seac' operator */ @@ -1543,7 +2580,7 @@ &haveWidth, 0 ); - if ( font->decoder->width_only ) + if ( decoder->width_only ) goto exit; if ( op1 == cf2_cmdHINTMASK ) @@ -1596,6 +2633,10 @@ case cf2_cmdRMOVETO: FT_TRACE4(( " rmoveto\n" )); + if ( font->isT1 && !decoder->flex_state && !haveWidth ) + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " No width. Use hsbw/sbw as first op\n" )); + if ( cf2_stack_count( opStack ) > 2 && !haveWidth ) *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), nominalWidthX ); @@ -1603,19 +2644,24 @@ /* width is defined or default after this */ haveWidth = TRUE; - if ( font->decoder->width_only ) + if ( decoder->width_only ) goto exit; curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) ); curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) ); - cf2_glyphpath_moveTo( &glyphPath, curX, curY ); + if ( !decoder->flex_state ) + cf2_glyphpath_moveTo( &glyphPath, curX, curY ); break; case cf2_cmdHMOVETO: FT_TRACE4(( " hmoveto\n" )); + if ( font->isT1 && !decoder->flex_state && !haveWidth ) + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " No width. Use hsbw/sbw as first op\n" )); + if ( cf2_stack_count( opStack ) > 1 && !haveWidth ) *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), nominalWidthX ); @@ -1623,7 +2669,7 @@ /* width is defined or default after this */ haveWidth = TRUE; - if ( font->decoder->width_only ) + if ( decoder->width_only ) goto exit; curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) ); @@ -1919,9 +2965,42 @@ ( byte3 << 8 ) | byte4 ); - FT_TRACE4(( " %.5f", v / 65536.0 )); + /* + * For Type 1: + * + * According to the specification, values > 32000 or < -32000 + * must be followed by a `div' operator to make the result be + * in the range [-32000;32000]. We expect that the second + * argument of `div' is not a large number. Additionally, we + * don't handle stuff like `<large1> <large2> <num> div <num> + * div' or <large1> <large2> <num> div div'. This is probably + * not allowed anyway. + * + * <large> <num> <num>+ div is not checked but should not be + * allowed as the large value remains untouched. + * + */ + if ( font->isT1 ) + { + if ( v > 32000 || v < -32000 ) + { + if ( large_int ) + FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):" + " no `div' after large integer\n" )); + else + large_int = TRUE; + } - cf2_stack_pushFixed( opStack, v ); + FT_TRACE4(( " %d", v )); + + cf2_stack_pushInt( opStack, (CF2_Int)v ); + } + else + { + FT_TRACE4(( " %.5fF", v / 65536.0 )); + + cf2_stack_pushFixed( opStack, v ); + } } } continue; /* don't clear stack */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psintrp.h index ec030e89444..4790aaa302a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psintrp.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2font.h */ +/* psintrp.h */ /* */ /* Adobe's CFF Interpreter (specification). */ /* */ @@ -36,12 +36,12 @@ /***************************************************************************/ -#ifndef CF2INTRP_H_ -#define CF2INTRP_H_ +#ifndef PSINTRP_H_ +#define PSINTRP_H_ -#include "cf2ft.h" -#include "cf2hints.h" +#include "psft.h" +#include "pshints.h" FT_BEGIN_HEADER @@ -77,7 +77,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2INTRP_H_ */ +#endif /* PSINTRP_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/psobjs.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psobjs.c index f04edea411a..f54bc7e4164 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/psobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psobjs.c @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,11 +20,13 @@ #include FT_INTERNAL_POSTSCRIPT_AUX_H #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_CALC_H +#include FT_DRIVER_H #include "psobjs.h" #include "psconv.h" #include "psauxerr.h" +#include "psauxmod.h" /*************************************************************************/ @@ -1761,11 +1763,748 @@ /*************************************************************************/ /*************************************************************************/ /***** *****/ + /***** CFF BUILDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* cff_builder_init */ + /* */ + /* <Description> */ + /* Initializes a given glyph builder. */ + /* */ + /* <InOut> */ + /* builder :: A pointer to the glyph builder to initialize. */ + /* */ + /* <Input> */ + /* face :: The current face object. */ + /* */ + /* size :: The current size object. */ + /* */ + /* glyph :: The current glyph object. */ + /* */ + /* hinting :: Whether hinting is active. */ + /* */ + FT_LOCAL_DEF( void ) + cff_builder_init( CFF_Builder* builder, + TT_Face face, + CFF_Size size, + CFF_GlyphSlot glyph, + FT_Bool hinting ) + { + builder->path_begun = 0; + builder->load_points = 1; + + builder->face = face; + builder->glyph = glyph; + builder->memory = face->root.memory; + + if ( glyph ) + { + FT_GlyphLoader loader = glyph->root.internal->loader; + + + builder->loader = loader; + builder->base = &loader->base.outline; + builder->current = &loader->current.outline; + FT_GlyphLoader_Rewind( loader ); + + builder->hints_globals = NULL; + builder->hints_funcs = NULL; + + if ( hinting && size ) + { + FT_Size ftsize = FT_SIZE( size ); + CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data; + + if ( internal ) + { + builder->hints_globals = (void *)internal->topfont; + builder->hints_funcs = glyph->root.internal->glyph_hints; + } + } + } + + builder->pos_x = 0; + builder->pos_y = 0; + + builder->left_bearing.x = 0; + builder->left_bearing.y = 0; + builder->advance.x = 0; + builder->advance.y = 0; + + builder->funcs = cff_builder_funcs; + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* cff_builder_done */ + /* */ + /* <Description> */ + /* Finalizes a given glyph builder. Its contents can still be used */ + /* after the call, but the function saves important information */ + /* within the corresponding glyph slot. */ + /* */ + /* <Input> */ + /* builder :: A pointer to the glyph builder to finalize. */ + /* */ + FT_LOCAL_DEF( void ) + cff_builder_done( CFF_Builder* builder ) + { + CFF_GlyphSlot glyph = builder->glyph; + + + if ( glyph ) + glyph->root.outline = *builder->base; + } + + + /* check that there is enough space for `count' more points */ + FT_LOCAL_DEF( FT_Error ) + cff_check_points( CFF_Builder* builder, + FT_Int count ) + { + return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 ); + } + + + /* add a new point, do not check space */ + FT_LOCAL_DEF( void ) + cff_builder_add_point( CFF_Builder* builder, + FT_Pos x, + FT_Pos y, + FT_Byte flag ) + { + FT_Outline* outline = builder->current; + + + if ( builder->load_points ) + { + FT_Vector* point = outline->points + outline->n_points; + FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face ); + + + if ( driver->hinting_engine == FT_HINTING_FREETYPE ) + { + point->x = x >> 16; + point->y = y >> 16; + } + else +#endif + { + /* cf2_decoder_parse_charstrings uses 16.16 coordinates */ + point->x = x >> 10; + point->y = y >> 10; + } + *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); + } + + outline->n_points++; + } + + + /* check space for a new on-curve point, then add it */ + FT_LOCAL_DEF( FT_Error ) + cff_builder_add_point1( CFF_Builder* builder, + FT_Pos x, + FT_Pos y ) + { + FT_Error error; + + + error = cff_check_points( builder, 1 ); + if ( !error ) + cff_builder_add_point( builder, x, y, 1 ); + + return error; + } + + + /* check space for a new contour, then add it */ + FT_LOCAL_DEF( FT_Error ) + cff_builder_add_contour( CFF_Builder* builder ) + { + FT_Outline* outline = builder->current; + FT_Error error; + + + if ( !builder->load_points ) + { + outline->n_contours++; + return FT_Err_Ok; + } + + error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); + if ( !error ) + { + if ( outline->n_contours > 0 ) + outline->contours[outline->n_contours - 1] = + (short)( outline->n_points - 1 ); + + outline->n_contours++; + } + + return error; + } + + + /* if a path was begun, add its first on-curve point */ + FT_LOCAL_DEF( FT_Error ) + cff_builder_start_point( CFF_Builder* builder, + FT_Pos x, + FT_Pos y ) + { + FT_Error error = FT_Err_Ok; + + + /* test whether we are building a new contour */ + if ( !builder->path_begun ) + { + builder->path_begun = 1; + error = cff_builder_add_contour( builder ); + if ( !error ) + error = cff_builder_add_point1( builder, x, y ); + } + + return error; + } + + + /* close the current contour */ + FT_LOCAL_DEF( void ) + cff_builder_close_contour( CFF_Builder* builder ) + { + FT_Outline* outline = builder->current; + FT_Int first; + + + if ( !outline ) + return; + + first = outline->n_contours <= 1 + ? 0 : outline->contours[outline->n_contours - 2] + 1; + + /* We must not include the last point in the path if it */ + /* is located on the first point. */ + if ( outline->n_points > 1 ) + { + FT_Vector* p1 = outline->points + first; + FT_Vector* p2 = outline->points + outline->n_points - 1; + FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1; + + + /* `delete' last point only if it coincides with the first */ + /* point and if it is not a control point (which can happen). */ + if ( p1->x == p2->x && p1->y == p2->y ) + if ( *control == FT_CURVE_TAG_ON ) + outline->n_points--; + } + + if ( outline->n_contours > 0 ) + { + /* Don't add contours only consisting of one point, i.e., */ + /* check whether begin point and last point are the same. */ + if ( first == outline->n_points - 1 ) + { + outline->n_contours--; + outline->n_points--; + } + else + outline->contours[outline->n_contours - 1] = + (short)( outline->n_points - 1 ); + } + } + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** PS BUILDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Function> */ + /* ps_builder_init */ + /* */ + /* <Description> */ + /* Initializes a given glyph builder. */ + /* */ + /* <InOut> */ + /* builder :: A pointer to the glyph builder to initialize. */ + /* */ + /* <Input> */ + /* face :: The current face object. */ + /* */ + /* size :: The current size object. */ + /* */ + /* glyph :: The current glyph object. */ + /* */ + /* hinting :: Whether hinting should be applied. */ + /* */ + FT_LOCAL_DEF( void ) + ps_builder_init( PS_Builder* ps_builder, + void* builder, + FT_Bool is_t1 ) + { + FT_ZERO( ps_builder ); + + if ( is_t1 ) + { + T1_Builder t1builder = (T1_Builder)builder; + + + ps_builder->memory = t1builder->memory; + ps_builder->face = (FT_Face)t1builder->face; + ps_builder->glyph = (CFF_GlyphSlot)t1builder->glyph; + ps_builder->loader = t1builder->loader; + ps_builder->base = t1builder->base; + ps_builder->current = t1builder->current; + + ps_builder->pos_x = &t1builder->pos_x; + ps_builder->pos_y = &t1builder->pos_y; + + ps_builder->left_bearing = &t1builder->left_bearing; + ps_builder->advance = &t1builder->advance; + + ps_builder->bbox = &t1builder->bbox; + ps_builder->path_begun = 0; + ps_builder->load_points = t1builder->load_points; + ps_builder->no_recurse = t1builder->no_recurse; + + ps_builder->metrics_only = t1builder->metrics_only; + } + else + { + CFF_Builder* cffbuilder = (CFF_Builder*)builder; + + + ps_builder->memory = cffbuilder->memory; + ps_builder->face = (FT_Face)cffbuilder->face; + ps_builder->glyph = cffbuilder->glyph; + ps_builder->loader = cffbuilder->loader; + ps_builder->base = cffbuilder->base; + ps_builder->current = cffbuilder->current; + + ps_builder->pos_x = &cffbuilder->pos_x; + ps_builder->pos_y = &cffbuilder->pos_y; + + ps_builder->left_bearing = &cffbuilder->left_bearing; + ps_builder->advance = &cffbuilder->advance; + + ps_builder->bbox = &cffbuilder->bbox; + ps_builder->path_begun = cffbuilder->path_begun; + ps_builder->load_points = cffbuilder->load_points; + ps_builder->no_recurse = cffbuilder->no_recurse; + + ps_builder->metrics_only = cffbuilder->metrics_only; + } + + ps_builder->is_t1 = is_t1; + ps_builder->funcs = ps_builder_funcs; + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* ps_builder_done */ + /* */ + /* <Description> */ + /* Finalizes a given glyph builder. Its contents can still be used */ + /* after the call, but the function saves important information */ + /* within the corresponding glyph slot. */ + /* */ + /* <Input> */ + /* builder :: A pointer to the glyph builder to finalize. */ + /* */ + FT_LOCAL_DEF( void ) + ps_builder_done( PS_Builder* builder ) + { + CFF_GlyphSlot glyph = builder->glyph; + + + if ( glyph ) + glyph->root.outline = *builder->base; + } + + + /* check that there is enough space for `count' more points */ + FT_LOCAL_DEF( FT_Error ) + ps_builder_check_points( PS_Builder* builder, + FT_Int count ) + { + return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 ); + } + + + /* add a new point, do not check space */ + FT_LOCAL_DEF( void ) + ps_builder_add_point( PS_Builder* builder, + FT_Pos x, + FT_Pos y, + FT_Byte flag ) + { + FT_Outline* outline = builder->current; + + + if ( builder->load_points ) + { + FT_Vector* point = outline->points + outline->n_points; + FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face ); + + + if ( !builder->is_t1 && + driver->hinting_engine == FT_HINTING_FREETYPE ) + { + point->x = x >> 16; + point->y = y >> 16; + } + else +#endif +#ifdef T1_CONFIG_OPTION_OLD_ENGINE +#ifndef CFF_CONFIG_OPTION_OLD_ENGINE + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face ); +#endif + if ( builder->is_t1 && + driver->hinting_engine == FT_HINTING_FREETYPE ) + { + point->x = FIXED_TO_INT( x ); + point->y = FIXED_TO_INT( y ); + } + else +#endif + { + /* cf2_decoder_parse_charstrings uses 16.16 coordinates */ + point->x = x >> 10; + point->y = y >> 10; + } + *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); + } + outline->n_points++; + } + + + /* check space for a new on-curve point, then add it */ + FT_LOCAL_DEF( FT_Error ) + ps_builder_add_point1( PS_Builder* builder, + FT_Pos x, + FT_Pos y ) + { + FT_Error error; + + + error = ps_builder_check_points( builder, 1 ); + if ( !error ) + ps_builder_add_point( builder, x, y, 1 ); + + return error; + } + + + /* check space for a new contour, then add it */ + FT_LOCAL_DEF( FT_Error ) + ps_builder_add_contour( PS_Builder* builder ) + { + FT_Outline* outline = builder->current; + FT_Error error; + + + /* this might happen in invalid fonts */ + if ( !outline ) + { + FT_ERROR(( "ps_builder_add_contour: no outline to add points to\n" )); + return FT_THROW( Invalid_File_Format ); + } + + if ( !builder->load_points ) + { + outline->n_contours++; + return FT_Err_Ok; + } + + error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); + if ( !error ) + { + if ( outline->n_contours > 0 ) + outline->contours[outline->n_contours - 1] = + (short)( outline->n_points - 1 ); + + outline->n_contours++; + } + + return error; + } + + + /* if a path was begun, add its first on-curve point */ + FT_LOCAL_DEF( FT_Error ) + ps_builder_start_point( PS_Builder* builder, + FT_Pos x, + FT_Pos y ) + { + FT_Error error = FT_Err_Ok; + + + /* test whether we are building a new contour */ + if ( !builder->path_begun ) + { + builder->path_begun = 1; + error = ps_builder_add_contour( builder ); + if ( !error ) + error = ps_builder_add_point1( builder, x, y ); + } + + return error; + } + + + /* close the current contour */ + FT_LOCAL_DEF( void ) + ps_builder_close_contour( PS_Builder* builder ) + { + FT_Outline* outline = builder->current; + FT_Int first; + + + if ( !outline ) + return; + + first = outline->n_contours <= 1 + ? 0 : outline->contours[outline->n_contours - 2] + 1; + + /* in malformed fonts it can happen that a contour was started */ + /* but no points were added */ + if ( outline->n_contours && first == outline->n_points ) + { + outline->n_contours--; + return; + } + + /* We must not include the last point in the path if it */ + /* is located on the first point. */ + if ( outline->n_points > 1 ) + { + FT_Vector* p1 = outline->points + first; + FT_Vector* p2 = outline->points + outline->n_points - 1; + FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1; + + + /* `delete' last point only if it coincides with the first */ + /* point and it is not a control point (which can happen). */ + if ( p1->x == p2->x && p1->y == p2->y ) + if ( *control == FT_CURVE_TAG_ON ) + outline->n_points--; + } + + if ( outline->n_contours > 0 ) + { + /* Don't add contours only consisting of one point, i.e., */ + /* check whether the first and the last point is the same. */ + if ( first == outline->n_points - 1 ) + { + outline->n_contours--; + outline->n_points--; + } + else + outline->contours[outline->n_contours - 1] = + (short)( outline->n_points - 1 ); + } + } + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ /***** OTHER *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Function> */ + /* ps_decoder_init */ + /* */ + /* <Description> */ + /* Creates a wrapper decoder for use in the combined */ + /* Type 1 / CFF interpreter. */ + /* */ + /* <InOut> */ + /* ps_decoder :: A pointer to the decoder to initialize. */ + /* */ + /* <Input> */ + /* decoder :: A pointer to the original decoder. */ + /* */ + /* is_t1 :: Flag indicating Type 1 or CFF */ + /* */ + FT_LOCAL_DEF( void ) + ps_decoder_init( PS_Decoder* ps_decoder, + void* decoder, + FT_Bool is_t1 ) + { + FT_ZERO( ps_decoder ); + + if ( is_t1 ) + { + T1_Decoder t1_decoder = (T1_Decoder)decoder; + + + ps_builder_init( &ps_decoder->builder, + &t1_decoder->builder, + is_t1 ); + + ps_decoder->cf2_instance = &t1_decoder->cf2_instance; + ps_decoder->psnames = t1_decoder->psnames; + + ps_decoder->num_glyphs = t1_decoder->num_glyphs; + ps_decoder->glyph_names = t1_decoder->glyph_names; + ps_decoder->hint_mode = t1_decoder->hint_mode; + ps_decoder->blend = t1_decoder->blend; + + ps_decoder->num_locals = (FT_UInt)t1_decoder->num_subrs; + ps_decoder->locals = t1_decoder->subrs; + ps_decoder->locals_len = t1_decoder->subrs_len; + ps_decoder->locals_hash = t1_decoder->subrs_hash; + + ps_decoder->buildchar = t1_decoder->buildchar; + ps_decoder->len_buildchar = t1_decoder->len_buildchar; + + ps_decoder->lenIV = t1_decoder->lenIV; + } + else + { + CFF_Decoder* cff_decoder = (CFF_Decoder*)decoder; + + + ps_builder_init( &ps_decoder->builder, + &cff_decoder->builder, + is_t1 ); + + ps_decoder->cff = cff_decoder->cff; + ps_decoder->cf2_instance = &cff_decoder->cff->cf2_instance; + ps_decoder->current_subfont = cff_decoder->current_subfont; + + ps_decoder->num_globals = cff_decoder->num_globals; + ps_decoder->globals = cff_decoder->globals; + ps_decoder->globals_bias = cff_decoder->globals_bias; + ps_decoder->num_locals = cff_decoder->num_locals; + ps_decoder->locals = cff_decoder->locals; + ps_decoder->locals_bias = cff_decoder->locals_bias; + + ps_decoder->glyph_width = &cff_decoder->glyph_width; + ps_decoder->width_only = cff_decoder->width_only; + + ps_decoder->hint_mode = cff_decoder->hint_mode; + + ps_decoder->get_glyph_callback = cff_decoder->get_glyph_callback; + ps_decoder->free_glyph_callback = cff_decoder->free_glyph_callback; + } + } + + + /* Synthesize a SubFont object for Type 1 fonts, for use in the */ + /* new interpreter to access Private dict data. */ + FT_LOCAL_DEF( void ) + t1_make_subfont( FT_Face face, + PS_Private priv, + CFF_SubFont subfont ) + { + CFF_Private cpriv = &subfont->private_dict; + FT_UInt n, count; + + + FT_ZERO( subfont ); + FT_ZERO( cpriv ); + + count = cpriv->num_blue_values = priv->num_blue_values; + for ( n = 0; n < count; n++ ) + cpriv->blue_values[n] = (FT_Pos)priv->blue_values[n]; + + count = cpriv->num_other_blues = priv->num_other_blues; + for ( n = 0; n < count; n++ ) + cpriv->other_blues[n] = (FT_Pos)priv->other_blues[n]; + + count = cpriv->num_family_blues = priv->num_family_blues; + for ( n = 0; n < count; n++ ) + cpriv->family_blues[n] = (FT_Pos)priv->family_blues[n]; + + count = cpriv->num_family_other_blues = priv->num_family_other_blues; + for ( n = 0; n < count; n++ ) + cpriv->family_other_blues[n] = (FT_Pos)priv->family_other_blues[n]; + + cpriv->blue_scale = priv->blue_scale; + cpriv->blue_shift = (FT_Pos)priv->blue_shift; + cpriv->blue_fuzz = (FT_Pos)priv->blue_fuzz; + + cpriv->standard_width = (FT_Pos)priv->standard_width[0]; + cpriv->standard_height = (FT_Pos)priv->standard_height[0]; + + count = cpriv->num_snap_widths = priv->num_snap_widths; + for ( n = 0; n < count; n++ ) + cpriv->snap_widths[n] = (FT_Pos)priv->snap_widths[n]; + + count = cpriv->num_snap_heights = priv->num_snap_heights; + for ( n = 0; n < count; n++ ) + cpriv->snap_heights[n] = (FT_Pos)priv->snap_heights[n]; + + cpriv->force_bold = priv->force_bold; + cpriv->lenIV = priv->lenIV; + cpriv->language_group = priv->language_group; + cpriv->expansion_factor = priv->expansion_factor; + + cpriv->subfont = subfont; + + + /* Initialize the random number generator. */ + if ( face->internal->random_seed != -1 ) + { + /* If we have a face-specific seed, use it. */ + /* If non-zero, update it to a positive value. */ + subfont->random = (FT_UInt32)face->internal->random_seed; + if ( face->internal->random_seed ) + { + do + { + face->internal->random_seed = (FT_Int32)cff_random( + (FT_UInt32)face->internal->random_seed ); + + } while ( face->internal->random_seed < 0 ); + } + } + if ( !subfont->random ) + { + FT_UInt32 seed; + + + /* compute random seed from some memory addresses */ + seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^ + (FT_Offset)(char*)&face ^ + (FT_Offset)(char*)&subfont ); + seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 ); + if ( seed == 0 ) + seed = 0x7384; + + subfont->random = seed; + } + } + + FT_LOCAL_DEF( void ) t1_decrypt( FT_Byte* buffer, FT_Offset length, @@ -1779,4 +2518,16 @@ } + FT_LOCAL_DEF( FT_UInt32 ) + cff_random( FT_UInt32 r ) + { + /* a 32bit version of the `xorshift' algorithm */ + r ^= r << 13; + r ^= r >> 17; + r ^= r << 5; + + return r; + } + + /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/psobjs.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psobjs.h index 202e5b24166..8e0fe5fa4c0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/psobjs.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psobjs.h @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,6 +22,7 @@ #include <ft2build.h> #include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H FT_BEGIN_HEADER @@ -193,17 +194,117 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ /***** *****/ + /***** CFF BUILDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + FT_LOCAL( void ) + cff_builder_init( CFF_Builder* builder, + TT_Face face, + CFF_Size size, + CFF_GlyphSlot glyph, + FT_Bool hinting ); + + FT_LOCAL( void ) + cff_builder_done( CFF_Builder* builder ); + + FT_LOCAL( FT_Error ) + cff_check_points( CFF_Builder* builder, + FT_Int count ); + + FT_LOCAL( void ) + cff_builder_add_point( CFF_Builder* builder, + FT_Pos x, + FT_Pos y, + FT_Byte flag ); + FT_LOCAL( FT_Error ) + cff_builder_add_point1( CFF_Builder* builder, + FT_Pos x, + FT_Pos y ); + FT_LOCAL( FT_Error ) + cff_builder_start_point( CFF_Builder* builder, + FT_Pos x, + FT_Pos y ); + FT_LOCAL( void ) + cff_builder_close_contour( CFF_Builder* builder ); + + FT_LOCAL( FT_Error ) + cff_builder_add_contour( CFF_Builder* builder ); + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** PS BUILDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + FT_LOCAL( void ) + ps_builder_init( PS_Builder* ps_builder, + void* builder, + FT_Bool is_t1 ); + + + FT_LOCAL( void ) + ps_builder_done( PS_Builder* builder ); + + FT_LOCAL( FT_Error ) + ps_builder_check_points( PS_Builder* builder, + FT_Int count ); + + FT_LOCAL( void ) + ps_builder_add_point( PS_Builder* builder, + FT_Pos x, + FT_Pos y, + FT_Byte flag ); + + FT_LOCAL( FT_Error ) + ps_builder_add_point1( PS_Builder* builder, + FT_Pos x, + FT_Pos y ); + + FT_LOCAL( FT_Error ) + ps_builder_add_contour( PS_Builder* builder ); + + FT_LOCAL( FT_Error ) + ps_builder_start_point( PS_Builder* builder, + FT_Pos x, + FT_Pos y ); + + FT_LOCAL( void ) + ps_builder_close_contour( PS_Builder* builder ); + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ /***** OTHER *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_LOCAL( void ) + ps_decoder_init( PS_Decoder* ps_decoder, + void* decoder, + FT_Bool is_t1 ); + + FT_LOCAL( void ) + t1_make_subfont( FT_Face face, + PS_Private priv, + CFF_SubFont subfont ); + + FT_LOCAL( void ) t1_decrypt( FT_Byte* buffer, FT_Offset length, FT_UShort seed ); + FT_LOCAL( FT_UInt32 ) + cff_random( FT_UInt32 r ); + + FT_END_HEADER #endif /* PSOBJS_H_ */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psread.c index 2b429e3eeb0..719863ce178 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psread.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2read.c */ +/* psread.c */ /* */ /* Adobe's code for stream handling (body). */ /* */ @@ -36,12 +36,12 @@ /***************************************************************************/ -#include "cf2ft.h" +#include "psft.h" #include FT_INTERNAL_DEBUG_H -#include "cf2glue.h" +#include "psglue.h" -#include "cf2error.h" +#include "pserror.h" /* Define CF2_IO_FAIL as 1 to enable random errors and random */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psread.h index b0b0db803a5..464b29ba743 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psread.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2read.h */ +/* psread.h */ /* */ /* Adobe's code for stream handling (specification). */ /* */ @@ -36,8 +36,8 @@ /***************************************************************************/ -#ifndef CF2READ_H_ -#define CF2READ_H_ +#ifndef PSREAD_H_ +#define PSREAD_H_ FT_BEGIN_HEADER @@ -62,7 +62,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2READ_H_ */ +#endif /* PSREAD_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c b/Build/source/libs/freetype2/freetype-src/src/psaux/psstack.c index 12a026d21d8..69d063349a1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psstack.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2stack.c */ +/* psstack.c */ /* */ /* Adobe's code for emulating a CFF stack (body). */ /* */ @@ -36,14 +36,14 @@ /***************************************************************************/ -#include "cf2ft.h" +#include "psft.h" #include FT_INTERNAL_DEBUG_H -#include "cf2glue.h" -#include "cf2font.h" -#include "cf2stack.h" +#include "psglue.h" +#include "psfont.h" +#include "psstack.h" -#include "cf2error.h" +#include "pserror.h" /* Allocate and initialize an instance of CF2_Stack. */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.h b/Build/source/libs/freetype2/freetype-src/src/psaux/psstack.h index ef08eefe411..38f7b41c689 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/psstack.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2stack.h */ +/* psstack.h */ /* */ /* Adobe's code for emulating a CFF stack (specification). */ /* */ @@ -36,8 +36,8 @@ /***************************************************************************/ -#ifndef CF2STACK_H_ -#define CF2STACK_H_ +#ifndef PSSTACK_H_ +#define PSSTACK_H_ FT_BEGIN_HEADER @@ -115,7 +115,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2STACK_H_ */ +#endif /* PSSTACK_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2types.h b/Build/source/libs/freetype2/freetype-src/src/psaux/pstypes.h index 5b7e1239af3..dfbaa3d475b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2types.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/pstypes.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* cf2types.h */ +/* pstypes.h */ /* */ /* Adobe's code for defining data types (specification only). */ /* */ @@ -36,8 +36,8 @@ /***************************************************************************/ -#ifndef CF2TYPES_H_ -#define CF2TYPES_H_ +#ifndef PSTYPES_H_ +#define PSTYPES_H_ #include <ft2build.h> #include FT_FREETYPE_H @@ -72,7 +72,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* CF2TYPES_H_ */ +#endif /* PSTYPES_H_ */ /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/rules.mk b/Build/source/libs/freetype2/freetype-src/src/psaux/rules.mk index 542ae12d2b0..a87bfe96873 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -33,12 +33,25 @@ PSAUX_DRV_SRC := $(PSAUX_DIR)/psobjs.c \ $(PSAUX_DIR)/t1cmap.c \ $(PSAUX_DIR)/afmparse.c \ $(PSAUX_DIR)/psconv.c \ - $(PSAUX_DIR)/psauxmod.c + $(PSAUX_DIR)/psauxmod.c \ + $(PSAUX_DIR)/psarrst.c \ + $(PSAUX_DIR)/psblues.c \ + $(PSAUX_DIR)/pserror.c \ + $(PSAUX_DIR)/psfont.c \ + $(PSAUX_DIR)/psft.c \ + $(PSAUX_DIR)/pshints.c \ + $(PSAUX_DIR)/psintrp.c \ + $(PSAUX_DIR)/psread.c \ + $(PSAUX_DIR)/psstack.c \ + $(PSAUX_DIR)/cffdecode.c # PSAUX driver headers # PSAUX_DRV_H := $(PSAUX_DRV_SRC:%c=%h) \ - $(PSAUX_DIR)/psauxerr.h + $(PSAUX_DIR)/psauxerr.h \ + $(PSAUX_DIR)/psfixed.h \ + $(PSAUX_DIR)/psglue.h \ + $(PSAUX_DIR)/pstypes.h # PSAUX driver object(s) diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/t1cmap.c b/Build/source/libs/freetype2/freetype-src/src/psaux/t1cmap.c index 45b713eb7b0..112a7892bac 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/t1cmap.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/t1cmap.c @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/t1cmap.h b/Build/source/libs/freetype2/freetype-src/src/psaux/t1cmap.h index 7870245a3a1..4308e31d2d7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/t1cmap.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/t1cmap.h @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/t1decode.c b/Build/source/libs/freetype2/freetype-src/src/psaux/t1decode.c index 1250b53f5de..6ad145661f2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/t1decode.c +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/t1decode.c @@ -4,7 +4,7 @@ /* */ /* PostScript Type 1 decoding routines (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -112,6 +112,56 @@ /*************************************************************************/ /* */ /* <Function> */ + /* t1_lookup_glyph_by_stdcharcode_ps */ + /* */ + /* <Description> */ + /* Looks up a given glyph by its StandardEncoding charcode. Used to */ + /* implement the SEAC Type 1 operator in the Adobe engine */ + /* */ + /* <Input> */ + /* face :: The current face object. */ + /* */ + /* charcode :: The character code to look for. */ + /* */ + /* <Return> */ + /* A glyph index in the font face. Returns -1 if the corresponding */ + /* glyph wasn't found. */ + /* */ + FT_LOCAL_DEF( FT_Int ) + t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder, + FT_Int charcode ) + { + FT_UInt n; + const FT_String* glyph_name; + FT_Service_PsCMaps psnames = decoder->psnames; + + + /* check range of standard char code */ + if ( charcode < 0 || charcode > 255 ) + return -1; + + glyph_name = psnames->adobe_std_strings( + psnames->adobe_std_encoding[charcode]); + + for ( n = 0; n < decoder->num_glyphs; n++ ) + { + FT_String* name = (FT_String*)decoder->glyph_names[n]; + + + if ( name && + name[0] == glyph_name[0] && + ft_strcmp( name, glyph_name ) == 0 ) + return (FT_Int)n; + } + + return -1; + } + + +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + /*************************************************************************/ + /* */ + /* <Function> */ /* t1_lookup_glyph_by_stdcharcode */ /* */ /* <Description> */ @@ -158,6 +208,15 @@ } + /* parse a single Type 1 glyph */ + FT_LOCAL_DEF( FT_Error ) + t1_decoder_parse_glyph( T1_Decoder decoder, + FT_UInt glyph ) + { + return decoder->parse_callback( decoder, glyph ); + } + + /*************************************************************************/ /* */ /* <Function> */ @@ -1579,14 +1638,286 @@ return FT_THROW( Stack_Underflow ); } +#else /* T1_CONFIG_OPTION_OLD_ENGINE */ - /* parse a single Type 1 glyph */ + /*************************************************************************/ + /* */ + /* <Function> */ + /* t1_decoder_parse_metrics */ + /* */ + /* <Description> */ + /* Parses a given Type 1 charstrings program to extract width */ + /* */ + /* <Input> */ + /* decoder :: The current Type 1 decoder. */ + /* */ + /* charstring_base :: The base address of the charstring stream. */ + /* */ + /* charstring_len :: The length in bytes of the charstring stream. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ FT_LOCAL_DEF( FT_Error ) - t1_decoder_parse_glyph( T1_Decoder decoder, - FT_UInt glyph ) + t1_decoder_parse_metrics( T1_Decoder decoder, + FT_Byte* charstring_base, + FT_UInt charstring_len ) { - return decoder->parse_callback( decoder, glyph ); + T1_Decoder_Zone zone; + FT_Byte* ip; + FT_Byte* limit; + T1_Builder builder = &decoder->builder; + +#ifdef FT_DEBUG_LEVEL_TRACE + FT_Bool bol = TRUE; +#endif + + + /* First of all, initialize the decoder */ + decoder->top = decoder->stack; + decoder->zone = decoder->zones; + zone = decoder->zones; + + builder->parse_state = T1_Parse_Start; + + FT_TRACE4(( "\n" + "Start charstring: get width\n" )); + + zone->base = charstring_base; + limit = zone->limit = charstring_base + charstring_len; + ip = zone->cursor = zone->base; + + /* now, execute loop */ + while ( ip < limit ) + { + FT_Long* top = decoder->top; + T1_Operator op = op_none; + FT_Int32 value = 0; + + +#ifdef FT_DEBUG_LEVEL_TRACE + if ( bol ) + { + FT_TRACE5(( " (%d)", decoder->top - decoder->stack )); + bol = FALSE; + } +#endif + + /*********************************************************************/ + /* */ + /* Decode operator or operand */ + /* */ + /* */ + + /* first of all, decompress operator or value */ + switch ( *ip++ ) + { + case 1: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 14: + case 15: + case 21: + case 22: + case 30: + case 31: + goto No_Width; + + case 13: + op = op_hsbw; + break; + + case 12: + if ( ip >= limit ) + { + FT_ERROR(( "t1_decoder_parse_metrics:" + " invalid escape (12+EOF)\n" )); + goto Syntax_Error; + } + + switch ( *ip++ ) + { + case 7: + op = op_sbw; + break; + + default: + goto No_Width; + } + break; + + case 255: /* four bytes integer */ + if ( ip + 4 > limit ) + { + FT_ERROR(( "t1_decoder_parse_metrics:" + " unexpected EOF in integer\n" )); + goto Syntax_Error; + } + + value = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) | + ( (FT_UInt32)ip[1] << 16 ) | + ( (FT_UInt32)ip[2] << 8 ) | + (FT_UInt32)ip[3] ); + ip += 4; + + /* According to the specification, values > 32000 or < -32000 must */ + /* be followed by a `div' operator to make the result be in the */ + /* range [-32000;32000]. We expect that the second argument of */ + /* `div' is not a large number. Additionally, we don't handle */ + /* stuff like `<large1> <large2> <num> div <num> div' or */ + /* <large1> <large2> <num> div div'. This is probably not allowed */ + /* anyway. */ + if ( value > 32000 || value < -32000 ) + { + FT_ERROR(( "t1_decoder_parse_metrics:" + " large integer found for width\n" )); + goto Syntax_Error; + } + else + { + value = (FT_Int32)( (FT_UInt32)value << 16 ); + } + + break; + + default: + if ( ip[-1] >= 32 ) + { + if ( ip[-1] < 247 ) + value = (FT_Int32)ip[-1] - 139; + else + { + if ( ++ip > limit ) + { + FT_ERROR(( "t1_decoder_parse_metrics:" + " unexpected EOF in integer\n" )); + goto Syntax_Error; + } + + if ( ip[-2] < 251 ) + value = ( ( ip[-2] - 247 ) * 256 ) + ip[-1] + 108; + else + value = -( ( ( ip[-2] - 251 ) * 256 ) + ip[-1] + 108 ); + } + + value = (FT_Int32)( (FT_UInt32)value << 16 ); + } + else + { + FT_ERROR(( "t1_decoder_parse_metrics:" + " invalid byte (%d)\n", ip[-1] )); + goto Syntax_Error; + } + } + + /*********************************************************************/ + /* */ + /* Push value on stack, or process operator */ + /* */ + /* */ + if ( op == op_none ) + { + if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) + { + FT_ERROR(( "t1_decoder_parse_metrics: stack overflow\n" )); + goto Syntax_Error; + } + +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " %d", value / 65536 )); +#endif + + *top++ = value; + decoder->top = top; + } + else /* general operator */ + { + FT_Int num_args = t1_args_count[op]; + + + FT_ASSERT( num_args >= 0 ); + + if ( top - decoder->stack < num_args ) + goto Stack_Underflow; + +#ifdef FT_DEBUG_LEVEL_TRACE + + if ( top - decoder->stack != num_args ) + FT_TRACE0(( "t1_decoder_parse_metrics:" + " too much operands on the stack" + " (seen %d, expected %d)\n", + top - decoder->stack, num_args )); + +#endif /* FT_DEBUG_LEVEL_TRACE */ + + top -= num_args; + + switch ( op ) + { + case op_hsbw: + FT_TRACE4(( " hsbw" )); + + builder->parse_state = T1_Parse_Have_Width; + + builder->left_bearing.x = ADD_LONG( builder->left_bearing.x, + top[0] ); + + builder->advance.x = top[1]; + builder->advance.y = 0; + + /* we only want to compute the glyph's metrics */ + /* (lsb + advance width), not load the rest of */ + /* it; so exit immediately */ + return FT_Err_Ok; + + case op_sbw: + FT_TRACE4(( " sbw" )); + + builder->parse_state = T1_Parse_Have_Width; + + builder->left_bearing.x = ADD_LONG( builder->left_bearing.x, + top[0] ); + builder->left_bearing.y = ADD_LONG( builder->left_bearing.y, + top[1] ); + + builder->advance.x = top[2]; + builder->advance.y = top[3]; + + /* we only want to compute the glyph's metrics */ + /* (lsb + advance width), not load the rest of */ + /* it; so exit immediately */ + return FT_Err_Ok; + + default: + FT_ERROR(( "t1_decoder_parse_metrics:" + " unhandled opcode %d\n", op )); + goto Syntax_Error; + } + + } /* general operator processing */ + + } /* while ip < limit */ + + FT_TRACE4(( "..end..\n\n" )); + + No_Width: + FT_ERROR(( "t1_decoder_parse_metrics:" + " no width, found op %d instead\n", + ip[-1] )); + Syntax_Error: + return FT_THROW( Syntax_Error ); + + Stack_Underflow: + return FT_THROW( Stack_Underflow ); } +#endif /* T1_CONFIG_OPTION_OLD_ENGINE */ /* initialize T1 decoder */ @@ -1641,7 +1972,16 @@ FT_LOCAL_DEF( void ) t1_decoder_done( T1_Decoder decoder ) { + FT_Memory memory = decoder->builder.memory; + + t1_builder_done( &decoder->builder ); + + if ( decoder->cf2_instance.finalizer ) + { + decoder->cf2_instance.finalizer( decoder->cf2_instance.data ); + FT_FREE( decoder->cf2_instance.data ); + } } diff --git a/Build/source/libs/freetype2/freetype-src/src/psaux/t1decode.h b/Build/source/libs/freetype2/freetype-src/src/psaux/t1decode.h index 12c27de775d..1d9718d678e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psaux/t1decode.h +++ b/Build/source/libs/freetype2/freetype-src/src/psaux/t1decode.h @@ -4,7 +4,7 @@ /* */ /* PostScript Type 1 decoding routines (specification). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -31,7 +31,11 @@ FT_BEGIN_HEADER FT_CALLBACK_TABLE const T1_Decoder_FuncsRec t1_decoder_funcs; + FT_LOCAL( FT_Int ) + t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder, + FT_Int charcode ); +#ifdef T1_CONFIG_OPTION_OLD_ENGINE FT_LOCAL( FT_Error ) t1_decoder_parse_glyph( T1_Decoder decoder, FT_UInt glyph_index ); @@ -40,6 +44,12 @@ FT_BEGIN_HEADER t1_decoder_parse_charstrings( T1_Decoder decoder, FT_Byte* base, FT_UInt len ); +#else + FT_LOCAL( FT_Error ) + t1_decoder_parse_metrics( T1_Decoder decoder, + FT_Byte* charstring_base, + FT_UInt charstring_len ); +#endif FT_LOCAL( FT_Error ) t1_decoder_init( T1_Decoder decoder, diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/Jamfile b/Build/source/libs/freetype2/freetype-src/src/pshinter/Jamfile index 2b65271cc4a..3f5f0ae40e5 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/pshinter Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/module.mk b/Build/source/libs/freetype2/freetype-src/src/pshinter/module.mk index 77e35c4c101..06707be3b4c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshalgo.c b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshalgo.c index 9ad1a3a02a3..b98077c62ef 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshalgo.c +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshalgo.c @@ -4,7 +4,7 @@ /* */ /* PostScript hinting algorithm (body). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ @@ -26,7 +26,7 @@ #undef FT_COMPONENT -#define FT_COMPONENT trace_pshalgo2 +#define FT_COMPONENT trace_pshalgo #ifdef DEBUG_HINTER diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshalgo.h b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshalgo.h index 62e97d152b0..c50683fbec6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshalgo.h +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshalgo.h @@ -4,7 +4,7 @@ /* */ /* PostScript hinting algorithm (specification). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshglob.c b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshglob.c index c68770c73a2..29f328d0e6d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshglob.c +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshglob.c @@ -5,7 +5,7 @@ /* PostScript hinter global hinting management (body). */ /* Inspired by the new auto-hinter module. */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshglob.h b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshglob.h index 8801cbada46..cf80bf40e64 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshglob.h +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshglob.h @@ -4,7 +4,7 @@ /* */ /* PostScript hinter global hinting management. */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshinter.c b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshinter.c index 13e07e14854..0eedac452d2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshinter.c +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshinter.c @@ -4,7 +4,7 @@ /* */ /* FreeType PostScript Hinting module */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshmod.c b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshmod.c index 860dc0ae823..0b8f6f99b83 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshmod.c +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType PostScript hinter module implementation (body). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshmod.h b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshmod.h index 1d2b40fa137..556de2fbc0e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshmod.h +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshmod.h @@ -4,7 +4,7 @@ /* */ /* PostScript hinter module interface (specification). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshnterr.h b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshnterr.h index 73d144e34c7..b9d02d2956a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshnterr.h +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshnterr.h @@ -4,7 +4,7 @@ /* */ /* PS Hinter error codes (specification only). */ /* */ -/* Copyright 2003-2017 by */ +/* Copyright 2003-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshpic.c b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshpic.c index c0d3a64f297..465ad31885b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshpic.c +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for pshinter module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshpic.h b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshpic.h index 8d9a01c9c5d..4469ba87c80 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshpic.h +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for pshinter module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshrec.c b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshrec.c index fff6d342508..6648d13d60f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshrec.c +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshrec.c @@ -4,7 +4,7 @@ /* */ /* FreeType PostScript hints recorder (body). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshrec.h b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshrec.h index e10bc2b1206..7e3dfe0d538 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/pshrec.h +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/pshrec.h @@ -4,7 +4,7 @@ /* */ /* Postscript (Type1/Type2) hints recorder (specification). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/pshinter/rules.mk b/Build/source/libs/freetype2/freetype-src/src/pshinter/rules.mk index 2be64043801..966690efc20 100644 --- a/Build/source/libs/freetype2/freetype-src/src/pshinter/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/pshinter/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/Jamfile b/Build/source/libs/freetype2/freetype-src/src/psnames/Jamfile index 5a6e2c0bd21..a0fd37397a3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/psnames Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/module.mk b/Build/source/libs/freetype2/freetype-src/src/psnames/module.mk index ddd22960c1a..410f48a191b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/psmodule.c b/Build/source/libs/freetype2/freetype-src/src/psnames/psmodule.c index 44ba9ec6ab6..8929ebe751d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/psmodule.c +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/psmodule.c @@ -4,7 +4,7 @@ /* */ /* PSNames module implementation (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/psmodule.h b/Build/source/libs/freetype2/freetype-src/src/psnames/psmodule.h index 6983b792347..3e94f8b437e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/psmodule.h +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/psmodule.h @@ -4,7 +4,7 @@ /* */ /* High-level PSNames module interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/psnamerr.h b/Build/source/libs/freetype2/freetype-src/src/psnames/psnamerr.h index f90bf5ea430..14eb76c99cf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/psnamerr.h +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/psnamerr.h @@ -4,7 +4,7 @@ /* */ /* PS names module error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/psnames.c b/Build/source/libs/freetype2/freetype-src/src/psnames/psnames.c index 22466d62308..febb80d594e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/psnames.c +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/psnames.c @@ -4,7 +4,7 @@ /* */ /* FreeType PSNames module component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/pspic.c b/Build/source/libs/freetype2/freetype-src/src/psnames/pspic.c index 8b9003439b3..85a06f36037 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/pspic.c +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/pspic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for psnames module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/pspic.h b/Build/source/libs/freetype2/freetype-src/src/psnames/pspic.h index 14497e73fa4..889780cc032 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/pspic.h +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/pspic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for psnames module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/pstables.h b/Build/source/libs/freetype2/freetype-src/src/psnames/pstables.h index 2a2b717d8f8..79545ee0396 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/pstables.h +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/pstables.h @@ -4,7 +4,7 @@ /* */ /* PostScript glyph names. */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/psnames/rules.mk b/Build/source/libs/freetype2/freetype-src/src/psnames/rules.mk index 69fa7322009..4d629d841c8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/psnames/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/psnames/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/Jamfile b/Build/source/libs/freetype2/freetype-src/src/raster/Jamfile index c9f3d6c636e..838e7ef57ef 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/raster/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/raster Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/ftmisc.h b/Build/source/libs/freetype2/freetype-src/src/raster/ftmisc.h index d1e6627ab49..7e401190711 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/ftmisc.h +++ b/Build/source/libs/freetype2/freetype-src/src/raster/ftmisc.h @@ -5,7 +5,7 @@ /* Miscellaneous macros for stand-alone rasterizer (specification */ /* only). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c b/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c index c5643f63349..4354730d54e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c +++ b/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.h b/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.h index 6b3050cb3d3..40b5d6d321c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.h +++ b/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.h @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/ftrend1.c b/Build/source/libs/freetype2/freetype-src/src/raster/ftrend1.c index 185a7f6fc2f..a7ce9731d77 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/ftrend1.c +++ b/Build/source/libs/freetype2/freetype-src/src/raster/ftrend1.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer interface (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -97,12 +97,12 @@ FT_Render_Mode mode, const FT_Vector* origin ) { - FT_Error error; - FT_Outline* outline; - FT_BBox cbox, cbox0; - FT_UInt width, height, pitch; - FT_Bitmap* bitmap; - FT_Memory memory; + FT_Error error = FT_Err_Ok; + FT_Outline* outline = &slot->outline; + FT_Bitmap* bitmap = &slot->bitmap; + FT_Memory memory = render->root.memory; + FT_Pos x_shift = 0; + FT_Pos y_shift = 0; FT_Raster_Params params; @@ -121,60 +121,6 @@ return FT_THROW( Cannot_Render_Glyph ); } - outline = &slot->outline; - - /* translate the outline to the new origin if needed */ - if ( origin ) - FT_Outline_Translate( outline, origin->x, origin->y ); - - /* compute the control box, and grid fit it */ - FT_Outline_Get_CBox( outline, &cbox0 ); - - /* undocumented but confirmed: bbox values get rounded */ -#if 1 - cbox.xMin = FT_PIX_ROUND( cbox0.xMin ); - cbox.yMin = FT_PIX_ROUND( cbox0.yMin ); - cbox.xMax = FT_PIX_ROUND( cbox0.xMax ); - cbox.yMax = FT_PIX_ROUND( cbox0.yMax ); -#else - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.xMax = FT_PIX_CEIL( cbox.xMax ); - cbox.yMax = FT_PIX_CEIL( cbox.yMax ); -#endif - - /* If either `width' or `height' round to 0, try */ - /* explicitly rounding up/down. In the case of */ - /* glyphs containing only one very narrow feature, */ - /* this gives the drop-out compensation in the scan */ - /* conversion code a chance to do its stuff. */ - width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); - if ( width == 0 ) - { - cbox.xMin = FT_PIX_FLOOR( cbox0.xMin ); - cbox.xMax = FT_PIX_CEIL( cbox0.xMax ); - - width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); - } - - height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); - if ( height == 0 ) - { - cbox.yMin = FT_PIX_FLOOR( cbox0.yMin ); - cbox.yMax = FT_PIX_CEIL( cbox0.yMax ); - - height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); - } - - if ( width > FT_USHORT_MAX || height > FT_USHORT_MAX ) - { - error = FT_THROW( Invalid_Argument ); - goto Exit; - } - - bitmap = &slot->bitmap; - memory = render->root.memory; - /* release old bitmap buffer */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { @@ -182,39 +128,48 @@ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } - pitch = ( ( width + 15 ) >> 4 ) << 1; - bitmap->pixel_mode = FT_PIXEL_MODE_MONO; - - bitmap->width = width; - bitmap->rows = height; - bitmap->pitch = (int)pitch; + ft_glyphslot_preset_bitmap( slot, mode, origin ); - if ( FT_ALLOC_MULT( bitmap->buffer, height, pitch ) ) + /* allocate new one */ + if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) ) goto Exit; slot->internal->flags |= FT_GLYPH_OWN_BITMAP; + x_shift = -slot->bitmap_left * 64; + y_shift = ( (FT_Int)bitmap->rows - slot->bitmap_top ) * 64; + + if ( origin ) + { + x_shift += origin->x; + y_shift += origin->y; + } + /* translate outline to render it into the bitmap */ - FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin ); + if ( x_shift || y_shift ) + FT_Outline_Translate( outline, x_shift, y_shift ); /* set up parameters */ params.target = bitmap; params.source = outline; - params.flags = 0; + params.flags = FT_RASTER_FLAG_DEFAULT; /* render outline into the bitmap */ error = render->raster_render( render->raster, ¶ms ); - FT_Outline_Translate( outline, cbox.xMin, cbox.yMin ); - - if ( error ) - goto Exit; + Exit: + if ( !error ) + /* everything is fine; the glyph is now officially a bitmap */ + slot->format = FT_GLYPH_FORMAT_BITMAP; + else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) + { + FT_FREE( bitmap->buffer ); + slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; + } - slot->format = FT_GLYPH_FORMAT_BITMAP; - slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 ); - slot->bitmap_top = (FT_Int)( cbox.yMax >> 6 ); + if ( x_shift || y_shift ) + FT_Outline_Translate( outline, -x_shift, -y_shift ); - Exit: return error; } diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/ftrend1.h b/Build/source/libs/freetype2/freetype-src/src/raster/ftrend1.h index cff702d140f..2abdf2d703b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/ftrend1.h +++ b/Build/source/libs/freetype2/freetype-src/src/raster/ftrend1.h @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/module.mk b/Build/source/libs/freetype2/freetype-src/src/raster/module.mk index aad39cb56ae..b115f416b2a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/raster/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/raster.c b/Build/source/libs/freetype2/freetype-src/src/raster/raster.c index 46a6690b178..76edd21e1e0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/raster.c +++ b/Build/source/libs/freetype2/freetype-src/src/raster/raster.c @@ -4,7 +4,7 @@ /* */ /* FreeType monochrome rasterer module component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/rasterrs.h b/Build/source/libs/freetype2/freetype-src/src/raster/rasterrs.h index 0d646908ad1..22a3e153406 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/rasterrs.h +++ b/Build/source/libs/freetype2/freetype-src/src/raster/rasterrs.h @@ -4,7 +4,7 @@ /* */ /* monochrome renderer error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/rastpic.c b/Build/source/libs/freetype2/freetype-src/src/raster/rastpic.c index 7085339b7b4..1dc8981b8a6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/rastpic.c +++ b/Build/source/libs/freetype2/freetype-src/src/raster/rastpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for raster module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/rastpic.h b/Build/source/libs/freetype2/freetype-src/src/raster/rastpic.h index dcd691310d3..6d0877c4239 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/rastpic.h +++ b/Build/source/libs/freetype2/freetype-src/src/raster/rastpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for raster module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/rules.mk b/Build/source/libs/freetype2/freetype-src/src/raster/rules.mk index 0462c931771..9aef1f0bab6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/raster/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/Jamfile b/Build/source/libs/freetype2/freetype-src/src/sfnt/Jamfile index 5971b251cf5..57977fc966b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/sfnt Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/module.mk b/Build/source/libs/freetype2/freetype-src/src/sfnt/module.mk index 81dea17de09..51ca67e7845 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/pngshim.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/pngshim.c index 560db4835af..16020266afd 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/pngshim.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/pngshim.c @@ -4,7 +4,7 @@ /* */ /* PNG Bitmap glyph support. */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* Google, Inc. */ /* Written by Stuart Gill and Behdad Esfahbod. */ /* */ @@ -82,42 +82,45 @@ typedef unsigned short v82 __attribute__(( vector_size( 16 ) )); - /* process blocks of 16 bytes in one rush, which gives a nice speed-up */ - limit = row_info->rowbytes - 16 + 1; - for ( ; i < limit; i += 16 ) + if ( row_info->rowbytes > 15 ) { - unsigned char* base = &data[i]; + /* process blocks of 16 bytes in one rush, which gives a nice speed-up */ + limit = row_info->rowbytes - 16 + 1; + for ( ; i < limit; i += 16 ) + { + unsigned char* base = &data[i]; - v82 s, s0, s1, a; + v82 s, s0, s1, a; - /* clang <= 3.9 can't apply scalar values to vectors */ - /* (or rather, it needs a different syntax) */ - v82 n0x80 = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; - v82 n0xFF = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - v82 n8 = { 8, 8, 8, 8, 8, 8, 8, 8 }; + /* clang <= 3.9 can't apply scalar values to vectors */ + /* (or rather, it needs a different syntax) */ + v82 n0x80 = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + v82 n0xFF = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + v82 n8 = { 8, 8, 8, 8, 8, 8, 8, 8 }; - v82 ma = { 1, 1, 3, 3, 5, 5, 7, 7 }; - v82 o1 = { 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF }; - v82 m0 = { 1, 0, 3, 2, 5, 4, 7, 6 }; + v82 ma = { 1, 1, 3, 3, 5, 5, 7, 7 }; + v82 o1 = { 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF }; + v82 m0 = { 1, 0, 3, 2, 5, 4, 7, 6 }; - memcpy( &s, base, 16 ); /* RGBA RGBA RGBA RGBA */ - s0 = s & n0xFF; /* R B R B R B R B */ - s1 = s >> n8; /* G A G A G A G A */ + ft_memcpy( &s, base, 16 ); /* RGBA RGBA RGBA RGBA */ + s0 = s & n0xFF; /* R B R B R B R B */ + s1 = s >> n8; /* G A G A G A G A */ - a = vector_shuffle( s1, ma ); /* A A A A A A A A */ - s1 |= o1; /* G 1 G 1 G 1 G 1 */ - s0 = vector_shuffle( s0, m0 ); /* B R B R B R B R */ + a = vector_shuffle( s1, ma ); /* A A A A A A A A */ + s1 |= o1; /* G 1 G 1 G 1 G 1 */ + s0 = vector_shuffle( s0, m0 ); /* B R B R B R B R */ - s0 *= a; - s1 *= a; - s0 += n0x80; - s1 += n0x80; - s0 = ( s0 + ( s0 >> n8 ) ) >> n8; - s1 = ( s1 + ( s1 >> n8 ) ) >> n8; + s0 *= a; + s1 *= a; + s0 += n0x80; + s1 += n0x80; + s0 = ( s0 + ( s0 >> n8 ) ) >> n8; + s1 = ( s1 + ( s1 >> n8 ) ) >> n8; - s = s0 | ( s1 << n8 ); - memcpy( base, &s, 16 ); + s = s0 | ( s1 << n8 ); + ft_memcpy( base, &s, 16 ); + } } #endif /* use `vector_size' */ @@ -234,7 +237,7 @@ return; } - memcpy( data, stream->cursor, length ); + ft_memcpy( data, stream->cursor, length ); FT_FRAME_EXIT(); } diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/pngshim.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/pngshim.h index 344eceac125..194238c3a20 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/pngshim.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/pngshim.h @@ -4,7 +4,7 @@ /* */ /* PNG Bitmap glyph support. */ /* */ -/* Copyright 2013-2017 by */ +/* Copyright 2013-2018 by */ /* Google, Inc. */ /* Written by Stuart Gill and Behdad Esfahbod. */ /* */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/rules.mk b/Build/source/libs/freetype2/freetype-src/src/sfnt/rules.mk index 230d56c946c..83acc66a8f6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c index 991433ee4cc..303e1ca9f1a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c @@ -4,7 +4,7 @@ /* */ /* High-level SFNT driver interface (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -862,7 +862,8 @@ NULL, &mm_var ); - if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ) + if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) && + !FT_IS_VARIATION( FT_FACE( face ) ) ) { SFNT_Service sfnt = (SFNT_Service)face->sfnt; @@ -1029,7 +1030,9 @@ return face->postscript_name; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( face->blend ) + if ( face->blend && + ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) || + FT_IS_VARIATION( FT_FACE( face ) ) ) ) { face->postscript_name = sfnt_get_var_ps_name( face ); return face->postscript_name; diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.h index 38710b60f2e..81c22d28870 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.h @@ -4,7 +4,7 @@ /* */ /* High-level SFNT driver interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sferrors.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/sferrors.h index 3cf73d725d3..74003d4b38c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sferrors.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sferrors.h @@ -4,7 +4,7 @@ /* */ /* SFNT error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfnt.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfnt.c index 6cf8c9ef30a..8b9a6b345df 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfnt.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfnt.c @@ -4,7 +4,7 @@ /* */ /* Single object library component. */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfntpic.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfntpic.c index 8eadd601fd4..db2d816ce68 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfntpic.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfntpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for sfnt module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfntpic.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfntpic.h index 3afb668db02..8f43122d81b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfntpic.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfntpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for sfnt module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c index 69bf0a5c3db..0c917030f37 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c @@ -4,7 +4,7 @@ /* */ /* SFNT object management (base). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -962,8 +962,6 @@ FT_Byte* instance_values = NULL; - face->is_default_instance = 1; - instance_index = FT_ABS( face_instance_index ) >> 16; /* test whether current face is a GX font with named instances */ @@ -1686,9 +1684,9 @@ (FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max : root->height ); - /* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */ - /* Adjust underline position from top edge to centre of */ - /* stroke to convert TrueType meaning to FreeType meaning. */ + /* See https://www.microsoft.com/typography/otspec/post.htm -- */ + /* Adjust underline position from top edge to centre of */ + /* stroke to convert TrueType meaning to FreeType meaning. */ root->underline_position = face->postscript.underlinePosition - face->postscript.underlineThickness / 2; root->underline_thickness = face->postscript.underlineThickness; diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.h index 705381459ac..1b8d1be5b1a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.h @@ -4,7 +4,7 @@ /* */ /* SFNT object management (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttbdf.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttbdf.c index 2196e3791ec..534201f229f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttbdf.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttbdf.c @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded BDF properties (body). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttbdf.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttbdf.h index 398b620600b..809a6630011 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttbdf.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttbdf.h @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded BDF properties (specification). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -28,6 +28,8 @@ FT_BEGIN_HEADER +#ifdef TT_CONFIG_OPTION_BDF + FT_LOCAL( void ) tt_face_free_bdf_props( TT_Face face ); @@ -37,6 +39,8 @@ FT_BEGIN_HEADER const char* property_name, BDF_PropertyRec *aprop ); +#endif /* TT_CONFIG_OPTION_BDF */ + FT_END_HEADER diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.c index b995e5c050a..8cc70f759af 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.c @@ -4,7 +4,7 @@ /* */ /* TrueType character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -518,7 +518,11 @@ if ( offset == 0 ) + { + if ( charcode == 0x100 ) + goto Exit; /* this happens only for a malformed cmap */ goto Next_SubHeader; + } if ( char_lo < start ) { @@ -547,9 +551,19 @@ } } - /* jump to next sub-header, i.e. higher byte value */ + /* If `charcode' is <= 0xFF, retry with `charcode + 1'. If */ + /* `charcode' is 0x100 after the loop, do nothing since we have */ + /* just reached the first sub-header for two-byte character codes. */ + /* */ + /* For all other cases, we jump to the next sub-header and adjust */ + /* `charcode' accordingly. */ Next_SubHeader: - charcode = FT_PAD_FLOOR( charcode, 256 ) + 256; + if ( charcode <= 0xFF ) + charcode++; + else if ( charcode == 0x100 ) + ; + else + charcode = FT_PAD_FLOOR( charcode, 0x100 ) + 0x100; } Exit: diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.h index f7de0437b07..d264d99d2c9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.h @@ -4,7 +4,7 @@ /* */ /* TrueType character mapping table (cmap) support (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmapc.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmapc.h index 9a5e70825ed..4980e9dd3dc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmapc.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmapc.h @@ -4,7 +4,7 @@ /* */ /* TT CMAP classes definitions (specification only). */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttkern.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttkern.c index 53d2436ae5c..68f15a20102 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttkern.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttkern.c @@ -5,7 +5,7 @@ /* Load the basic TrueType kerning table. This doesn't handle */ /* kerning data within the GPOS table at the moment. */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttkern.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttkern.h index db1a30bdb0f..4e45d0964b4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttkern.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttkern.h @@ -5,7 +5,7 @@ /* Load the basic TrueType kerning table. This doesn't handle */ /* kerning data within the GPOS table at the moment. */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c index df99baa53e9..a86a546c3dd 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c @@ -5,7 +5,7 @@ /* Load the basic TrueType tables, i.e., tables that can be either in */ /* TTF or OTF fonts (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -338,7 +338,7 @@ SFNT_HeaderRec sfnt; FT_Error error; FT_Memory memory = stream->memory; - FT_UShort nn, valid_entries; + FT_UShort nn, valid_entries = 0; static const FT_Frame_Field offset_table_fields[] = { diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.h index 296da86ed32..f94be8b7bd0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.h @@ -5,7 +5,7 @@ /* Load the basic TrueType tables, i.e., tables that can be either in */ /* TTF or OTF fonts (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttmtx.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttmtx.c index 394c6db85cb..6ddda95b567 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttmtx.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttmtx.c @@ -4,7 +4,7 @@ /* */ /* Load the metrics tables common to TTF and OTF fonts (body). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttmtx.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttmtx.h index 2b93ab2f0e1..ab00acd7952 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttmtx.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttmtx.h @@ -4,7 +4,7 @@ /* */ /* Load the metrics tables common to TTF and OTF fonts (specification). */ /* */ -/* Copyright 2006-2017 by */ +/* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttpost.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttpost.c index 69929c8d452..f140649993a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttpost.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttpost.c @@ -5,7 +5,7 @@ /* PostScript name table processing for TrueType and OpenType fonts */ /* (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttpost.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttpost.h index 722485e32d1..3bec07e4454 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttpost.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttpost.h @@ -5,7 +5,7 @@ /* PostScript name table processing for TrueType and OpenType fonts */ /* (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.c index f41847b0af0..53e61756d18 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.c @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded bitmap support (body). */ /* */ -/* Copyright 2005-2017 by */ +/* Copyright 2005-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* Copyright 2013 by Google, Inc. */ @@ -1007,8 +1007,9 @@ goto Fail; } - FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d components\n", - num_components )); + FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d component%s\n", + num_components, + num_components == 1 ? "" : "s" )); for ( nn = 0; nn < num_components; nn++ ) { diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.h b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.h index e859ddda452..ce2af3c1628 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.h +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.h @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded bitmap support (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/Jamfile b/Build/source/libs/freetype2/freetype-src/src/smooth/Jamfile index 4cd0769ee61..9957d5e915e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/smooth Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.c b/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.c index df645e66c98..6ce6f86444c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.c +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.c @@ -4,7 +4,7 @@ /* */ /* A new `perfect' anti-aliasing renderer (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -370,7 +370,7 @@ typedef ptrdiff_t FT_PtrDist; /* optimize a division and modulo operation on the same parameters */ /* into a single call to `__aeabi_idivmod'. See */ /* */ - /* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721 */ + /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721 */ #undef FT_DIV_MOD #define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \ FT_BEGIN_STMNT \ @@ -582,8 +582,8 @@ typedef ptrdiff_t FT_PtrDist; if ( ex < ras.min_ex ) ex = ras.min_ex - 1; - /* record the current one if it is valid */ - if ( !ras.invalid ) + /* record the current one if it is valid and substantial */ + if ( !ras.invalid && ( ras.area || ras.cover ) ) gray_record_cell( RAS_VAR ); ras.area = 0; @@ -1300,8 +1300,6 @@ typedef ptrdiff_t FT_PtrDist; int y; - FT_TRACE7(( "gray_sweep: start\n" )); - for ( y = ras.min_ey; y < ras.max_ey; y++ ) { PCell cell = ras.ycells[y - ras.min_ey]; @@ -1327,8 +1325,6 @@ typedef ptrdiff_t FT_PtrDist; if ( cover != 0 ) gray_hline( RAS_VAR_ x, y, cover, ras.max_ex - x ); } - - FT_TRACE7(( "gray_sweep: end\n" )); } @@ -1722,8 +1718,11 @@ typedef ptrdiff_t FT_PtrDist; if ( !ras.invalid ) gray_record_cell( RAS_VAR ); - FT_TRACE7(( "band [%d..%d]: %d cells\n", - ras.min_ey, ras.max_ey, ras.num_cells )); + FT_TRACE7(( "band [%d..%d]: %d cell%s\n", + ras.min_ey, + ras.max_ey, + ras.num_cells, + ras.num_cells == 1 ? "" : "s" )); } else { @@ -1740,35 +1739,43 @@ typedef ptrdiff_t FT_PtrDist; static int gray_convert_glyph( RAS_ARG ) { + const TCoord yMin = ras.min_ey; + const TCoord yMax = ras.max_ey; + const TCoord xMin = ras.min_ex; + const TCoord xMax = ras.max_ex; + TCell buffer[FT_MAX_GRAY_POOL]; - TCoord band_size = FT_MAX_GRAY_POOL / 8; - TCoord count = ras.max_ey - ras.min_ey; - int num_bands; - TCoord min, max, max_y; + size_t height = (size_t)( yMax - yMin ); + size_t n = FT_MAX_GRAY_POOL / 8; + TCoord y; TCoord bands[32]; /* enough to accommodate bisections */ TCoord* band; /* set up vertical bands */ - if ( count > band_size ) + if ( height > n ) { /* two divisions rounded up */ - num_bands = (int)( ( count + band_size - 1) / band_size ); - band_size = ( count + num_bands - 1 ) / num_bands; + n = ( height + n - 1 ) / n; + height = ( height + n - 1 ) / n; } - min = ras.min_ey; - max_y = ras.max_ey; + /* memory management */ + n = ( height * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) / sizeof ( TCell ); - for ( ; min < max_y; min = max ) + ras.cells = buffer + n; + ras.max_cells = (FT_PtrDist)( FT_MAX_GRAY_POOL - n ); + ras.ycells = (PCell*)buffer; + + for ( y = yMin; y < yMax; ) { - max = min + band_size; - if ( max > max_y ) - max = max_y; + ras.min_ey = y; + y += height; + ras.max_ey = FT_MIN( y, yMax ); band = bands; - band[1] = min; - band[0] = max; + band[1] = xMin; + band[0] = xMax; do { @@ -1776,27 +1783,12 @@ typedef ptrdiff_t FT_PtrDist; int error; - /* memory management */ - { - size_t ycount = (size_t)width; - size_t cell_start; - - - cell_start = ( ycount * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) / - sizeof ( TCell ); - - ras.cells = buffer + cell_start; - ras.max_cells = (FT_PtrDist)( FT_MAX_GRAY_POOL - cell_start ); - ras.num_cells = 0; - - ras.ycells = (PCell*)buffer; - while ( ycount ) - ras.ycells[--ycount] = NULL; - } + FT_MEM_ZERO( ras.ycells, height * sizeof ( PCell ) ); + ras.num_cells = 0; ras.invalid = 1; - ras.min_ey = band[1]; - ras.max_ey = band[0]; + ras.min_ex = band[1]; + ras.max_ex = band[0]; error = gray_convert_glyph_inner( RAS_VAR ); @@ -1812,8 +1804,7 @@ typedef ptrdiff_t FT_PtrDist; /* render pool overflow; we will reduce the render band by half */ width >>= 1; - /* This is too complex for a single scanline; there must */ - /* be some problems. */ + /* this should never happen even with tiny rendering pool */ if ( width == 0 ) { FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" )); diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.h b/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.h index a5447da1a97..9e11ca675ef 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.h +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.h @@ -4,7 +4,7 @@ /* */ /* FreeType smooth renderer declaration */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmerrs.h b/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmerrs.h index a528c61832b..226dc1b0017 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmerrs.h +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmerrs.h @@ -4,7 +4,7 @@ /* */ /* smooth renderer error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmooth.c b/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmooth.c index 963435de150..ef176bdf1ec 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmooth.c +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmooth.c @@ -4,7 +4,7 @@ /* */ /* Anti-aliasing renderer interface (body). */ /* */ -/* Copyright 2000-2017 by */ +/* Copyright 2000-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -97,74 +97,17 @@ const FT_Vector* origin, FT_Render_Mode required_mode ) { - FT_Error error; + FT_Error error = FT_Err_Ok; FT_Outline* outline = &slot->outline; FT_Bitmap* bitmap = &slot->bitmap; FT_Memory memory = render->root.memory; - FT_BBox cbox; FT_Pos x_shift = 0; FT_Pos y_shift = 0; - FT_Pos x_left, y_top; - FT_Pos width, height, pitch; FT_Int hmul = ( mode == FT_RENDER_MODE_LCD ); FT_Int vmul = ( mode == FT_RENDER_MODE_LCD_V ); FT_Raster_Params params; - FT_Bool have_outline_shifted = FALSE; - FT_Bool have_buffer = FALSE; - -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - - FT_LcdFiveTapFilter lcd_weights = { 0 }; - FT_Bool have_custom_weight = FALSE; - FT_Bitmap_LcdFilterFunc lcd_filter_func = NULL; - - - if ( slot->face ) - { - FT_Char i; - - - for ( i = 0; i < FT_LCD_FILTER_FIVE_TAPS; i++ ) - if ( slot->face->internal->lcd_weights[i] != 0 ) - { - have_custom_weight = TRUE; - break; - } - } - - /* - * The LCD filter can be set library-wide and per-face. Face overrides - * library. If the face filter weights are all zero (the default), it - * means that the library default should be used. - */ - if ( have_custom_weight ) - { - /* - * A per-font filter is set. It always uses the default 5-tap - * in-place FIR filter. - */ - ft_memcpy( lcd_weights, - slot->face->internal->lcd_weights, - FT_LCD_FILTER_FIVE_TAPS ); - lcd_filter_func = ft_lcd_filter_fir; - } - else - { - /* - * The face's lcd_weights is {0, 0, 0, 0, 0}, meaning `use library - * default'. If the library is set to use no LCD filtering - * (lcd_filter_func == NULL), `lcd_filter_func' here is also set to - * NULL and the tests further below pass over the filtering process. - */ - ft_memcpy( lcd_weights, - slot->library->lcd_weights, - FT_LCD_FILTER_FIVE_TAPS ); - lcd_filter_func = slot->library->lcd_filter_func; - } - -#endif /*FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ /* check glyph image format */ if ( slot->format != render->glyph_format ) @@ -180,100 +123,6 @@ goto Exit; } - if ( origin ) - { - x_shift = origin->x; - y_shift = origin->y; - } - - /* compute the control box, and grid fit it */ - /* taking into account the origin shift */ - FT_Outline_Get_CBox( outline, &cbox ); - -#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - - /* add minimal padding for LCD rendering */ - if ( hmul ) - { - cbox.xMax += 21; - cbox.xMin -= 21; - } - - if ( vmul ) - { - cbox.yMax += 21; - cbox.yMin -= 21; - } - -#else /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - - /* add minimal padding for LCD filter depending on specific weights */ - if ( lcd_filter_func ) - { - if ( hmul ) - { - cbox.xMax += lcd_weights[4] ? 43 - : lcd_weights[3] ? 22 : 0; - cbox.xMin -= lcd_weights[0] ? 43 - : lcd_weights[1] ? 22 : 0; - } - - if ( vmul ) - { - cbox.yMax += lcd_weights[4] ? 43 - : lcd_weights[3] ? 22 : 0; - cbox.yMin -= lcd_weights[0] ? 43 - : lcd_weights[1] ? 22 : 0; - } - } - -#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - - cbox.xMin = FT_PIX_FLOOR( cbox.xMin + x_shift ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin + y_shift ); - cbox.xMax = FT_PIX_CEIL( cbox.xMax + x_shift ); - cbox.yMax = FT_PIX_CEIL( cbox.yMax + y_shift ); - - x_shift -= cbox.xMin; - y_shift -= cbox.yMin; - - x_left = cbox.xMin >> 6; - y_top = cbox.yMax >> 6; - - width = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6; - height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6; - - pitch = width; - if ( hmul ) - { - width *= 3; - pitch = FT_PAD_CEIL( width, 4 ); - } - - if ( vmul ) - height *= 3; - - /* - * XXX: on 16bit system, we return an error for huge bitmap - * to prevent an overflow. - */ - if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX || - x_left < FT_INT_MIN || y_top < FT_INT_MIN ) - { - error = FT_THROW( Invalid_Pixel_Size ); - goto Exit; - } - - /* Required check is (pitch * height < FT_ULONG_MAX), */ - /* but we care realistic cases only. Always pitch <= width. */ - if ( width > 0x7FFF || height > 0x7FFF ) - { - FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n", - width, height )); - error = FT_THROW( Raster_Overflow ); - goto Exit; - } - /* release old bitmap buffer */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { @@ -281,30 +130,30 @@ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } + ft_glyphslot_preset_bitmap( slot, mode, origin ); + /* allocate new one */ - if ( FT_ALLOC( bitmap->buffer, (FT_ULong)( pitch * height ) ) ) + if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) ) goto Exit; - else - have_buffer = TRUE; slot->internal->flags |= FT_GLYPH_OWN_BITMAP; - slot->format = FT_GLYPH_FORMAT_BITMAP; - slot->bitmap_left = (FT_Int)x_left; - slot->bitmap_top = (FT_Int)y_top; + x_shift = 64 * -slot->bitmap_left; + y_shift = 64 * -slot->bitmap_top; + if ( bitmap->pixel_mode == FT_PIXEL_MODE_LCD_V ) + y_shift += 64 * (FT_Int)bitmap->rows / 3; + else + y_shift += 64 * (FT_Int)bitmap->rows; - bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; - bitmap->num_grays = 256; - bitmap->width = (unsigned int)width; - bitmap->rows = (unsigned int)height; - bitmap->pitch = pitch; + if ( origin ) + { + x_shift += origin->x; + y_shift += origin->y; + } /* translate outline to render it into the bitmap */ if ( x_shift || y_shift ) - { FT_Outline_Translate( outline, x_shift, y_shift ); - have_outline_shifted = TRUE; - } /* set up parameters */ params.target = bitmap; @@ -351,45 +200,68 @@ if ( error ) goto Exit; - if ( lcd_filter_func ) - lcd_filter_func( bitmap, mode, lcd_weights ); + /* finally apply filtering */ + if ( hmul || vmul ) + { + FT_Byte* lcd_weights; + FT_Bitmap_LcdFilterFunc lcd_filter_func; + + + /* Per-face LCD filtering takes priority if set up. */ + if ( slot->face && slot->face->internal->lcd_filter_func ) + { + lcd_weights = slot->face->internal->lcd_weights; + lcd_filter_func = slot->face->internal->lcd_filter_func; + } + else + { + lcd_weights = slot->library->lcd_weights; + lcd_filter_func = slot->library->lcd_filter_func; + } + + if ( lcd_filter_func ) + lcd_filter_func( bitmap, mode, lcd_weights ); + } #else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ if ( hmul ) /* lcd */ { FT_Byte* line; - FT_Byte* temp; - FT_Int i, j; + FT_Byte* temp = NULL; + FT_UInt i, j; + + unsigned int height = bitmap->rows; + unsigned int width = bitmap->width; + int pitch = bitmap->pitch; /* Render 3 separate monochrome bitmaps, shifting the outline */ /* by 1/3 pixel. */ width /= 3; - FT_Outline_Translate( outline, 21, 0 ); + bitmap->buffer += width; error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; FT_Outline_Translate( outline, -21, 0 ); + x_shift -= 21; bitmap->buffer += width; error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, -21, 0 ); - bitmap->buffer += width; + FT_Outline_Translate( outline, 42, 0 ); + x_shift += 42; + bitmap->buffer -= 2 * width; error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, 21, 0 ); - bitmap->buffer -= 2 * width; - /* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */ /* XXX: It is more efficient to render every third byte above. */ @@ -398,7 +270,7 @@ for ( i = 0; i < height; i++ ) { - line = bitmap->buffer + i * pitch; + line = bitmap->buffer + i * (FT_ULong)pitch; for ( j = 0; j < width; j++ ) { temp[3 * j ] = line[j]; @@ -412,60 +284,59 @@ } else if ( vmul ) /* lcd_v */ { + int pitch = bitmap->pitch; + + /* Render 3 separate monochrome bitmaps, shifting the outline */ /* by 1/3 pixel. Triple the pitch to render on each third row. */ bitmap->pitch *= 3; bitmap->rows /= 3; - FT_Outline_Translate( outline, 0, 21 ); - bitmap->buffer += 2 * pitch; + bitmap->buffer += pitch; error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, 0, -21 ); - bitmap->buffer -= pitch; + FT_Outline_Translate( outline, 0, 21 ); + y_shift += 21; + bitmap->buffer += pitch; error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, 0, -21 ); - bitmap->buffer -= pitch; + FT_Outline_Translate( outline, 0, -42 ); + y_shift -= 42; + bitmap->buffer -= 2 * pitch; error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, 0, 21 ); - bitmap->pitch /= 3; bitmap->rows *= 3; } else /* grayscale */ - { error = render->raster_render( render->raster, ¶ms ); - if ( error ) - goto Exit; - } #endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - /* everything is fine; don't deallocate buffer */ - have_buffer = FALSE; - - error = FT_Err_Ok; - Exit: - if ( have_outline_shifted ) - FT_Outline_Translate( outline, -x_shift, -y_shift ); - if ( have_buffer ) + if ( !error ) + { + /* everything is fine; the glyph is now officially a bitmap */ + slot->format = FT_GLYPH_FORMAT_BITMAP; + } + else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { FT_FREE( bitmap->buffer ); slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } + if ( x_shift || y_shift ) + FT_Outline_Translate( outline, -x_shift, -y_shift ); + return error; } @@ -492,14 +363,8 @@ FT_Render_Mode mode, const FT_Vector* origin ) { - FT_Error error; - - error = ft_smooth_render_generic( render, slot, mode, origin, - FT_RENDER_MODE_LCD ); - if ( !error ) - slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD; - - return error; + return ft_smooth_render_generic( render, slot, mode, origin, + FT_RENDER_MODE_LCD ); } @@ -510,14 +375,8 @@ FT_Render_Mode mode, const FT_Vector* origin ) { - FT_Error error; - - error = ft_smooth_render_generic( render, slot, mode, origin, - FT_RENDER_MODE_LCD_V ); - if ( !error ) - slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V; - - return error; + return ft_smooth_render_generic( render, slot, mode, origin, + FT_RENDER_MODE_LCD_V ); } diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmooth.h b/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmooth.h index 6dfd65726c6..c76ffc5034e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmooth.h +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/ftsmooth.h @@ -4,7 +4,7 @@ /* */ /* Anti-aliasing renderer interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/ftspic.c b/Build/source/libs/freetype2/freetype-src/src/smooth/ftspic.c index fb89be34885..10f04cf4ccf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/ftspic.c +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/ftspic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for smooth module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/ftspic.h b/Build/source/libs/freetype2/freetype-src/src/smooth/ftspic.h index 9ddd1c79056..80fb64cff43 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/ftspic.h +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/ftspic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for smooth module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/module.mk b/Build/source/libs/freetype2/freetype-src/src/smooth/module.mk index 804e9b13861..5b8bc3be3b6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/rules.mk b/Build/source/libs/freetype2/freetype-src/src/smooth/rules.mk index dfdc9bc30f5..f30824a367a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/smooth.c b/Build/source/libs/freetype2/freetype-src/src/smooth/smooth.c index e0460d9d46d..5249a8931e3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/smooth.c +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/smooth.c @@ -4,7 +4,7 @@ /* */ /* FreeType anti-aliasing rasterer module component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/afblue.pl b/Build/source/libs/freetype2/freetype-src/src/tools/afblue.pl index 027b6304136..7c6f1a7df13 100755 --- a/Build/source/libs/freetype2/freetype-src/src/tools/afblue.pl +++ b/Build/source/libs/freetype2/freetype-src/src/tools/afblue.pl @@ -5,7 +5,7 @@ # # Process a blue zone character data file. # -# Copyright 2013-2017 by +# Copyright 2013-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/content.py b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/content.py index 283d8151887..c9969dbe5bb 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/content.py +++ b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/content.py @@ -3,7 +3,7 @@ # # Parse comment blocks to build content blocks (library file). # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner. # # This file is part of the FreeType project, and may only be used, @@ -453,15 +453,32 @@ class ContentProcessor: markup_lines = [] first = 1 + margin = -1 + in_code = 0 + for line in content: - found = None - for t in re_markup_tags: - m = t.match( line ) + if in_code: + m = re_code_end.match( line ) + if m and len( m.group( 1 ) ) <= margin: + in_code = 0 + margin = -1 + else: + m = re_code_start.match( line ) if m: - found = string.lower( m.group( 1 ) ) - prefix = len( m.group( 0 ) ) - line = " " * prefix + line[prefix:] # remove markup from line - break + in_code = 1 + margin = len( m.group( 1 ) ) + + found = None + + if not in_code: + for t in re_markup_tags: + m = t.match( line ) + if m: + found = string.lower( m.group( 1 ) ) + prefix = len( m.group( 0 ) ) + # remove markup from line + line = " " * prefix + line[prefix:] + break # is it the start of a new markup section ? if found: diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/docmaker.py b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/docmaker.py index 4e25ff0f87b..253a4d35af7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/docmaker.py +++ b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/docmaker.py @@ -4,7 +4,7 @@ # # Convert source code markup to HTML documentation. # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner. # # This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/formatter.py b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/formatter.py index 2745754f389..2708fd40d60 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/formatter.py +++ b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/formatter.py @@ -3,7 +3,7 @@ # # Convert parsed content blocks to a structured document (library file). # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner. # # This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/sources.py b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/sources.py index 06407e16436..2cd5a3379c2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/sources.py +++ b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/sources.py @@ -3,7 +3,7 @@ # # Convert source code comments to multi-line blocks (library file). # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner. # # This file is part of the FreeType project, and may only be used, @@ -171,7 +171,7 @@ re_bold = re.compile( r"\*((?:\w|-)(?:\w|'|-)*)\*(.*)" ) # *bold* # # This regular expression code to identify an URL has been taken from # -# http://mail.python.org/pipermail/tutor/2002-September/017228.html +# https://mail.python.org/pipermail/tutor/2002-September/017228.html # # (with slight modifications). # diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/tohtml.py b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/tohtml.py index 012b55e49a7..7f5ecda41ce 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/tohtml.py +++ b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/tohtml.py @@ -3,7 +3,7 @@ # # A sub-class container of the `Formatter' class to produce HTML. # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner. # # This file is part of the FreeType project, and may only be used, @@ -25,7 +25,7 @@ import time # The following strings define the HTML header used by all generated pages. html_header_1 = """\ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" -"http://www.w3.org/TR/html4/loose.dtd"> +"https://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/utils.py b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/utils.py index ba5b2e7596e..f40f1674a04 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/utils.py +++ b/Build/source/libs/freetype2/freetype-src/src/tools/docmaker/utils.py @@ -3,7 +3,7 @@ # # Auxiliary functions for the `docmaker' tool (library file). # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner. # # This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/README b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/README index 20336ae2e5f..09d8e9f325e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/README +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/README @@ -6,7 +6,7 @@ ftfuzzer.cc ----------- This file contains a target function for FreeType fuzzing. It can be -used with libFuzzer (http://llvm.org/docs/LibFuzzer.html) or +used with libFuzzer (https://llvm.org/docs/LibFuzzer.html) or potentially any other similar fuzzer. Usage: @@ -20,7 +20,7 @@ Usage: -fsanitize=address,signed-integer-overflow,shift You also need the header files from the `libarchive' library - (http://www.libarchive.org/) for handling tar files (see file + (https://www.libarchive.org/) for handling tar files (see file `ftmutator.cc' below for more). 2. Link with `libFuzzer' (it contains `main') and `libarchive'. @@ -68,7 +68,7 @@ a convenience `main' function. Link it with `ftfuzzer.cc', ---------------------------------------------------------------------- -Copyright 2015-2017 by +Copyright 2015-2018 by David Turner, Robert Wilhelm, and Werner Lemberg. This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftfuzzer.cc b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftfuzzer.cc index 4da0c2bf255..acf2bc98200 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftfuzzer.cc +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftfuzzer.cc @@ -2,7 +2,7 @@ // // A fuzzing function to test FreeType with libFuzzer. // -// Copyright 2015-2017 by +// Copyright 2015-2018 by // David Turner, Robert Wilhelm, and Werner Lemberg. // // This file is part of the FreeType project, and may only be used, @@ -43,8 +43,7 @@ #include FT_OUTLINE_H #include FT_BBOX_H #include FT_MODULE_H -#include FT_CFF_DRIVER_H -#include FT_TRUETYPE_DRIVER_H +#include FT_DRIVER_H #include FT_MULTIPLE_MASTERS_H @@ -61,7 +60,7 @@ return; // try to activate Adobe's CFF engine; it might not be the default - unsigned int cff_hinting_engine = FT_CFF_HINTING_ADOBE; + unsigned int cff_hinting_engine = FT_HINTING_ADOBE; FT_Property_Set( library, "cff", "hinting-engine", &cff_hinting_engine ); diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftmutator.cc b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftmutator.cc index 22aa5a77730..ae4b1404048 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftmutator.cc +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/ftmutator.cc @@ -2,7 +2,7 @@ // // A custom fuzzer mutator to test for FreeType with libFuzzer. // -// Copyright 2015-2017 by +// Copyright 2015-2018 by // David Turner, Robert Wilhelm, and Werner Lemberg. // // This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/rasterfuzzer.cc b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/rasterfuzzer.cc index ae9b1a56d45..c69b95ea0fa 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/rasterfuzzer.cc +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/rasterfuzzer.cc @@ -2,7 +2,7 @@ // // A fuzzing function to test FreeType's rasterizers with libFuzzer. // -// Copyright 2016-2017 by +// Copyright 2016-2018 by // David Turner, Robert Wilhelm, and Werner Lemberg. // // This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/runinput.cc b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/runinput.cc index 15261207e8f..2b02f57580b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/runinput.cc +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftfuzzer/runinput.cc @@ -2,7 +2,7 @@ // // A `main' function for fuzzers like `ftfuzzer.cc'. // -// Copyright 2015-2017 by +// Copyright 2015-2018 by // David Turner, Robert Wilhelm, and Werner Lemberg. // // This file is part of the FreeType project, and may only be used, diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/glnames.py b/Build/source/libs/freetype2/freetype-src/src/tools/glnames.py index 3270eebb3d2..b048d293641 100755 --- a/Build/source/libs/freetype2/freetype-src/src/tools/glnames.py +++ b/Build/source/libs/freetype2/freetype-src/src/tools/glnames.py @@ -6,7 +6,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -151,7 +151,7 @@ mac_standard_names = \ # The list of standard `SID' glyph names. For the official list, # see Annex A of document at # -# http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf . +# https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5176.CFF.pdf . # sid_standard_names = \ [ @@ -5318,7 +5318,7 @@ def main(): write( "/* */\n" ) write( "/* PostScript glyph names. */\n" ) write( "/* */\n" ) - write( "/* Copyright 2005-2017 by */\n" ) + write( "/* Copyright 2005-2018 by */\n" ) write( "/* David Turner, Robert Wilhelm, and Werner Lemberg. */\n" ) write( "/* */\n" ) write( "/* This file is part of the FreeType project, and may only be used, */\n" ) diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/update-copyright-year b/Build/source/libs/freetype2/freetype-src/src/tools/update-copyright-year index 4b04bfc995f..934f11cf028 100755 --- a/Build/source/libs/freetype2/freetype-src/src/tools/update-copyright-year +++ b/Build/source/libs/freetype2/freetype-src/src/tools/update-copyright-year @@ -2,7 +2,7 @@ eval '(exit $?0)' && eval 'exec perl -wS -i "$0" ${1+"$@"}' & eval 'exec perl -wS -i "$0" $argv:q' if 0; -# Copyright 2015-2017 by +# Copyright 2015-2018 by # Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/Jamfile b/Build/source/libs/freetype2/freetype-src/src/truetype/Jamfile index 22d406cd7da..e321fba14a6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/truetype Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/module.mk b/Build/source/libs/freetype2/freetype-src/src/truetype/module.mk index 563c584e2bd..16bc9c8b208 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/rules.mk b/Build/source/libs/freetype2/freetype-src/src/truetype/rules.mk index ad3d007455f..e16113f128e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/truetype.c b/Build/source/libs/freetype2/freetype-src/src/truetype/truetype.c index 301b82ad1c7..484370975c6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/truetype.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/truetype.c @@ -4,7 +4,7 @@ /* */ /* FreeType TrueType driver component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.c index a1653b241ca..820cafbb8d8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.c @@ -4,7 +4,7 @@ /* */ /* TrueType font driver implementation (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -31,7 +31,7 @@ #include FT_SERVICE_TRUETYPE_ENGINE_H #include FT_SERVICE_TRUETYPE_GLYF_H #include FT_SERVICE_PROPERTIES_H -#include FT_TRUETYPE_DRIVER_H +#include FT_DRIVER_H #include "ttdriver.h" #include "ttgload.h" @@ -233,8 +233,8 @@ { #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* no fast retrieval for blended MM fonts without VVAR table */ - if ( !face->is_default_instance && - !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) + if ( ( FT_IS_NAMED_INSTANCE( ttface ) || FT_IS_VARIATION( ttface ) ) && + !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) return FT_THROW( Unimplemented_Feature ); #endif @@ -253,8 +253,8 @@ { #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* no fast retrieval for blended MM fonts without HVAR table */ - if ( !face->is_default_instance && - !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) + if ( ( FT_IS_NAMED_INSTANCE( ttface ) || FT_IS_VARIATION( ttface ) ) && + !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) return FT_THROW( Unimplemented_Feature ); #endif @@ -498,6 +498,7 @@ (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */ (FT_Set_Var_Design_Func)TT_Set_Var_Design, /* set_var_design */ (FT_Get_Var_Design_Func)TT_Get_Var_Design, /* get_var_design */ + (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */ (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */ (FT_Done_Blend_Func) tt_done_blend /* done_blend */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.h index 3bcba7f745b..707aa68edf3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.h @@ -4,7 +4,7 @@ /* */ /* High-level TrueType driver interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/tterrors.h b/Build/source/libs/freetype2/freetype-src/src/truetype/tterrors.h index a49f205156b..88bca3a04af 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/tterrors.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/tterrors.h @@ -4,7 +4,7 @@ /* */ /* TrueType error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.c index 5e102c61519..32ed34aba5e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.c @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -24,7 +24,7 @@ #include FT_INTERNAL_SFNT_H #include FT_TRUETYPE_TAGS_H #include FT_OUTLINE_H -#include FT_TRUETYPE_DRIVER_H +#include FT_DRIVER_H #include FT_LIST_H #include "ttgload.h" @@ -664,7 +664,52 @@ } while ( subglyph->flags & MORE_COMPONENTS ); gloader->current.num_subglyphs = num_subglyphs; - FT_TRACE5(( " %d components\n", num_subglyphs )); + FT_TRACE5(( " %d component%s\n", + num_subglyphs, + num_subglyphs > 1 ? "s" : "" )); + +#ifdef FT_DEBUG_LEVEL_TRACE + { + FT_UInt i; + + + subglyph = gloader->current.subglyphs; + + for ( i = 0; i < num_subglyphs; i++ ) + { + if ( num_subglyphs > 1 ) + FT_TRACE7(( " subglyph %d:\n", i )); + + FT_TRACE7(( " glyph index: %d\n", subglyph->index )); + + if ( subglyph->flags & ARGS_ARE_XY_VALUES ) + FT_TRACE7(( " offset: x=%d, y=%d\n", + subglyph->arg1, + subglyph->arg2 )); + else + FT_TRACE7(( " matching points: base=%d, component=%d\n", + subglyph->arg1, + subglyph->arg2 )); + + if ( subglyph->flags & WE_HAVE_A_SCALE ) + FT_TRACE7(( " scaling: %f\n", + subglyph->transform.xx / 65536.0 )); + else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE ) + FT_TRACE7(( " scaling: x=%f, y=%f\n", + subglyph->transform.xx / 65536.0, + subglyph->transform.yy / 65536.0 )); + else if ( subglyph->flags & WE_HAVE_A_2X2 ) + FT_TRACE7(( " scaling: xx=%f, yx=%f\n" + " xy=%f, yy=%f\n", + subglyph->transform.xx / 65536.0, + subglyph->transform.yx / 65536.0, + subglyph->transform.xy / 65536.0, + subglyph->transform.yy / 65536.0 )); + + subglyph++; + } + } +#endif /* FT_DEBUG_LEVEL_TRACE */ #ifdef TT_USE_BYTECODE_INTERPRETER @@ -756,7 +801,7 @@ { FT_TRACE1(( "TT_Hint_Glyph: too long instructions" )); FT_TRACE1(( " (0x%lx byte) is truncated\n", - loader->glyph->control_len )); + loader->glyph->control_len )); } n_ins = loader->glyph->control_len; @@ -889,7 +934,8 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( !loader->face->is_default_instance ) + if ( FT_IS_NAMED_INSTANCE( FT_FACE( loader->face ) ) || + FT_IS_VARIATION( FT_FACE( loader->face ) ) ) { /* Deltas apply to the unscaled data. */ error = TT_Vary_Apply_Glyph_Deltas( loader->face, @@ -991,9 +1037,24 @@ vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); } + } +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* if we have a HVAR table, `pp1' and/or `pp2' are already adjusted */ + if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) || + !IS_HINTED( loader->load_flags ) ) +#endif + { loader->pp1 = outline->points[n_points - 4]; loader->pp2 = outline->points[n_points - 3]; + } + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* if we have a VVAR table, `pp3' and/or `pp4' are already adjusted */ + if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) || + !IS_HINTED( loader->load_flags ) ) +#endif + { loader->pp3 = outline->points[n_points - 2]; loader->pp4 = outline->points[n_points - 1]; } @@ -1145,8 +1206,28 @@ if ( subglyph->flags & ROUND_XY_TO_GRID ) { - x = FT_PIX_ROUND( x ); - y = FT_PIX_ROUND( y ); + TT_Face face = loader->face; + TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); + + + if ( IS_HINTED( loader->load_flags ) ) + { + /* + * We round the horizontal offset only if there is hinting along + * the x axis; this corresponds to integer advance width values. + * + * Theoretically, a glyph's bytecode can toggle ClearType's + * `backward compatibility' mode, which would allow modification + * of the advance width. In reality, however, applications + * neither allow nor expect modified advance widths if sub-pixel + * rendering is active. + * + */ + if ( driver->interpreter_version == TT_INTERPRETER_VERSION_35 ) + x = FT_PIX_ROUND( x ); + + y = FT_PIX_ROUND( y ); + } } } } @@ -1359,6 +1440,7 @@ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( loader->face ); #endif + #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 ) { @@ -1577,7 +1659,8 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( !loader->face->is_default_instance ) + if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) || + FT_IS_VARIATION( FT_FACE( face ) ) ) { /* a small outline structure with four elements for */ /* communication with `TT_Vary_Apply_Glyph_Deltas' */ @@ -1711,7 +1794,7 @@ /* clear the nodes filled by sibling chains */ node = ft_list_get_node_at( &loader->composites, recurse_count ); for ( node2 = node; node2; node2 = node2->next ) - node2->data = (void*)ULONG_MAX; + node2->data = (void*)FT_ULONG_MAX; /* check whether we already have a composite glyph with this index */ if ( FT_List_Find( &loader->composites, @@ -1751,7 +1834,8 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( !face->is_default_instance ) + if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) || + FT_IS_VARIATION( FT_FACE( face ) ) ) { short i, limit; FT_SubGlyph subglyph; @@ -2609,7 +2693,8 @@ TT_LoaderRec loader; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT -#define IS_DEFAULT_INSTANCE ( ( (TT_Face)glyph->face )->is_default_instance ) +#define IS_DEFAULT_INSTANCE ( !( FT_IS_NAMED_INSTANCE( glyph->face ) || \ + FT_IS_VARIATION( glyph->face ) ) ) #else #define IS_DEFAULT_INSTANCE 1 #endif diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.h index 1dd6c841db4..d237cfd2841 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.h @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.c index 49aa53a687b..6f456cf8c41 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.c @@ -4,7 +4,7 @@ /* */ /* TrueType GX Font Variation loader */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -1043,10 +1043,11 @@ outerIndex, innerIndex ); - FT_TRACE5(( "%s value %d adjusted by %d units (%s)\n", + FT_TRACE5(( "%s value %d adjusted by %d unit%s (%s)\n", vertical ? "vertical height" : "horizontal width", *avalue, delta, + delta == 1 ? "" : "s", vertical ? "VVAR" : "HVAR" )); *avalue += delta; @@ -1333,13 +1334,15 @@ if ( p ) { - FT_TRACE5(( "value %c%c%c%c (%d units) adjusted by %d units (MVAR)\n", + FT_TRACE5(( "value %c%c%c%c (%d unit%s) adjusted by %d unit%s (MVAR)\n", (FT_Char)( value->tag >> 24 ), (FT_Char)( value->tag >> 16 ), (FT_Char)( value->tag >> 8 ), (FT_Char)( value->tag ), value->unmodified, - delta )); + value->unmodified == 1 ? "" : "s", + delta, + delta == 1 ? "" : "s" )); /* since we handle both signed and unsigned values as FT_Short, */ /* ensure proper overflow arithmetic */ @@ -1499,8 +1502,10 @@ blend->gv_glyphcnt = gvar_head.glyphCount; offsetToData = gvar_start + gvar_head.offsetToData; - FT_TRACE5(( "gvar: there are %d shared coordinates:\n", - blend->tuplecount )); + FT_TRACE5(( "gvar: there %s %d shared coordinate%s:\n", + blend->tuplecount == 1 ? "is" : "are", + blend->tuplecount, + blend->tuplecount == 1 ? "" : "s" )); if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) ) goto Exit; @@ -1728,7 +1733,9 @@ /* based on the [min,def,max] values for the axis to be [-1,0,1]. */ /* Then, if there's an `avar' table, we renormalize this range. */ - FT_TRACE5(( "design coordinates:\n" )); + FT_TRACE5(( "%d design coordinate%s:\n", + num_coords, + num_coords == 1 ? "" : "s" )); a = mmvar->axis; for ( i = 0; i < num_coords; i++, a++ ) @@ -1746,17 +1753,17 @@ a->minimum / 65536.0, a->maximum / 65536.0 )); - if ( coord > a->maximum) + if ( coord > a->maximum ) coord = a->maximum; else coord = a->minimum; } if ( coord < a->def ) - normalized[i] = -FT_DivFix( coords[i] - a->def, + normalized[i] = -FT_DivFix( coord - a->def, a->minimum - a->def ); else if ( coord > a->def ) - normalized[i] = FT_DivFix( coords[i] - a->def, + normalized[i] = FT_DivFix( coord - a->def, a->maximum - a->def ); else normalized[i] = 0; @@ -1822,16 +1829,8 @@ nc = blend->num_axis; } - if ( face->doblend ) - { - for ( i = 0; i < nc; i++ ) - design[i] = coords[i]; - } - else - { - for ( i = 0; i < nc; i++ ) - design[i] = 0; - } + for ( i = 0; i < nc; i++ ) + design[i] = coords[i]; for ( ; i < num_coords; i++ ) design[i] = 0; @@ -1940,11 +1939,11 @@ TT_Get_MM_Var( TT_Face face, FT_MM_Var* *master ) { - FT_Stream stream = face->root.stream; - FT_Memory memory = face->root.memory; + FT_Stream stream = face->root.stream; + FT_Memory memory = face->root.memory; FT_ULong table_len; - FT_Error error = FT_Err_Ok; - FT_ULong fvar_start; + FT_Error error = FT_Err_Ok; + FT_ULong fvar_start = 0; FT_UInt i, j; FT_MM_Var* mmvar = NULL; FT_Fixed* next_coords; @@ -1954,10 +1953,20 @@ FT_Fixed* c; FT_Var_Named_Style* ns; GX_FVar_Head fvar_head; - FT_Bool usePsName; + FT_Bool usePsName = 0; FT_UInt num_instances; + FT_UInt num_axes; FT_UShort* axis_flags; + FT_Offset mmvar_size; + FT_Offset axis_flags_size; + FT_Offset axis_size; + FT_Offset namedstyle_size; + FT_Offset next_coords_size; + FT_Offset next_name_size; + + FT_Bool need_init; + static const FT_Frame_Field fvar_fields[] = { @@ -1995,7 +2004,9 @@ /* read the font data and set up the internal representation */ /* if not already done */ - if ( !face->blend ) + need_init = !face->blend; + + if ( need_init ) { FT_TRACE2(( "FVAR " )); @@ -2037,21 +2048,49 @@ if ( FT_NEW( face->blend ) ) goto Exit; - /* `num_instances' holds the number of all named instances, */ - /* including the default instance which might be missing */ - /* in fvar's table of named instances */ - num_instances = face->root.style_flags >> 16; - - /* prepare storage area for MM data; this cannot overflow */ - /* 32-bit arithmetic because of the size limits used in the */ - /* `fvar' table validity check in `sfnt_init_face' */ - face->blend->mmvar_len = - sizeof ( FT_MM_Var ) + - fvar_head.axisCount * sizeof ( FT_UShort ) + - fvar_head.axisCount * sizeof ( FT_Var_Axis ) + - num_instances * sizeof ( FT_Var_Named_Style ) + - num_instances * fvar_head.axisCount * sizeof ( FT_Fixed ) + - fvar_head.axisCount * 5; + num_axes = fvar_head.axisCount; + } + else + num_axes = face->blend->num_axis; + + /* `num_instances' holds the number of all named instances, */ + /* including the default instance which might be missing */ + /* in fvar's table of named instances */ + num_instances = (FT_UInt)face->root.style_flags >> 16; + + /* prepare storage area for MM data; this cannot overflow */ + /* 32-bit arithmetic because of the size limits used in the */ + /* `fvar' table validity check in `sfnt_init_face' */ + + /* the various `*_size' variables, which we also use as */ + /* offsets into the `mmlen' array, must be multiples of the */ + /* pointer size (except the last one); without such an */ + /* alignment there might be runtime errors due to */ + /* misaligned addresses */ +#undef ALIGN_SIZE +#define ALIGN_SIZE( n ) \ + ( ( (n) + sizeof (void*) - 1 ) & ~( sizeof (void*) - 1 ) ) + + mmvar_size = ALIGN_SIZE( sizeof ( FT_MM_Var ) ); + axis_flags_size = ALIGN_SIZE( num_axes * + sizeof ( FT_UShort ) ); + axis_size = ALIGN_SIZE( num_axes * + sizeof ( FT_Var_Axis ) ); + namedstyle_size = ALIGN_SIZE( num_instances * + sizeof ( FT_Var_Named_Style ) ); + next_coords_size = ALIGN_SIZE( num_instances * + num_axes * + sizeof ( FT_Fixed ) ); + next_name_size = num_axes * 5; + + if ( need_init ) + { + face->blend->mmvar_len = mmvar_size + + axis_flags_size + + axis_size + + namedstyle_size + + next_coords_size + + next_name_size; if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) ) goto Exit; @@ -2061,7 +2100,7 @@ /* the data gets filled in later on */ mmvar->num_axis = - fvar_head.axisCount; + num_axes; mmvar->num_designs = ~0U; /* meaningless in this context; each glyph */ /* may have a different number of designs */ @@ -2071,22 +2110,23 @@ /* alas, no public field in `FT_Var_Axis' for axis flags */ axis_flags = - (FT_UShort*)&( mmvar[1] ); + (FT_UShort*)( (char*)mmvar + mmvar_size ); mmvar->axis = - (FT_Var_Axis*)&( axis_flags[fvar_head.axisCount] ); + (FT_Var_Axis*)( (char*)axis_flags + axis_flags_size ); mmvar->namedstyle = - (FT_Var_Named_Style*)&( mmvar->axis[fvar_head.axisCount] ); + (FT_Var_Named_Style*)( (char*)mmvar->axis + axis_size ); - next_coords = - (FT_Fixed*)&( mmvar->namedstyle[num_instances] ); + next_coords = (FT_Fixed*)( (char*)mmvar->namedstyle + + namedstyle_size ); for ( i = 0; i < num_instances; i++ ) { mmvar->namedstyle[i].coords = next_coords; - next_coords += fvar_head.axisCount; + next_coords += num_axes; } - next_name = (FT_String*)next_coords; - for ( i = 0; i < fvar_head.axisCount; i++ ) + next_name = (FT_String*)( (char*)mmvar->namedstyle + + namedstyle_size + next_coords_size ); + for ( i = 0; i < num_axes; i++ ) { mmvar->axis[i].name = next_name; next_name += 5; @@ -2098,7 +2138,7 @@ goto Exit; a = mmvar->axis; - for ( i = 0; i < fvar_head.axisCount; i++ ) + for ( i = 0; i < num_axes; i++ ) { GX_FVar_Axis axis_rec; @@ -2148,7 +2188,7 @@ /* named instance coordinates are stored as design coordinates; */ /* we have to convert them to normalized coordinates also */ if ( FT_NEW_ARRAY( face->blend->normalized_stylecoords, - fvar_head.axisCount * num_instances ) ) + num_axes * num_instances ) ) goto Exit; if ( fvar_head.instanceCount && !face->blend->avar_loaded ) @@ -2168,14 +2208,14 @@ { /* PostScript names add 2 bytes to the instance record size */ if ( FT_FRAME_ENTER( ( usePsName ? 6L : 4L ) + - 4L * fvar_head.axisCount ) ) + 4L * num_axes ) ) goto Exit; ns->strid = FT_GET_USHORT(); (void) /* flags = */ FT_GET_USHORT(); c = ns->coords; - for ( j = 0; j < fvar_head.axisCount; j++, c++ ) + for ( j = 0; j < num_axes; j++, c++ ) *c = FT_GET_LONG(); /* valid psid values are 6, [256;32767], and 0xFFFF */ @@ -2184,11 +2224,8 @@ else ns->psid = 0xFFFF; - ft_var_to_normalized( face, - fvar_head.axisCount, - ns->coords, - nsc ); - nsc += fvar_head.axisCount; + ft_var_to_normalized( face, num_axes, ns->coords, nsc ); + nsc += num_axes; FT_FRAME_EXIT(); } @@ -2237,7 +2274,7 @@ a = mmvar->axis; c = ns->coords; - for ( j = 0; j < fvar_head.axisCount; j++, a++, c++ ) + for ( j = 0; j < num_axes; j++, a++, c++ ) *c = a->def; } } @@ -2258,23 +2295,24 @@ FT_MEM_COPY( mmvar, face->blend->mmvar, face->blend->mmvar_len ); axis_flags = - (FT_UShort*)&( mmvar[1] ); + (FT_UShort*)( (char*)mmvar + mmvar_size ); mmvar->axis = - (FT_Var_Axis*)&( axis_flags[mmvar->num_axis] ); + (FT_Var_Axis*)( (char*)axis_flags + axis_flags_size ); mmvar->namedstyle = - (FT_Var_Named_Style*)&( mmvar->axis[mmvar->num_axis] ); + (FT_Var_Named_Style*)( (char*)mmvar->axis+ axis_size ); - next_coords = - (FT_Fixed*)&( mmvar->namedstyle[mmvar->num_namedstyles] ); + next_coords = (FT_Fixed*)( (char*)mmvar->namedstyle + + namedstyle_size ); for ( n = 0; n < mmvar->num_namedstyles; n++ ) { mmvar->namedstyle[n].coords = next_coords; - next_coords += mmvar->num_axis; + next_coords += num_axes; } a = mmvar->axis; - next_name = (FT_String*)next_coords; - for ( n = 0; n < mmvar->num_axis; n++ ) + next_name = (FT_String*)( (char*)mmvar->namedstyle + + namedstyle_size + next_coords_size ); + for ( n = 0; n < num_axes; n++ ) { a->name = next_name; @@ -2309,10 +2347,9 @@ FT_Error error = FT_Err_Ok; GX_Blend blend; FT_MM_Var* mmvar; - FT_UInt i, j; + FT_UInt i; - FT_Bool is_default_instance = TRUE; - FT_Bool all_design_coords = FALSE; + FT_Bool all_design_coords = FALSE; FT_Memory memory = face->root.memory; @@ -2357,9 +2394,6 @@ error = FT_THROW( Invalid_Argument ); goto Exit; } - - if ( coords[i] != 0 ) - is_default_instance = FALSE; } FT_TRACE5(( "\n" )); @@ -2390,6 +2424,12 @@ } else { + FT_Bool have_diff = 0; + FT_UInt j; + FT_Fixed* c; + FT_Fixed* n; + + manageCvt = mcvt_retain; for ( i = 0; i < num_coords; i++ ) @@ -2397,10 +2437,34 @@ if ( blend->normalizedcoords[i] != coords[i] ) { manageCvt = mcvt_load; + have_diff = 1; break; } } + if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ) + { + FT_UInt idx = (FT_UInt)face->root.face_index >> 16; + + + c = blend->normalizedcoords + i; + n = blend->normalized_stylecoords + idx * mmvar->num_axis + i; + for ( j = i; j < mmvar->num_axis; j++, n++, c++ ) + if ( *c != *n ) + have_diff = 1; + } + else + { + c = blend->normalizedcoords + i; + for ( j = i; j < mmvar->num_axis; j++, c++ ) + if ( *c != 0 ) + have_diff = 1; + } + + /* return value -1 indicates `no change' */ + if ( !have_diff ) + return -1; + for ( ; i < mmvar->num_axis; i++ ) { if ( blend->normalizedcoords[i] != 0 ) @@ -2454,32 +2518,6 @@ } } - /* check whether the current variation tuple coincides */ - /* with a named instance */ - - for ( i = 0; i < blend->mmvar->num_namedstyles; i++ ) - { - FT_Fixed* nsc = blend->normalized_stylecoords + i * blend->num_axis; - FT_Fixed* ns = blend->normalizedcoords; - - - for ( j = 0; j < blend->num_axis; j++, nsc++, ns++ ) - { - if ( *nsc != *ns ) - break; - } - - if ( j == blend->num_axis ) - break; - } - - /* adjust named instance index */ - face->root.face_index &= 0xFFFF; - if ( i < blend->mmvar->num_namedstyles ) - face->root.face_index |= ( i + 1 ) << 16; - - face->is_default_instance = is_default_instance; - /* enforce recomputation of the PostScript name; */ FT_FREE( face->postscript_name ); face->postscript_name = NULL; @@ -2519,7 +2557,19 @@ FT_UInt num_coords, FT_Fixed* coords ) { - return tt_set_mm_blend( face, num_coords, coords, 1 ); + FT_Error error; + + + error = tt_set_mm_blend( face, num_coords, coords, 1 ); + if ( error ) + return error; + + if ( num_coords ) + face->root.face_flags |= FT_FACE_FLAG_VARIATION; + else + face->root.face_flags &= ~FT_FACE_FLAG_VARIATION; + + return FT_Err_Ok; } @@ -2635,11 +2685,12 @@ FT_UInt i; FT_Memory memory = face->root.memory; - FT_Var_Axis* a; - FT_Fixed* c; - + FT_Fixed* c; + FT_Fixed* n; FT_Fixed* normalized = NULL; + FT_Bool have_diff = 0; + if ( !face->blend ) { @@ -2664,14 +2715,55 @@ goto Exit; } - FT_MEM_COPY( blend->coords, - coords, - num_coords * sizeof ( FT_Fixed ) ); + c = blend->coords; + n = coords; + for ( i = 0; i < num_coords; i++, n++, c++ ) + { + if ( *c != *n ) + { + *c = *n; + have_diff = 1; + } + } + + if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ) + { + FT_UInt instance_index; + FT_Var_Named_Style* named_style; + - a = mmvar->axis + num_coords; - c = blend->coords + num_coords; - for ( i = num_coords; i < mmvar->num_axis; i++, a++, c++ ) - *c = a->def; + instance_index = (FT_UInt)face->root.face_index >> 16; + named_style = mmvar->namedstyle + instance_index - 1; + + n = named_style->coords + num_coords; + for ( ; i < mmvar->num_axis; i++, n++, c++ ) + { + if ( *c != *n ) + { + *c = *n; + have_diff = 1; + } + } + } + else + { + FT_Var_Axis* a; + + + a = mmvar->axis + num_coords; + for ( ; i < mmvar->num_axis; i++, a++, c++ ) + { + if ( *c != a->def ) + { + *c = a->def; + have_diff = 1; + } + } + } + + /* return value -1 indicates `no change' */ + if ( !have_diff ) + return -1; if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) ) goto Exit; @@ -2682,6 +2774,13 @@ ft_var_to_normalized( face, num_coords, blend->coords, normalized ); error = tt_set_mm_blend( face, mmvar->num_axis, normalized, 0 ); + if ( error ) + goto Exit; + + if ( num_coords ) + face->root.face_flags |= FT_FACE_FLAG_VARIATION; + else + face->root.face_flags &= ~FT_FACE_FLAG_VARIATION; Exit: FT_FREE( normalized ); @@ -2765,6 +2864,90 @@ /*************************************************************************/ + /* */ + /* <Function> */ + /* TT_Set_Named_Instance */ + /* */ + /* <Description> */ + /* Set the given named instance, also resetting any further */ + /* variation. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* instance_index :: The instance index, starting with value 1. */ + /* Value 0 indicates to not use an instance. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + TT_Set_Named_Instance( TT_Face face, + FT_UInt instance_index ) + { + FT_Error error = FT_ERR( Invalid_Argument ); + GX_Blend blend; + FT_MM_Var* mmvar; + + FT_UInt num_instances; + + + if ( !face->blend ) + { + if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) ) + goto Exit; + } + + blend = face->blend; + mmvar = blend->mmvar; + + num_instances = (FT_UInt)face->root.style_flags >> 16; + + /* `instance_index' starts with value 1, thus `>' */ + if ( instance_index > num_instances ) + goto Exit; + + if ( instance_index > 0 && mmvar->namedstyle ) + { + FT_Memory memory = face->root.memory; + SFNT_Service sfnt = (SFNT_Service)face->sfnt; + + FT_Var_Named_Style* named_style; + FT_String* style_name; + + + named_style = mmvar->namedstyle + instance_index - 1; + + error = sfnt->get_name( face, + (FT_UShort)named_style->strid, + &style_name ); + if ( error ) + goto Exit; + + /* set (or replace) style name */ + FT_FREE( face->root.style_name ); + face->root.style_name = style_name; + + /* finally, select the named instance */ + error = TT_Set_Var_Design( face, + mmvar->num_axis, + named_style->coords ); + if ( error ) + goto Exit; + } + else + error = TT_Set_Var_Design( face, 0, NULL ); + + face->root.face_index = ( instance_index << 16 ) | + ( face->root.face_index & 0xFFFFL ); + face->root.face_flags &= ~FT_FACE_FLAG_VARIATION; + + Exit: + return error; + } + + + /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GX VAR PARSING ROUTINES *****/ @@ -2810,8 +2993,10 @@ FT_Fixed* im_start_coords = NULL; FT_Fixed* im_end_coords = NULL; GX_Blend blend = face->blend; - FT_UInt point_count; - FT_UShort* localpoints; + FT_UInt point_count, spoint_count = 0; + FT_UShort* sharedpoints = NULL; + FT_UShort* localpoints = NULL; + FT_UShort* points; FT_Short* deltas; @@ -2880,11 +3065,24 @@ offsetToData += table_start; - /* The documentation implies there are flags packed into */ - /* `tupleCount', but John Jenkins says that shared points don't apply */ - /* to `cvar', and no other flags are defined. */ + if ( tupleCount & GX_TC_TUPLES_SHARE_POINT_NUMBERS ) + { + here = FT_Stream_FTell( stream ); + + FT_Stream_SeekSet( stream, offsetToData ); + + sharedpoints = ft_var_readpackedpoints( stream, + table_len, + &spoint_count ); + offsetToData = FT_Stream_FTell( stream ); + + FT_Stream_SeekSet( stream, here ); + } - FT_TRACE5(( "cvar: there are %d tuples:\n", tupleCount & 0xFFF )); + FT_TRACE5(( "cvar: there %s %d tuple%s:\n", + ( tupleCount & 0xFFF ) == 1 ? "is" : "are", + tupleCount & 0xFFF, + ( tupleCount & 0xFFF ) == 1 ? "" : "s" )); for ( i = 0; i < ( tupleCount & 0xFFF ); i++ ) { @@ -2898,26 +3096,25 @@ tupleDataSize = FT_GET_USHORT(); tupleIndex = FT_GET_USHORT(); - /* There is no provision here for a global tuple coordinate section, */ - /* so John says. There are no tuple indices, just embedded tuples. */ - if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD ) { for ( j = 0; j < blend->num_axis; j++ ) tuple_coords[j] = FT_GET_SHORT() * 4; /* convert from */ /* short frac to fixed */ } - else + else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount ) { - /* skip this tuple; it makes no sense */ - - if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) - for ( j = 0; j < 2 * blend->num_axis; j++ ) - (void)FT_GET_SHORT(); + FT_TRACE2(( "tt_face_vary_cvt:" + " invalid tuple index\n" )); - offsetToData += tupleDataSize; - continue; + error = FT_THROW( Invalid_Table ); + goto Exit; } + else + FT_MEM_COPY( + tuple_coords, + &blend->tuplecoords[( tupleIndex & 0xFFF ) * blend->num_axis], + blend->num_axis * sizeof ( FT_Fixed ) ); if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) { @@ -2932,11 +3129,8 @@ tuple_coords, im_start_coords, im_end_coords ); - if ( /* tuple isn't active for our blend */ - apply == 0 || - /* global points not allowed, */ - /* if they aren't local, makes no sense */ - !( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS ) ) + + if ( apply == 0 ) /* tuple isn't active for our blend */ { offsetToData += tupleDataSize; continue; @@ -2946,14 +3140,27 @@ FT_Stream_SeekSet( stream, offsetToData ); - localpoints = ft_var_readpackedpoints( stream, - table_len, - &point_count ); - deltas = ft_var_readpackeddeltas( stream, - table_len, - point_count == 0 ? face->cvt_size - : point_count ); - if ( !localpoints || !deltas ) + if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS ) + { + localpoints = ft_var_readpackedpoints( stream, + table_len, + &point_count ); + points = localpoints; + } + else + { + points = sharedpoints; + point_count = spoint_count; + } + + deltas = ft_var_readpackeddeltas( stream, + table_len, + point_count == 0 ? face->cvt_size + : point_count ); + + if ( !points || + !deltas || + ( localpoints == ALL_POINTS && point_count != face->cvt_size ) ) ; /* failure, ignore it */ else if ( localpoints == ALL_POINTS ) @@ -3005,7 +3212,7 @@ FT_Long orig_cvt; - pindex = localpoints[j]; + pindex = points[j]; if ( (FT_ULong)pindex >= face->cvt_size ) continue; @@ -3044,6 +3251,8 @@ FT_FRAME_EXIT(); Exit: + if ( sharedpoints != ALL_POINTS ) + FT_FREE( sharedpoints ); FT_FREE( tuple_coords ); FT_FREE( im_start_coords ); FT_FREE( im_end_coords ); @@ -3330,7 +3539,6 @@ glyph_start = FT_Stream_FTell( stream ); /* each set of glyph variation data is formatted similarly to `cvar' */ - /* (except we get shared points and global tuples) */ if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis ) || FT_NEW_ARRAY( im_start_coords, blend->num_axis ) || @@ -3367,8 +3575,10 @@ FT_Stream_SeekSet( stream, here ); } - FT_TRACE5(( "gvar: there are %d tuples:\n", - tupleCount & GX_TC_TUPLE_COUNT_MASK )); + FT_TRACE5(( "gvar: there %s %d tuple%s:\n", + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are", + tupleCount & GX_TC_TUPLE_COUNT_MASK, + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" )); for ( j = 0; j < n_points; j++ ) points_org[j] = outline->points[j]; @@ -3470,7 +3680,7 @@ FT_Pos delta_y = FT_MulFix( deltas_y[j], apply ); - if ( j < n_points - 3 ) + if ( j < n_points - 4 ) { outline->points[j].x += delta_x; outline->points[j].y += delta_y; @@ -3480,25 +3690,25 @@ /* To avoid double adjustment of advance width or height, */ /* adjust phantom points only if there is no HVAR or VVAR */ /* support, respectively. */ - if ( j == ( n_points - 3 ) && - !( face->variation_support & - TT_FACE_FLAG_VAR_HADVANCE ) ) + if ( j == ( n_points - 4 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_LSB ) ) + outline->points[j].x += delta_x; + + else if ( j == ( n_points - 3 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_HADVANCE ) ) outline->points[j].x += delta_x; else if ( j == ( n_points - 2 ) && !( face->variation_support & - TT_FACE_FLAG_VAR_LSB ) ) - outline->points[j].x += delta_x; + TT_FACE_FLAG_VAR_TSB ) ) + outline->points[j].y += delta_y; else if ( j == ( n_points - 1 ) && !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) outline->points[j].y += delta_y; - - else if ( j == ( n_points - 0 ) && - !( face->variation_support & - TT_FACE_FLAG_VAR_TSB ) ) - outline->points[j].y += delta_y; } #ifdef FT_DEBUG_LEVEL_TRACE @@ -3565,8 +3775,36 @@ FT_Pos delta_y = points_out[j].y - points_org[j].y; - outline->points[j].x += delta_x; - outline->points[j].y += delta_y; + if ( j < n_points - 4 ) + { + outline->points[j].x += delta_x; + outline->points[j].y += delta_y; + } + else + { + /* To avoid double adjustment of advance width or height, */ + /* adjust phantom points only if there is no HVAR or VVAR */ + /* support, respectively. */ + if ( j == ( n_points - 4 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_LSB ) ) + outline->points[j].x += delta_x; + + else if ( j == ( n_points - 3 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_HADVANCE ) ) + outline->points[j].x += delta_x; + + else if ( j == ( n_points - 2 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_TSB ) ) + outline->points[j].y += delta_y; + + else if ( j == ( n_points - 1 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_VADVANCE ) ) + outline->points[j].y += delta_y; + } #ifdef FT_DEBUG_LEVEL_TRACE if ( delta_x || delta_y ) diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.h index 7e81719a3e1..a37bb90266c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.h @@ -4,7 +4,7 @@ /* */ /* TrueType GX Font Variation loader (specification) */ /* */ -/* Copyright 2004-2017 by */ +/* Copyright 2004-2018 by */ /* David Turner, Robert Wilhelm, Werner Lemberg and George Williams. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,6 +27,8 @@ FT_BEGIN_HEADER +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /*************************************************************************/ /* */ /* <Struct> */ @@ -402,6 +404,10 @@ FT_BEGIN_HEADER FT_Fixed* coords ); FT_LOCAL( FT_Error ) + TT_Set_Named_Instance( TT_Face face, + FT_UInt instance_index ); + + FT_LOCAL( FT_Error ) tt_face_vary_cvt( TT_Face face, FT_Stream stream ); @@ -435,6 +441,8 @@ FT_BEGIN_HEADER FT_LOCAL( void ) tt_done_blend( TT_Face face ); +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + FT_END_HEADER diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c index ddcc839bb30..d855aaaa9c6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c @@ -4,7 +4,7 @@ /* */ /* TrueType bytecode interpreter (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -25,7 +25,7 @@ #include FT_INTERNAL_CALC_H #include FT_TRIGONOMETRY_H #include FT_SYSTEM_H -#include FT_TRUETYPE_DRIVER_H +#include FT_DRIVER_H #include FT_MULTIPLE_MASTERS_H #include "ttinterp.h" @@ -5690,7 +5690,11 @@ ( B1 & 63 ) != 0 && ( B2 & 63 ) != 0 && B1 != B2 ) - Move_Zp2_Point( exc, point, -dx, -dy, TRUE ); + Move_Zp2_Point( exc, + point, + NEG_LONG( dx ), + NEG_LONG( dy ), + TRUE ); } } else if ( exc->face->sph_compatibility_mode ) @@ -5722,7 +5726,7 @@ if ( ( B1 & 63 ) == 0 && ( B2 & 63 ) != 0 && B1 != B2 ) - Move_Zp2_Point( exc, point, 0, -dy, TRUE ); + Move_Zp2_Point( exc, point, 0, NEG_LONG( dy ), TRUE ); } } else if ( exc->sph_in_func_flags & SPH_FDEF_TYPEMAN_DIAGENDCTRL ) @@ -5991,7 +5995,7 @@ exc->tt_metrics.compensations[0] ); } - exc->func_move( exc, &exc->zp0, point, distance - org_dist ); + exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) ); Fail: exc->GS.rp0 = point; @@ -6074,8 +6078,12 @@ /* single width cut-in test */ - if ( FT_ABS( org_dist - exc->GS.single_width_value ) < - exc->GS.single_width_cutin ) + /* |org_dist - single_width_value| < single_width_cutin */ + if ( exc->GS.single_width_cutin > 0 && + org_dist < exc->GS.single_width_value + + exc->GS.single_width_cutin && + org_dist > exc->GS.single_width_value - + exc->GS.single_width_cutin ) { if ( org_dist >= 0 ) org_dist = exc->GS.single_width_value; @@ -7153,7 +7161,7 @@ SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP ) && ( B1 & 63 ) != 0 && ( B2 & 63 ) != 0 ) ) ) - exc->func_move( exc, &exc->zp0, A, -B ); + exc->func_move( exc, &exc->zp0, A, NEG_LONG( B ) ); } } else @@ -8478,7 +8486,9 @@ } while ( !exc->instruction_trap ); LNo_Error_: - FT_TRACE4(( " %d instructions executed\n", ins_counter )); + FT_TRACE4(( " %d instruction%s executed\n", + ins_counter == 1 ? "" : "s", + ins_counter )); return FT_Err_Ok; LErrorCodeOverflow_: diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.h index abbecfcee3b..2966439ea25 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.h @@ -4,7 +4,7 @@ /* */ /* TrueType bytecode interpreter (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.c index 081fa2f1a5c..bc8086f2568 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.c @@ -4,7 +4,7 @@ /* */ /* Objects manager (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,7 +21,7 @@ #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H #include FT_INTERNAL_SFNT_H -#include FT_TRUETYPE_DRIVER_H +#include FT_DRIVER_H #include "ttgload.h" #include "ttpload.h" @@ -147,7 +147,7 @@ { #define TRICK_NAMES_MAX_CHARACTERS 19 -#define TRICK_NAMES_COUNT 18 +#define TRICK_NAMES_COUNT 23 static const char trick_names[TRICK_NAMES_COUNT] [TRICK_NAMES_MAX_CHARACTERS + 1] = @@ -165,6 +165,11 @@ "cpop", /* dftt-p7.ttf; version 1.00, 1992 [DLJGyShoMedium] */ "DFGirl-W6-WIN-BF", /* dftt-h6.ttf; version 1.00, 1993 */ + "DFGothic-EB", /* DynaLab Inc. 1992-1995 */ + "DFGyoSho-Lt", /* DynaLab Inc. 1992-1995 */ + "DFHSGothic-W5", /* DynaLab Inc. 1992-1995 */ + "DFHSMincho-W3", /* DynaLab Inc. 1992-1995 */ + "DFHSMincho-W7", /* DynaLab Inc. 1992-1995 */ "DFKaiSho-SB", /* dfkaisb.ttf */ "DFKaiShu", "DFKai-SB", /* kaiu.ttf; version 3.00, 1998 [DFKaiShu-SB-Estd-BF] */ @@ -265,7 +270,7 @@ tt_check_trickyness_sfnt_ids( TT_Face face ) { #define TRICK_SFNT_IDS_PER_FACE 3 -#define TRICK_SFNT_IDS_NUM_FACES 19 +#define TRICK_SFNT_IDS_NUM_FACES 26 static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES] [TRICK_SFNT_IDS_PER_FACE] = { @@ -284,6 +289,31 @@ { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */ { 0xA344A1EBUL, 0x000001E1UL } /* prep */ }, + { /* DFGothic-EB */ + { 0x12C3EBB2UL, 0x00000350UL }, /* cvt */ + { 0xB680EE64UL, 0x000087A7UL }, /* fpgm */ + { 0xCE939563UL, 0x00000758UL } /* prep */ + }, + { /* DFGyoSho-Lt */ + { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */ + { 0xCE5956E9UL, 0x0000BC85UL }, /* fpgm */ + { 0x8272F416UL, 0x00000045UL } /* prep */ + }, + { /* DFHSGothic-W5 */ + { 0x1262EB4EUL, 0x00000350UL }, /* cvt */ + { 0xE86A5D64UL, 0x00007940UL }, /* fpgm */ + { 0x7850F729UL, 0x000005FFUL } /* prep */ + }, + { /* DFHSMincho-W3 */ + { 0x122DEB0AUL, 0x00000350UL }, /* cvt */ + { 0x3D16328AUL, 0x0000859BUL }, /* fpgm */ + { 0xA93FC33BUL, 0x000002CBUL } /* prep */ + }, + { /* DFHSMincho-W7 */ + { 0x125FEB26UL, 0x00000350UL }, /* cvt */ + { 0xA5ACC982UL, 0x00007EE1UL }, /* fpgm */ + { 0x90999196UL, 0x0000041FUL } /* prep */ + }, { /* DFKaiShu */ { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */ { 0x5A30CA3BUL, 0x00009063UL }, /* fpgm */ @@ -294,6 +324,16 @@ { 0xA6E78C01UL, 0x00008998UL }, /* fpgm */ { 0x13A42602UL, 0x0000007EUL } /* prep */ }, + { /* DLCLiShu */ + { 0x07DCF546UL, 0x00000308UL }, /* cvt */ + { 0x40FE7C90UL, 0x00008E2AUL }, /* fpgm */ + { 0x608174B5UL, 0x0000007AUL } /* prep */ + }, + { /* DLCHayBold */ + { 0xEB891238UL, 0x00000308UL }, /* cvt */ + { 0xD2E4DCD4UL, 0x0000676FUL }, /* fpgm */ + { 0x8EA5F293UL, 0x000003B8UL } /* prep */ + }, { /* HuaTianKaiTi */ { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */ { 0x9C9E48B8UL, 0x0000BEA2UL }, /* fpgm */ @@ -657,46 +697,17 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT { - FT_Int instance_index = face_index >> 16; + FT_UInt instance_index = (FT_UInt)face_index >> 16; if ( FT_HAS_MULTIPLE_MASTERS( ttface ) && instance_index > 0 ) { - error = TT_Get_MM_Var( face, NULL ); + error = TT_Set_Named_Instance( face, instance_index ); if ( error ) goto Exit; - if ( face->blend->mmvar->namedstyle ) - { - FT_Memory memory = ttface->memory; - - FT_Var_Named_Style* named_style; - FT_String* style_name; - - - /* in `face_index', the instance index starts with value 1 */ - named_style = face->blend->mmvar->namedstyle + instance_index - 1; - error = sfnt->get_name( face, - (FT_UShort)named_style->strid, - &style_name ); - if ( error ) - goto Exit; - - /* set style name; if already set, replace it */ - if ( face->root.style_name ) - FT_FREE( face->root.style_name ); - face->root.style_name = style_name; - - /* finally, select the named instance */ - error = TT_Set_Var_Design( face, - face->blend->mmvar->num_axis, - named_style->coords ); - if ( error ) - goto Exit; - - tt_apply_mvar( face ); - } + tt_apply_mvar( face ); } } diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.h index cdacee75e5a..38fa30e4e9f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.h @@ -4,7 +4,7 @@ /* */ /* Objects manager (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpic.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpic.c index 66bd7e1934c..cdbb80639e1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpic.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for truetype module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpic.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpic.h index 1410cd73c30..df878ae6f1d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpic.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for truetype module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c index bcf6b34f67f..d9526ad082b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c @@ -4,7 +4,7 @@ /* */ /* TrueType-specific tables loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.h index 79079f345af..fa125272472 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.h @@ -4,7 +4,7 @@ /* */ /* TrueType-specific tables loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttsubpix.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttsubpix.c index 1c8cf011098..d94bcc8b50d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttsubpix.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttsubpix.c @@ -4,7 +4,7 @@ /* */ /* TrueType Subpixel Hinting. */ /* */ -/* Copyright 2010-2017 by */ +/* Copyright 2010-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,7 +22,7 @@ #include FT_INTERNAL_SFNT_H #include FT_TRUETYPE_TAGS_H #include FT_OUTLINE_H -#include FT_TRUETYPE_DRIVER_H +#include FT_DRIVER_H #include "ttsubpix.h" @@ -753,24 +753,24 @@ /* Does font name match rule family? */ - if ( strcmp( detected_font_name, rule_font_name ) == 0 ) + if ( ft_strcmp( detected_font_name, rule_font_name ) == 0 ) return TRUE; /* Is font name a wildcard ""? */ - if ( strcmp( rule_font_name, "" ) == 0 ) + if ( ft_strcmp( rule_font_name, "" ) == 0 ) return TRUE; /* Is font name contained in a class list? */ for ( i = 0; i < FAMILY_CLASS_RULES_SIZE; i++ ) { - if ( strcmp( FAMILY_CLASS_Rules[i].name, rule_font_name ) == 0 ) + if ( ft_strcmp( FAMILY_CLASS_Rules[i].name, rule_font_name ) == 0 ) { for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ ) { - if ( strcmp( FAMILY_CLASS_Rules[i].member[j], "" ) == 0 ) + if ( ft_strcmp( FAMILY_CLASS_Rules[i].member[j], "" ) == 0 ) continue; - if ( strcmp( FAMILY_CLASS_Rules[i].member[j], - detected_font_name ) == 0 ) + if ( ft_strcmp( FAMILY_CLASS_Rules[i].member[j], + detected_font_name ) == 0 ) return TRUE; } } @@ -788,24 +788,24 @@ /* Does font style match rule style? */ - if ( strcmp( detected_font_style, rule_font_style ) == 0 ) + if ( ft_strcmp( detected_font_style, rule_font_style ) == 0 ) return TRUE; /* Is font style a wildcard ""? */ - if ( strcmp( rule_font_style, "" ) == 0 ) + if ( ft_strcmp( rule_font_style, "" ) == 0 ) return TRUE; /* Is font style contained in a class list? */ for ( i = 0; i < STYLE_CLASS_RULES_SIZE; i++ ) { - if ( strcmp( STYLE_CLASS_Rules[i].name, rule_font_style ) == 0 ) + if ( ft_strcmp( STYLE_CLASS_Rules[i].name, rule_font_style ) == 0 ) { for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ ) { - if ( strcmp( STYLE_CLASS_Rules[i].member[j], "" ) == 0 ) + if ( ft_strcmp( STYLE_CLASS_Rules[i].member[j], "" ) == 0 ) continue; - if ( strcmp( STYLE_CLASS_Rules[i].member[j], - detected_font_style ) == 0 ) + if ( ft_strcmp( STYLE_CLASS_Rules[i].member[j], + detected_font_style ) == 0 ) return TRUE; } } diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttsubpix.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttsubpix.h index c68f97ff074..1070bb016fd 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttsubpix.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttsubpix.h @@ -4,7 +4,7 @@ /* */ /* TrueType Subpixel Hinting. */ /* */ -/* Copyright 2010-2017 by */ +/* Copyright 2010-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/Jamfile b/Build/source/libs/freetype2/freetype-src/src/type1/Jamfile index 6c10a31a18a..b94b7d0aae9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/type1/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/type1 Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/module.mk b/Build/source/libs/freetype2/freetype-src/src/type1/module.mk index f299d6fe88d..3fea5cc16fe 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/type1/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/rules.mk b/Build/source/libs/freetype2/freetype-src/src/type1/rules.mk index 97bef288f0f..cb1a1428609 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/type1/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1afm.c b/Build/source/libs/freetype2/freetype-src/src/type1/t1afm.c index 11a2646fc25..61053d9a640 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1afm.c +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1afm.c @@ -4,7 +4,7 @@ /* */ /* AFM support for Type 1 fonts (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1afm.h b/Build/source/libs/freetype2/freetype-src/src/type1/t1afm.h index 9f62cd013d9..cb8d302b4d4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1afm.h +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1afm.h @@ -4,7 +4,7 @@ /* */ /* AFM support for Type 1 fonts (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1driver.c b/Build/source/libs/freetype2/freetype-src/src/type1/t1driver.c index c2089947f94..029b410b476 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1driver.c +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1driver.c @@ -4,7 +4,7 @@ /* */ /* Type 1 driver interface (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,6 +30,8 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_HASH_H +#include FT_INTERNAL_POSTSCRIPT_PROPS_H +#include FT_DRIVER_H #include FT_SERVICE_MULTIPLE_MASTERS_H #include FT_SERVICE_GLYPH_DICT_H @@ -37,6 +39,7 @@ #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_SERVICE_POSTSCRIPT_INFO_H +#include FT_SERVICE_PROPERTIES_H #include FT_SERVICE_KERNING_H @@ -126,6 +129,7 @@ (FT_Get_MM_Var_Func) T1_Get_MM_Var, /* get_mm_var */ (FT_Set_Var_Design_Func)T1_Set_Var_Design, /* set_var_design */ (FT_Get_Var_Design_Func)T1_Get_Var_Design, /* get_var_design */ + (FT_Set_Instance_Func) T1_Reset_MM_Blend, /* set_instance */ (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */ (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */ @@ -614,6 +618,18 @@ /* + * PROPERTY SERVICE + * + */ + + FT_DEFINE_SERVICE_PROPERTIESREC( + t1_service_properties, + + (FT_Properties_SetFunc)ps_property_set, /* set_property */ + (FT_Properties_GetFunc)ps_property_get ) /* get_property */ + + + /* * SERVICE LIST * */ @@ -624,6 +640,7 @@ { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict }, { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TYPE_1 }, { FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info }, + { FT_SERVICE_ID_PROPERTIES, &t1_service_properties }, #ifndef T1_CONFIG_OPTION_NO_AFM { FT_SERVICE_ID_KERNING, &t1_service_kerning }, @@ -713,7 +730,7 @@ FT_MODULE_DRIVER_SCALABLE | FT_MODULE_DRIVER_HAS_HINTER, - sizeof ( FT_DriverRec ), + sizeof ( PS_DriverRec ), "type1", 0x10000L, diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1driver.h b/Build/source/libs/freetype2/freetype-src/src/type1/t1driver.h index 292786448dc..2b1507233dd 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1driver.h +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1driver.h @@ -4,7 +4,7 @@ /* */ /* High-level Type 1 driver interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1errors.h b/Build/source/libs/freetype2/freetype-src/src/type1/t1errors.h index 492dbb4a421..9e0151b9571 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1errors.h +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1errors.h @@ -4,7 +4,7 @@ /* */ /* Type 1 error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1gload.c b/Build/source/libs/freetype2/freetype-src/src/type1/t1gload.c index aaf19b6dcce..87d40e75660 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1gload.c +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1gload.c @@ -4,7 +4,7 @@ /* */ /* Type 1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -23,6 +23,8 @@ #include FT_INTERNAL_STREAM_H #include FT_OUTLINE_H #include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_CFF_TYPES_H +#include FT_DRIVER_H #include "t1errors.h" @@ -37,37 +39,28 @@ #define FT_COMPONENT trace_t1gload - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ - /********** *********/ - /********** The following code is in charge of computing *********/ - /********** the maximum advance width of the font. It *********/ - /********** quickly processes each glyph charstring to *********/ - /********** extract the value from either a `sbw' or `seac' *********/ - /********** operator. *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - static FT_Error T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder, FT_UInt glyph_index, - FT_Data* char_string ) + FT_Data* char_string, + FT_Bool* force_scaling ) { T1_Face face = (T1_Face)decoder->builder.face; T1_Font type1 = &face->type1; FT_Error error = FT_Err_Ok; + PSAux_Service psaux = (PSAux_Service)face->psaux; + const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs; + PS_Decoder psdecoder; + #ifdef FT_CONFIG_OPTION_INCREMENTAL FT_Incremental_InterfaceRec *inc = face->root.internal->incremental_interface; #endif +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); +#endif decoder->font_matrix = type1->font_matrix; decoder->font_offset = type1->font_offset; @@ -90,9 +83,56 @@ } if ( !error ) - error = decoder->funcs.parse_charstrings( - decoder, (FT_Byte*)char_string->pointer, - (FT_UInt)char_string->length ); + { + /* choose which renderer to use */ +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + if ( driver->hinting_engine == FT_HINTING_FREETYPE || + decoder->builder.metrics_only ) + error = decoder_funcs->parse_charstrings_old( + decoder, + (FT_Byte*)char_string->pointer, + (FT_UInt)char_string->length ); +#else + if ( decoder->builder.metrics_only ) + error = decoder_funcs->parse_metrics( + decoder, + (FT_Byte*)char_string->pointer, + (FT_UInt)char_string->length ); +#endif + else + { + CFF_SubFontRec subfont; + + + psaux->ps_decoder_init( &psdecoder, decoder, TRUE ); + + psaux->t1_make_subfont( FT_FACE( face ), + &face->type1.private_dict, &subfont ); + psdecoder.current_subfont = &subfont; + + error = decoder_funcs->parse_charstrings( + &psdecoder, + (FT_Byte*)char_string->pointer, + (FT_ULong)char_string->length ); + + /* Adobe's engine uses 16.16 numbers everywhere; */ + /* as a consequence, glyphs larger than 2000ppem get rejected */ + if ( FT_ERR_EQ( error, Glyph_Too_Big ) ) + { + /* this time, we retry unhinted and scale up the glyph later on */ + /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */ + /* 0x400 for both `x_scale' and `y_scale' in this case) */ + ((T1_GlyphSlot)decoder->builder.glyph)->hint = FALSE; + + *force_scaling = TRUE; + + error = decoder_funcs->parse_charstrings( + &psdecoder, + (FT_Byte*)char_string->pointer, + (FT_ULong)char_string->length ); + } + } + } #ifdef FT_CONFIG_OPTION_INCREMENTAL @@ -126,8 +166,10 @@ FT_UInt glyph_index ) { FT_Data glyph_data; - FT_Error error = T1_Parse_Glyph_And_Get_Char_String( - decoder, glyph_index, &glyph_data ); + FT_Bool force_scaling = FALSE; + FT_Error error = T1_Parse_Glyph_And_Get_Char_String( + decoder, glyph_index, &glyph_data, + &force_scaling ); #ifdef FT_CONFIG_OPTION_INCREMENTAL @@ -149,6 +191,23 @@ } + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********** *********/ + /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ + /********** *********/ + /********** The following code is in charge of computing *********/ + /********** the maximum advance width of the font. It *********/ + /********** quickly processes each glyph charstring to *********/ + /********** extract the value from either a `sbw' or `seac' *********/ + /********** operator. *********/ + /********** *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + FT_LOCAL_DEF( FT_Error ) T1_Compute_Max_Advance( T1_Face face, FT_Pos* max_advance ) @@ -278,6 +337,8 @@ T1_DecoderRec decoder; T1_Face face = (T1_Face)t1glyph->face; FT_Bool hinting; + FT_Bool scaled; + FT_Bool force_scaling = FALSE; T1_Font type1 = &face->type1; PSAux_Service psaux = (PSAux_Service)face->psaux; const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs; @@ -325,7 +386,10 @@ hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); + scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ); + glyph->hint = hinting; + glyph->scaled = scaled; t1glyph->format = FT_GLYPH_FORMAT_OUTLINE; error = decoder_funcs->init( &decoder, @@ -355,13 +419,15 @@ /* now load the unscaled outline */ error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index, - &glyph_data ); + &glyph_data, + &force_scaling ); if ( error ) goto Exit; #ifdef FT_CONFIG_OPTION_INCREMENTAL glyph_data_loaded = 1; #endif + hinting = glyph->hint; font_matrix = decoder.font_matrix; font_offset = decoder.font_offset; @@ -451,7 +517,7 @@ } #endif - if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) + if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling ) { /* scale the outline and the metrics */ FT_Int n; diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1gload.h b/Build/source/libs/freetype2/freetype-src/src/type1/t1gload.h index cc4d5e734fb..72ef76f6ae3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1gload.h +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1gload.h @@ -4,7 +4,7 @@ /* */ /* Type 1 Glyph Loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1load.c b/Build/source/libs/freetype2/freetype-src/src/type1/t1load.c index f569d6bec36..2b8d4893c69 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1load.c +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1load.c @@ -4,7 +4,7 @@ /* */ /* Type 1 font loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -366,14 +366,16 @@ } - FT_LOCAL_DEF( FT_Error ) - T1_Set_MM_Blend( T1_Face face, + static FT_Error + t1_set_mm_blend( T1_Face face, FT_UInt num_coords, FT_Fixed* coords ) { PS_Blend blend = face->blend; FT_UInt n, m; + FT_Bool have_diff = 0; + if ( !blend ) return FT_THROW( Invalid_Argument ); @@ -405,9 +407,36 @@ result = FT_MulFix( result, factor ); } - blend->weight_vector[n] = result; + + if ( blend->weight_vector[n] != result ) + { + blend->weight_vector[n] = result; + have_diff = 1; + } } + /* return value -1 indicates `no change' */ + return have_diff ? FT_Err_Ok : -1; + } + + + FT_LOCAL_DEF( FT_Error ) + T1_Set_MM_Blend( T1_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + FT_Error error; + + + error = t1_set_mm_blend( face, num_coords, coords ); + if ( error ) + return error; + + if ( num_coords ) + face->root.face_flags |= FT_FACE_FLAG_VARIATION; + else + face->root.face_flags &= ~FT_FACE_FLAG_VARIATION; + return FT_Err_Ok; } @@ -452,6 +481,7 @@ FT_UInt num_coords, FT_Long* coords ) { + FT_Error error; PS_Blend blend = face->blend; FT_UInt n, p; FT_Fixed final_blends[T1_MAX_MM_DESIGNS]; @@ -518,7 +548,28 @@ final_blends[n] = the_blend; } - return T1_Set_MM_Blend( face, blend->num_axis, final_blends ); + error = t1_set_mm_blend( face, blend->num_axis, final_blends ); + if ( error ) + return error; + + if ( num_coords ) + face->root.face_flags |= FT_FACE_FLAG_VARIATION; + else + face->root.face_flags &= ~FT_FACE_FLAG_VARIATION; + + return FT_Err_Ok; + } + + + /* MM fonts don't have named instances, so only the design is reset */ + + FT_LOCAL_DEF( FT_Error ) + T1_Reset_MM_Blend( T1_Face face, + FT_UInt instance_index ) + { + FT_UNUSED( instance_index ); + + return T1_Set_MM_Blend( face, 0, NULL ); } @@ -1266,7 +1317,7 @@ if ( ft_isdigit( *cur ) || *cur == '[' ) { T1_Encoding encode = &face->type1.encoding; - FT_Int count, n; + FT_Int count, array_size, n; PS_Table char_table = &loader->encoding_table; FT_Memory memory = parser->root.memory; FT_Error error; @@ -1283,13 +1334,12 @@ else count = (FT_Int)T1_ToInt( parser ); - /* only composite fonts (which we don't support) */ - /* can have larger values */ + array_size = count; if ( count > 256 ) { - FT_ERROR(( "parse_encoding: invalid encoding array size\n" )); - parser->root.error = FT_THROW( Invalid_File_Format ); - return; + FT_TRACE2(( "parse_encoding:" + " only using first 256 encoding array entries\n" )); + array_size = 256; } T1_Skip_Spaces( parser ); @@ -1305,18 +1355,18 @@ } /* we use a T1_Table to store our charnames */ - loader->num_chars = encode->num_chars = count; - if ( FT_NEW_ARRAY( encode->char_index, count ) || - FT_NEW_ARRAY( encode->char_name, count ) || + loader->num_chars = encode->num_chars = array_size; + if ( FT_NEW_ARRAY( encode->char_index, array_size ) || + FT_NEW_ARRAY( encode->char_name, array_size ) || FT_SET_ERROR( psaux->ps_table_funcs->init( - char_table, count, memory ) ) ) + char_table, array_size, memory ) ) ) { parser->root.error = error; return; } /* We need to `zero' out encoding_table.elements */ - for ( n = 0; n < count; n++ ) + for ( n = 0; n < array_size; n++ ) { char* notdef = (char *)".notdef"; @@ -1409,11 +1459,14 @@ len = (FT_UInt)( parser->root.cursor - cur ); - parser->root.error = T1_Add_Table( char_table, charcode, - cur, len + 1 ); - if ( parser->root.error ) - return; - char_table->elements[charcode][len] = '\0'; + if ( n < array_size ) + { + parser->root.error = T1_Add_Table( char_table, charcode, + cur, len + 1 ); + if ( parser->root.error ) + return; + char_table->elements[charcode][len] = '\0'; + } n++; } diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1load.h b/Build/source/libs/freetype2/freetype-src/src/type1/t1load.h index 2d86984f0e7..03be3f7f937 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1load.h +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1load.h @@ -4,7 +4,7 @@ /* */ /* Type 1 font loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -90,6 +90,10 @@ FT_BEGIN_HEADER FT_Long* coords ); FT_LOCAL( FT_Error ) + T1_Reset_MM_Blend( T1_Face face, + FT_UInt instance_index ); + + FT_LOCAL( FT_Error ) T1_Get_Var_Design( T1_Face face, FT_UInt num_coords, FT_Fixed* coords ); diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1objs.c b/Build/source/libs/freetype2/freetype-src/src/type1/t1objs.c index 5ac1292ae0b..7333c4c9587 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1objs.c +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1objs.c @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,6 +21,7 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_IDS_H +#include FT_DRIVER_H #include "t1gload.h" #include "t1load.h" @@ -379,7 +380,7 @@ /* simplistic and might get some things wrong. For a full-featured */ /* algorithm you might have a look at the whitepaper given at */ /* */ - /* http://blogs.msdn.com/text/archive/2007/04/23/wpf-font-selection-model.aspx */ + /* https://blogs.msdn.com/text/archive/2007/04/23/wpf-font-selection-model.aspx */ /* get style name -- be careful, some broken fonts only */ /* have a `/FontName' dictionary entry! */ @@ -578,9 +579,42 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - T1_Driver_Init( FT_Module driver ) + T1_Driver_Init( FT_Module module ) { - FT_UNUSED( driver ); + PS_Driver driver = (PS_Driver)module; + + FT_UInt32 seed; + + + /* set default property values, cf. `ftt1drv.h' */ +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + driver->hinting_engine = FT_HINTING_FREETYPE; +#else + driver->hinting_engine = FT_HINTING_ADOBE; +#endif + + driver->no_stem_darkening = TRUE; + + driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1; + driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1; + driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2; + driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2; + driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3; + driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3; + driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4; + driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4; + + /* compute random seed from some memory addresses */ + seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^ + (FT_Offset)(char*)&module ^ + (FT_Offset)(char*)module->memory ); + seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 ); + + driver->random_seed = (FT_Int32)seed; + if ( driver->random_seed < 0 ) + driver->random_seed = -driver->random_seed; + else if ( driver->random_seed == 0 ) + driver->random_seed = 123456789; return FT_Err_Ok; } diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1objs.h b/Build/source/libs/freetype2/freetype-src/src/type1/t1objs.h index 39d26bf8b9a..8298e036f4b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1objs.h +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1objs.h @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -120,12 +120,12 @@ FT_BEGIN_HEADER FT_Bool hint; FT_Bool scaled; - FT_Int max_points; - FT_Int max_contours; - FT_Fixed x_scale; FT_Fixed y_scale; + FT_Int max_points; + FT_Int max_contours; + } T1_GlyphSlotRec; diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1parse.c b/Build/source/libs/freetype2/freetype-src/src/type1/t1parse.c index 18dd26434ce..8e201e5ef5a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1parse.c +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1parse.c @@ -4,7 +4,7 @@ /* */ /* Type 1 parser (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1parse.h b/Build/source/libs/freetype2/freetype-src/src/type1/t1parse.h index 3396680d1a3..4ac82ae913e 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1parse.h +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1parse.h @@ -4,7 +4,7 @@ /* */ /* Type 1 parser (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1tokens.h b/Build/source/libs/freetype2/freetype-src/src/type1/t1tokens.h index ca0c55f9037..43a65d88ea4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1tokens.h +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1tokens.h @@ -4,7 +4,7 @@ /* */ /* Type 1 tokenizer (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/type1.c b/Build/source/libs/freetype2/freetype-src/src/type1/type1.c index 81795376ef2..72eff59bfed 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/type1.c +++ b/Build/source/libs/freetype2/freetype-src/src/type1/type1.c @@ -4,7 +4,7 @@ /* */ /* FreeType Type 1 driver component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/Jamfile b/Build/source/libs/freetype2/freetype-src/src/type42/Jamfile index b826bbc4619..b98de05a746 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/type42/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/type42 Jamfile # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/module.mk b/Build/source/libs/freetype2/freetype-src/src/type42/module.mk index 2f52806808d..3d4732bb6f7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/type42/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/rules.mk b/Build/source/libs/freetype2/freetype-src/src/type42/rules.mk index d7e89650153..9325d3898fd 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/type42/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2017 by +# Copyright 2002-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.c b/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.c index 366cfb3a1de..f579b2708c8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.c @@ -4,7 +4,7 @@ /* */ /* High-level Type 42 driver interface (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.h b/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.h index 1ac4a0a1a12..3667f3e0667 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.h +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.h @@ -4,7 +4,7 @@ /* */ /* High-level Type 42 driver interface (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42error.h b/Build/source/libs/freetype2/freetype-src/src/type42/t42error.h index fda92abf57c..e3978a76077 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42error.h +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42error.h @@ -4,7 +4,7 @@ /* */ /* Type 42 error codes (specification only). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.c b/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.c index 1c4ebd768a0..66e5c403825 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.c +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.c @@ -4,7 +4,7 @@ /* */ /* Type 42 objects manager (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.h b/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.h index eb4c5bf69f8..3bad5135e09 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.h +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.h @@ -4,7 +4,7 @@ /* */ /* Type 42 objects manager (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c b/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c index e7c6770bd29..4813d1f3f98 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.c @@ -4,7 +4,7 @@ /* */ /* Type 42 font parser (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.h b/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.h index 7a68606f2e2..f35d23de635 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.h +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42parse.h @@ -4,7 +4,7 @@ /* */ /* Type 42 font parser (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42types.h b/Build/source/libs/freetype2/freetype-src/src/type42/t42types.h index 2306ab6c773..d0aa2de5705 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42types.h +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42types.h @@ -4,7 +4,7 @@ /* */ /* Type 42 font data types (specification only). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/type42.c b/Build/source/libs/freetype2/freetype-src/src/type42/type42.c index ae8ac267823..6a89cfbed1b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/type42.c +++ b/Build/source/libs/freetype2/freetype-src/src/type42/type42.c @@ -4,7 +4,7 @@ /* */ /* FreeType Type 42 driver component. */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/winfonts/Jamfile b/Build/source/libs/freetype2/freetype-src/src/winfonts/Jamfile index 52aa7f93662..4385e3b39f1 100644 --- a/Build/source/libs/freetype2/freetype-src/src/winfonts/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/winfonts/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/winfonts Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/winfonts/fnterrs.h b/Build/source/libs/freetype2/freetype-src/src/winfonts/fnterrs.h index 4251021a700..3a86af5aace 100644 --- a/Build/source/libs/freetype2/freetype-src/src/winfonts/fnterrs.h +++ b/Build/source/libs/freetype2/freetype-src/src/winfonts/fnterrs.h @@ -4,7 +4,7 @@ /* */ /* Win FNT/FON error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/winfonts/module.mk b/Build/source/libs/freetype2/freetype-src/src/winfonts/module.mk index ffc53a19f9f..13f9077cfc6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/winfonts/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/winfonts/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/winfonts/rules.mk b/Build/source/libs/freetype2/freetype-src/src/winfonts/rules.mk index 73e825d9ae0..d694d1a7711 100644 --- a/Build/source/libs/freetype2/freetype-src/src/winfonts/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/winfonts/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.c b/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.c index 4c479623193..36bd3148d51 100644 --- a/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.c +++ b/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.c @@ -4,7 +4,7 @@ /* */ /* FreeType font driver for Windows FNT/FON files */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* Copyright 2003 Huw D M Davies for Codeweavers */ /* Copyright 2007 Dmitry Timoshkov for Codeweavers */ diff --git a/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.h b/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.h index 884b645a2db..4885c9d7452 100644 --- a/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.h +++ b/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.h @@ -4,7 +4,7 @@ /* */ /* FreeType font driver for Windows FNT/FON files */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* Copyright 2007 Dmitry Timoshkov for Codeweavers */ /* */ |