git.lucas.co / fontpreview
git clone https://git.lucas.co/fontpreview.git

README.md (3.8K)

  1 <p align="center"><img src="extra/logo.png"><br><sub>✨ Very customizable and minimal font previewer written in bash ✨</sub></p>
  2 
  3 `fontpreview` is a commandline tool that lets you **quickly search** for fonts
  4 that are installed on your machine and preview them. The **fuzzy search** feature
  5 is provided by `fzf` and the preview is generated with `imagemagick` and then
  6 displayed using `nsxiv`. This tool is **highly customizable**, almost all of the
  7 variables in this tool can be changed using the commandline flags or you can
  8 configure them using environment variables.
  9 
 10 ![](extra/demo.gif)
 11 
 12 ## Dependencies
 13 
 14 - `xdotool`
 15 - `fzf`
 16 - `imagemagick`
 17 - `nsxiv`
 18 
 19 ## Installation
 20 ### Install using `make`
 21 ```bash
 22 # Clone the repo
 23 $ git clone https://github.com/sdushantha/fontpreview
 24 
 25 # Change your current directory to fontpreview
 26 $ cd fontpreview
 27 
 28 # Install it
 29 $ sudo make install
 30 ```
 31 
 32 ### Install it locally
 33 ```bash
 34 # Download the fontpreview source code, save as fontpreview
 35 # and make it executeable
 36 $ curl -L https://git.io/raw_fontpreview > fontpreview && chmod +x fontpreview
 37 
 38 # Then move fontpreview to somewhere in your $PATH
 39 # Here is an example
 40 $ mv fontpreview ~/scripts/
 41 ```
 42 
 43 ## Usage
 44 ```
 45 $ fontpreview --help
 46 usage: fontpreview [-h] [--size "px"] [--position "+x+y"] [--search-prompt SEARCH_PROMPT]
 47                    [--font-size "FONT_SIZE"] [--bg-color "BG_COLOR"] [--fg-color "FG_COLOR"]
 48                    [--preview-text "PREVIEW_TEXT"] [-i font.otf] [-o preview.png] [--version]
 49 
 50 ┌─┐┌─┐┌┐┌┌┬┐┌─┐┬─┐┌─┐┬  ┬┬┌─┐┬ ┬
 51 ├┤ │ ││││ │ ├─┘├┬┘├┤ └┐┌┘│├┤ │││
 52 └  └─┘┘└┘ ┴ ┴  ┴└─└─┘ └┘ ┴└─┘└┴┘
 53 Very customizable and minimal font previewer written in bash
 54 
 55 optional arguments:
 56    -h, --help            show this help message and exit
 57    -i, --input           filename of the input font (.otf, .ttf, .woff are supported)
 58    -o, --output          filename of the output preview image (input.png if not set)
 59    --size                size of the font preview window
 60    --position            the position where the font preview window should be displayed
 61    --search-prompt       input prompt of fuzzy searcher
 62    --font-size           font size
 63    --bg-color            background color of the font preview window
 64    --fg-color            foreground color of the font preview window
 65    --preview-text        preview text that should be displayed in the font preview window
 66    --version             show the version of fontpreview you are using
 67 ```
 68 
 69 If you want to generate a preview image for a **single** font file
 70 (.otf, .ttf, and .woff are supported), use the `-i` and `-o` option
 71 to indicate the filename of the input font and the output preview
 72 image.
 73 
 74 ```
 75 $ fontpreview -i font.otf -o preview.png
 76 ```
 77 
 78 This can be used with [überzug](https://github.com/seebye/ueberzug)
 79 to implement font preview within terminal file managers such as
 80 [vifm](https://vifm.info/).
 81 
 82 ![](extra/vifm.png)
 83 
 84 A detailed setup instructions can be found [here](https://krasjet.com/scribbles/font-preview.html)
 85 
 86 
 87 ## Configure
 88 You can configure `fontpreview` through environment variables.
 89 
 90 This can be in your `.bashrc`, `.zshrc`, etc
 91 
 92 ```bash
 93 # Input prompt of fuzzy searcher
 94 export FONTPREVIEW_SEARCH_PROMPT="❯ "
 95 
 96 # Size of the font preview window
 97 export FONTPREVIEW_SIZE=532x365
 98 
 99 # The position where the font preview window should be displayed
100 export FONTPREVIEW_POSITION="+0+0"
101 
102 # Font size
103 export FONTPREVIEW_FONT_SIZE=38
104 
105 # Background color of the font preview window
106 export FONTPREVIEW_BG_COLOR="#ffffff"
107 
108 # Foreground color of the font preview window
109 export FONTPREVIEW_FG_COLOR="#000000"
110 
111 # Preview text that should be displayed in the font preview window
112 export FONTPREVIEW_PREVIEW_TEXT="ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n1234567890\n!@$\%(){}[]"
113 ```