<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jonathan Boiser</title>
    <description>The latest articles on DEV Community by Jonathan Boiser (@jonboiser).</description>
    <link>https://dev.to/jonboiser</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F21606%2F17c46e45-b01d-4dc7-bafb-22778531b5d7.png</url>
      <title>DEV Community: Jonathan Boiser</title>
      <link>https://dev.to/jonboiser</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jonboiser"/>
    <language>en</language>
    <item>
      <title>How to install your personal font library with Homebrew</title>
      <dc:creator>Jonathan Boiser</dc:creator>
      <pubDate>Sat, 19 Mar 2022 20:58:04 +0000</pubDate>
      <link>https://dev.to/jonboiser/how-to-install-your-personal-font-library-with-homebrew-fc0</link>
      <guid>https://dev.to/jonboiser/how-to-install-your-personal-font-library-with-homebrew-fc0</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;This tutorial shows you how to create your own private Homebrew Cask for your paid/closed-license fonts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a ZIP (or TAR) file of all fonts&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/Homebrew/homebrew-cask-fonts/blob/master/CONTRIBUTING.md#automatic-generation"&gt;Generate the Cask for your font library ZIP&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Host the ZIP in a semi-secret location like Dropbox or Google Drive&lt;/li&gt;
&lt;li&gt;Optionally, host the Cask file in a semi-secret location like Dropbox/Google Drive or as a GitHub gist.&lt;/li&gt;
&lt;li&gt;Now you can install your font library on a new computer with a single &lt;code&gt;brew install --cask ...&lt;/code&gt; command!&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Some caveats
&lt;/h2&gt;

&lt;p&gt;If you don't like the idea of having your fonts out in the open, there &lt;em&gt;is&lt;/em&gt; a potential workaround—but that will be for a later post.&lt;/p&gt;

&lt;p&gt;Also, I'm also aware that there are simpler, but slightly less convenient and portable ways to do this, like &lt;code&gt;cp&lt;/code&gt;ing your fonts to &lt;code&gt;~/Library/Fonts&lt;/code&gt;, but what fun is that?&lt;/p&gt;

&lt;p&gt;Finally, if you have a font in mind that &lt;em&gt;is&lt;/em&gt; openly licensed but not yet on Homebrew, you can use what you learned in this tutorial and actually contribute a Pull Request to &lt;code&gt;homebrew-cask-fonts&lt;/code&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;For macOS users, &lt;a href="//brew.sh"&gt;Homebrew&lt;/a&gt; is a convenient way to install open-license fonts, like &lt;a href="https://github.com/tonsky/FiraCode"&gt;Fira Code&lt;/a&gt; or &lt;a href="https://www.jetbrains.com/lp/mono/"&gt;JetBrains Mono&lt;/a&gt; via a command like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--cask&lt;/span&gt; font-fira-code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, if you have accumulated your own collection of paid fonts for coding or design, they will &lt;em&gt;not&lt;/em&gt; be available via Homebrew and you will need to individually download them to your computer and install them.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For example, when I am provisioning a new Mac, I need to login to Dropbox, find my folder of files, download them, then install them through the Font Book application.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this tutorial, I will describe how you can replace this manual workflow with the same &lt;code&gt;brew install --cask font-xyz&lt;/code&gt; workflow available for free fonts. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By using Homebrew, you also get the ability to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;specify the installation directory with &lt;code&gt;brew install --cask --fontDir ...&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;uninstall fonts with &lt;code&gt;brew uninstall font-xyz&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;get modular and create casks for individual fonts, collections of fonts, specific versions or stylistic sets, and so on&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://brew.sh/"&gt;Install Homebrew&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Homebrew/homebrew-cask-fonts#homebrew-cask-fonts"&gt;Tap the fonts Cask&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;brew install lcdf-typetools&lt;/code&gt;, which you'll need later to create the custom Cask&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: Collect your private fonts into an archive
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;For this tutorial, I will use &lt;a href="https://fonts.google.com/specimen/Roboto+Mono"&gt;Roboto Mono&lt;/a&gt; from Google Fonts and pretend that is one of my private fonts (even though you could download it via Homebrew).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Collect your fonts in one place and create a ZIP archive of them.&lt;/p&gt;

