├── LICENSE
├── README.md
├── fp
├── install.sh
└── preview.png
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Manas
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Font Preview
2 | A Simple Customizable FontPreview Sh Script.
3 |
4 |
5 |
6 |
7 | # Dependencies
8 | ```
9 | ImageMagick
10 | ```
11 |
12 | # Install
13 | ```
14 | git clone https://github.com/Manas140/FP.git && cd FP
15 | ./install.sh i
16 | ```
17 |
18 | # Usage
19 | ```
20 | Usage: fp -[fs|fg|bg|ws|pt|lf|lb|rf|rb|iv|h] font_path
21 | -h: help
22 | -fs: font size.
23 | -fg: foreground color.
24 | -bg: background color.
25 | -ws: window size.
26 | -pt: preview text.
27 | -lf: linear foreground gradient.
28 | -lb: linear background gradient.
29 | -rf: radial foreground gradient.
30 | -rb: radial background gradient.
31 | -iv: image viewer.
32 | ```
33 |
34 | # Example
35 | ```
36 | fp ~/.fonts/ComicNeue-Bold.ttf -fs 25 -lb SlateBlue3-IndianRed1 -fg snow1
37 | ```
38 |
--------------------------------------------------------------------------------
/fp:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # variables
4 | cr="\033[1;31m"
5 | cg="\033[1;32m"
6 | cb="\033[1;34m"
7 | text="
8 | A B C D E F G H I J K L M
9 | N O P Q R S T U V W X Y Z
10 | a b c d e f g h i j k l m
11 | n o p q r s t u v w x y z
12 | 0 1 2 3 4 5 6 7 8 9
13 | ' \" ? ! ( ~ ) [ # ] { @ }
14 | / & < - + = > $ : ; , . *
15 | "
16 | window_size="600x400"
17 | font_size="20"
18 | foreground="#e8e3e3"
19 | background="#151515"
20 | background="xc:$background"
21 | imageviewer="xdg-open"
22 |
23 | #function
24 | help() {
25 | printf "${cg}FP : Font Preview
26 | Usage: fp ${cb}-[fs|fg|bg|ws|pt|lf|lb|rf|rb|iv|h] font_path
27 | ${cb}-h: ${cg}help
28 | ${cb}-fs: ${cg}font size.
29 | ${cb}-fg: ${cg}foreground color.
30 | ${cb}-bg: ${cg}background color.
31 | ${cb}-ws: ${cg}window size.
32 | ${cb}-pt: ${cg}preview text.
33 | ${cb}-lf: ${cg}linear foreground gradient.
34 | ${cb}-lb: ${cg}linear background gradient.
35 | ${cb}-rf: ${cg}radial foreground gradient.
36 | ${cb}-rb: ${cg}radial background gradient.
37 | ${cb}-iv: ${cg}image viewer.
38 | ${cg}Example: fp ${cb}-fs 25 -fg #151515 -bg #E8E3E3 -ws 400x200 -pt \"Hello World\" ~/.fonts/Rubik-Bold.ttf
39 | ${cr}Report issues at: https://github.com/manas140/fp/
40 | " && exit
41 | }
42 |
43 | check_dependencies() {
44 | if ! $(type 'convert' >/dev/null); then
45 | printf "${cr}Error: Could not find 'convert', Make sure you have ImageMagick installed.\n" && exit 1
46 | fi
47 | case "$(read -r os _ < /proc/version && printf "$os\n")" in
48 | *Linux*)
49 | if $(type 'xdg-open' >/dev/null); then
50 | open_command="xdg-open"
51 | else
52 | printf "${cr}Error: Could not find 'xdg-open', Make sure you have xdg-utils installed.\n"
53 | fi;;
54 | *Darwin*) open_command="open";;
55 | *) printf "${cr}Error: Os Not Supported\n" && exit 1;;
56 | esac
57 | if [ $open_command = "" ]; then
58 | printf "${cr}Error: No ImageViewer Found, Try Using '-iv open_command' flag\n" && exit 1;
59 | fi
60 | }
61 |
62 | main() {
63 | check_dependencies
64 | rm -r /tmp/fp 2>/dev/null
65 | mkdir -p /tmp/fp
66 | c=1
67 | while read -r font; do
68 | printf "${cr}"
69 | if [ -f "$font" ]; then
70 | convert -size "$window_size" -fill "$foreground" "$background"\
71 | -gravity southwest -font "$font" -annotate +10+10 "$font"\
72 | -gravity center -pointsize "$font_size" -font "$font" -annotate +0+0 "$text"\
73 | -flatten "/tmp/fp/$c.png" && c=$(( $c + 1)) && printf "${cg}Font: $font\n"
74 | else
75 | printf "${cr}Error: Not A Valid Font '$font'\n";
76 | fi
77 | done <<-EOF
78 | $fonts
79 | EOF
80 | $open_command /tmp/fp/1.png 2>/dev/null
81 | }
82 |
83 | while true; do
84 | case "$1" in
85 | "") break;;
86 | -bg) background="xc:$2"; shift;;
87 | -fg) foreground="$2"; shift;;
88 | -fs) font_size="$2"; shift;;
89 | -ws) window_size="$2"; shift;;
90 | -pt) text="$2"; shift;;
91 | -lf) foreground="gradient:$2"; shift;;
92 | -rf) foreground="radial-gradient:$2"; shift;;
93 | -lb) background="gradient:$2"; shift;;
94 | -rb) background="radial-gradient:$2"; shift;;
95 | -iv) open_command="$2"; shift;;
96 | *-h*) help;;
97 | *) fonts=$(printf "$1\n$fonts");;
98 | esac
99 | shift
100 | done
101 | main
102 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | cr="\033[1;31m"
4 | cg="\033[1;32m"
5 | cb="\033[1;34m"
6 | printf "${cr}"
7 | case $1 in
8 | *u*) sudo rm -r /usr/local/bin/fp && printf "${cg}[*] FP Uninstalled\n${cr}";;
9 | *i*) sudo cp fp /usr/local/bin/fp && printf "${cg}[*] FP Installed\n${cr}";;
10 | *) printf "${cg}Usage: ./install.sh ${cb}[i|u]${cb}
11 | i:${cg} Install
12 | ${cb}u:${cg} Uninstall\n"
13 | esac
14 |
--------------------------------------------------------------------------------
/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Manas140/FP/133ebaccef54550792c11ff48f6427453b204926/preview.png
--------------------------------------------------------------------------------