diff options
Diffstat (limited to 'modules/by-name/lf/lf/ctpv/prev/font')
-rw-r--r-- | modules/by-name/lf/lf/ctpv/prev/font/default.nix | 17 | ||||
-rw-r--r-- | modules/by-name/lf/lf/ctpv/prev/font/font.sh | 18 |
2 files changed, 35 insertions, 0 deletions
diff --git a/modules/by-name/lf/lf/ctpv/prev/font/default.nix b/modules/by-name/lf/lf/ctpv/prev/font/default.nix new file mode 100644 index 00000000..f5301008 --- /dev/null +++ b/modules/by-name/lf/lf/ctpv/prev/font/default.nix @@ -0,0 +1,17 @@ +{pkgs, ...}: { + soispha.programs.lf.ctpv.previewers = { + font = { + previewer = ./font.sh; + matches.mime = [ + "font/*" + "application/vnd.ms-opentype" + + # TODO: This should be added (ext: 'eot') <2024-12-04> + # "application/vnd.ms-fontobject" + ]; + dependencies = [ + pkgs.fontforge # for `fontimage` + ]; + }; + }; +} diff --git a/modules/by-name/lf/lf/ctpv/prev/font/font.sh b/modules/by-name/lf/lf/ctpv/prev/font/font.sh new file mode 100644 index 00000000..4065557e --- /dev/null +++ b/modules/by-name/lf/lf/ctpv/prev/font/font.sh @@ -0,0 +1,18 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH + +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +cache_f="$cache_f" + +. %HELPERS + +font() { + fontimage -o "$cache_f.png" "$f" 2>/dev/null && + mv -- "$cache_f.png" "$cache_f" +} + +convert_and_show_image font |