If you have ever wondered whether it is possible to automate the generation of fonts for the web or if you are tired of entering the Font Squirrel every time, then, as they say, welcome to Cat.
The other day I wrote a console utility, essentially a client, for the popular web font generator
Font Squirrel . I called her Marmot (Marmot), and this is what she can do:
marmot Averia-Regular.ttf
Marmot takes any font, uploads it to Font Squirrel and downloads the archive with the woff, ttf, eot and svg version of the font. By default, the generator default settings are used.
In the archive that you download from Font Squirrel there is always a file called
generator-config.txt , so Marmot can read it:
marmot -c generator-config.txt font.otf
Cool, cool, where to download, how to set?
Marmot is written in Ruby, set as a regular jam:
')
gem install marmot
And how to set it up?
One of the options is to use the config file about which I wrote above. The format is JSON, they look like this:
{ "formats":["ttf", "woff", "svg"], "fallback":"none", "subset_custom_range":"E000-F8FF", "emsquare":"1000" }
The second option is to set parameters via the console:
marmot --no-add-hyphens --formats=ttf,woff font.otf
There are many parameters, and sometimes their names are frankly incomprehensible, to make it easier, we go to
the generator page and run the following code in the console:
$("input[value='expert'], input[value='advanced']").click(); $("table input").each(function(){ $(this).after($("<div style='color:red;'>"+$(this).attr("name")+" : "+$(this).attr("value")+"</div>")); });
So it will be clearer:

The picture about the trolley or why it is necessary
In fact, in most cases it is probably easier to go to the generator page, generate the necessary font once and put it in the folder with the project.
Well, you're funny, and why did I read all this then?
The other day I had to work with the icon font (and this is now a fashionable theme, yes?) And as new icons were added, this dull conversion procedure had to be repeated every time. To not do this (and also save you all from such agony), I wrote Marmot.
Now I just run the script engine, like this:
rm -r ./web/app/assets/fonts/icons marmot -dc ./web/config/font-config.json ./design/icons-Regular.otf output.zip && unzip output.zip -d ./web/app/assets/fonts/icons
... and all
My work is useful to all those who sometimes wanted to automate this process, and so to geeks like me, who like to do everything from the console.
If anyone is interested, here is the code for github:
code for GithubPeace for everyone