{"id":128,"date":"2013-04-21T21:36:54","date_gmt":"2013-04-22T03:36:54","guid":{"rendered":"http:\/\/logicalchaos.org\/blog\/?p=128"},"modified":"2013-04-29T18:01:52","modified_gmt":"2013-04-30T00:01:52","slug":"kerning-pairs-part-i","status":"publish","type":"post","link":"http:\/\/logicalchaos.org\/blog\/2013\/04\/kerning-pairs-part-i\/","title":{"rendered":"Kerning Pairs Part I"},"content":{"rendered":"<p>I was listening to <a href=\"http:\/\/macpowerusers.com\/2013\/03\/mac-power-users-128-typography-with-ina-saltz\" title=\"Mac Power Users #128\">Mac Power Users 128<\/a>.  The guest had an interesting comment on designing a typeface and how good designers adjust the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Kerning\" title=\"kerning\">kerning<\/a> for every pair of letters in the language.  In the english language, there are 6.15611958020716E36 (26^26) possible pairs of lower case letters alone.  I&#8217;m thinking that&#8217;s not happening.<br \/>\n<!--more--><br \/>\nSo I wrote a quick little Java program to count all pairs of letters seen in the standard dictionary on my Mac.  I filtered out all words that contained non letters and lowercased all characters.  The dictionary contains 235886 words and the program comes up with 609 unique pairs of characters.  Now I&#8217;m thinking  we&#8217;re in the realm of reasonable.<\/p>\n<p>Presumably a typeface designer will pick the top X pairs to adjust and leave the remainder at the default kerning.  The 609 pairs doesn&#8217;t consider any capitalization.  If any dictionary word can be at the start of a sentence, 342 pairs are added.<\/p>\n<p>The top 10 pairs of characters are<\/p>\n<pre><span class=\"inner-pre\" style=\"font-family: monospace\"><ol><li>ti 31517<\/li><li>er 31480<\/li><li>in 31201<\/li><li>at 26675<\/li><li>en 23654<\/li><li>ri 22994<\/li><li>ra 22790<\/li><li>ro 22195<\/li><li>an 22063<\/li><li>re 21966<\/li><\/ol><\/span><\/pre>\n<p>The files containing the pairs are <a href=\"http:\/\/logicalchaos.org\/blog\/wp-content\/uploads\/2013\/04\/KP.txt\">KP<\/a>, sorted alphabetically, and <a href=\"http:\/\/logicalchaos.org\/blog\/wp-content\/uploads\/2013\/04\/KPn.txt\">KPn<\/a>, sorted numerically by frequency.<\/p>\n<p><code lang=\"java\"><br \/>\nimport java.io.FileReader;<br \/>\nimport java.io.IOException;<br \/>\nimport java.util.Map;<br \/>\nimport java.util.Scanner;<br \/>\nimport java.util.TreeMap;<\/p>\n<p>public class KerningPairs {<\/p>\n<p>    private static final Map<String, Integer> PAIRS_FREQ    = new TreeMap<String, Integer>();<br \/>\n    private static final int                  STRING_LENGTH = 2;<\/p>\n<p>    private static void addPair(final String substring) {<br \/>\n        Integer count = Integer.valueOf(0);<br \/>\n        if (KerningPairs.PAIRS_FREQ.containsKey(substring)) {<br \/>\n            count = KerningPairs.PAIRS_FREQ.get(substring);<br \/>\n        }<br \/>\n        KerningPairs.PAIRS_FREQ.put(substring, count + 1);<br \/>\n    }<\/p>\n<p>    public static void main(final String[] args) throws IOException {<br \/>\n        final FileReader fileReader = new FileReader(\"\/usr\/share\/dict\/words\");<br \/>\n        final Scanner scanner = new Scanner(fileReader);<\/p>\n<p>        while (scanner.hasNext()) {<br \/>\n            final String line = scanner.next();<br \/>\n            if (line.matches(\"\\\\p{Alpha}{2,}\")) {<br \/>\n                final String lcLine = line.toLowerCase();<br \/>\n                for (int i = 0; i < (lcLine.length() - KerningPairs.STRING_LENGTH); i++) {\n                    final String substring = lcLine.substring(i, i\n                            + KerningPairs.STRING_LENGTH);\n                    KerningPairs.addPair(substring);\n                }\n            }\n        }\n        for (final String pair : KerningPairs.PAIRS_FREQ.keySet()) {\n            System.out.println(pair + \"\\t\" + KerningPairs.PAIRS_FREQ.get(pair));\n        }\n        fileReader.close();\n    }\n}\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was listening to Mac Power Users 128. The guest had an interesting comment on designing a typeface and how good designers adjust the kerning for every pair of letters in the language. In the english language, there are 6.15611958020716E36 &hellip; <a href=\"http:\/\/logicalchaos.org\/blog\/2013\/04\/kerning-pairs-part-i\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[19],"_links":{"self":[{"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/posts\/128"}],"collection":[{"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":43,"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":224,"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/posts\/128\/revisions\/224"}],"wp:attachment":[{"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/logicalchaos.org\/blog\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}