<?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: Derek Reynolds</title>
    <description>The latest articles on DEV Community by Derek Reynolds (@drk).</description>
    <link>https://dev.to/drk</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%2F79628%2Ff72926d0-bc63-4978-8727-6262eeb54f1a.png</url>
      <title>DEV Community: Derek Reynolds</title>
      <link>https://dev.to/drk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drk"/>
    <language>en</language>
    <item>
      <title>Dockerize The Small Things</title>
      <dc:creator>Derek Reynolds</dc:creator>
      <pubDate>Fri, 29 Mar 2019 18:59:27 +0000</pubDate>
      <link>https://dev.to/drk/dockerize-the-small-things-52cj</link>
      <guid>https://dev.to/drk/dockerize-the-small-things-52cj</guid>
      <description>&lt;h1&gt;
  
  
  tl;dr
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Some familiarity with &lt;a href="https://facebook.github.io/react-native/" rel="noopener noreferrer"&gt;react-native&lt;/a&gt;, &lt;a href="http://yarnpkg.com" rel="noopener noreferrer"&gt;yarn&lt;/a&gt;, &lt;a href="https://www.docker.com" rel="noopener noreferrer"&gt;Docker&lt;/a&gt; and the command line will be helpful.&lt;/li&gt;
&lt;li&gt;Workflows that run in development environments could become problematic when devs  use different machines, OSes, versions.&lt;/li&gt;
&lt;li&gt;Using Docker for common development tasks (like generating code using native dependencies) is dope even though there's extra overhead in using Docker.&lt;/li&gt;
&lt;li&gt;Check out the full config/setup at the bottom.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setup
&lt;/h1&gt;

&lt;p&gt;Docker has many applications around automating development environments and production environments. It's often not intuitive or easy to work with, but the trade-offs are typically worth it. With such a complex and powerful tool that's somewhat difficult to learn: is it worthwhile for automating smaller tasks? I think so.&lt;/p&gt;

&lt;p&gt;I recently hit an issue generating icon fonts for use in a React Native application. For mostly performance and simplicity it's recommended to use fonts over SVG for icons. That's what I've seen and been told anyway 🤷‍♂️. React Native (at least iOS as a platform) can work with True Type Font (&lt;code&gt;.ttf&lt;/code&gt;) files. The setup I'm working with is a directory of separate SVG files per icon. The sister www project already has some tooling around converting those SVG files in to all necessary font files, CSS and preview HTML using the &lt;a href="https://github.com/FontCustom/fontcustom" rel="noopener noreferrer"&gt;&lt;code&gt;FontCustom&lt;/code&gt;&lt;/a&gt; ruby library. Pretty nifty.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's Go
&lt;/h1&gt;

&lt;p&gt;With everything installed and ready to go I run the &lt;code&gt;fontcustom compile&lt;/code&gt; command and everything generates accordingly. I check the web preview file generated and the icons look dope. As part of my config I also generate a React component file that uses &lt;a href="https://www.github.com/oblador/react-native-vector-icons" rel="noopener noreferrer"&gt;&lt;code&gt;react-native-vector-icons&lt;/code&gt;&lt;/a&gt; under the hood for rendering the icons from the generated &lt;code&gt;.ttf&lt;/code&gt; font file. Run the app to check out some of the icons and they're great. Feels like I cheated. On closer inspection though the icons were slightly off in a few cases… Funky.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzl40ajfrqzh92wgxiwds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzl40ajfrqzh92wgxiwds.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The times icon looks a bit thinner when rendered in iOS vs the web.&lt;/em&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Debugging
&lt;/h1&gt;

&lt;p&gt;Where is this happening? Does &lt;code&gt;react-native-vector-icons&lt;/code&gt; have a hard time generating glyphs from the &lt;code&gt;.ttf&lt;/code&gt; file? Are all fonts rendering thinner? Can I hack this at the &lt;code&gt;react-native&lt;/code&gt; layer? Is the &lt;code&gt;.ttf&lt;/code&gt; file any different than the other files like &lt;code&gt;.woff&lt;/code&gt; or &lt;code&gt;.woff2&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;After attempting to address in code I wanted to verify the &lt;code&gt;.ttf&lt;/code&gt; file used was producing the same glyphs as the other file formats. I edited the generated preview html file by commenting out the other file formats in CSS and sure enough the glyph was thinner in a browser as well when using the &lt;code&gt;.ttf&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Icon Font: hc-awesome */&lt;/span&gt;

