#9516
Fonts: optional ImFont::KerningFn pair-adjust hook
Summary
- Add
ImFont::KerningFn/KerningUserData: optional extra advance (pixels atsize) between consecutive codepoints. - Applied in
RenderTextandImFontCalcTextSizeExso layout matches draw. NULLkeeps the current advance-only path (one null check per glyph). No atlas / loader changes.
Why
ImGui places glyphs by AdvanceX only. Hosts that already have pair data (legacy kern, HarfBuzz GPOS, or a custom table) cannot feed it into chrome/ImGui::Text without wrapping every call. This hook is the smallest seam: the atlas stays a glyph cache; the host owns shaping.
Omar noted in #618 that kerning would be nice as an optional per-font path because text-size calc is a bottleneck. This is that option: default cost is unchanged.
Word-wrap (CalcWordWrapPosition) is not adjusted yet; wrap points can be off by the pair extras on a line. Happy to add that if this shape is acceptable.
Test plan
- Default (
KerningFn == NULL): demo / examples look identical. - Set a callback that returns a known extra for
A+V;ImGui::Text(AV)andCalcTextSize(AV)both pick it up. - Newlines reset the previous codepoint (no pair across lines).