summaryrefslogtreecommitdiffstats
path: root/snap/local
diff options
context:
space:
mode:
Diffstat (limited to 'snap/local')
-rw-r--r--snap/local/print-inkscape-version.cpp43
-rwxr-xr-xsnap/local/scripts/ghostscript-libraries7
-rwxr-xr-xsnap/local/scripts/private-fontcache39
3 files changed, 89 insertions, 0 deletions
diff --git a/snap/local/print-inkscape-version.cpp b/snap/local/print-inkscape-version.cpp
new file mode 100644
index 0000000..210f806
--- /dev/null
+++ b/snap/local/print-inkscape-version.cpp
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// Use the Inkscape compiled version identifier and print it out with
+// the Snap restrictions on versions. Only a few characters are allowed
+// and a limit of 32 characters total.
+
+#include "inkscape-version.h"
+
+#include <iostream>
+#include <cctype>
+
+int main (int argc, char ** argv) {
+ std::string outstr;
+
+ for (const auto& c : std::string{Inkscape::version_string}) {
+ if (outstr.length() == 32) {
+ break;
+ }
+
+ if (std::isalpha(c) || std::isdigit(c)) {
+ outstr.append(1, c);
+ continue;
+ }
+
+ if (c == '(' || c == ')' || c == ',') {
+ continue;
+ }
+
+ if (c == '.' || c == '-') {
+ outstr.append(1, c);
+ continue;
+ }
+
+ outstr.append(1, '-');
+ }
+
+ while (outstr.length() > 0 && !std::isalpha(outstr.back()) && !std::isdigit(outstr.back())) {
+ outstr.pop_back();
+ }
+
+ std::cout << outstr << std::endl;
+
+ return 0;
+}
diff --git a/snap/local/scripts/ghostscript-libraries b/snap/local/scripts/ghostscript-libraries
new file mode 100755
index 0000000..1184ce1
--- /dev/null
+++ b/snap/local/scripts/ghostscript-libraries
@@ -0,0 +1,7 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Make it so that Ghostscript can find itself in the snap directory
+
+export GS_LIB=`find ${SNAP}/usr/share/ghostscript -name gs_init.ps | head -1 | xargs dirname`
+
+exec "$@"
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 "$@"