From 255f83825235080240c64c61c6c62abb6beec962 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 7 Feb 2017 14:32:54 +0000
Subject: freetype2: update to 2.7.1

---
 .../0001-Enable-table-validation-modules.patch     |  34 +++++++
 .../freetype2/0002-Enable-subpixel-rendering.patch |  25 +++++
 .../0003-Enable-infinality-subpixel-hinting.patch  |  27 ++++++
 .../freetype2/0005-freetype-2.5.2-more-demos.patch |  17 ++++
 abs/core/freetype2/PKGBUILD                        | 106 ++++++++++++++-------
 abs/core/freetype2/fix_segfault_with_harfbuzz.diff |  32 -------
 .../freetype2/freetype-2.2.1-enable-valid.patch    |  20 ----
 abs/core/freetype2/freetype-2.5.1-enable-sph.patch |  13 ---
 abs/core/freetype2/freetype-2.5.1-enable-spr.patch |  13 ---
 abs/core/freetype2/freetype2.install               |   8 ++
 abs/core/freetype2/freetype2.sh                    |  12 +++
 11 files changed, 196 insertions(+), 111 deletions(-)
 create mode 100644 abs/core/freetype2/0001-Enable-table-validation-modules.patch
 create mode 100644 abs/core/freetype2/0002-Enable-subpixel-rendering.patch
 create mode 100644 abs/core/freetype2/0003-Enable-infinality-subpixel-hinting.patch
 create mode 100644 abs/core/freetype2/0005-freetype-2.5.2-more-demos.patch
 delete mode 100644 abs/core/freetype2/fix_segfault_with_harfbuzz.diff
 delete mode 100644 abs/core/freetype2/freetype-2.2.1-enable-valid.patch
 delete mode 100644 abs/core/freetype2/freetype-2.5.1-enable-sph.patch
 delete mode 100644 abs/core/freetype2/freetype-2.5.1-enable-spr.patch
 create mode 100644 abs/core/freetype2/freetype2.install
 create mode 100644 abs/core/freetype2/freetype2.sh

