mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00

This PR changes `font.Collection` to automagically adjust the sizes of added fonts so that their metrics (specifically their ex height, or their ideograph character width if they have one) match the primary font. This is like [`font-size-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size-adjust) from CSS. This is a big win for users who use mixed writing systems and rely heavily on fallback fonts. For example, in #7774 it's pointed out that CJK characters are not very well harmonized with existing Latin glyphs, well: |Before (`main`)|After (this PR)| |-|-| |<img width="326" alt="image" src="https://github.com/user-attachments/assets/c11d372d-ec69-426d-b008-1f56a7430f23" />|<img width="326" alt="image" src="https://github.com/user-attachments/assets/efcb56ea-0572-481a-b632-a0b5cd170fa9" />| This also improves our handling of the horizontal alignment of fallback glyphs. It's not an ideal solution; it only works for glyphs narrower than the cell width because it messes with ligatures if we include glyphs wider than the cell width; and most things would look better if the center were proportionally remapped based on the ratio from the glyph advance to the cell width, but that messes with glyphs designed to align vertically so it can't be done, instead the original advance width is centered in the cell width.