Skip to content

fix synthetic font application - #13606

Open
UnsaltedScholar wants to merge 1 commit into
ghostty-org:mainfrom
UnsaltedScholar:fix-synthetic-font-application
Open

fix synthetic font application #13606
UnsaltedScholar wants to merge 1 commit into
ghostty-org:mainfrom
UnsaltedScholar:fix-synthetic-font-application

Conversation

@UnsaltedScholar

@UnsaltedScholar UnsaltedScholar commented Aug 4, 2026

Copy link
Copy Markdown

Fix synthetic font application for fonts without native italic/bold face but for which fontconfig returns non-italic/bold face on query.

First reported in: #13583

Edit:
I truly apologize for not including this earlier, I was a tad overeager after my vouch request was approved and I was quite rushed and ended up creating this pull request on my phone during lunch and had several errands afterwards.

AI Usage Disclaimer:
GPT 5.6 Sol was used to understand the project structure. Specifically, I basically asked it to look at the codebase and tell me what files/functions were relevant to how Ghostty applies synthetic fonts. From there, I simply used ZLS to jump definitions until I found what I thought was the right spot.

@UnsaltedScholar
UnsaltedScholar requested a review from a team as a code owner August 4, 2026 16:11

@mitchellh mitchellh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code quality has major issues. It looks like undisclosed AI to me. If its AI, then I suspect you can learn yourself how to fix it.

@UnsaltedScholar

Copy link
Copy Markdown
Author

@mitchellh
I apologize for forgetting to add the AI usage declaration (see edit in initial comment), but unfortunately the quality issues are a result of being a physicist who has learned to code from other physicists, not AI in this case (hopefully this didn't come across as sarcastic). The 22 lines I have added are all mine; I thought I was doing the correct thing by keeping my changes as small as possible (a habit I have learned from trying not to break my lab's 15+ year old c/c++ analysis software).

I don't know the Ghostty team's internal design decisions beyond the comments provided in the code currently, so I wanted to keep my footprint minimal (or at least what I thought was minimal; granted, in retrospect, putting the changes where they are now probably wasn't the best idea).

I understand that it is not anyone's responsibility to teach me to code here. However, more specific guidance about your objection, whether it's my code placement, the "style" I used, or something else, would help me correct the changes. I'd rather not try to guess at the project's intended design constraints.

This all being said, I would appreciate some clarification on the following questions before I attempt to implement anything more robust:

  1. Should Ghostty search the remaining descriptors if Fontconfig's first candidate for bold/italic is regular?
  2. Is demibold a close enough match to a bold request (e.g. if, for some reason, a font has demibold but not bold as a named weight)?
  3. Is Ghostty fine with allowing native oblique for italic requests (when native italic is missing)
  4. For edge cases (e.g. missing properties), should Ghostty just accept what Fontconfig gives (i.e. how pedantic should I be in checking things fontconfig may throw)?

I really like Ghostty, and would still like to address this issue correctly, but I currently lack a full idea of the expected behavior.

@mitchellh

Copy link
Copy Markdown
Contributor

The 22 lines I have added are all mine

If this the case, I will dedicate the time to perform a helpful review. When its AI I don't because the person on the other side often doesn't reciprocate, but in this case I shall. Stand by.

Comment thread src/font/discovery.zig Outdated
Comment thread src/font/discovery.zig Outdated
Comment thread src/font/discovery.zig Outdated
Comment thread src/font/discovery.zig Outdated
…ace but for which fontconfig returns non-italic/bold face on query
@UnsaltedScholar
UnsaltedScholar force-pushed the fix-synthetic-font-application branch from 16d0b97 to ae7bd53 Compare August 5, 2026 05:51
@UnsaltedScholar

UnsaltedScholar commented Aug 5, 2026

Copy link
Copy Markdown
Author

After more trial and error than anticipated, I managed to clean up the implementation following your guidance (even managed to remove the need for converting from int to enum entirely). I couldn't find any way to make it more compact and still handle all(?) the edge cases.

Thank you for taking the time to provide comments on my initial implementation. I'm sorry it was subpar, but I shall keep your suggestions in mind for the future.

Some notes:

  • bold_min is somewhat arbitrary, but I chose demibold because it is the lightest weight that contains "bold" in the name
  • italic and oblique are both accepted native fonts when italics are requested (only really applies if a font for some reason has oblique but not italics, which would be weird, but I guess possible)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants