diff options
-rw-r--r-- | ranger/config/rifle.conf | 5 | ||||
-rw-r--r-- | ranger/core/main.py | 11 | ||||
-rwxr-xr-x | ranger/data/scope.sh | 21 | ||||
-rw-r--r-- | ranger/gui/curses_shortcuts.py | 2 |
4 files changed, 36 insertions, 3 deletions
diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index 454b8a14..4f2f2cf2 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -212,6 +212,11 @@ ext rar, has unrar = unrar l "$1" | less ext rar, has unrar = for file in "$@"; do unrar x "$file"; done #------------------------------------------- +# Fonts +#------------------------------------------- +mime ^font, has fontforge, X, flag f = fontforge "$@" + +#------------------------------------------- # Flag t fallback terminals #------------------------------------------- # Rarely installed terminal emulators get higher priority; It is assumed that diff --git a/ranger/core/main.py b/ranger/core/main.py index 17b546c0..d6b8ac30 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -402,8 +402,15 @@ def load_settings( # pylint: disable=too-many-locals,too-many-branches,too-many except OSError: LOG.debug('Unable to access plugin directory: %s', plugindir) else: - plugins = [p[:-3] for p in plugin_files - if p.endswith('.py') and not p.startswith('_')] + plugins = [] + for path in plugin_files: + if not path.startswith('_'): + if path.endswith('.py'): + # remove trailing '.py' + plugins.append(path[:-3]) + elif os.path.isdir(os.path.join(plugindir, path)): + plugins.append(path) + if not os.path.exists(fm.confpath('plugins', '__init__.py')): LOG.debug("Creating missing '__init__.py' file in plugin folder") fobj = open(fm.confpath('plugins', '__init__.py'), 'w') diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 13df2603..33666fcb 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -152,6 +152,27 @@ handle_image() { # "${FILE_PATH}" "${IMAGE_CACHE_PATH}" "${DEFAULT_SIZE%x*}" \ # && exit 6 || exit 1;; + # Font + application/font*|application/*opentype) + preview_png="/tmp/$(basename "${IMAGE_CACHE_PATH%.*}").png" + if fontimage -o "${preview_png}" \ + --pixelsize "120" \ + --fontname \ + --pixelsize "80" \ + --text " ABCDEFGHIJKLMNOPQRSTUVWXYZ " \ + --text " abcdefghijklmnopqrstuvwxyz " \ + --text " 0123456789.:,;(*!?') ff fl fi ffi ffl " \ + --text " The quick brown fox jumps over the lazy dog. " \ + "${FILE_PATH}"; + then + convert -- "${preview_png}" "${IMAGE_CACHE_PATH}" \ + && rm "${preview_png}" \ + && exit 6 + else + exit 1 + 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|\ diff --git a/ranger/gui/curses_shortcuts.py b/ranger/gui/curses_shortcuts.py index 14f1e0e4..b507a5c2 100644 --- a/ranger/gui/curses_shortcuts.py +++ b/ranger/gui/curses_shortcuts.py @@ -14,7 +14,7 @@ REVERSE_ADDCH_ARGS = sys.version[0:5] == '3.4.0' def _fix_surrogates(args): return [isinstance(arg, str) and arg.encode('utf-8', 'surrogateescape') - .decode('utf-8', 'replace') or arg for arg in args] + .decode('utf-8', 'replace').replace(u'\u0000', '') or arg for arg in args] class CursesShortcuts(SettingsAware): |