diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
commit | 35a96bde514a8897f6f0fcc41c5833bf63df2e2a (patch) | |
tree | 657d15a03cc46bd099fc2c6546a7a4ad43815d9f /snap/local/scripts/private-fontcache | |
parent | Initial commit. (diff) | |
download | inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.tar.xz inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'snap/local/scripts/private-fontcache')
-rwxr-xr-x | snap/local/scripts/private-fontcache | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/snap/local/scripts/private-fontcache b/snap/local/scripts/private-fontcache new file mode 100755 index 0000000..964dfd6 --- /dev/null +++ b/snap/local/scripts/private-fontcache @@ -0,0 +1,39 @@ +#!/bin/bash +# Ensure that we prioritize using the private font cache +# SPDX-License-Identifier: GPL-2.0-or-later + +# ensure_dir_exists calls `mkdir -p` if the given path is not a directory. +# This speeds up execution time by avoiding unnecessary calls to mkdir. +# +# Usage: ensure_dir_exists <path> [<mkdir-options>]... +function ensure_dir_exists() { + [ -d "$1" ] || mkdir -p "$@" +} + +# Set $REALHOME to the users real home directory +REALHOME=$(getent passwd $UID | cut -d ':' -f 6) + +# Set config folder to local path +export XDG_CONFIG_HOME="$SNAP_USER_DATA/.config" +ensure_dir_exists "$XDG_CONFIG_HOME" +chmod 700 "$XDG_CONFIG_HOME" + +function make_user_fontconfig { + echo "<fontconfig>" + echo " <dir>$REALHOME/.local/share/fonts</dir>" + echo " <dir>$REALHOME/.fonts</dir>" + echo " <cachedir prefix=\"xdg\">fontconfig</cachedir>" + echo " <cachedir>$SNAP_DATA/fontconfig</cachedir>" + echo " <include ignore_missing=\"yes\">/etc/fonts/fonts.conf</include>" + if [ ! -z $SNAP_DESTKOP_RUNTIME ]; then + echo " <include ignore_missing=\"yes\">${SNAP_DESKTOP_RUNTIME}/etc/fonts/fonts.conf</include>" + fi + echo "</fontconfig>" +} + +ensure_dir_exists "$XDG_CONFIG_HOME/fontconfig" +make_user_fontconfig > "$XDG_CONFIG_HOME/fontconfig/fonts.conf" + +export FONTCONFIG_FILE=${XDG_CONFIG_HOME}/fontconfig/fonts.conf + +exec "$@" |