<?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: James Grubb</title>
    <description>The latest articles on DEV Community by James Grubb (@makingthings).</description>
    <link>https://dev.to/makingthings</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%2F63998%2F3fd59152-0811-4791-8724-95a1f25a4dd9.jpg</url>
      <title>DEV Community: James Grubb</title>
      <link>https://dev.to/makingthings</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/makingthings"/>
    <language>en</language>
    <item>
      <title>How to kern lettering with SVG's dx attribute.</title>
      <dc:creator>James Grubb</dc:creator>
      <pubDate>Sat, 25 Apr 2020 11:29:39 +0000</pubDate>
      <link>https://dev.to/makingthings/how-to-kern-lettering-with-svg-s-dx-attribute-3po9</link>
      <guid>https://dev.to/makingthings/how-to-kern-lettering-with-svg-s-dx-attribute-3po9</guid>
      <description>&lt;h2&gt;
  
  
  The devil is in the detail
&lt;/h2&gt;




&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2tos22PA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/makingthings/image/upload/c_scale%2Cf_auto%2Cw_800/c_fit%2Cu_device:kern%2Cw_600%2Cx_0%2Cy_-10/v1520245523/device/Apple_Macbook_Air_13_22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2tos22PA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/makingthings/image/upload/c_scale%2Cf_auto%2Cw_800/c_fit%2Cu_device:kern%2Cw_600%2Cx_0%2Cy_-10/v1520245523/device/Apple_Macbook_Air_13_22.png" alt="The Kerning Game"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you ever played the &lt;a href="https://type.method.ac/#"&gt;Kerning Game&lt;/a&gt;? I scored 72 out of 100, it's not easy and the scoring is a little subjective (that's my excuse 😀). &lt;/p&gt;

&lt;p&gt;To kern a word is to adjust the space between letters and whilst it might be overkill to do this on every blog post &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;, there are occasions where a wordmark might benefit from a little tlk (tender-loving-kerning)&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/limitedunlimited/embed/eYpBwxd?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In the above &lt;em&gt;Codepen&lt;/em&gt;, the word &lt;strong&gt;Devil&lt;/strong&gt; is set in Google's &lt;strong&gt;Akronim&lt;/strong&gt; type-face. With the browser's default font-kerning settings - &lt;code&gt;font-kerning: auto&lt;/code&gt;, notwithstanding, the first two letters &lt;strong&gt;D&lt;/strong&gt; and &lt;strong&gt;e&lt;/strong&gt; sit a little awkwardly, &lt;em&gt;perhaps they are socially distancing?&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  dx to the rescue
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;"The dx attribute indicates a shift along the x-axis on the position of an element or its content." &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/dx"&gt;MDN Web docs&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If we add a unitless value to the &lt;code&gt;&amp;lt;text&amp;gt;&lt;/code&gt; &lt;code&gt;dx&lt;/code&gt; attribute our Devil will shift along the x-axis by that units amount (and in relation to the svg's viewBox dimensions)&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/limitedunlimited/embed/OJyWONv?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;If you continue reading the MDN Web docs they describe using multiple dx values&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If there are multiple values, dx defines a shift along the x-axis for each individual glyph relative to the preceding glyph. If there are fewer values than glyphs, the remaining glyphs use a value of 0. If there are more values than glyphs, extra values are ignored.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's help the &lt;strong&gt;D&lt;/strong&gt; and &lt;strong&gt;e&lt;/strong&gt; kiss and makeup by adjusting the individual spaces. I find that once you start tinkering you end up looking at all the letter spaces. This is what I ended up with. &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/limitedunlimited/embed/pojRaGx?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;As I mentioned, kerning is quite subjective and if you can, it's worth asking someone to look over your shoulder and get their kerning opinion.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;!!!WARNING!!!&lt;/em&gt; once you start looking at kerning you will see bad kerning everywhere&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IHEE6uch--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/makingthings/image/upload/v1587813508/articles/svg/parade-even.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IHEE6uch--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/makingthings/image/upload/v1587813508/articles/svg/parade-even.jpg" alt="Parade aligned"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;I hope you enjoyed this article. Of course, this method relies on using SVG in your markup. If you are using HTML, you could, for example, wrap each letter with a &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; with a &lt;code&gt;display: inline-block&lt;/code&gt; class and adjust margins or relative positions. There are a number of other methods out there. &lt;/p&gt;

&lt;h4&gt;
  
  
  Usefull links
&lt;/h4&gt;

&lt;p&gt;1 &lt;a href="https://css-tricks.com/creating-web-type-&amp;lt;br&amp;gt;%0Alockup/"&gt;creating-web-type-lockup&lt;/a&gt;&lt;br&gt;
2 &lt;a href="https://99designs.co.uk/blog/tips/11-kerning-tips/"&gt;11-kerning-tips&lt;/a&gt;&lt;br&gt;
3 &lt;a href="https://vanseodesign.com/web-design/how-to-manipulate-svg-text/"&gt;How to manipulate SVG text&lt;/a&gt;&lt;/p&gt;

</description>
      <category>svg</category>
      <category>html</category>
      <category>css</category>
    </item>
  </channel>
</rss>
