Skip to content

Add shaping debugger#2500

Merged
justvanrossum merged 107 commits intomainfrom
shaper-debugger
Mar 27, 2026
Merged

Add shaping debugger#2500
justvanrossum merged 107 commits intomainfrom
shaper-debugger

Conversation

@justvanrossum
Copy link
Copy Markdown
Member

This adds "tracing" or "debugging" functionality to text shaping and OpenType feature processing, via the HarfBuzz message API. This is the same as what Crowbar does, but integrated in Fontra's rendering machinery.

The UI is part of the "Input characters and output glyphs" panel, and is currently very flat and simple. There is a new accordion item labeled "Shaping debugger", that is closed by default. Once opened, it shows a list with "messages" from HarfBuzz and Fontra's own positioning feature emulation. You can click on a message to make the canvas display the text as it would render at that point during the shaping process.

This reverts commit d16b60b.

This problem has been fixed differently in #2499
@justvanrossum
Copy link
Copy Markdown
Member Author

justvanrossum commented Mar 25, 2026

Updates:

  1. Move the debugger between the char list and the glyph list. This feels more natural when stepping through GSUB, as it prevents the debugger list from jumping around if the number of rendered glyphs change
  2. Hide ineffective lookups and individual items by default. There is a little hamburger menu next to the "Shaping debugger" accordion item title that allows you to toggle this setting
  3. Don't try to balance "recursing"/"recursed" messages. But also don't filter out "recursing" messages, so we can at least see to what lookup it is recursing to
image

@justvanrossum
Copy link
Copy Markdown
Member Author

(Think think this could be done now, but a little more stress-testing wouldn't hurt...)

@khaledhosny
Copy link
Copy Markdown
Contributor

All looks good now. I really like it.

One little thing, then clicking on collapsed steps, the glyph output before applying any of the enclosed changes is shown. This was confusing a bit at the start e.g. I expected to see the output of fina feature when clicking on it, but I got the output of ccmp feature. Maybe if the item is collapsed then the output of the last enclosed step should be shown, and when it is expanded it acts like it is now?

@khaledhosny
Copy link
Copy Markdown
Contributor

It would also be nice if page reload remembered which panel item was expanded or collapsed (right now it always expands Input characters and Output glyphs and collapses Shaping debugger.

I still think it would be nice to have this.

@khaledhosny
Copy link
Copy Markdown
Contributor

The only crucially missing bit for me is lookup names source line numbers.

Let's see how receptive the fontc team is to changes to make this possible.

googlefonts/fontc#1933

@justvanrossum
Copy link
Copy Markdown
Member Author

glyph output before applying any of the enclosed changes is shown. This was confusing a bit at the start

Yes, I see that is confusing, and I struggled with it a bit. The behavior you suggests sounds good but has one oddity: selecting the "folder" item would result in a different "breakpoint" when folded and unfolded. But perhaps that is still more intuitive than the current behavior.

@justvanrossum
Copy link
Copy Markdown
Member Author

It would also be nice if page reload remembered which panel item was expanded or collapsed (right now it always expands Input characters and Output glyphs and collapses Shaping debugger.

"Page reload" should not really be a thing for end users, so this would be mostly a convenience for us, and not for the general user. I'll think about it, but for this reason it's not high on my priority list.

@khaledhosny
Copy link
Copy Markdown
Contributor

glyph output before applying any of the enclosed changes is shown. This was confusing a bit at the start

Yes, I see that is confusing, and I struggled with it a bit. The behavior you suggests sounds good but has one oddity: selecting the "folder" item would result in a different "breakpoint" when folded and unfolded. But perhaps that is still more intuitive than the current behavior.

I thought about that as well, and I’m not very sure which is best, but I feel the current behavior is probably less intuitive than the other option.

@khaledhosny
Copy link
Copy Markdown
Contributor

It would also be nice if page reload remembered which panel item was expanded or collapsed (right now it always expands Input characters and Output glyphs and collapses Shaping debugger.

"Page reload" should not really be a thing for end users, so this would be mostly a convenience for us, and not for the general user. I'll think about it, but for this reason it's not high on my priority list.

Right.

@justvanrossum
Copy link
Copy Markdown
Member Author

Maybe if the item is collapsed then the output of the last enclosed step should be shown, and when it is expanded it acts like it is now?

I implemented this and I think you are right that this is much more intuitive behavior.

@khaledhosny
Copy link
Copy Markdown
Contributor

Maybe if the item is collapsed then the output of the last enclosed step should be shown, and when it is expanded it acts like it is now?

I implemented this and I think you are right that this is much more intuitive behavior.

It is much better now indeed.

I tested the debugger with a few fonts and I think it is pretty good now.

@justvanrossum justvanrossum merged commit 88eecaf into main Mar 27, 2026
4 checks passed
@justvanrossum justvanrossum deleted the shaper-debugger branch March 27, 2026 08:52
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