fontconfig: Branch 'main' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 11 13:56:53 UTC 2024


 conf.d/70-no-bitmaps-and-emoji.conf       |   13 +++++++++
 conf.d/70-no-bitmaps-except-emoji.conf    |   14 +++++++++
 conf.d/70-no-bitmaps.conf                 |   11 +------
 conf.d/Makefile.am                        |    2 +
 conf.d/meson.build                        |    2 +
 doc/fcconfig.fncs                         |   13 +++++++++
 fontconfig/fontconfig.h                   |    4 ++
 src/fcint.h                               |    4 --
 test/Makefile.am                          |   10 ++++--
 test/run-test-conf.sh                     |    2 +
 test/test-70-no-bitmaps-and-emoji.json    |   34 +++++++++++++++++++++++
 test/test-70-no-bitmaps-except-emoji.json |   43 ++++++++++++++++++++++++++++++
 test/test-conf.c                          |   27 ++++++++++++++----
 13 files changed, 156 insertions(+), 23 deletions(-)

New commits:
commit c6849aca73c60c3fcba5c6e4e2cb2d7b59050dd2
Author: Akira TAGOH <akira at tagoh.org>
Date:   Fri Mar 8 03:02:33 2024 +0900

    Add test cases for 70-no-bitmap-and-emoji.conf and 70-no-bitmap-except-emoji.conf

diff --git a/doc/fcconfig.fncs b/doc/fcconfig.fncs
index df25e2d..49e691e 100644
--- a/doc/fcconfig.fncs
+++ b/doc/fcconfig.fncs
@@ -502,3 +502,16 @@ before using <function>FcConfigFileInfoIterInit</function> and then
 <function>FcConfigDestroy</function> when the relevant values are no longer referenced.
 @SINCE@         2.12.91
 @@
+
+ at RET@		FcBool
+ at FUNC@		FcConfigAcceptFont
+ at TYPE1@		FcConfig *			@ARG1@		config
+ at TYPE2@		FcPattern *			@ARG2@		pat
+ at PURPOSE@	Test whether the given pattern matches deny list
+ at DESC@
+fontconfig has the deny list which is built against <rejectfont> directive
+in configuration file. This function tries to match 'pat' with them and
+return FcFalse if 'pat' is rejected, otherwise FcTrue.
+ at SINCE@		2.15.1
+@@
+
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index 77974e1..47d7b83 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -453,6 +453,10 @@ FcPublic FcFontSet *
 FcConfigGetFonts (FcConfig	*config,
 		  FcSetName	set);
 
+FcPublic FcBool
+FcConfigAcceptFont (FcConfig	    *config,
+		    const FcPattern *font);
+
 FcPublic FcBool
 FcConfigAppFontAddFile (FcConfig    *config,
 			const FcChar8  *file);
diff --git a/src/fcint.h b/src/fcint.h
index fbf0e81..86676b3 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -732,10 +732,6 @@ FcConfigPatternsAdd (FcConfig	*config,
 		     FcPattern	*pattern,
 		     FcBool	accept);
 
-FcPrivate FcBool
-FcConfigAcceptFont (FcConfig	    *config,
-		    const FcPattern *font);
-
 FcPrivate FcFileTime
 FcConfigModifiedTime (FcConfig *config);
 
diff --git a/test/Makefile.am b/test/Makefile.am
index 03f7324..3b79c78 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,8 +1,8 @@
-# 
+#
 #  test/Makefile.am
-# 
+#
 #  Copyright © 2003 Keith Packard
-# 
+#
 #  Permission to use, copy, modify, distribute, and sell this software and its
 #  documentation for any purpose is hereby granted without fee, provided that
 #  the above copyright notice appear in all copies and that both that
@@ -12,7 +12,7 @@
 #  specific, written prior permission.  The authors make no
 #  representations about the suitability of this software for any purpose.  It
 #  is provided "as is" without express or implied warranty.
-# 
+#
 #  THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 #  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 #  EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
@@ -46,6 +46,8 @@ TESTDATA =			\
 	fonts.conf.in		\
 	test-45-generic.json	\
 	test-60-generic.json	\
+	test-70-no-bitmaps-and-emoji.json	\
+	test-70-no-bitmaps-except-emoji.json	\
 	test-90-synthetic.json	\
 	test-issue-286.json	\
 	test-style-match.json	\
