3
$\begingroup$

Do anyone know any algorithm which would calculate automatically kerning of characters based on glyph shapes when user types text?

I don't mean trivial calculation of advance widths or similar, I mean analyzing the shape of glyphs to estimate the visually optimal distance between characters. For example if we lay out three characters sequentially in a line, the middle character should SEEM to be in the center of the line despite of the character's shapes. An example enlightens the kerning-on-the-fly functionality:

An example of kerning-on-the-fly can be seen from below snapshot: enter image description here

In the above image a seems to be too right. It should be shifted a certain amount towards T so that it seems to be in the middle of T and g. The algorithm should examine the shapes of T and a (and possibly other letters also) and decide how much a have to be shifted to the left. This certain amount is the thing that the algorithm should calculate - WITHOUT EXAMINING THE POSSIBLE KERNING PAIRS OF THE FONT.

I'm thinking of coding a javascript (+svg+html) program that uses hand drawn fonts and many of them lacks kerning pairs. The textfields will be editable and can include text of multiple fonts. I think that kerning-on-the-fly could be one way to ensure mean text flow in this case.

EDIT: One starting point to this could be to use svg font, so it's easy to get path values. In svg font the path is defined this way:

   

The algorithm (or javascript code) should examine those paths some way and determine the optimal distance between them.

  • 1
    I voted to close as off-topic. I'm not sure where this belongs; you might try http://stackoverflow.com. Mathematics it is not.2012-10-13
  • 1
    Was closed on http://stackoverflow.com/questions/12654826/kerning-on-the-fly. So if this is not mathematics (to calculate distances between curves and lines) then I have no idea where this belongs.2012-10-13
  • 1
    You haven't asked a question about how to calculate specific distances between specific curves and specific lines. If you would it would certainly be on topic. What you asked us for is an extremely vaguely specified algorithm whose quality so far could only be judged by aesthetic standards; there's not even a hint of quantification of concepts such as "should seem to be" in the question.2012-10-13
  • 0
    This actually *is* kind of a mathematical question, it just wasn't worded that way. It sounds as if what the OP wants is an algorithm with takes to shapes $S_1$,$S_2$ and finds a (horizontal) translates $T_x$ such that the distance between $S_1$ and $T_x(S_2)$ appears to the viewer to be some pre-choosen $d$. This tricky part is, of course, to mathematically express the idea of "apparent distance".2012-10-13
  • 0
    @joriki It's OK to ask what mathematical definition people can come up with though, no?2012-10-13
  • 0
    @Timo: Not everything that is off-topic on SO is automatically on-topic here. This question is one of aesthetics, not of coding or mathematics (at least until you have decided on a particular mathematical definition of the aesthetics you want to implement).2012-10-13
  • 0
    @HenningMakholm: The first sentence is of course true. But there is an implementation of kerning-on-the-fly: Adobe's Optical Kerning, which is not bad at all. And AFAIK it is aesthetics+mathematics+coding, all in one nice package.2012-10-13
  • 0
    The Gods so said this is not a mathematic question. Any ideas where this question belongs? Not Stackexchange at all?2012-10-13
  • 0
    Because this is considered as off topic in Stackoverflow and here, I made a new try in http://graphicdesign.stackexchange.com/questions/11016/kerning-on-the-fly .2012-10-13

1 Answers 1