bramstein / typeset

TeX line breaking algorithm in JavaScript
BSD 2-Clause "Simplified" License
996 stars 74 forks source link

Kerning #7

Closed jawj closed 11 years ago

jawj commented 11 years ago

I was thinking of using this library in a project I'm working on to create PDF documents in the web browser. (Although, since I see in other issues that you're working on a new version, I may hold off for now).

I was thinking about how to deal with kerning in the box/glue/penalty model, and wondering if you'd considered this. Take the word 'suckers'. The combined width of 'suckers' will be less than the combined separate widths of 'suck' and 'ers', because of kerning between the k and the e.

I'm surprised to see that Knuth & Plass make no mention of kerning, so perhaps I've missed something obvious here. But it seems to me that a solution would be to insert negative-width, fixed-width glue after each hyphen-related penalty, which will be stripped at the start of a line, but not otherwise.

Does this seem right to you?

All the best, George

bramstein commented 11 years ago

I've considered kerning, but decided to ignore it for now (back when I wrote this most browsers didn't do any kerning, but they are starting to do this now.) I think TeX is doing something like you suggested, but I'm not sure. I'll definitely give your suggestion a try.