SDL2_ttf kerning not working?

In a (relatively) recent update to SDL2_ttf, kerning seems to have stopped working.

My test is to measure the width of the string “AVATAR” using TTF_SizeUTF8(), with kerning disabled and enabled using TTF_SetFontKerning().

Using 48pt DejaVuSans and SDL_ttf 2.20.2 I’m getting a width of 259 pixels for both. This definitely used not to be the case, the effect of kerning on this string should be very marked.

Is this a bug?

probably always on with sdl_ttf/harfbuzz,
some info here Get kerning between two individual codepoints · harfbuzz/harfbuzz · Discussion #2767 · GitHub

No, the value returned corresponds to the width of the string without kerning, in other words it’s the same as the sum of the widths of the individual characters. It’s as if kerning is permanently off, not on.

Edit: Using the values returned by TTF_GetFontKerningSizeGlyphs32() the string width with kerning should be about 240 pixels rather than about 260.

Edit 2: Here’s a visual comparison:

kerning_demo

I also see that.
SDL_ttf + FT + DejaVu use the kerning.
SDL_ttf + FT + HarfBuzz + DejaVusSans doesn’t use the kerning.

but with other font, it works. (eg SDL_ttf + FT + HarfBuzz + otherfont).
so that’s something with HB ignoring DejaVuSans kerning information …

What other font did you try? Using FreeSans instead of DejaVuSans makes no difference here, still no kerning.

trying for instance:

fonts/ITCAvantGardeStd-Demi.ttf
fonts/DroidSansFallback.ttf
fonts/HelveticaNeue-Regular.ttf
fonts/ttf-bitstream-vera-1.10/Vera.ttf

I don’t have any of those. It still seems a serious bug that kerning no longer works when it used to (presumably before Harfbuzz) with the same fonts; clearly a kerning table exists in those fonts otherwise TTF_GetFontKerningSizeGlyphs32() wouldn’t work.

you can find them on internet

Maybe so, but I can’t replace the fonts shipped with my app because they would have different metrics and programs with carefully-designed layouts could break (line wraps happening when they didn’t before, that kind of thing).

I’m simply asking for the SDL2_ttf regression to be fixed. If kerning worked previously to the incorporation of HarfBuzz, it should work now. This is how software ‘upgrades’ are supposed to happen!

this should be reported to harfbuzz, I guess:

I think you’d want to do some debugging to figure out where the problem is before reporting it to a specific place. For example SDL_ttf can be compiled without harfbuzz support, whereas harfbuzz is required for kerning to work with certain fonts.

As said, I have tested with SDL_ttf and I know that since I did the update of SDL_ttf to use Harbuzz

SDL_ttf + FT + DejaVuSans uses the kerning.
SDL_ttf + FT + HarfBuzz + DejaVuSans doesn’t use the kerning.

but with other font, kerning works. (eg SDL_ttf + FT + HarfBuzz + otherfont).
so that’s something with HB ignoring DejaVuSans kerning information …