I asked the Kimi AI how to further improve GSHorizontalTypesetter. Here is what it came up with:
https://www.kimi.com/share/19d34cdb-8242-8fc9-8000-00001fd46e3b
Enable Kerning (Currently Disabled)
The kerning code is commented out as a "major bottleneck" but this significantly degrades text quality. Implement with caching:
// PROPOSED: Add kerning cache to avoid repeated font metrics calls
struct {
NSGlyph prevGlyph;
NSGlyph currGlyph;
float kernAdjustment;
} *kerningCache;
size_t kerningCacheSize;
// Use conservative kerning: only query when glyph pair changes
if (lastGlyph && lastGlyph != NSNullGlyph && glyphEntry->font == font) {
float kern = [font advancementForGlyph: lastGlyph].width +
[font advancementForGlyph: glyphEntry->glyph].width -
[font advancementForGlyphPair: lastGlyph : glyphEntry->glyph].width;
if (kern != 0) {
position.x += kern;
glyphEntry->nominal = NO;
}
}
We should of course check if this is a bottle neck.
I asked the Kimi AI how to further improve GSHorizontalTypesetter. Here is what it came up with:
https://www.kimi.com/share/19d34cdb-8242-8fc9-8000-00001fd46e3b
Enable Kerning (Currently Disabled)
The kerning code is commented out as a "major bottleneck" but this significantly degrades text quality. Implement with caching:
We should of course check if this is a bottle neck.