diff --git a/test/run-test-conf.sh b/test/run-test-conf.sh
index bbb56f4..20b80e1 100644
--- a/test/run-test-conf.sh
+++ b/test/run-test-conf.sh
@@ -42,6 +42,8 @@ fi
 for i in \
 	45-generic.conf \
 	60-generic.conf \
+	70-no-bitmaps-and-emoji.conf \
+	70-no-bitmaps-except-emoji.conf \
 	90-synthetic.conf \
     ; do
     test_json=$(echo test-$i|sed s'/\.conf/.json/')
diff --git a/test/test-70-no-bitmaps-and-emoji.json b/test/test-70-no-bitmaps-and-emoji.json
new file mode 100644
index 0000000..6868a5b
--- /dev/null
+++ b/test/test-70-no-bitmaps-and-emoji.json
@@ -0,0 +1,34 @@
+{
+  "fonts": [
+    {
+      "family": "Noto Color Emoji",
+      "style": "Regular",
+      "outline": false,
+      "scalable": true
+    },
+    {
+      "family": "Fixed",
+      "style": "Regular",
+      "outline": false,
+      "scalable": false
+    }
+  ],
+  "tests": [
+    {
+      "method": "match",
+      "query": {
+        "family": "Noto Color Emoji"
+      },
+      "result": {
+      }
+    },
+    {
+      "method": "match",
+      "query": {
+        "family": "Fixed"
+      },
+      "result": {
+      }
+    }
+  ]
+}
diff --git a/test/test-70-no-bitmaps-except-emoji.json b/test/test-70-no-bitmaps-except-emoji.json
new file mode 100644
index 0000000..fbef5af
--- /dev/null
+++ b/test/test-70-no-bitmaps-except-emoji.json
@@ -0,0 +1,43 @@
+{
+  "fonts": [
+    {
+      "family": "Noto Color Emoji",
+      "style": "Regular",
+      "outline": false,
+      "scalable": true
+    },
+    {
+      "family": "Fixed",
+      "style": "Regular",
+      "outline": false,
+      "scalable": false
+    }
+  ],
+  "tests": [
+    {
+      "method": "match",
+      "query": {
+        "family": "Noto Color Emoji"
+      },
+      "result": {
+        "family": "Noto Color Emoji",
+        "style": "Regular",
+        "outline": false,
+        "scalable": true
+      }
+    },
+    {
+      "method": "match",
+      "query": {
+        "family": "Fixed"
+      },
+      "$comment": "fontconfig always fallback to something. Even though the expected result here would be no result.",
+      "result": {
+        "family": "Noto Color Emoji",
+        "style": "Regular",
+        "outline": false,
+        "scalable": true
+      }
+    }
+  ]
+}
diff --git a/test/test-conf.c b/test/test-conf.c
index 235dce5..c5ddabe 100644
--- a/test/test-conf.c
+++ b/test/test-conf.c
@@ -278,7 +278,7 @@ build_pattern (json_object *obj)
 }
 
 static FcFontSet *
-build_fs (json_object *obj)
+build_fs (FcConfig *config, json_object *obj)
 {
     FcFontSet *fs = FcFontSetCreate ();
     int i, n;
@@ -292,7 +292,10 @@ build_fs (json_object *obj)
 	if (json_object_get_type (o) != json_type_object)
 	    continue;
 	pat = build_pattern (o);
-	FcFontSetAdd (fs, pat);
+	if (FcConfigAcceptFont (config, pat))
+	    FcFontSetAdd (fs, pat);
+	else
+	    FcPatternDestroy(pat);
     }
 
     return fs;
@@ -310,7 +313,7 @@ build_fonts (FcConfig *config, json_object *root)
 	fprintf (stderr, "W: No fonts defined\n");
 	return FcFalse;
     }
-    fs = build_fs (fonts);
+    fs = build_fs (config, fonts);
     /* FcConfigSetFonts (config, fs, FcSetSystem); */
     if (config->fonts[FcSetSystem])
 	FcFontSetDestroy (config->fonts[FcSetSystem]);
@@ -385,7 +388,11 @@ run_test (FcConfig *config, json_object *root)
 		}
 		if (result_fs)
 		    FcFontSetDestroy (result_fs);
