summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorLeo Vivier <zaephon@gmail.com>2019-01-14 17:21:02 +0100
committerLeo Vivier <zaephon@gmail.com>2019-01-14 17:23:20 +0100
commit51181722d4e6bfa338680bf9b031095db8609916 (patch)
tree4025407f031258ae645dcab8bd0ae5bed5b935fc
parent35839cb44068b91628826e6d2c832f9d2f56dc68 (diff)
downloadranger-51181722d4e6bfa338680bf9b031095db8609916.tar.gz
Add font preview with fontimage
-rwxr-xr-xranger/data/scope.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index 326796e1..2a84796f 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -129,6 +129,26 @@ handle_image() {
         #              -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \
         #         && exit 6 || exit 1;;
 
+	# Font
+	application/font*|application/*opentype)
+	    preview_png="/tmp/$(basename ${IMAGE_CACHE_PATH%.*}).png"
+            fontimage -o "${preview_png}" \
+		      --pixelsize "100" \
+		      --fontname \
+		      --text "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+		      --text "abcdefghijklmnopqrstuvwxyz" \
+		      --text "0123456789.:,;(*!?') ff fl fi ffi ffl" \
+		      --text "The quick brown fox jumps over the lazy dog." \
+		      "${FILE_PATH}"
+	    if [[ "$?" > 0 ]] ; then
+		exit 1
+	    else
+		convert "${preview_png}" "${IMAGE_CACHE_PATH}" \
+		    && rm "${preview_png}" \
+                    && exit 6
+	    fi
+	    ;;
+
         # Preview archives using the first image inside.
         # (Very useful for comic book collections for example.)
         # application/zip|application/x-rar|application/x-7z-compressed|\