Skip to content

Add warning when glyph is not found - #6989

Closed
Andrew15-5 wants to merge 1 commit into
typst:mainfrom
Andrew15-5:tofu-warning
Closed

Andrew15-5 wants to merge 1 commit into
typst:mainfrom
Andrew15-5:tofu-warning

Conversation

@Andrew15-5

@Andrew15-5 Andrew15-5 commented Sep 30, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #5137.

I was about to ask how hard is it to implement #5137, but then I looked inside, and there is a clear place where compiler knows that font family is not found and there is even access to engine to collect the warning. So it's really easy.

However, engine is under a shared reference and I don't know how to get span for the warned text/glyph. So I changed engine to be a mutable reference as well as I added missing spans to the function body. I only then realized that Preparation has the needed spans inside, so the change reduced a little.

I still don't know how to get accurate spans, like in the ShapedText::build. But offset 0 works not that bad for a simple example:

No warnings here.

#emoji.axe

#set text(fallback: false)
No warnings here either.

textテキストтекст
image

The warning text can be so many things, so I have no idea what to print. Also being able to check for --font-path and --ignore-system-fonts flags can improve hint precision. Also can't add native hints in warning!.

Anyway, looks like it's pretty much ready, other than engine/span/message issues. I mean, it works, which is nice to see.

Since it's unreasonable to go through almost hundred pages in a PDF to see if there are any tofus in it (search doesn't work), this warning is a life savior, making sure that Typst uses your specified fonts/system fonts, but you will not have any oopsie-daisy when you want to print or share the PDF. It takes yet another hard task off your shoulders. I just tried it on a big document, and no warnings. I guess I'm good.

@Andrew15-5
Andrew15-5 marked this pull request as draft October 6, 2025 01:35
@laurmaedje laurmaedje added text Related to the text category, which is all about text handling, shaping, etc. diagnostics Improvements to compiler errors labels Oct 27, 2025
@laurmaedje laurmaedje added the waiting-on-review This PR is waiting to be reviewed. label Nov 17, 2025
@laurmaedje laurmaedje closed this Dec 15, 2025
@laurmaedje laurmaedje removed the waiting-on-review This PR is waiting to be reviewed. label Dec 15, 2025
@typst typst locked and limited conversation to collaborators Dec 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

diagnostics Improvements to compiler errors text Related to the text category, which is all about text handling, shaping, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add warning when a glyph isn't found in any font

2 participants