&lt;p&gt;You can also structure the archive however you want, with different font families in their own directory, for example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ unzip -l Roboto_Mono.zip 
Archive:  Roboto_Mono.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
    11560  05-13-2015 00:00   LICENSE.txt
    87872  05-13-2015 00:00   static/RobotoMono-Thin.ttf
    87788  05-13-2015 00:00   static/RobotoMono-ExtraLight.ttf
    87592  05-13-2015 00:00   static/RobotoMono-Light.ttf
    86908  05-13-2015 00:00   static/RobotoMono-Regular.ttf
    86820  05-13-2015 00:00   static/RobotoMono-Medium.ttf
    87076  05-13-2015 00:00   static/RobotoMono-SemiBold.ttf
    87008  05-13-2015 00:00   static/RobotoMono-Bold.ttf
    93056  05-13-2015 00:00   static/RobotoMono-ThinItalic.ttf
    93408  05-13-2015 00:00   static/RobotoMono-ExtraLightItalic.ttf
    93760  05-13-2015 00:00   static/RobotoMono-LightItalic.ttf
    93904  05-13-2015 00:00   static/RobotoMono-Italic.ttf
    93948  05-13-2015 00:00   static/RobotoMono-MediumItalic.ttf
    93940  05-13-2015 00:00   static/RobotoMono-SemiBoldItalic.ttf
    94148  05-13-2015 00:00   static/RobotoMono-BoldItalic.ttf
   182172  05-13-2015 00:00   RobotoMono-VariableFont_wght.ttf
   195012  05-13-2015 00:00   RobotoMono-Italic-VariableFont_wght.ttf
     2559  03-19-2022 12:44   README.txt
---------                     -------
  1658531                     18 files

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The ZIP from Google Fonts contains other files, but they will be ignored by the Cask generator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 2: Generate the Cask file for your private font archive
&lt;/h2&gt;

&lt;p&gt;Follow &lt;a href="https://github.com/Homebrew/homebrew-cask-fonts/blob/master/CONTRIBUTING.md#automatic-generation"&gt;these instructions&lt;/a&gt; to generate the Cask file, which automates some steps, like computing the SHA256 hash and creating a list of font files to install.&lt;/p&gt;

&lt;p&gt;Run this command on its own to preview the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;brew &lt;span class="nt"&gt;--repository&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/Library/Taps/homebrew/homebrew-cask-fonts/developer/bin/font_casker"&lt;/span&gt; Roboto_Mono.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ "$(brew --repository)/Library/Taps/homebrew/homebrew-cask-fonts/developer/bin/font_casker" Roboto_Mono.zip
FAMILY: Roboto Mono
cask 'FIXME' do
  version "3.000"
  sha256 "d5c35dbe54b9fb53898f05f318492fb39b78c6c3d3aa919eaf0f01f4fe61387d"

  url ""
  name ""
  homepage ""

  font "RobotoMono-Italic-VariableFont_wght.ttf"
  font "RobotoMono-VariableFont_wght.ttf"
  font "static/RobotoMono-Bold.ttf"
  font "static/RobotoMono-BoldItalic.ttf"
  font "static/RobotoMono-ExtraLight.ttf"
  font "static/RobotoMono-ExtraLightItalic.ttf"
  font "static/RobotoMono-Italic.ttf"
  font "static/RobotoMono-Light.ttf"
  font "static/RobotoMono-LightItalic.ttf"
  font "static/RobotoMono-Medium.ttf"
  font "static/RobotoMono-MediumItalic.ttf"
  font "static/RobotoMono-Regular.ttf"
  font "static/RobotoMono-SemiBold.ttf"
  font "static/RobotoMono-SemiBoldItalic.ttf"
  font "static/RobotoMono-Thin.ttf"
  font "static/RobotoMono-ThinItalic.ttf"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You will get an error if you did not install &lt;code&gt;lcdf-typetools&lt;/code&gt;, as described in the prerequisites.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can copy-paste this output to a text editor and save it as a Ruby file (e.g. &lt;code&gt;font-roboto-mono-private.rb&lt;/code&gt;), or run the command again and pipe it to a text file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;brew &lt;span class="nt"&gt;--repository&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/Library/Taps/homebrew/homebrew-cask-fonts/developer/bin/font_casker"&lt;/span&gt; Roboto_Mono.zip &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; font-roboto-mono-private.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will return to edit this file later on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Host your font archive in a "secret" URL
&lt;/h2&gt;

&lt;p&gt;Casks need to access their installation artifacts (e.g. font ZIPs) from a public URL.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;WARNING: if you publicize or share this URL in any way, you will most likely be in violation of your end-user license agreement. So don't do that!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The simplest way to do this is to upload it to a service like  Dropbox or Google Drive. In this tutorial, I will use Google Drive.&lt;/p&gt;

