From 6575d354c8176c67c847b0e0a6cdd42800731a00 Mon Sep 17 00:00:00 2001
From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Date: Fri, 12 Nov 2021 10:33:32 +0200
Subject: [PATCH] build: Bump Fonconfig version up to 2.12.6

---
 depends/packages/fontconfig.mk                |  7 +--
 .../fontconfig/gperf_header_regen.patch       |  8 +--
 .../fontconfig/remove_char_width_usage.patch  | 62 -------------------
 doc/dependencies.md                           |  2 +-
 4 files changed, 8 insertions(+), 71 deletions(-)
 delete mode 100644 depends/patches/fontconfig/remove_char_width_usage.patch

diff --git a/depends/packages/fontconfig.mk b/depends/packages/fontconfig.mk
index 22b5022f06d..c8b2fc33d57 100644
--- a/depends/packages/fontconfig.mk
+++ b/depends/packages/fontconfig.mk
@@ -1,10 +1,10 @@
 package=fontconfig
-$(package)_version=2.12.1
+$(package)_version=2.12.6
 $(package)_download_path=https://www.freedesktop.org/software/fontconfig/release/
 $(package)_file_name=$(package)-$($(package)_version).tar.bz2
-$(package)_sha256_hash=b449a3e10c47e1d1c7a6ec6e2016cca73d3bd68fbbd4f0ae5cc6b573f7d6c7f3
+$(package)_sha256_hash=cf0c30807d08f6a28ab46c61b8dbd55c97d2f292cf88f3a07d3384687f31f017
 $(package)_dependencies=freetype expat
-$(package)_patches=remove_char_width_usage.patch gperf_header_regen.patch
+$(package)_patches=gperf_header_regen.patch
 
 define $(package)_set_vars
   $(package)_config_opts=--disable-docs --disable-static --disable-libxml2 --disable-iconv
@@ -12,7 +12,6 @@ define $(package)_set_vars
 endef
 
 define $(package)_preprocess_cmds
-  patch -p1 < $($(package)_patch_dir)/remove_char_width_usage.patch && \
   patch -p1 < $($(package)_patch_dir)/gperf_header_regen.patch
 endef
 
diff --git a/depends/patches/fontconfig/gperf_header_regen.patch b/depends/patches/fontconfig/gperf_header_regen.patch
index 3ffd1674e03..b1a70d5fb12 100644
--- a/depends/patches/fontconfig/gperf_header_regen.patch
+++ b/depends/patches/fontconfig/gperf_header_regen.patch
@@ -13,12 +13,12 @@ diff --git a/src/Makefile.in b/src/Makefile.in
 index f4626ad..4ae1b00 100644
 --- a/src/Makefile.in
 +++ b/src/Makefile.in
-@@ -903,7 +903,7 @@ fcobjshash.gperf: fcobjshash.gperf.h fcobjs.h
+@@ -912,7 +912,7 @@
  	' - > $@.tmp && \
- 	mv -f $@.tmp $@ || ( $(RM) $@.tmp && false )
+ 	mv -f $@.tmp fcobjshash.gperf && touch $@ || ( $(RM) $@.tmp && false )
 
--fcobjshash.h: fcobjshash.gperf
+-fcobjshash.h: Makefile fcobjshash.gperf
 +fcobjshash.h:
- 	$(AM_V_GEN) $(GPERF) -m 100 $< > $@.tmp && \
+ 	$(AM_V_GEN) $(GPERF) --pic -m 100 fcobjshash.gperf > $@.tmp && \
  	mv -f $@.tmp $@ || ( $(RM) $@.tmp && false )
 
