Show HN: Kerning.js — Take control of your web typography
endtwist.github.com
endtwist.github.com
Instead, to fit with the standard way people define CSS properties, this library should be taking a prefix for itself, like -kerning-*, and then defining any of its extensions to CSS within that namespace: that way it is almost guaranteed to not cause problems going forward.
I would recommend outsourcing your parsing though. It's a tough job and things like CSS hacks can really take your regexes for a loop.
I'd recommend trying out http://glazman.org/JSCSSP/ or https://github.com/nzakas/parser-lib/tree/master/src/css which Nicholas uses for CSSLint.
Though perhaps not the most robust, the library I'm using now (http://bililite.com/blog/2009/01/16/jquery-css-parser/) seems to work fine with all of what I've thrown at it. It is also, by far, the smallest of the three CSS parsing libraries (14kb vs JSCSSP's 165kb).
I recently read Robert Bringhurst's excellent Elements of Typographic Style, but have no idea how to apply it to the web.
(There is an effort to translate the work at webtypography.net, but frankly, most of the sections are some equivalent of "you should do X, but X is not possible right now, but maybe with some CSS extension in the future X will be possible.")
It seems like maybe we have choice of fonts now (through TypeKit, Google Web Fonts). But kerning and justification seem to be mostly accomplished through these sorts of JavaScript hacks, and text figures seem outright impossible. What is a wannabe typographer supposed to do on the web with current tools? Are lettering.js, kerning.js, kern.js, linebreak.js and similar usable or just experiments?
More generally, what does the current web typographer's toolbox look like at the moment?
Basically, your doubts are well founded: you don’t have very much reliable control over typography on the web.[0] Things like kerning.js are probably best regarded as admirable proofs of concept for future work.
You’re also right that webtypography.net is limited by our technology, but I think it’s also limited in its approach. ETS is a wonderful book,[1] but it’s really about print typography, and few of its practical guidelines are both possible and wise to apply directly to the web.
TypeKit is pretty good. Google Web Fonts is kind of a disaster from a fine typography viewpoint. Some of the fonts are nice for headlines, but last time I checked there isn’t a single text typeface which is reasonably attractive, kerned well, and has a real italic. Not one. There are some good decorative faces in there, but no drop-in Verdana replacement.
And text figures? Pffft. Small caps? Double pffft.
Here are some things that you have control over and are worth worrying about if you’re interested in web typography, in no particular order:
— Get past ASCII. Use real dashes, quotes, and apostrophes. Don’t put too much trust in automatic curly-izers, even when attached to reputable projects like Markdown.[2] And so on.
— Design on a grid. Set CSS’s line-height property by hand, or you’ll have interfering vertical rhythms. I like to set h1-6’s line-height to an even multiple of the base, but some people would consider this overkill. Set the sup and sub element’s line-heights to 0px or else they’ll screw with the leading. And so on.
— Think about how people actually read on screens. For example, on my screen, reading on full #ffffff is slightly uncomfortable after a while. People with wide screens will get ridiculously long lines if you don’t set a width to something sane like 60em. And so on.
0. Before someone says that this is a good thing because content and presentation should be separate, let me point out that we’re talking about presentation defaults here. No one wants to force everyone to see (or be screen-read) exactly the same thing. If we had some support for things like kerning in CSS, they would stay in CSS and be expected to degrade gracefully.
1. So good that I recommend it as an example of manual-writing to people with no interest in typography.
2. I’ve written about the problem of automatically curling apostrophes at http://rheme.net/apostrophes . In short, it’s hard to have a simple and fast algorithm that corrects the apostrophes/quotes in both:
She said "I like rock 'n' roll".
and He said "I have a 'friend' who does too".
This is the kind of thing that only people who care about it will care about.You may find this interesting: http://webtypography.net/toc/
This is perhaps more elegant, but it makes your CSS too tightly bound to your content. Add a word in the markup, and you'll have to update your CSS as well, with a none or whatnot.
By all means, nice work, I just rarely work with pages where I know how the content will turn out.
Edit: Fixed a typo.
text-rendering: optimizeLegibility;
... which will give you improved handling of kerning pairs and ligatures.see: http://www.aestheticallyloyal.com/public/optimize-legibility...
Doing it declaratively through css is nice, but it would be nicer if it used vendor prefixes correctly to avoid namespace collisions instead of misusing them the way it does.
Why wouldn't I simply wrap it in a span, then it even works on browser with JS switched off. Uh, and once I have to edit the copy and add a single word somewhere, everything breaks.
I can think of a few instances where I could have used the ability to target a specific letter in the past, specifically as it relates to logotypes or branding, but none that involved targeting the 235th letter.
i.e. Google aside, does Bing and other crawlers interpret:
<span>Perfect</span>
To be the same as:
<span> <span class="word2" style="display: inline-block; "><span class="char1" style="display: inline-block; margin-right: 1px; ">p</span><span class="char2" style="display: inline-block; margin-right: 0px; ">e</span><span class="char3" style="display: inline-block; margin-right: 2px; ">r</span><span class="char4" style="display: inline-block; margin-right: 0px; ">f</span><span class="char5" style="display: inline-block; margin-right: 0px; ">e</span><span class="char6" style="display: inline-block; margin-right: 0px; ">c</span><span class="char7" style="display: inline-block; margin-right: 0px; ">t</span><span class="char8" style="display: inline-block; margin-right: 0px; ">.</span> </span>
Also...
SPANNITY SPANNNN SPANNITY SPANNNN
<header>
<h1>Kerning.js</h1>
<h2>Take control of your web typography.</h2>
</header>
Check out http://stackoverflow.com/questions/2061844/does-googles-craw... for the usual caveats.My only concern is whether this is (in startup lingo) a painkiller or a vitamin - as in, this is really nice to have, if you're that worried about kerning, but perhaps not enough of a pain-point for designers and developers to warrant learning a new set of nested and prefixed CSS rules, just to do something that's possible to hack together on a case-by-case basis with something like lettering.js...
Perhaps if there's a way to simplify the syntax or provide easy copy-paste examples, it'll remove the barrier to entry?
Still, applaud the work and the code looks great.
Designers/front-ends, what things would you like to control about your type now, that you can't yet?