&lt;p&gt;I uploaded &lt;code&gt;Roboto_Mono.zip&lt;/code&gt; to my Google Drive and generated a public link. These links are formatted like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://drive.google.com/file/d/{{FILE_ID}}/view?usp=sharing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;{{FILE_ID}}&lt;/code&gt; is a long string like &lt;code&gt;1wWK75gYcMBxugCjAuyInW8tSGZJivjla&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;However, these links aren't directly usable by Homebrew, since they point to a preview page, and not the actual file.&lt;/p&gt;

&lt;p&gt;To fix this, take the &lt;code&gt;FILE_ID&lt;/code&gt; and create this URL (Source: &lt;a href="https://www.howtogeek.com/747810/how-to-make-a-direct-download-link-for-google-drive-files/"&gt;How To Geek&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://drive.google.com/uc?export=download&amp;amp;id={{FILE_ID}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the link in your browser. Instead of being taken to a Google Drive preview page, your browser should download it directly to your computer, which is what we want.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Add the URL to the Cask
&lt;/h2&gt;

&lt;p&gt;Going back to the Cask (&lt;code&gt;font-robot-mono-private.rb&lt;/code&gt;), make these edits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Make sure to delete the first line "FAMILY: Roboto Mono"&lt;/span&gt;

&lt;span class="c1"&gt;# The Cask name must match the file name&lt;/span&gt;
&lt;span class="n"&gt;cask&lt;/span&gt; &lt;span class="s1"&gt;'font-roboto-mono-private'&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="s2"&gt;"1.000"&lt;/span&gt;
  &lt;span class="n"&gt;sha256&lt;/span&gt; &lt;span class="s2"&gt;"d5c35dbe54b9fb53898f05f318492fb39b78c6c3d3aa919eaf0f01f4fe61387d"&lt;/span&gt;

  &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="s2"&gt;"https://drive.google.com/uc?export=download&amp;amp;id={{FILE_ID}}"&lt;/span&gt;
  &lt;span class="nb"&gt;name&lt;/span&gt; &lt;span class="s2"&gt;"Robot Mono Private"&lt;/span&gt;
  &lt;span class="n"&gt;homepage&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"RobotoMono-Italic-VariableFont_wght.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"RobotoMono-VariableFont_wght.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-Bold.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-BoldItalic.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-ExtraLight.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-ExtraLightItalic.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-Italic.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-Light.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-LightItalic.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-Medium.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-MediumItalic.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-Regular.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-SemiBold.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-SemiBoldItalic.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-Thin.ttf"&lt;/span&gt;
  &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="s2"&gt;"static/RobotoMono-ThinItalic.ttf"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you make these changes, the Cask is ready to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--cask&lt;/span&gt; ./font-robot-mono-private.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Optional: Host the Cask in a "secret" location
&lt;/h2&gt;

&lt;p&gt;If you want to install these fonts on any other computer with Homebrew, you can host the Cask file in an obscure location, like a secret GitHub gist.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;WARNING: Again, because this Cask file contains a link to the ZIP file, don't publicize the Cask, or else be in risk of violating your fonts' EULAs!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Unfortunately, you can't directly use the URL in &lt;code&gt;brew install --cask&lt;/code&gt;—you will have to download the file first and then reference the local copy.&lt;/p&gt;

&lt;p&gt;Example using my &lt;a href="https://gist.githubusercontent.com/jonboiser/655275dcf814b3f258846e4b86ebda5e/raw/db219fcad63368847bfe04aa6546aab37363608e/font-robot-mono-private.rb"&gt;"secret" gist with Roboto Mono&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget https://gist.githubusercontent.com/jonboiser/655275dcf814b3f258846e4b86ebda5e/raw/db219fcad63368847bfe04aa6546aab37363608e/font-roboto-mono-private.rb
brew &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--cask&lt;/span&gt; ./font-roboto-mono-private.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can save that snippet in a script or in your notes for the next time you want to download your personal fonts with one line!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;And that's it!&lt;/p&gt;

&lt;p&gt;Let me know in the comments how you used this technique, how you plan to use it, or if you have any additional suggestions to improve it.&lt;/p&gt;

&lt;p&gt;In an upcoming post, I will describe how to accomplish this process without publishing your fonts in secret-but-public URLs by preloading the Homebrew cache. &lt;/p&gt;

&lt;p&gt;This approach is not as portable, but still gives you the benefits of using the Homebrew CLI for managing your fonts.&lt;/p&gt;

&lt;p&gt;I'd be curious if any of you might have some insights into this. Please share in the comments!&lt;/p&gt;

</description>
      <category>homebrew</category>
      <category>macos</category>
      <category>fonts</category>
    </item>
  </channel>
</rss>
