diff --git a/FcStrBuildFilename.3 b/FcStrBuildFilename.3 new file mode 100644 index 0000000..c16d1f9 --- /dev/null +++ b/FcStrBuildFilename.3 @@ -0,0 +1,16 @@ +.\" auto-generated by docbook2man-spec from docbook-utils package +.TH "FcStrBuildFilename" "3" "07 June 2019" "Fontconfig 2.13.1" "" +.SH NAME +FcStrBuildFilename \- Concatenate strings as a file path +.SH SYNOPSIS +.nf +\fB#include +.sp +FcChar8 * FcStrBuildFilename (const FcChar8 *\fIpath\fB, \&...\fI\fB); +.fi\fR +.SH "DESCRIPTION" +.PP +Creates a filename from the given elements of strings as file paths +and concatenate them with the appropriate file separator. +Arguments must be null-terminated. +This returns a newly-allocated memory which should be freed when no longer needed. diff --git a/fontconfig-fcvalidate.patch b/fontconfig-fcvalidate.patch new file mode 100644 index 0000000..f0c8735 --- /dev/null +++ b/fontconfig-fcvalidate.patch @@ -0,0 +1,26 @@ +From c336b8471877371f0190ba06f7547c54e2b890ba Mon Sep 17 00:00:00 2001 +From: Akira TAGOH +Date: Thu, 9 May 2019 07:10:11 +0000 +Subject: [PATCH 1/5] fc-validate: returns an error code when missing some + glyphs + +Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/154 +--- + fc-validate/fc-validate.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/fc-validate/fc-validate.c b/fc-validate/fc-validate.c +index 2ceee20..327ae63 100644 +--- a/fc-validate/fc-validate.c ++++ b/fc-validate/fc-validate.c +@@ -197,6 +197,7 @@ main (int argc, char **argv) + { + FcChar32 ucs4, pos, map[FC_CHARSET_MAP_SIZE]; + ++ err = 1; + printf (_("%s:%d Missing %d glyph(s) to satisfy the coverage for %s language\n"), + argv[i], index, count, lang); + +-- +2.22.0.rc3 + diff --git a/fontconfig-flatpak.patch b/fontconfig-flatpak.patch new file mode 100644 index 0000000..0f49b71 --- /dev/null +++ b/fontconfig-flatpak.patch @@ -0,0 +1,3009 @@ +From 12aebf728fec7b3cc7c203b27f2cf8fd203f81c6 Mon Sep 17 00:00:00 2001 +From: Akira TAGOH +Date: Fri, 12 Apr 2019 12:03:57 +0000 +Subject: [PATCH 1/6] Rework Flatpak support + +fontconfig relies on font paths to determine cache filename +and it is used to generate MD5. this means fontconfig +re-generates caches even if it has same fonts. +This affects the performance a lot on Flatpak applications +because they share fonts from host with different +paths and then re-generating caches at first run. + +So we put an UUID into .uuid at a font directory as +an unique identifier, and generate caches with it instead +of MD5. However, this affects the reproducible builds now +because UUID is randomly generated and it is impossible to predict. + +So reverting it and introduce new mechanism to share caches. + +fontconfig now has remap-dir element to handle a font +path as a different path internally. let's see: + +/run/host/fonts + +When accessing a cache from host, fontconfig considers it is +a cache for /run/host/fonts and shows patterns to applications +like that. + +So what if having own fonts under /usr/share/fonts? +To address this, fontconfig extends dir element to give a salt +to allow generating different cache filename. + +/usr/share/fonts + +Then fontconfig generates a cache in the different name +to what host has. +--- + conf.d/05-reset-dirs-sample.conf | 9 + + conf.d/Makefile.am | 1 + + configure.ac | 33 ---- + doc/fccache.fncs | 5 +- + doc/fcstring.fncs | 12 ++ + doc/fontconfig-user.sgml | 21 +- + fc-cache/fc-cache.c | 12 +- + fontconfig/fontconfig.h | 4 + + fonts.dtd | 17 ++ + src/Makefile.am | 3 +- + src/fccache.c | 322 +++++++++++++------------------ + src/fccfg.c | 168 ++++++++++++---- + src/fcdir.c | 8 - + src/fchash.c | 20 -- + src/fcint.h | 39 +++- + src/fcstr.c | 166 ++++++++++++++++ + src/fcxml.c | 277 ++++++++++++++++++-------- + test/Makefile.am | 13 +- + test/fonts.conf.in | 1 + + test/run-test-conf.sh | 2 +- + test/run-test-map.sh | 107 ++++++++++ + test/run-test.sh | 197 ++++++++++++------- + test/test-bz106632.c | 85 ++++---- + test/test-conf.c | 1 + + test/test-hash.c | 187 ------------------ + test/test-issue107.c | 248 ++++++++++++++++++++++++ + 26 files changed, 1271 insertions(+), 687 deletions(-) + create mode 100644 conf.d/05-reset-dirs-sample.conf + create mode 100755 test/run-test-map.sh + delete mode 100644 test/test-hash.c + create mode 100644 test/test-issue107.c + +diff --git a/conf.d/05-reset-dirs-sample.conf b/conf.d/05-reset-dirs-sample.conf +new file mode 100644 +index 00000000..80bb6fb8 +--- /dev/null ++++ b/conf.d/05-reset-dirs-sample.conf +@@ -0,0 +1,9 @@ ++ ++ ++ ++ Re-define fonts dirs sample ++ ++ ++ fonts ++ ++ +diff --git a/conf.d/Makefile.am b/conf.d/Makefile.am +index ff03fb2e..d0f3f263 100644 +--- a/conf.d/Makefile.am ++++ b/conf.d/Makefile.am +@@ -52,6 +52,7 @@ config_DATA = $(DOC_FILES) + + templatedir = $(TEMPLATEDIR) + template_DATA = \ ++ 05-reset-dirs-sample.conf \ + 10-autohint.conf \ + 10-hinting-full.conf \ + 10-hinting-medium.conf \ +diff --git a/configure.ac b/configure.ac +index fb8af467..4a864f64 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -332,39 +332,6 @@ AM_CONDITIONAL(FREETYPE_PCF_LONG_FAMILY_NAMES, test "x$have_pcf_long_family_name + LIBS="$fontconfig_save_libs" + CFLAGS="$fontconfig_save_cflags" + +-# +-# Check for uuid +-# +-if test "$os_win32" != "yes"; then +- use_pkgconfig_for_uuid=yes +- if test -n "${UUID_LIBS}"; then +- save_UUID_LIBS=$UUID_LIBS +- fi +- PKG_CHECK_MODULES([UUID], [uuid], +- [use_pkgconfig_for_uuid=yes], +- [use_pkgconfig_for_uuid=no]) +- if test "x$use_pkgconfig_for_uuid" = "xno"; then +- AC_MSG_CHECKING([where uuid functions comes from]) +- AC_TRY_LINK([#include ], +- [uuid_t a; uuid_generate(a);], +- [AC_MSG_RESULT([builtin]) +- UUID_CFLAGS="" +- UUID_LIBS="" +- ],[AC_MSG_ERROR([ +-*** uuid is required. install util-linux. +- ])]) +- else +- if test -z "${save_UUID_LIBS+x}" && test "x${UUID_LIBS}" != "x"; then +- PKGCONFIG_REQUIRES_PRIVATELY="$PKGCONFIG_REQUIRES_PRIVATELY uuid" +- fi +- fi +-else +- UUID_CFLAGS="" +- UUID_LIBS="" +-fi +-AC_SUBST(UUID_CFLAGS) +-AC_SUBST(UUID_LIBS) +- + # + # Check expat configuration + # +diff --git a/doc/fccache.fncs b/doc/fccache.fncs +index 972b6423..cf791349 100644 +--- a/doc/fccache.fncs ++++ b/doc/fccache.fncs +@@ -95,10 +95,7 @@ to config. + @TYPE3@ FcConfig * @ARG3@ config + @PURPOSE@ Create .uuid file at a directory + @DESC@ +-This is to create .uuid file containing an UUID at a font directory of +-dir. +-The UUID will be used to identify the font directory and is used to determine +-the cache filename if available. ++This function is deprecated. it doesn't take any effects. + @SINCE@ 2.12.92 + @@ + +diff --git a/doc/fcstring.fncs b/doc/fcstring.fncs +index 0412bbd1..d5ec043b 100644 +--- a/doc/fcstring.fncs ++++ b/doc/fcstring.fncs +@@ -223,6 +223,18 @@ This is just a wrapper around free(3) which helps track memory usage of + strings within the fontconfig library. + @@ + ++@RET@ FcChar8 * ++@FUNC@ FcStrBuildFilename ++@TYPE1@ const FcChar8 * @ARG1@ path ++@TYPE2@ ... ++@PURPOSE@ Concatenate strings as a file path ++@DESC@ ++Creates a filename from the given elements of strings as file paths ++and concatenate them with the appropriate file separator. ++Arguments must be null-terminated. ++This returns a newly-allocated memory which should be freed when no longer needed. ++@@ ++ + @RET@ FcChar8 * + @FUNC@ FcStrDirname + @TYPE1@ const FcChar8 * @ARG1@ file +diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml +index 89df86ef..9fbfe94a 100644 +--- a/doc/fontconfig-user.sgml ++++ b/doc/fontconfig-user.sgml +@@ -310,9 +310,13 @@ following structure: + This is the top level element for a font configuration and can contain + <dir>, <cachedir>, <include>, <match> and <alias> elements in any order. + +- <literal><dir prefix="default"></literal> ++ <literal><dir prefix="default" salt=""></literal> + This element contains a directory name which will be scanned for font files +-to include in the set of available fonts. If 'prefix' is set to "xdg", the value in the XDG_DATA_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details. ++to include in the set of available fonts. ++ ++If 'prefix' is set to "xdg", the value in the XDG_DATA_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details. ++ ++'salt' property affects to determine cache filename. this is useful for example when having different fonts sets on same path at container and share fonts from host on different font path. + + <literal><cachedir prefix="default"></literal> + This element contains a directory name that is supposed to be stored or read +@@ -346,6 +350,19 @@ drawn as blanks on the screen. Within the <blank> elem + Unicode characters which is supposed to be blank in an <int> element. + Characters outside of this set which are drawn as blank will be elided from + the set of characters supported by the font. ++ ++ <literal><remap-dir prefix="default" as-path="" salt=""<</literal> ++This element contains a directory name where will be mapped ++as the path 'as-path' in cached information. ++This is useful if the directory name is an alias ++(via a bind mount or symlink) to another directory in the system for ++which cached font information is likely to exist. ++ ++'salt' property affects to determine cache filename as same as <dir> element. ++ ++ <literal><reset-dirs /></literal> ++This element removes all of fonts directories where added by <dir> elements. ++This is useful to override fonts directories from system to own fonts directories only. + + <literal><rescan></literal> + The <rescan> element holds an <int> element which indicates the default +diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c +index 87e30208..7c58f406 100644 +--- a/fc-cache/fc-cache.c ++++ b/fc-cache/fc-cache.c +@@ -191,7 +191,6 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, + if (really_force) + { + FcDirCacheUnlink (dir, config); +- FcDirCacheCreateUUID ((FcChar8 *) dir, FcTrue, config); + } + + cache = NULL; +@@ -392,6 +391,17 @@ main (int argc, char **argv) + return 1; + } + ++ if (verbose) ++ { ++ const FcChar8 *dir; ++ ++ printf ("Font directories:\n"); ++ while ((dir = FcStrListNext (list))) ++ { ++ printf ("\t%s\n", dir); ++ } ++ FcStrListFirst(list); ++ } + changed = 0; + ret = scanDirs (list, config, force, really_force, verbose, error_on_no_fonts, &changed); + FcStrListDone (list); +diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h +index bac1dda7..af870d0e 100644 +--- a/fontconfig/fontconfig.h ++++ b/fontconfig/fontconfig.h +@@ -1076,6 +1076,10 @@ FcUtf16Len (const FcChar8 *string, + int *nchar, + int *wchar); + ++FcPublic FcChar8 * ++FcStrBuildFilename (const FcChar8 *path, ++ ...); ++ + FcPublic FcChar8 * + FcStrDirname (const FcChar8 *file); + +diff --git a/fonts.dtd b/fonts.dtd +index 479f2c0f..fede9a79 100644 +--- a/fonts.dtd ++++ b/fonts.dtd +@@ -4,6 +4,8 @@ + cachedir | + include | + config | ++ remap-dir | ++ reset-dirs | + selectfont | + match | + alias)* > +@@ -94,6 +96,21 @@ + + + --> ++ ++ ++ ++ ++ ++ ++ ++ +