&lt;span class="k"&gt;@font-face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"hc-awesome"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url("./hc-awesome.eot")&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url("./hc-awesome.eot?#iefix")&lt;/span&gt; &lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;"embedded-opentype"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
       &lt;span class="c"&gt;/* url("./hc-awesome.woff2") format("woff2"),
       url("./hc-awesome.woff") format("woff"), */&lt;/span&gt;
       &lt;span class="sx"&gt;url("./hc-awesome.ttf")&lt;/span&gt; &lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;"truetype"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="c"&gt;/* url("./hc-awesome.svg#hc-awesome") format("svg"); */&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Up to this point I had been running the same &lt;code&gt;fontcustom compile&lt;/code&gt; command for the web project on my host OSX machine. The &lt;code&gt;FontCustom&lt;/code&gt; lib hasn't been updated in a while so I was wondering if it was buggy on newer versions of OSX. This prompted me to experiment with running the command in a Linux environment. Specifically in Docker.&lt;/p&gt;

&lt;h1&gt;
  
  
  Dockerizing
&lt;/h1&gt;

&lt;p&gt;The web project is already using Docker for more "Docker-ish" problems like running a local database so it wasn't a huge leap to leverage that infrastructure for a much smaller task like generating fonts. I added a &lt;code&gt;Dockerfile&lt;/code&gt;, co-locating it next to the directory with my SVG source files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Used the Docker community ruby image&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; ruby:2.6&lt;/span&gt;

&lt;span class="c"&gt;# Installed all the same dependencies from our host machine, but using Linux flavors.&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; upgrade
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; &lt;span class="nb"&gt;install &lt;/span&gt;zlib1g-dev fontforge
&lt;span class="k"&gt;RUN &lt;/span&gt;git clone https://github.com/bramstein/sfnt2woff-zopfli.git sfnt2woff-zopfli &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;sfnt2woff-zopfli &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mv &lt;/span&gt;sfnt2woff-zopfli /usr/local/bin/sfnt2woff
&lt;span class="k"&gt;RUN &lt;/span&gt;git clone &lt;span class="nt"&gt;--recursive&lt;/span&gt; https://github.com/google/woff2.git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;woff2 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make clean all &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mv &lt;/span&gt;woff2_compress /usr/local/bin/ &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mv &lt;/span&gt;woff2_decompress /usr/local/bin/
&lt;span class="k"&gt;RUN &lt;/span&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;fontcustom

&lt;span class="c"&gt;# Copies the directory containing the SVG files in to the built container&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . .&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to build a container to run the &lt;code&gt;fontcustom compile&lt;/code&gt; command in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; hc/hc-awesome &lt;span class="nb"&gt;.&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally running the command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run
    &lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;realpath&lt;/span&gt; ./generated&lt;span class="si"&gt;)&lt;/span&gt;:/generated 
    &lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="nt"&gt;-t&lt;/span&gt; hc/hc-awesome 
    &lt;span class="se"&gt;\ &lt;/span&gt;fontcustom compile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A couple things to note about that &lt;code&gt;docker run&lt;/code&gt; command.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-v&lt;/code&gt; is the option for configuring a Volume which we can think of as mirroring a directory from your host machine to a directory in the container.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;realpath&lt;/code&gt; is necessary because the &lt;code&gt;-v&lt;/code&gt; option expects an absolute path.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;-t&lt;/code&gt; option is specifying the container we previously built.&lt;/li&gt;
&lt;li&gt;Finally we're providing the command to be run in the container &lt;code&gt;fontcustom compile&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So here we're saying "whatever data (files) show up in the &lt;code&gt;/generated&lt;/code&gt; directory in the container should also show up in the &lt;code&gt;./generated&lt;/code&gt; directory that's co-located with the &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If everything worked out ok we should see the same font files, CSS and HTML preview in our host machine's &lt;code&gt;./generated&lt;/code&gt; directory.&lt;/p&gt;

&lt;h1&gt;
  
  
  The React Component
&lt;/h1&gt;

&lt;p&gt;Earlier I skipped how this is done, but once we have our generated files from fontcustom we can run the the &lt;code&gt;generate-icon&lt;/code&gt; command from &lt;code&gt;react-native-vector-icons&lt;/code&gt; on our &lt;strong&gt;host&lt;/strong&gt; machine, not Docker, to create our React component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn generate-icon 
  &lt;span class="se"&gt;\ &lt;/span&gt;Icon/generated/hc-awesome.css 
  &lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="nt"&gt;--componentName&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;hc-awesome 
  &lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="nt"&gt;--fontFamily&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;hc-awesome 
  &lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="nt"&gt;-p&lt;/span&gt; .hc-awesome- 
  &lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="nt"&gt;-o&lt;/span&gt; Icon/generated/HcAwesomeIcon.tsx 
  &lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="nt"&gt;-t&lt;/span&gt; Icon/lib/iconSet.tpl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when we run our app we should see a nice accurate glyph…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fb1valqiwydjftbd8umt7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fb1valqiwydjftbd8umt7.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Much better!&lt;/p&gt;