diff --git a/abs/core/freetype2/0001-Enable-table-validation-modules.patch b/abs/core/freetype2/0001-Enable-table-validation-modules.patch
new file mode 100644
index 0000000..3e9451f
--- /dev/null
+++ b/abs/core/freetype2/0001-Enable-table-validation-modules.patch
@@ -0,0 +1,34 @@
+From c3680bf8d38cf759c1e33dcc2d2d51e0a4fea2f9 Mon Sep 17 00:00:00 2001
+From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
+Date: Tue, 23 Jun 2015 08:40:29 +0200
+Subject: [PATCH 1/3] Enable table validation modules
+
+---
+ modules.cfg | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/modules.cfg b/modules.cfg
+index f30049c38cc45159..7b8e50fe1b34584a 100644
+--- a/modules.cfg
++++ b/modules.cfg
+@@ -120,7 +120,7 @@ AUX_MODULES += cache
+ # TrueType GX/AAT table validation.  Needs ftgxval.c below.
+ #
+ # No FT_CONFIG_OPTION_PIC support.
+-# AUX_MODULES += gxvalid
++AUX_MODULES += gxvalid
+ 
+ # Support for streams compressed with gzip (files with suffix .gz).
+ #
+@@ -143,7 +143,7 @@ AUX_MODULES += bzip2
+ # OpenType table validation.  Needs ftotval.c below.
+ #
+ # No FT_CONFIG_OPTION_PIC support.
+-# AUX_MODULES += otvalid
++AUX_MODULES += otvalid
+ 
+ # Auxiliary PostScript driver component to share common code.
+ #
+-- 
+2.9.3
+
diff --git a/abs/core/freetype2/0002-Enable-subpixel-rendering.patch b/abs/core/freetype2/0002-Enable-subpixel-rendering.patch
new file mode 100644
index 0000000..dfb5796
--- /dev/null
+++ b/abs/core/freetype2/0002-Enable-subpixel-rendering.patch
@@ -0,0 +1,25 @@
+From 96f09f08417887b2618c177bccfb6da2906568d9 Mon Sep 17 00:00:00 2001
+From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
+Date: Tue, 23 Jun 2015 08:43:07 +0200
+Subject: [PATCH 2/3] Enable subpixel rendering
+
+---
+ include/freetype/config/ftoption.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
+index 90c123ef93e9ea04..67a361dd41e0b026 100644
+--- a/include/freetype/config/ftoption.h
++++ b/include/freetype/config/ftoption.h
+@@ -122,7 +122,7 @@ FT_BEGIN_HEADER
+   /* This is done to allow FreeType clients to run unmodified, forcing     */
+   /* them to display normal gray-level anti-aliased glyphs.                */
+   /*                                                                       */
+-/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
++#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
+ 
+ 
+   /*************************************************************************/
+-- 
+2.9.3
+
diff --git a/abs/core/freetype2/0003-Enable-infinality-subpixel-hinting.patch b/abs/core/freetype2/0003-Enable-infinality-subpixel-hinting.patch
new file mode 100644
index 0000000..bbfa2a2
--- /dev/null
+++ b/abs/core/freetype2/0003-Enable-infinality-subpixel-hinting.patch
@@ -0,0 +1,27 @@
+From 220e96a9a8d7aff6ad0f0f1aa12c79cdb563331c Mon Sep 17 00:00:00 2001
+From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
+Date: Mon, 29 Aug 2016 08:43:10 +0200
+Subject: [PATCH 3/3] Enable infinality subpixel hinting
+
+---
+ include/freetype/config/ftoption.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
+index 67a361dd41e0b026..c4812862518b66a6 100644
+--- a/include/freetype/config/ftoption.h
++++ b/include/freetype/config/ftoption.h
+@@ -675,8 +675,8 @@ FT_BEGIN_HEADER
+   /* [1] http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
+   /*                                                                       */
+ /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING  1         */
+-#define TT_CONFIG_OPTION_SUBPIXEL_HINTING  2
+-/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING  ( 1 | 2 ) */
++/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING  2         */
++#define TT_CONFIG_OPTION_SUBPIXEL_HINTING     ( 1 | 2 )
+ 
+ 
+   /*************************************************************************/
+-- 
+2.9.3
+
diff --git a/abs/core/freetype2/0005-freetype-2.5.2-more-demos.patch b/abs/core/freetype2/0005-freetype-2.5.2-more-demos.patch
new file mode 100644
index 0000000..e737cb7
--- /dev/null
+++ b/abs/core/freetype2/0005-freetype-2.5.2-more-demos.patch
@@ -0,0 +1,17 @@
+--- ft2demos-2.5.2/Makefile
++++ ft2demos-2.5.2/Makefile
+@@ -296,10 +296,10 @@ else
+   # The following programs are not compiled automatically; either comment
+   # out the affected line or use the program name as a Makefile target.
+   #
+-  # EXES += ftchkwd
+-  # EXES += ftmemchk
+-  # EXES += ftpatchk
+-  # EXES += fttimer
++  EXES += ftchkwd
++  EXES += ftmemchk
++  EXES += ftpatchk
++  EXES += fttimer
+   # EXES += testname
+ 
+   exes: $(EXES:%=$(BIN_DIR_2)/%$E)
diff --git a/abs/core/freetype2/PKGBUILD b/abs/core/freetype2/PKGBUILD
index a8236f6..80f5160 100644
--- a/abs/core/freetype2/PKGBUILD
+++ b/abs/core/freetype2/PKGBUILD
@@ -1,55 +1,95 @@
 # $Id$
 # Maintainer: Jan de Groot <jgc@archlinux.org>
 
-pkgname=freetype2
-pkgver=2.5.3
-pkgrel=2
-pkgdesc="TrueType font rendering library"
+pkgbase=freetype2
+pkgname=('freetype2' 'freetype2-demos')
+pkgver=2.7.1
+pkgrel=1
 arch=(i686 x86_64)
 license=('GPL')
