Okay, thanks!G'day @jonatec and welcome to linux.org
I am moving your Thread to Command Line, because it will get scripting attention there.
Let your helpers know which version Linux Mint, too eg 18, 19.
Good luck
Chris Turner
wizardfromoz
sudo fc-cache -f -v
Again, not scripts (which typically is not a good place for a newbie to start).... but terminal commands will be very useful as you learn more. Below is a link with many helpful tips on tweaking your Linux Mint Cinnamon, but you don't need to do each one... just review and see what you think. There is a special section on fonts, where it describes how to install the Microsoft collection, and another collection too.Anyway I'm a Linux newbie. Can anyone recommend an idiots guide to creating and running scripts on Linux?
fc-cache /home/jonatec/myfonts
Great, thanks!Well, I will keep knocking you on the head to learn the terminology correctly! At the moment, you are only using Linux terminal commands. A script is a different thing, kind of like a program. A script can run just a single terminal command, or it can run a very complicated set of many commands. Save your thoughts for scripts for later... because you need to learn commands first, and from there you can build scripts.
apt-get (install) is a terminal command to install a program... not fonts. sudo is always needed to install software in Linux, or you could become the root user first and then install.
Linux expects your fonts to be in a common location (/usr/share/fonts/truetype/) but you do not have to follow the convention. The terminal command, fc-cache, scans your system's common locations. If you don't want to copy your fonts to the common location, you can force fc-cache to scan the folder you use, but you have to tell it where that is. Example:
Code:fc-cache /home/jonatec/myfonts
Of course, the location in the command needs to be exact. Remember that Linux is case sensitive too, so a folder named MyFonts is not the same as myfonts.
Cheers
I fancy getting this scripting knowledge under my belt... I've downloaded all the fonts I reckon I need into a local folder, then tried the following, but didn't work:
sudo apt-get install design.graffiti.comicsansms.ttf cour.ttf
cd /path/to/local-fonts/
sudo cp *.ttf /usr/share/fonts/truetype/ && sudo fc-cache -f -v
sudo -k
/path/to/local-fonts/
in the above with the actual directory you downloaded the fonts to.&&
is a logical AND operation. So the fc-cache
command will only be ran if the initial cp
command succeeds.cp
command fails - for example if there are no .ttf files in the directory - then the fc-cache
command will NOT be ran.sudo -k
command at the end revokes administrative permissions - so the next time a sudo command is entered it will require you to enter your password.These commands worked great! Even a dummy could follow.If you want to manually install a set of fonts, you would need to copy them to the appropriate system directory and then update the systems font-cache. The instructions to do this are described in the link posted by @Condobloke .
Assuming all of the fonts are truetype .ttf fonts, then in a fresh terminal you'd use the following commands:
Bash:cd /path/to/local-fonts/ sudo cp *.ttf /usr/share/fonts/truetype/ && sudo fc-cache -f -v sudo -k
NOTES:
Replace/path/to/local-fonts/
in the above with the actual directory you downloaded the fonts to.
In the above the&&
is a logical AND operation. So thefc-cache
command will only be ran if the initialcp
command succeeds.
If thecp
command fails - for example if there are no .ttf files in the directory - then thefc-cache
command will NOT be ran.
And thesudo -k
command at the end revokes administrative permissions - so the next time a sudo command is entered it will require you to enter your password.
Regarding turning those commands into a script:
The obvious payoff to creating a script is that any time you wanted to install some ttf fonts - you could just run your script and tell it which directory the fonts you want to install are in.
Which would save you having to remember the commands/paths you will need to use to install them manually.
But for the sake of one or two simple commands that would copy some ttf files and update the font-cache - you're potentially looking at quite a lot of housekeeping code to avoid any potential problems. So it might take a little time to fully develop your script and make it robust enough to handle any adverse situations.
e.g. accidental, or deliberate misuse by users.
So it's swings and roundabouts really!
If you're likely to need to install new fonts regularly - then by all means - set up a script to do it.
If you're not likely to be doing it often - just make a note of the commands required to manually install fonts and type them (or copy/paste them from a file) as and when you need to use them.
A good time to learn about the man pages (built-in help manuals). At a terminal, enter1) Is there a Linux command to list the contents of the font cache?
man fc-cache
and it will give you instructions about usage, options, and usually examples. With fc-cache, it also names some similar commands, such as fc-list
. That will generate a lot of output (because there a lot of fonts!) and so you might want to capture the full list into a file, like this:fc-list > /home/jonatec/Desktop/myfonts.txt
Same method as with truetype, but into a different folder. Copy your OTF files to: /user/share/fonts/opentype/ ... then run2) How to install an OTF font?
fc-cache -f -v
as before.