diff --git a/depends/patches/fontconfig/remove_char_width_usage.patch b/depends/patches/fontconfig/remove_char_width_usage.patch
deleted file mode 100644
index 9f69081890c..00000000000
--- a/depends/patches/fontconfig/remove_char_width_usage.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-commit 28165a9b078583dc8e9e5c344510e37582284cef
-Author: fanquake <fanquake@gmail.com>
-Date:   Mon Aug 17 20:35:42 2020 +0800
-
-    Remove usage of CHAR_WIDTH
-
-    CHAR_WIDTH which is reserved and clashes with glibc 2.25+
-
-    See #10851.
-
-diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
-index 5c72b22..843c532 100644
---- a/fontconfig/fontconfig.h
-+++ b/fontconfig/fontconfig.h
-@@ -128,7 +128,7 @@ typedef int		FcBool;
- #define FC_USER_CACHE_FILE	    ".fonts.cache-" FC_CACHE_VERSION
-
- /* Adjust outline rasterizer */
--#define FC_CHAR_WIDTH	    "charwidth"	/* Int */
-+#define FC_CHARWIDTH	    "charwidth"	/* Int */
- #define FC_CHAR_HEIGHT	    "charheight"/* Int */
- #define FC_MATRIX	    "matrix"    /* FcMatrix */
-
-diff --git a/src/fcobjs.h b/src/fcobjs.h
-index 1fc4f65..d27864b 100644
---- a/src/fcobjs.h
-+++ b/src/fcobjs.h
-@@ -51,7 +51,7 @@ FC_OBJECT (DPI,			FcTypeDouble,	NULL)
- FC_OBJECT (RGBA,		FcTypeInteger,	NULL)
- FC_OBJECT (SCALE,		FcTypeDouble,	NULL)
- FC_OBJECT (MINSPACE,		FcTypeBool,	NULL)
--FC_OBJECT (CHAR_WIDTH,		FcTypeInteger,	NULL)
-+FC_OBJECT (CHARWIDTH,		FcTypeInteger,	NULL)
- FC_OBJECT (CHAR_HEIGHT,		FcTypeInteger,	NULL)
- FC_OBJECT (MATRIX,		FcTypeMatrix,	NULL)
- FC_OBJECT (CHARSET,		FcTypeCharSet,	FcCompareCharSet)
-diff --git a/src/fcobjshash.gperf b/src/fcobjshash.gperf
-index 80a0237..eb4ad84 100644
---- a/src/fcobjshash.gperf
-+++ b/src/fcobjshash.gperf
-@@ -44,7 +44,7 @@ int id;
- "rgba",FC_RGBA_OBJECT
- "scale",FC_SCALE_OBJECT
- "minspace",FC_MINSPACE_OBJECT
--"charwidth",FC_CHAR_WIDTH_OBJECT
-+"charwidth",FC_CHARWIDTH_OBJECT
- "charheight",FC_CHAR_HEIGHT_OBJECT
- "matrix",FC_MATRIX_OBJECT
- "charset",FC_CHARSET_OBJECT
-diff --git a/src/fcobjshash.h b/src/fcobjshash.h
-index 5a4d1ea..4e66bb0 100644
---- a/src/fcobjshash.h
-+++ b/src/fcobjshash.h
-@@ -284,7 +284,7 @@ FcObjectTypeLookup (register const char *str, register unsigned int len)
-       {(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str43,FC_CHARSET_OBJECT},
-       {-1},
- #line 47 "fcobjshash.gperf"
--      {(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str45,FC_CHAR_WIDTH_OBJECT},
-+      {(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str45,FC_CHARWIDTH_OBJECT},
- #line 48 "fcobjshash.gperf"
-       {(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str46,FC_CHAR_HEIGHT_OBJECT},
- #line 55 "fcobjshash.gperf"
diff --git a/doc/dependencies.md b/doc/dependencies.md
index f2b6760ac2a..24422f1d7bc 100644
--- a/doc/dependencies.md
+++ b/doc/dependencies.md
@@ -8,7 +8,7 @@ These are the dependencies currently used by Bitcoin Core. You can find instruct
 | Berkeley DB | [4.8.30](https://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html) | 4.8.x | No |  |  |
 | Boost | [1.71.0](https://www.boost.org/users/download/) | [1.64.0](https://github.com/bitcoin/bitcoin/pull/22320) | No |  |  |
 | Clang<sup>[ \* ](#note1)</sup> |  | [7.0](https://releases.llvm.org/download.html) (C++17 & std::filesystem support) |  |  |  |
-| fontconfig | [2.12.1](https://www.freedesktop.org/software/fontconfig/release/) |  | No | Yes |  |
+| Fontconfig | [2.12.6](https://www.freedesktop.org/software/fontconfig/release/) |  | No | Yes |  |
 | FreeType | [2.11.0](https://download.savannah.gnu.org/releases/freetype) |  | No |  | [Yes](https://github.com/bitcoin/bitcoin/blob/master/depends/packages/qt.mk) (Android only) |
 | GCC |  | [8.1](https://gcc.gnu.org/) (C++17 & std::filesystem support) |  |  |  |
 | glibc | | [2.18](https://www.gnu.org/software/libc/) |  |  |  |  |