diff --git a/SOURCES/fontconfig-fix-remapdir.patch b/SOURCES/fontconfig-fix-remapdir.patch
new file mode 100644
index 0000000..e6bc9c5
--- /dev/null
+++ b/SOURCES/fontconfig-fix-remapdir.patch
@@ -0,0 +1,129 @@
+diff -pruN fontconfig-2.14.0.orig/test/run-test.sh fontconfig-2.14.0/test/run-test.sh
+--- fontconfig-2.14.0.orig/test/run-test.sh 2022-12-02 21:12:26.755100156 +0900
++++ fontconfig-2.14.0/test/run-test.sh 2022-12-02 21:14:19.306721780 +0900
+@@ -180,14 +180,8 @@ TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontcon
+ sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
+ s!@REMAPDIR@!$TESTTMPDIR/fonts!
+ s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf
+-echo "$BWRAP --bind / / --bind \"$CACHEDIR\" \"$TESTTMPDIR\"/cache.dir --bind \"$FONTDIR\" \"$TESTTMPDIR\"/fonts --bind .. \"$TESTTMPDIR\"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE \"$TESTTMPDIR\"/build/test/bind-fonts.conf \"$TESTTMPDIR\"/build/fc-match/fc-match\"$EXEEXT\" -f \"%{file}\n\" \":foundry=Misc\" > xxx"
+-ls $CACHEDIR
+-ls $TESTTMPDIR
+-ls $FONTDIR
+ $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "%{file}\n" ":foundry=Misc" > xxx
+-echo "$BWRAP --bind / / --bind \"$CACHEDIR\" \"$TESTTMPDIR\"/cache.dir --bind \"$FONTDIR\" \"$TESTTMPDIR\"/fonts --bind .. \"$TESTTMPDIR\"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE \"$TESTTMPDIR\"/build/test/bind-fonts.conf \"$TESTTMPDIR\"/build/test/test-bz106618\"$EXEEXT\" | sort > flist1"
+ $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/test-bz106618"$EXEEXT" | sort > flist1
+-echo "$BWRAP --bind / / --bind \"$CACHEDIR\" \"$TESTTMPDIR\"/cache.dir --bind \"$FONTDIR\" \"$TESTTMPDIR\"/fonts --bind .. \"$TESTTMPDIR\"/build --dev-bind /dev /dev find \"$TESTTMPDIR\"/fonts/ -type f -name '*.pcf' | sort > flist2"
+ $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > flist2
+ ls -l "$CACHEDIR" > out2
+ if cmp out1 out2 > /dev/null ; then : ; else
+From fc0e9a78d2fe3b26f0b93c2a99b160e75e2a9f89 Mon Sep 17 00:00:00 2001
+From: Akira TAGOH
+Date: Wed, 28 Sep 2022 21:39:09 +0900
+Subject: [PATCH 1/3] Real fix of 91114d18c
+
+The change in 91114d18c broke remapping font paths.
+
+Patch from Mattias Clasen
+
+Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/331
+---
+ src/fcstr.c | 6 +-----
+ 1 file changed, 1 insertion(+), 5 deletions(-)
+
+diff --git a/src/fcstr.c b/src/fcstr.c
+index 3fe518f..5ce65da 100644
+--- a/src/fcstr.c
++++ b/src/fcstr.c
+@@ -1467,7 +1467,6 @@ FcStrSetAddFilenamePairWithSalt (FcStrSet *set, const FcChar8 *a, const FcChar8
+ {
+ FcChar8 *new_a = NULL;
+ FcChar8 *new_b = NULL;
+- FcChar8 *rs = NULL;
+ FcBool ret;
+
+ if (a)
+@@ -1487,10 +1486,7 @@ FcStrSetAddFilenamePairWithSalt (FcStrSet *set, const FcChar8 *a, const FcChar8
+ }
+ }
+ /* Override maps with new one if exists */
+- if (FcStrSetMemberAB (set, new_a, new_b, &rs))
+- {
+- FcStrSetDel (set, rs);
+- }
++ FcStrSetDel (set, new_a);
+ ret = FcStrSetAddTriple (set, new_a, new_b, salt);
+ if (new_a)
+ FcStrFree (new_a);
+--
+2.38.1
+
+From a10d07682a09ce5effbd121920b119618f4b7775 Mon Sep 17 00:00:00 2001
+From: Akira TAGOH
+Date: Wed, 28 Sep 2022 23:30:06 +0900
+Subject: [PATCH 2/3] Fix test cases for wrong use of remap-dir
+
+---
+ test/run-test.sh | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/test/run-test.sh b/test/run-test.sh
+index 1cedb8d..2b8a412 100644
+--- a/test/run-test.sh
++++ b/test/run-test.sh
+@@ -177,11 +177,14 @@ $FCCACHE "$FONTDIR"
+ sleep 1
+ ls -l "$CACHEDIR" > out1
+ TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+-sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
++# Once font dir is remapped, we could use $FONTDIR as different one in theory.
++# but we don't use it here and to avoid duplicate entries, set the non-existing
++# directory here.
++sed "s!@FONTDIR@!$FONTDIR/a!
+ s!@REMAPDIR@!$TESTTMPDIR/fonts!
+ s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf
+ $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "%{file}\n" ":foundry=Misc" > xxx
+-$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/test-bz106618"$EXEEXT" | sort > flist1
++$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/test-bz106618"$EXEEXT" > flist1
+ $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > flist2
+ ls -l "$CACHEDIR" > out2
+ if cmp out1 out2 > /dev/null ; then : ; else
+@@ -273,7 +276,10 @@ sleep 1
+ (cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out1
+ TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+ mkdir -p "$TESTTMPDIR"/cache.dir
+-sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
++# Once font dir is remapped, we could use $FONTDIR as different one in theory.
++# but we don't use it here and to avoid duplicate entries, set the non-existing
++# directory here.
++sed "s!@FONTDIR@!$FONTDIR/a!
+ s!@REMAPDIR@!$TESTTMPDIR/fonts!
+ s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf
+ $BWRAP --bind / / --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-cache/fc-cache"$EXEEXT" "$TESTTMPDIR"/fonts
+--
+2.38.1
+
+From dac7f285c5c1a8876954075c7fcac6b8aa0fa5b9 Mon Sep 17 00:00:00 2001
+From: Akira TAGOH
+Date: Thu, 29 Sep 2022 00:04:00 +0900
+Subject: [PATCH 3/3] Add back sort command Oops
+
+---
+ test/run-test.sh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/test/run-test.sh b/test/run-test.sh
+index 2b8a412..c3da72a 100644
+--- a/test/run-test.sh
++++ b/test/run-test.sh
+@@ -184,7 +184,7 @@ sed "s!@FONTDIR@!$FONTDIR/a!
+ s!@REMAPDIR@!$TESTTMPDIR/fonts!
+ s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf
+ $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "%{file}\n" ":foundry=Misc" > xxx
+-$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/test-bz106618"$EXEEXT" > flist1
++$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/test-bz106618"$EXEEXT" | sort > flist1
+ $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > flist2
+ ls -l "$CACHEDIR" > out2
+ if cmp out1 out2 > /dev/null ; then : ; else
+--
+2.38.1
+
diff --git a/SPECS/fontconfig.spec b/SPECS/fontconfig.spec
index 734d1fa..2414613 100644
--- a/SPECS/fontconfig.spec
+++ b/SPECS/fontconfig.spec
@@ -5,7 +5,7 @@
Summary: Font configuration and customization library
Name: fontconfig
Version: 2.14.0
-Release: 1%{?dist}
+Release: 2%{?dist}
# src/ftglue.[ch] is in Public Domain
# src/fccache.c contains Public Domain code
# fc-case/CaseFolding.txt is in the UCD
@@ -21,6 +21,7 @@ Patch0: %{name}-sleep-less.patch
Patch4: %{name}-drop-lang-from-pkgkit-format.patch
Patch5: %{name}-disable-network-required-test.patch
Patch6: %{name}-revert-noto-default.patch
+Patch7: %{name}-fix-remapdir.patch
BuildRequires: libxml2-devel
BuildRequires: freetype-devel >= %{freetype_version}
@@ -191,6 +192,10 @@ fi
* Wed Mar 15 2023 MSVSphere Packaging Team - 2.14.0-1
- Rebuilt for MSVSphere 9.1.
+* Fri Dec 2 2022 Akira TAGOH - 2.14.0-2
+- Fix the wrong behavior on remap-dir in config.
+ Resolves: rhbz#2150227
+
* Thu Mar 31 2022 Akira TAGOH - 2.14.0-1
- New upstream release.
- Rebase to 2.14 and revert Noto Default change happened in f36.