-url="http://freetype.sourceforge.net"
-# adding harfbuzz for improved OpenType features auto-hinting 
+url="http://www.freetype.org/"
+# adding harfbuzz for improved OpenType features auto-hinting
 # introduces a cycle dep to harfbuzz depending on freetype wanted by upstream
-depends=('zlib' 'bzip2' 'sh' 'libpng' 'harfbuzz')
-source=(http://downloads.sourceforge.net/sourceforge/freetype/freetype-${pkgver}.tar.bz2{,.sig}
-        freetype-2.2.1-enable-valid.patch
-        freetype-2.5.1-enable-spr.patch
-        freetype-2.5.1-enable-sph.patch
-        fix_segfault_with_harfbuzz.diff)
-sha1sums=('d3c26cc17ec7fe6c36f4efc02ef92ab6aa3f4b46'
+makedepends=('libx11' 'zlib' 'bzip2' 'sh' 'libpng' 'harfbuzz')
+source=(https://download.savannah.gnu.org/releases/freetype/freetype-${pkgver}.tar.bz2{,.sig}
+        https://download.savannah.gnu.org/releases/freetype/freetype-doc-${pkgver}.tar.bz2{,.sig}
+        https://download.savannah.gnu.org/releases/freetype/ft2demos-${pkgver}.tar.bz2{,.sig}
+        0001-Enable-table-validation-modules.patch
+        0002-Enable-subpixel-rendering.patch
+        0003-Enable-infinality-subpixel-hinting.patch
+        0005-freetype-2.5.2-more-demos.patch
+        freetype2.sh)
+sha1sums=('4d08a9a6567c6332d58e9a5f9a7e9e3fbce66789'
           'SKIP'
-          'f279d922a873d62a8af50bfc873051839d194dca'
-          '13ee8d558593db991ad29fa090b461f914536104'
-          'c31fa3d342ead56f3acfa1f267b474a7686d0014'
-          'c99013b4c19494cd26031878368191cd2b4459b0')
+          'd8ce472cd775b8ce50d127689acab59181e72ecf'
+          'SKIP'
+          '2ebe93df13eb45dac8515c5ed0216ef694c33f18'
+          'SKIP'
+          'b31882ef5e8447e761acee1c4a44c0630cd4d465'
+          'b1494810ed3aca25cdd8e8cedf634e5adfe6c09e'
+          '41d27140fd590945e22e012c9dce62de3d6f11e6'
+          '72cfecbe738085eec475e012617661ad0cc9b76f'
+          'bc6df1661c4c33e20f5ce30c2da8ad3c2083665f')
+validpgpkeys=('58E0C111E39F5408C5D3EC76C1A60EACE707FDA5')
 
 prepare() {
-  cd "${srcdir}/freetype-${pkgver}"
-  patch -Np1 -i "${srcdir}/freetype-2.2.1-enable-valid.patch"
-  patch -Np1 -i "${srcdir}/freetype-2.5.1-enable-spr.patch"
-  
-  # fix segfaults # https://bugs.archlinux.org/task/39365
-  # http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=23367ff97f33ef6a2b7e1fced1157c87a46d9596
-  patch -Np1 -i "${srcdir}/fix_segfault_with_harfbuzz.diff"
-  
-  # Disabled for now due to resistance
-  # Kept here for easier rebuilds via ABS
-  # https://bugs.archlinux.org/task/35274
-  #patch -Np1 -i "${srcdir}/freetype-2.5.1-enable-sph.patch"
+  # Rename source dir to allow building the demos
+  mv freetype-${pkgver} freetype2
+
+  cd freetype2
+  patch -Np1 -i ../0001-Enable-table-validation-modules.patch
+  patch -Np1 -i ../0002-Enable-subpixel-rendering.patch
+  patch -Np1 -i ../0003-Enable-infinality-subpixel-hinting.patch
+
+  cd ../ft2demos-${pkgver}
+  # enable more demos
+  patch -Np1 -i ../0005-freetype-2.5.2-more-demos.patch
+
+  # Suppress RPATH
+  sed -i '/X11_LIB:%=-R%/d' graph/x11/rules.mk
 }
 
 build() {
-  cd "${srcdir}/freetype-${pkgver}"
+  cd freetype2
   ./configure --prefix=/usr --disable-static
   make
+
+  # Build demos
+  cd ../ft2demos-${pkgver}
+  make
 }
 
 check() {
-  cd "${srcdir}/freetype-${pkgver}"
+  cd freetype2
   make -k check
 }
 