&lt;h1&gt;
  
  
  Taking It Further
&lt;/h1&gt;

&lt;p&gt;Even as I was writing this I was thinking of alternative approaches to Dockerizing this task. There's awesome tools/services like &lt;a href="http://icomoon.io" rel="noopener noreferrer"&gt;IcoMoon.io&lt;/a&gt; or &lt;a href="http://fontello.com" rel="noopener noreferrer"&gt;Fontello&lt;/a&gt; which provide a more manual method of generating icons as well as an API (Fontello). I was optimizing for not introducing too much new tech (I'd argue I introduced no new tech) and solving quickly which meant not going down a rabbit hole of a different flow (I'm using the same commands just in Docker). Now both projects can benefit from a consistent icon compilation process no matter who generates them. Going forward I think it'd be rad to automate this a bit more and have a service that can fetch the latest icons from GitHub and output all the necessary files for any project that needs them.&lt;/p&gt;

&lt;h1&gt;
  
  
  Config
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package.json
Icon/
  generated/
  svgs/
  lib/
    iconSet.tpl
  Dockerfile
  fontcustom.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  package.json
&lt;/h2&gt;

&lt;p&gt;This is a truncated version showing how we can encapsulate the commands as a single yarn script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"hcawesome"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"hcawesome:build &amp;amp;&amp;amp; yarn hcawesome:compile &amp;amp;&amp;amp; yarn hcawesome:clean &amp;amp;&amp;amp; yarn hcawesome:generate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"hcawesome:build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"docker build -t hc/hc-awesome ./Icon"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"hcawesome:compile"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"docker run -v $(realpath ./Icon/generated):/generated -t hc/hc-awesome fontcustom compile"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"hcawesome:clean"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cd ./Icon/generated &amp;amp;&amp;amp; rm *.eot *.svg *.woff *.woff2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"hcawesome:generate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"yarn generate-icon Icon/generated/hc-awesome.css --componentName=hc-awesome --fontFamily=hc-awesome -p .hc-awesome- -o Icon/generated/HcAwesomeIcon.tsx -t Icon/lib/iconSet.tpl"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dockerfile
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Used the Docker community ruby image&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; ruby:2.6&lt;/span&gt;

&lt;span class="c"&gt;# Installed all the same dependencies from our host machine, but using Linux flavors.&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; upgrade
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; &lt;span class="nb"&gt;install &lt;/span&gt;zlib1g-dev fontforge
&lt;span class="k"&gt;RUN &lt;/span&gt;git clone https://github.com/bramstein/sfnt2woff-zopfli.git sfnt2woff-zopfli &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;sfnt2woff-zopfli &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mv &lt;/span&gt;sfnt2woff-zopfli /usr/local/bin/sfnt2woff
&lt;span class="k"&gt;RUN &lt;/span&gt;git clone &lt;span class="nt"&gt;--recursive&lt;/span&gt; https://github.com/google/woff2.git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;woff2 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make clean all &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mv &lt;/span&gt;woff2_compress /usr/local/bin/ &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mv &lt;/span&gt;woff2_decompress /usr/local/bin/
&lt;span class="k"&gt;RUN &lt;/span&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;fontcustom

&lt;span class="c"&gt;# Copies the directory containing the SVG files in to the built container&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . .&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  fontcustom.yml
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# =============================================================================&lt;/span&gt;
&lt;span class="c1"&gt;# Font Custom Configuration&lt;/span&gt;
&lt;span class="c1"&gt;#   This file should live in the directory where you run `fontcustom compile`.&lt;/span&gt;
&lt;span class="c1"&gt;#   For more info, visit &amp;lt;https://github.com/FontCustom/fontcustom&amp;gt;.&lt;/span&gt;
&lt;span class="c1"&gt;# =============================================================================&lt;/span&gt;

&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;
&lt;span class="c1"&gt;# Project Info&lt;/span&gt;
&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;

&lt;span class="c1"&gt;# The font's name. Also determines the file names of generated templates.&lt;/span&gt;
&lt;span class="na"&gt;font_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hc-awesome&lt;/span&gt;

&lt;span class="c1"&gt;# Format of CSS selectors. {{glyph}} is substituted for the glyph name.&lt;/span&gt;
&lt;span class="na"&gt;css_selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.hc-awesome-{{glyph}}&lt;/span&gt;

&lt;span class="c1"&gt;# Generate fonts without asset-busting hashes.&lt;/span&gt;
&lt;span class="na"&gt;no_hash&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="c1"&gt;# Encode WOFF fonts into the generated CSS.&lt;/span&gt;
&lt;span class="na"&gt;base64&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="c1"&gt;# Forces compilation, even if inputs have not changed&lt;/span&gt;
&lt;span class="c1"&gt;#force: true&lt;/span&gt;

&lt;span class="c1"&gt;# Display (possibly useful) debugging messages.&lt;/span&gt;
&lt;span class="c1"&gt;#debug: true&lt;/span&gt;

&lt;span class="c1"&gt;# Hide status messages.&lt;/span&gt;
&lt;span class="c1"&gt;#quiet: true&lt;/span&gt;

&lt;span class="c1"&gt;# Copyright information.&lt;/span&gt;
&lt;span class="c1"&gt;#copyright:&lt;/span&gt;

&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;
&lt;span class="c1"&gt;# Input / Output Locations&lt;/span&gt;
&lt;span class="c1"&gt;#   You can save generated fonts, CSS, and other files to different locations&lt;/span&gt;
&lt;span class="c1"&gt;#   here. Font Custom can also read input vectors and templates from different&lt;/span&gt;
&lt;span class="c1"&gt;#   places.&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#   NOTE:&lt;/span&gt;
&lt;span class="c1"&gt;#   - Be sure to preserve the whitespace in these YAML hashes.&lt;/span&gt;
&lt;span class="c1"&gt;#   - INPUT[:vectors] and OUTPUT[:fonts] are required. Everything else is&lt;/span&gt;
&lt;span class="c1"&gt;#     optional.&lt;/span&gt;
&lt;span class="c1"&gt;#   - Specify output locations for custom templates by including their file&lt;/span&gt;
&lt;span class="c1"&gt;#     names as the key.&lt;/span&gt;
&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;

&lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;vectors&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./svgs&lt;/span&gt;
&lt;span class="c1"&gt;#  templates: my/templates&lt;/span&gt;

&lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;fonts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./generated&lt;/span&gt;
  &lt;span class="na"&gt;css&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./generated&lt;/span&gt;
&lt;span class="c1"&gt;#  preview: app/views/styleguide&lt;/span&gt;
&lt;span class="c1"&gt;#  my-custom-template.yml: path/to/template/output&lt;/span&gt;

&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;
&lt;span class="c1"&gt;# Templates&lt;/span&gt;
&lt;span class="c1"&gt;#   A YAML array of templates and files to generate alongside fonts. Custom&lt;/span&gt;
&lt;span class="c1"&gt;#   templates should be saved in the INPUT[:templates] directory and referenced&lt;/span&gt;
&lt;span class="c1"&gt;#   by their base file name.&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#   For Rails and Compass templates, set `preprocessor_path` as the relative&lt;/span&gt;
&lt;span class="c1"&gt;#   path from OUTPUT[:css] to OUTPUT[:fonts]. By default, these are the same&lt;/span&gt;
&lt;span class="c1"&gt;#   directory.&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#   Included in Font Custom: preview, css, scss, scss-rails&lt;/span&gt;
&lt;span class="c1"&gt;#   Default: css, preview&lt;/span&gt;
&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;

&lt;span class="c1"&gt;#templates:&lt;/span&gt;
&lt;span class="c1"&gt;#- scss-rails&lt;/span&gt;
&lt;span class="c1"&gt;#- preview&lt;/span&gt;
&lt;span class="c1"&gt;#- my-custom-template.yml&lt;/span&gt;

&lt;span class="c1"&gt;#preprocessor_path: ../fonts/&lt;/span&gt;

&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;
&lt;span class="c1"&gt;# Font Settings (defaults shown)&lt;/span&gt;
&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;

&lt;span class="c1"&gt;# Size (in pica points) for which your font is designed.&lt;/span&gt;
&lt;span class="c1"&gt;#font_design_size: 16&lt;/span&gt;

&lt;span class="c1"&gt;# The em size. Setting this will scale the entire font to the given size.&lt;/span&gt;
&lt;span class="c1"&gt;#font_em: 512&lt;/span&gt;

&lt;span class="c1"&gt;# The font's ascent and descent. Used to calculate the baseline.&lt;/span&gt;
&lt;span class="c1"&gt;#font_ascent: 448&lt;/span&gt;
&lt;span class="c1"&gt;#font_descent: 64&lt;/span&gt;

&lt;span class="c1"&gt;# Horizontally fit glyphs to their individual vector widths.&lt;/span&gt;
&lt;span class="na"&gt;autowidth&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  lib/iconSet.tpl
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
 * ${componentName} icon set component.
 * Usage: &amp;lt;${componentName} name="icon-name" size={20} color="#4F8EF7" /&amp;gt;
 */

import createIconSet from 'react-native-vector-icons/lib/create-icon-set'
export const glyphMap = ${glyphMap}

const iconSet = createIconSet(glyphMap, '${fontFamily}', '${componentName}.ttf')

export default iconSet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>docker</category>
      <category>reactnative</category>
      <category>iconfonts</category>
      <category>svg</category>
    </item>
  </channel>
</rss>
