alexmyczko / fnt Goto Github PK
View Code? Open in Web Editor NEWapt for fonts, the missing font manager for macOS/linux
License: MIT License
apt for fonts, the missing font manager for macOS/linux
License: MIT License
I get line 175: unxz: command not found
when running fnt search some_font
. It still finds what I'm looking for, but it prints this error. Because it found it, I'm assuming, its either not a critical dependency or I'm missing some results or something. I was able to find xz
in Homebrew and this clears up the error.
I feel it would be nice to have a mention of the dependency in the REAME.md. Would you like to have such a mention? If so, would you prefer to add it yourself or would you want a Pull request for it?
I will also look to add xz
to the Homebrew formula here to get Homebrew to take care of this dependency when installing fnt
with brew install fnt
on the systems it supports.
depending on os it can use open(macOS or GNUstep), feh/xdg-open ($DISPLAY set) to preview the font
I guess I have to introduce a new variable for preferred image viewer and think of a good name for it
https://en.wikibooks.org/wiki/Guide_to_Unix/Environment_Variables
serif
sans-serif
mono
script
display
find some cli tool/way to figure out how to classify a font(files). help welcome
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
The simplest "closer" answer would be: TMPDIR="$HOME/.cache/fnt"
(note double quotes so that http://shellcheck.net
doesn't yell at you for "what if your $USER has spaces in it?"
Likely more correct would be: CACHEDIR="${XDG_CACHE_HOME:-$HOME/.cache}/fnt"
https://wiki.bash-hackers.org/syntax/pe#use_a_default_value
echo "Your home directory is: ${HOME:-/home/$USER}."
...then either remove the cache dir you control after each execution, or maybe provide some sort of --cache
support.
LOVE your code, the $TO_CHECK && $INSTALLER
technique is awesome for non-package-manager-based scripts. If you're amenable, I'd probably mess around and submit a patch for some of this or would be happy to discuss, as I love some of the potential that this utility has.
The font preview is a nifty idea, but the resolution is too low. I don't know much about chafa, but I thought it handled sixels which would allow for a crisp bitmap display in the terminal. Perhaps there is something fnt needs to do to enable it?
Here is an comparison with using sixels, via the ImageMagick convert
command, to view a font on the command line in a terminal that handles graphics. (Xterm).
convert -list font | grep Font | grep -v Noto
convert -size 800x -font Iosevka label:'ABC xyz' sixel:- ; echo
convert -size 800x -background orange -fill white -font Sudo-Regular label:$'\U2022 ABC xyz \U1F5D1' sixel:- ; echo
But that only works for fonts that are already installed. My hope is that fnt
will be able to do the same thing for any font.
It would be nice if there is rpm package of fnt, so it can be installed on fedora.
In fnt line 29:
echo Please report $s to https://github.com/alexmyczko/fnt/issues
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
echo Please report "$s" to https://github.com/alexmyczko/fnt/issues
In fnt line 35:
which $a >/dev/null
^---^ SC2230: which is non-standard. Use builtin 'command -v' instead.
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
which "$a" >/dev/null
In fnt line 36:
if [ ! $? -eq 0 ]; then
^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
In fnt line 37:
echo $a not found, please use $i to install it.
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
echo "$a" not found, please use $i to install it.
In fnt line 42:
if [ ${1}x == x ]; then
^--^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
if [ "${1}"x == x ]; then
In fnt line 52:
if [ ! -d ${TMPDIR} ]; then mkdir -p ${TMPDIR}; fi
^-------^ SC2086: Double quote to prevent globbing and word splitting.
^-------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
if [ ! -d "${TMPDIR}" ]; then mkdir -p "${TMPDIR}"; fi
In fnt line 53:
if [ -f ${TMPDIR}/Packages.xz ]; then rm ${TMPDIR}/Packages.xz; fi
^-------^ SC2086: Double quote to prevent globbing and word splitting.
^-------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
if [ -f "${TMPDIR}"/Packages.xz ]; then rm "${TMPDIR}"/Packages.xz; fi
In fnt line 54:
curl -s $INDEX -o ${TMPDIR}/Packages.xz
^-------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
curl -s $INDEX -o "${TMPDIR}"/Packages.xz
In fnt line 61:
ls -1 $HOME/Library/Fonts/*.?tf $HOME/.fonts/*.?tf 2>/dev/null | while read f; do
^-- SC2012: Use find instead of ls to better handle non-alphanumeric filenames.
^---^ SC2086: Double quote to prevent globbing and word splitting.
^---^ SC2086: Double quote to prevent globbing and word splitting.
^--^ SC2162: read without -r will mangle backslashes.
Did you mean:
ls -1 "$HOME"/Library/Fonts/*.?tf "$HOME"/.fonts/*.?tf 2>/dev/null | while read f; do
In fnt line 62:
echo "$f [$(otfinfo -u ""$f"" 2>/dev/null|wc -l)]" | sed s,.*/,,
^-- SC2027: The surrounding quotes actually unquote this. Remove or escape them.
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
echo "$f [$(otfinfo -u """$f""" 2>/dev/null|wc -l)]" | sed s,.*/,,
In fnt line 68:
img=$(lynx -dump https://screenshots.debian.net/package/fonts-$2 | grep large.png | sed s,.*http,http,)
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
img=$(lynx -dump https://screenshots.debian.net/package/fonts-"$2" | grep large.png | sed s,.*http,http,)
In fnt line 70:
curl -s $img -o ${TMPDIR}/preview.png
^--^ SC2086: Double quote to prevent globbing and word splitting.
^-------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
curl -s "$img" -o "${TMPDIR}"/preview.png
In fnt line 71:
chafa --invert -c none --symbols block+border-solid ${TMPDIR}/preview.png
^-------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
chafa --invert -c none --symbols block+border-solid "${TMPDIR}"/preview.png
In fnt line 77:
p=$(cat $HOME/.fnt/Packages.xz |unxz| grep -v "^Architecture:\|^Section:\|^Priority:\|^Replaces:\|^Provides:\|^Brekas:\|^Maintainer:\|^MD5sum:\|^Source:\|^Breaks:\|^Multi-Arch:\|^Description-\|^Tag:\|^SHA256:"|awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-"|grep fonts-$2|head -1)
^---^ SC2086: Double quote to prevent globbing and word splitting.
^--------------------^ SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
p=$(cat "$HOME"/.fnt/Packages.xz |unxz| grep -v "^Architecture:\|^Section:\|^Priority:\|^Replaces:\|^Provides:\|^Brekas:\|^Maintainer:\|^MD5sum:\|^Source:\|^Breaks:\|^Multi-Arch:\|^Description-\|^Tag:\|^SHA256:"|awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-"|grep fonts-"$2"|head -1)
In fnt line 79:
name=$(echo $p | awk '{print $2}')
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
name=$(echo "$p" | awk '{print $2}')
In fnt line 80:
ver=$(echo $p | awk '{print $4}')
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
ver=$(echo "$p" | awk '{print $4}')
In fnt line 81:
instsize=$(echo $p | awk '{print $6}')
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
instsize=$(echo "$p" | awk '{print $6}')
In fnt line 82:
downsize=$(echo $p | awk '{print $NF}')
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
downsize=$(echo "$p" | awk '{print $NF}')
In fnt line 83:
url=$(echo $p | awk '{print $(NF-2)}')
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
url=$(echo "$p" | awk '{print $(NF-2)}')
In fnt line 84:
f=$(basename $url)
^--^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
f=$(basename "$url")
In fnt line 86:
curl -s ${MIRROR}${url} -o ${TMPDIR}/$f
^----^ SC2086: Double quote to prevent globbing and word splitting.
^-------^ SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
curl -s ${MIRROR}"${url}" -o "${TMPDIR}"/"$f"
In fnt line 87:
cd ${TMPDIR}
^----------^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
^-------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
cd "${TMPDIR}" || exit
In fnt line 88:
ar x $f
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
ar x "$f"
In fnt line 90:
find ${TMPDIR} . -name "*.?tf" -exec cp {} $target \;
^-------^ SC2086: Double quote to prevent globbing and word splitting.
^-----^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
find "${TMPDIR}" . -name "*.?tf" -exec cp {} "$target" \;
In fnt line 91:
rm $f control.tar* data.tar* debian-binary
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
rm "$f" control.tar* data.tar* debian-binary
In fnt line 92:
rm -rf ${TMPDIR}/usr
^-----------^ SC2115: Use "${var:?}" to ensure this never expands to /usr .
^-------^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
rm -rf "${TMPDIR}"/usr
In fnt line 101:
cat $HOME/.fnt/Packages.xz |unxz |grep ^Package:\ fonts-|awk '{print $2}' | grep "$2"
^---^ SC2086: Double quote to prevent globbing and word splitting.
^--------------------^ SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
Did you mean:
cat "$HOME"/.fnt/Packages.xz |unxz |grep ^Package:\ fonts-|awk '{print $2}' | grep "$2"
For more information:
https://www.shellcheck.net/wiki/SC2027 -- The surrounding quotes actually u...
https://www.shellcheck.net/wiki/SC2115 -- Use "${var:?}" to ensure this nev...
https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |...
The AppStream specification is providing a metadata standard for fonts, this allow them to be available in Application Software Managers (like GNOME Shell, elementary AppCenter or KDE Discover).
It would be freat if fnt would create such metadata to easily be able to install them.
in a loop
download random font
select random pop colors
random words, render horizontal/vertical, and
45° and 22.5° rotated random texts
wait n seconds
bestloopever
Perhaps I am not the proper target audience for fnt, but for me it is overwhelming. I already have a lot of fonts on my system and there are hundreds available for Debian, so I can easily install more if I know the name of what I want. The problem I have is that there are hundreds of fonts, so I can't simply say apt install font-best-typeface-ever
. fnt offers even more fonts but I don't see that it provides any better way of sifting through them.
I know this is perhaps too big a request to wish for, but I would like to see fnt grow the ability to help people sort and select fonts quickly.
If you think this is a good idea, I have some ideas for ways that might work:
Categories would be one way to do it: For example, if I am looking for a traditional, formal font, I don't need to be shown whimsical, fun fonts.
Metapackages of fonts that people use together commonly would be handy. For example, there could be a set for basic word processing, another for designers, and maybe one for command line users.
Searching by Unicode coverage would be helpful (at least for people like me who use unusual glyphs). For example, what fonts support U+FDFD?
Ideally, fnt
would show a Quick Comparison of fonts found from such a search. I wrote a tool which does that, but it only works for the fonts installed.
Sorting by Popularity is a way that many font sites work and would probably be helpful to people, although maybe there should also be a reverse option for folks who want to avoid overly popular fonts. fnt
could probably leverage the Debian popcon database for this.
Having a small Blurb, like one sees on bottles of wine, describing the characteristics and purpose of the font would be helpful. Many OFL font designers have already written such descriptions for their fonts.
Showing a Single line Preview of multiple fonts would be great. Here's an example of one way to show all the fonts available on your system, one per line, in a terminal. (Requires ImageMagick and a sixel capable terminal. For simplicity, the height is hardcoded to 20 pixels, but see my ugrep
program for an example of how to detect the size of the character cell):
for f in $(convert -list font | grep Font: | cut -d: -f2- ); do printf "%40s" "$f "; convert -size x20 -font "$f" label:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 abcdefghijklmnopqrstuvwxyz" sixel:-; done
Searching by Similar fonts can be helpful. For example, I might want something that has some of the same characteristics as Iosevka
and it'd be great if fnt
could show me suggestions for alternatives.
Conversely, deduplicating would reduce the overwhelm by not presenting multiple versions of fonts that are too similar any way. For example, when I fnt search obs
I am shown two fonts, "google-lobster" and "google-lobster-two", but there is no way in fnt
to distinguish them. (By the way, typing fnt preview google-lobster
returns "Couldn't retrieve preview". Using fnt preview lobster
does show me a preview but it is actually a third font, "fonts-lobster", which may or may not be the same as google-lobster. If they are substantially the same, it would be nice if fewer lobsters were shown by default.)
That is probably more than enough ideas, so I'll just stop here.
Make command like fnt install anonymouspro azeretmono cousine dejavu firacode hack ibmplexmono notosansmono oxygenmono robotomono victormono
to install all the fonts specified.
I was confused finding that command from above will install only anonymouspro
and silently exit, without any indication that it doesn't install the rest of the fonts.
That feature will bring fnt install
on par with typical distro installer behavior, e.g. apt-get install package1 package2
does installs both of packages.
So far I did simple loop in my dotfiles:
# Change to `fnt install` after https://github.com/alexmyczko/fnt/issues/30 is fixed
fonts=(anonymouspro \
azeretmono \
cousine \
dejavu \
firacode \
hack \
ibmplexmono \
notosansmono \
oxygenmono \
robotomono \
victormono \
)
for font in ${fonts[@]}; do
fnt install $font
done
Thanks
the default /etc/fonts/fonts.conf
has:
<!-- Font directory list -->
<dir>/usr/share/fonts</dir>
<dir>/usr/local/share/fonts</dir>
<dir prefix="xdg">fonts</dir>
<!-- the following element will be removed in the future -->
<dir>~/.fonts</dir>
As you can see, ~/.fonts/
is deprecated now, and it should be whatever XDG environment variables point to (or ~/.local/share/fonts/
by default).
the api only works with an api key which treats your privacy in a bad way:
https://developers.google.com/fonts/
so we will resort using the github repository of it.
the link the designers via google+ which is dead: https://plus.google.com/?pli=1
since github.com also limits access to it with api keys, i'll use a mirror of the github repo self hosted, looks do-able...
You said the following in your rationale section:
If you run macOS, neither fink, brew, nor macports come with a great list of available to install fonts.
I never used fink and didn't use MacPorts for font management but I certainly do use https://github.com/Homebrew/homebrew-cask-fonts According to GitHub's listing it contains roughly 1700 different fonts all installable by using established HB/HB Cask workflow. I don't know about you but that certainly fits my great list standards 😄
Now for the honest question: Am I missing something here that makes fnt better choice compared to it, or you somehow managed to miss its existence? 🤔
Nevertheless, I very much like the idea and simple and effective cross-platform implementation. 👍
The webserver hosting prebuilt distro packages is down (80, 443 is not listening), seems only SSH is open. Could you check that? Thank you :)
I have been working at installing this because it looks great. :) There was no compatible package available so I downloaded the release v 1.4.1
.
First issue is that the suggested make install
results in this:
if test ! -d //usr/bin ; then mkdir -p //usr/bin ; fi
install -m 755 fnt //usr/bin/
install: cannot create regular file '//usr/bin/fnt': Permission denied
makefile:11: recipe for target 'install' failed
make: *** [install] Error 1
Which I guessed correctly meant that sudo
was required. Perhaps either the error or the instructions could be clarified. So sudo make install
whose output was also confusing:
if test ! -d //usr/bin ; then mkdir -p //usr/bin ; fi
install -m 755 fnt //usr/bin/
if test ! -d //usr/share/man/man1 ; then mkdir -p //usr/share/man/man1; fi
install -c -m 644 fnt.1 //usr/share/man/man1/ ; gzip -9 //usr/share/man/man1/fnt.1
if test ! -d //usr/local/share/zsh/site-functions ; then mkdir -p //usr/local/share/zsh/site-functions ; fi
install -m 755 completions/_fnt //usr/local/share/zsh/site-functions/
successful? not? easy to find out by running fnt
which alerted that there are unmet dependencies:
chafa not found, please use apt to install it.
So I went to find this package chafa
, which was not available via apt
. On the developer's page there are instructions on how to add the ppa
so I am guessing many people would not find it available by default. But installed it one way or another.
then tried running fnt
otfinfo not found, please use apt to install it.
I was able to find how to install otfinfo
only as part of the package lcdf-typetools
; not sure if it is available independently. The latter was available via apt
while otfinfo
itself was not.
I think it is traditional for dependencies to be checked during install rather than afterwards, when the program is run? Not sure if the output of make
was something to do with that.
Assuming you do not want to get extremely complicated with figuring out what exactly version of OS each user is running and providing precise instructions, I don't know but maybe something like these would be helpful error messages instead:
Required package chafa not found, please consult https://hpjansson.org/chafa for install instructions.
Required package otfinfo not found, please use apt or your preferred package manager to install the parent package lcdf-typetools or consult https://www.lcdf.org/type/ for further information.
Also when I was poking around in fnt
I noticed something about the the error dispayed if brew
is not found on Mac.
If I am reading correctly, it looks like the error if brew
is not installed would be instructions to use brew
to install it. If the case, I would suggest the following instead
Required package brew not found, please consult https://brew.sh/ for further install instructions.
I am not a programmer but I did search the repo to find code about the dependencies. I think the relevant bit is here. Based on that, here is a draft/suggestion of what could reasonably included in the readme or some ancillary location for dependencies.
Dependencies
Mac
brew
curl
- should be installed by default
- if needed, available via
brew
withbrew install curl
otfinfo
- packaged with with
lcdf-typetools
which is available viabrew
withbrew install lcdf-typetools
chafa
- available viabrew
withbrew install chafa
Linux
curl
- should be installed by default
- available via
apt
if neededsudo apt install curl
chafa
- see website for install optionsotfinfo
- packaged with with
lcdf-typetools
which is likely available viasudo apt install lcdf-typetools
or your preferred package manager; consult website for install optionsFreeBSD
curl
chafa
otfinfo
- packaged with with
lcdf-typetools
; consult website for install optionsHaiku OS
Windows
cmd.exe
OR
- No outside dependencies
I included explicit instructions for Mac and Linux which are the two systems I am familiar with (Mac more than the 1000 variations of Linux).
cmd.exe
as last I knew that was part of the OS so maybe that's just internal for the program and nothing the user would need to think of, therefor does not need mentioned.I am happy to make a PR for the readme if you are amenable to this. As I mentioned I am not a programmer or anything so if there is a bunch of requirements to setting up a development environment it is unlikely to be worth the time. If it's just textfiles and git I can do it. I'm not capable of making a PR for the error messages because they require coding.
Or you can handle it whatever way works for you, edit, discard etc.
Hi,
From help:
update -u -- updates the font package index of debian sid
Does this mean that when a font is updated it downloads and install the latest version? How would I upgrade a font?
Thanks!
Atkinson Hyperlegible Font is missing
source: https://github.com/googlefonts/atkinson-hyperlegible
About Atkinson Hyperlegible
Atkinson Hyperlegible, named after the founder of the Braille Institute, has been developed specifically to increase legibility for readers with low vision, and to improve comprehension.
Having a traditional grotesque sans-serif at its core, it departs from tradition to incorporate unambiguous, distinctive elements—and at times, unexpected forms—always with the goal of increasing character recognition and ultimately improve reading.
yeah umm what
Honestly, I thought I already had this up and running, guess not. Obviously, it would be nice if this project supported OpenBSD. It appears to already support FreeBSD, which is not too different to make compatibility a gargantuan obstacle.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.