-package() {
-  cd "${srcdir}/freetype-${pkgver}"
+package_freetype2() {
+  pkgdesc="TrueType font rendering library"
+  depends=('zlib' 'bzip2' 'sh' 'libpng' 'harfbuzz')
+  provides=('libfreetype.so')
+  install=freetype2.install
+  backup=('etc/profile.d/freetype2.sh')
+
+  cd freetype2
   make DESTDIR="${pkgdir}" install
+  install -Dm644 ../freetype2.sh "${pkgdir}/etc/profile.d/freetype2.sh"
+
+  # Package docs
+  install -dm755 "${pkgdir}/usr/share/doc"
+  cp -a docs "${pkgdir}/usr/share/doc/${pkgname}"
+
+  cd ../ft2demos-${pkgver}
+  mkdir -p $srcdir/ft-demos
+  for _i in bin/{f,t}t*; do
+    libtool --mode=install install $_i "$srcdir/ft-demos"
+  done
+}
+
+package_freetype2-demos() {
+  pkgdesc="Freetype tools and demos"
+  depends=('freetype2' 'libx11')
+
+  install -dm755 "${pkgdir}/usr/bin"
+  cp -a $srcdir/ft-demos/* "${pkgdir}/usr/bin"
 }
diff --git a/abs/core/freetype2/fix_segfault_with_harfbuzz.diff b/abs/core/freetype2/fix_segfault_with_harfbuzz.diff
deleted file mode 100644
index a1832eb..0000000
--- a/abs/core/freetype2/fix_segfault_with_harfbuzz.diff
+++ /dev/null
@@ -1,32 +0,0 @@
-From 23367ff97f33ef6a2b7e1fced1157c87a46d9596 Mon Sep 17 00:00:00 2001
-From: Werner Lemberg <wl@gnu.org>
-Date: Mon, 17 Mar 2014 06:33:14 +0000
-Subject: Fix Savannah bug #41869.
-
-This works around a problem with HarfBuzz (<= 0.9.26), which doesn't
-validate glyph indices returned by
-`hb_ot_layout_lookup_collect_glyphs'.
-
-* src/autofit/hbshim.c (af_get_coverage): Guard `idx'.
-
-* docs/CHANGES: Updated.
----
-diff --git a/src/autofit/hbshim.c b/src/autofit/hbshim.c
-index 11fb743..2eda8d7 100644
---- a/src/autofit/hbshim.c
-+++ b/src/autofit/hbshim.c
-@@ -347,6 +347,11 @@
-       count++;
- #endif
- 
-+      /* HarfBuzz 0.9.26 and older doesn't validate glyph indices */
-+      /* returned by `hb_ot_layout_lookup_collect_glyphs'...      */
-+      if ( idx >= (hb_codepoint_t)globals->glyph_count )
-+        continue;
-+
-       if ( gstyles[idx] == AF_STYLE_UNASSIGNED )
-         gstyles[idx] = (FT_Byte)style_class->style;
- #ifdef FT_DEBUG_LEVEL_TRACE
---
-cgit v0.9.0.2
-
diff --git a/abs/core/freetype2/freetype-2.2.1-enable-valid.patch b/abs/core/freetype2/freetype-2.2.1-enable-valid.patch
deleted file mode 100644
index c78b6b7..0000000
--- a/abs/core/freetype2/freetype-2.2.1-enable-valid.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- freetype-2.2.1/modules.cfg.orig	2006-07-07 21:01:09.000000000 -0400
-+++ freetype-2.2.1/modules.cfg	2006-07-07 21:01:54.000000000 -0400
-@@ -110,7 +110,7 @@
- AUX_MODULES += cache
- 
- # TrueType GX/AAT table validation.  Needs ftgxval.c below.
--# AUX_MODULES += gxvalid
-+AUX_MODULES += gxvalid
- 
- # Support for streams compressed with gzip (files with suffix .gz).
- #
-@@ -124,7 +124,7 @@
- 
- # OpenType table validation.  Needs ftotval.c below.
- #
--# AUX_MODULES += otvalid
-+AUX_MODULES += otvalid
- 
- # Auxiliary PostScript driver component to share common code.
- #
diff --git a/abs/core/freetype2/freetype-2.5.1-enable-sph.patch b/abs/core/freetype2/freetype-2.5.1-enable-sph.patch
deleted file mode 100644
index 69f73b7..0000000
--- a/abs/core/freetype2/freetype-2.5.1-enable-sph.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git i/include/config/ftoption.h w/include/config/ftoption.h
-index fe2ba15..1ab4226 100644
---- i/include/config/ftoption.h
-+++ w/include/config/ftoption.h
-@@ -591,7 +591,7 @@ FT_BEGIN_HEADER
-   /*   This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be    */
-   /*   defined.                                                            */
-   /*                                                                       */
--/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING */
-+#define TT_CONFIG_OPTION_SUBPIXEL_HINTING
- 
- 
-   /*************************************************************************/
diff --git a/abs/core/freetype2/freetype-2.5.1-enable-spr.patch b/abs/core/freetype2/freetype-2.5.1-enable-spr.patch
deleted file mode 100644
index 0d300a8..0000000
--- a/abs/core/freetype2/freetype-2.5.1-enable-spr.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git i/include/config/ftoption.h w/include/config/ftoption.h
-index fe2ba15..22ce1a3 100644
---- i/include/config/ftoption.h
-+++ w/include/config/ftoption.h
-@@ -92,7 +92,7 @@ FT_BEGIN_HEADER
-   /* This is done to allow FreeType clients to run unmodified, forcing     */
-   /* them to display normal gray-level anti-aliased glyphs.                */
-   /*                                                                       */
--/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-+#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- 
- 
-   /*************************************************************************/
diff --git a/abs/core/freetype2/freetype2.install b/abs/core/freetype2/freetype2.install
new file mode 100644
index 0000000..5d4d1e7
--- /dev/null
+++ b/abs/core/freetype2/freetype2.install
@@ -0,0 +1,8 @@
+post_upgrade() {
+  if (( $(vercmp $2 2.7-1) < 0 )); then
+    cat <<MSG
+  The Arch-specific FT2_SUBPIXEL_HINTING has been removed.
+  Subpixel hinting is now configured in /etc/profile.d/freetype2.sh .
+MSG
+  fi
+}
diff --git a/abs/core/freetype2/freetype2.sh b/abs/core/freetype2/freetype2.sh
new file mode 100644
index 0000000..93165d3
--- /dev/null
+++ b/abs/core/freetype2/freetype2.sh
@@ -0,0 +1,12 @@
+# Subpixel hinting mode can be chosen by setting the right TrueType interpreter
+# version. The available settings are:
+#
+#     truetype:interpreter-version=35  # Classic mode (default in 2.6)
+#     truetype:interpreter-version=38  # Infinality mode
+#     truetype:interpreter-version=40  # Minimal mode (default in 2.7)
+#
+# There are more properties that can be set, separated by whitespace. Please
+# refer to the FreeType documentation for details.
+
+# Uncomment and configure below
+#export FREETYPE_PROPERTIES="truetype:interpreter-version=40"
-- 
cgit v0.12