-		result_fs = build_fs (iter.val);
+		result_fs = build_fs (config, iter.val);
+	    }
+	    else if (strcmp (iter.key, "$comment") == 0)
+	    {
+		/* ignore it */
 	    }
 	    else
 	    {
@@ -453,8 +460,16 @@ run_test (FcConfig *config, json_object *root)
 	    }
 	    else
 	    {
-		fprintf (stderr, "E: no match\n");
-		fail++;
+		FcPatternIter iter;
+		int x, vc;
+
+		FcPatternIterStart (result, &iter);
+		vc = FcPatternIterValueCount (result, &iter);
+		if (vc > 0)
+		{
+		    fprintf (stderr, "E: no match\n");
+		    fail++;
+		}
 	    }
 	}
 	else if (method != NULL && strcmp (method, "list") == 0)
commit 810a300398dc93b7becca4a7f286e8999adc09a5
Author: Akira TAGOH <akira at tagoh.org>
Date:   Fri Mar 8 01:55:14 2024 +0900

    Sort out bitmap related config files
    
    70-no-bitmaps-and-emoji.conf: reject bitmap fonts including bitmap emoji fonts.
    70-no-bitmaps-except-emoji.conf: reject bitmap fonts except bitmap emoji fonts.
    70-no-bitmaps.conf: same to 70-no-bitmaps-except-emoji.conf for backward compatibility
    but deprecated. This will be dropped in the future.
    
    Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/409

diff --git a/conf.d/70-no-bitmaps-and-emoji.conf b/conf.d/70-no-bitmaps-and-emoji.conf
new file mode 100644
index 0000000..3e18a4c
--- /dev/null
+++ b/conf.d/70-no-bitmaps-and-emoji.conf
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
+<fontconfig>
+  <description>Reject bitmap fonts, including bitmap emoji fonts</description>
+  <!-- Reject bitmap fonts -->
+  <selectfont>
+    <rejectfont>
+      <pattern>
+        <patelt name="outline"><bool>false</bool></patelt>
+      </pattern>
+    </rejectfont>
+  </selectfont>
+</fontconfig>
diff --git a/conf.d/70-no-bitmaps-except-emoji.conf b/conf.d/70-no-bitmaps-except-emoji.conf
new file mode 100644
index 0000000..3170cd6
--- /dev/null
+++ b/conf.d/70-no-bitmaps-except-emoji.conf
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
+<fontconfig>
+  <description>Reject bitmap fonts except bitmap emoji fonts</description>
+  <!-- Reject bitmap fonts -->
+  <selectfont>
+    <rejectfont>
+      <pattern>
+        <patelt name="outline"><bool>false</bool></patelt>
+        <patelt name="scalable"><bool>false</bool></patelt>
+      </pattern>
+    </rejectfont>
+  </selectfont>
+</fontconfig>
diff --git a/conf.d/70-no-bitmaps.conf b/conf.d/70-no-bitmaps.conf
index 10203ac..767e411 100644
--- a/conf.d/70-no-bitmaps.conf
+++ b/conf.d/70-no-bitmaps.conf
@@ -1,13 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
 <fontconfig>
-  <description>Reject bitmap fonts</description>
-<!-- Reject bitmap fonts -->
- <selectfont>
-  <rejectfont>
-   <pattern>
-     <patelt name="outline"><bool>false</bool></patelt>
-   </pattern>
-  </rejectfont>
- </selectfont>
+  <description>Reject bitmap fonts except bitmap emoji fonts (deprecated; use 70-no-bitmaps-except-emoji.conf)</description>
+  <include ignore_missing="yes">70-no-bitmaps-except-emoji.conf</include>
 </fontconfig>
diff --git a/conf.d/Makefile.am b/conf.d/Makefile.am
index fd85834..737b4fb 100644
--- a/conf.d/Makefile.am
+++ b/conf.d/Makefile.am
@@ -98,6 +98,8 @@ template_DATA =				\
 	65-nonlatin.conf		\
 	69-unifont.conf			\
 	70-no-bitmaps.conf		\
+	70-no-bitmaps-and-emoji.conf	\
+	70-no-bitmaps-except-emoji.conf	\
 	70-yes-bitmaps.conf		\
 	80-delicious.conf		\
 	90-synthetic.conf
diff --git a/conf.d/meson.build b/conf.d/meson.build
index 8e89611..b6d07ee 100644
--- a/conf.d/meson.build
+++ b/conf.d/meson.build
@@ -36,6 +36,8 @@ conf_files = [
   '65-nonlatin.conf',
   '69-unifont.conf',
   '70-no-bitmaps.conf',
+  '70-no-bitmaps-and-emoji.conf',
+  '70-no-bitmaps-except-emoji.conf',
   '70-yes-bitmaps.conf',
   '80-delicious.conf',
   '90-synthetic.conf',


More information about the Fontconfig mailing list