adobe-fonts / source-serif

Typeface for setting text in many sizes, weights, and languages. Designed to complement Source Sans.
https://adobe-fonts.github.io/source-serif
SIL Open Font License 1.1
2.15k stars 161 forks source link

Small caps kerning #128

Closed schombert closed 7 months ago

schombert commented 10 months ago

When turning on small caps with smcp, I have noticed that some of the small capital letters seem to not kern with each other optimally. In particular, av (AV) seems to be unkerned. Or at least, I think this is what is happening. It could also be that the software for rendering the text isn't handling the kerning properly with smcp on (if this is the case please let me know and I will redirect the problem appropriately).

frankrolf commented 10 months ago

A screenshot says more than a thousand words. Small Caps are kerned to capital letters, but of course there may be mistakes.

schombert commented 10 months ago

image Here is what it looks like when I use them as button labels (using smcp).

frankrolf commented 10 months ago

Ha, cool use! :-)

I get this on my end, so something seems off with the implementing environment:

image
schombert commented 10 months ago

Thanks. I will redirect the problem to elsewhere (probably freetype, since it isn't returning the correct kerning between the glyphs). Love the font BTW; it is becoming my default choice for a lot of things.

schombert commented 10 months ago

So I did some more digging, and it turns out that freetype doesn't natively support kerning when it is encoded in the newer opentype tables, and only supports it for legacy ttf kerning information. I am not in a position to switch away from freetype or use one of the more full-featured libraries built on top of it at the moment. So instead I hand rolled some routines that grab the more easily accessible information out of GPOS. With that in place, I managed to get the rendering to look like the following: image I don't think it is quite perfect, but it is at least not totally disfigured.

frankrolf commented 10 months ago

I think this looks great, much better than the original! From freetype.org:

Note that OpenType fonts (OTF) provide two distinct mechanisms for kerning, using the ‘kern’ and ‘GPOS’ tables, respectively, which are part of the OTF files. Older fonts only contain the former, while recent fonts contain both tables or even ‘GPOS’ data only. FreeType only supports kerning via the (rather simple) ‘kern’ table. For the interpretation of kerning data in the (highly sophisticated) ‘GPOS’ table you need a higher-level library like ICU or HarfBuzz since it can be context dependent (this is, the kerning may vary depending on the position within a text string, for example).

It’s a bit unclear what “older” and “recent” means in this context, but fonts today cannot make do with a kern table alone (this has been true for several decades). It would make sense for you to also use harfBuzz, which will give you not just glyph rasterization (FreeType’s job), but also full access to OpenType features.