4 ms·
TeX finds out about character widths and kerning pairs and ligature replacements from outside of TeX itself. TeX is perfectly happy to ligature together "--" in
by drfuchs 6y ago
TeX finds out about character widths and kerning pairs and ligature replacements from outside of TeX itself. TeX is perfectly happy to ligature together "--" into an en-dash, and "---" into an em-dash, and to then kern either one of them with whatever characters you like, if instructed to do so by these externally-supplied per-font instructions. So, it seems like you're being troubled by the externally-provided font info rather than any limitation of TeX per se.
Boring details: TeX, as it comes from Knuth, reads TFM ("TeX Font Metric") files to supply this per-font information. Knuth's Computer Modern fonts do not contain any kerning pairs that contain dash characters, which one may be pleased or displeased about. Various enhanced-TeXs get font info from the OS or perhaps directly from, say, OpenType font files. If the ligature and kern info isn't passed into TeX from there properly, or doesn't exist in the font itself, then of course you won't get the results you're looking for.
- spekcular 6y agoYes, but there's no way to get optical kerning, right?
- leephillips 6y agoI think this information would be built in to any high-quality font. As drfuchs tried to explain, TeX has no information about letterforms; that’s not its job.
- drfuchs 6y agoArguably, there is no algorithmic way to compute high-quality kerning based on character shapes (just as there's no way to determine, say, character width just from an outline). If there were, then Apple would build it into MacOS and iOS, and Microsoft would build it into Windows, and Google would build it into Android, and then all applications from TextEdit to Word, Safari to Chrome, and troff to TeX would automatically get told about these synthetic kerning pairs, and use them by default. That said, Adobe does have a proprietary optical kerning scheme that they use in their applications. But it's turned off by default (hint, hint), and their documentation is a bit defensive about it: "Optical kerning adjusts the spacing between adjacent characters based on their shapes, and is optimized for use with Roman glyphs. Some fonts include robust kern-pair specifications. However, when a font includes only minimal built-in kerning or none at all, or if you use two different typefaces or sizes in one or more words on a line, you may want to use the optical kerning option for the Roman text in your document." Loosely translated: Fonts from real type foundries have kerning pairs carefully created by their designers; if you have slap-dash one where they didn't bother, we'll do the best we can if you want. YMMV.