mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-08 14:23:23 +00:00
This is a big one, I kind of over scoped a touch. I don't have it in me to do a clean-up pass on this code before PR-ing it, so apologies for any weirdness; I'll happily resolve any feedback, but trying to review my own code right now is not something my brain wants to do. #### Summary - Font metric calculations reworked to be based primarily on data from font tables, and now the majority of the logic is shared between CoreText and FreeType, and we have more control over the specifics. - Sprite font metrics for the position and thickness of underlines, strikethroughs, and overlines are now separate, as well as box drawing thickness, allowing for individual adjustments. - Minimums are applied to font metrics to avoid *completely* broken results from fonts with degenerate values in them. ### Unified Metrics Calculations I added a solid foundation for parsing as many SFNT font tables as we need, and added parsing for `head`, `hhea` (unused), `post`, and `OS/2`. I didn't make a strong effort to account for variable fonts, so if a variable font changes vertical metrics significantly it could cause issues -- luckily, width, which is the most likely metric to change, is not a problem, since we get the width by having our backends measure the advances for us, which does account for variations correctly. ### Separated Sprite Metrics I reworked the sprite renderer to just get a copy of the metrics that it can use directly, instead of being given its own metrics (width, height, thickness) -- so that the different thickness metrics can be used for their intended purposes, and so that offsets for "unadjusted" characters can be handled in the Box renderer itself. ### Minimums Prevent degenerate fonts and bad `adjust` configs from creating, e.g. zero-thickness underlines by applying a minimum to certain fields after calculating metrics and after applying modifiers. ### Misc. Fixed `init` for CoreText faces selecting the first predefined instance of a variable font rather than the default.