Skip to content

font preview: allow custom preview string (and colors). #3856

@ciqven

Description

@ciqven

yazi --debug output

Yazi
    Version: 26.1.22 (26.1.22_2 2026-02-28)
    Debug  : false
    Triple : x86_64-unknown-linux-gnu (linux-x86_64)
    Rustc  : 1.93.0 (254b5960 2026-01-19)

Ya
    Version: 26.1.22 (26.1.22_2 2026-02-28)

Config
    Init             : /home/ciqven/.config/yazi/init.lua (447 chars)
    Yazi             : /home/ciqven/.config/yazi/yazi.toml (281 chars)
    Keymap           : /home/ciqven/.config/yazi/keymap.toml (19365 chars)
    Theme            : /home/ciqven/.config/yazi/theme.toml (3885 chars)
    VFS              : /home/ciqven/.config/yazi/vfs.toml (No such file or directory (os error 2))
    Package          : /home/ciqven/.config/yazi/package.toml (231 chars)
    Dark/light flavor: "" / ""

Emulator
    TERM                : Some("xterm-kitty")
    TERM_PROGRAM        : None
    TERM_PROGRAM_VERSION: None
    Brand.from_env      : Some(Kitty)
    Emulator.detect     : Emulator { kind: Left(Kitty), version: "kitty(0.46.2)", light: false, csi_16t: (9, 18), force_16t: false }

Adapter
    Adapter.matches    : Kgp
    Dimension.available: Dimension { rows: 84, columns: 212, width: 1908, height: 1512 }

Desktop
    XDG_SESSION_TYPE           : Some("tty")
    WAYLAND_DISPLAY            : None
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL              : Some("/bin/bash")
    EDITOR             : Some("/usr/bin/nano")
    VISUAL             : None
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None
    YAZI_ZOXIDE_OPTS   : None
    FZF_DEFAULT_OPTS   : None
    FZF_DEFAULT_COMMAND: None

Text Opener
    default     : Some(OpenerRule { run: "nano %s", block: true, orphan: false, desc: "", for: None, spread: true })
    block-create: Some(OpenerRule { run: "nano %s", block: true, orphan: false, desc: "", for: None, spread: true })
    block-rename: Some(OpenerRule { run: "nano %s", block: true, orphan: false, desc: "", for: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : No such file or directory (os error 2)
    tmux build flags   : enable-sixel=Unknown
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file          : 5.46
    ueberzugpp    : No such file or directory (os error 2)
    ffmpeg/ffprobe: 6.1.4 / 6.1.4
    pdftoppm      : 25.12.0
    magick        : 7.1.2-13
    fzf           : 0.70.0
    fd/fdfind     : No such file or directory (os error 2) / No such file or directory (os error 2)
    rg            : 15.1.0
    chafa         : No such file or directory (os error 2)
    zoxide        : No such file or directory (os error 2)
    7zz/7z        : 26.00 / 26.00
    resvg         : No such file or directory (os error 2)
    jq            : 1.8.1

Clipboard
    wl-copy/paste: No such file or directory (os error 2) / No such file or directory (os error 2)
    xclip        : 0.13
    xsel         : No such file or directory (os error 2)

Routine
    `file -bL --mime-type`: text/plain


See https://yazi-rs.github.io/docs/plugins/overview#debugging on how to enable logging or debug runtime errors.

Please describe the problem you're trying to solve

When I select a font file in yazi, I get a preview generated with ImageMagick.

This preview covers upper and lowercase letters, numbers, and some special chars. However, I work a lot with fonts for different scripts as part of my hobbies and would like this text to be configurable.

Looking at https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/plugins/font.lua, this seems to be the hardcoded TEXT variable at line 1.

A nice to have would be to allow some more of the args passed to imagemagick in that file to be customized, like foreground and background color so they fit my theme.

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

An optional config file somewhere where I can set the preview text (and maybe colors?).

From looking around I guess this would be a setup method in font.lua with opts, which the user can then call from init.lua with their desired config? I must admit I am no lua expert, just based this on what I saw in zoxide.lua in the same dir :)

Additional context

I'm willing to try making a PR for this if it is feasible and desired to implement.

Checklist

  • I have searched the existing issues/discussions
  • The latest nightly build doesn't already have this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions