SKETCH-2728: Adding fallback font names to generated SVG files#302
Merged
KevKeating merged 1 commit intoschrodinger:mainfrom Apr 13, 2026
Merged
SKETCH-2728: Adding fallback font names to generated SVG files#302KevKeating merged 1 commit intoschrodinger:mainfrom
KevKeating merged 1 commit intoschrodinger:mainfrom
Conversation
juzerzarif
approved these changes
Apr 9, 2026
rachelnwalker
approved these changes
Apr 9, 2026
ethan-schrodinger
approved these changes
Apr 12, 2026
Comment on lines
+387
to
+389
| * Post-process the contents of the SVG file after Qt has generated it | ||
| * @param svg_data The contents of the SVG file | ||
| * @param opts The options used to render the SVG |
Collaborator
There was a problem hiding this comment.
Would it make sense to include here the goals of the post-processing?
Collaborator
Author
There was a problem hiding this comment.
I thought about doing that, but it seemed like any description here would become stale far more quickly than the comments that are above each block of code in the body of the function.
KevKeating
added a commit
that referenced
this pull request
Apr 13, 2026
* Linked Case: SKETCH-2728, SKETCH-2682, LDID8-1488 ### Description @rachelnwalker finally figured out why the images in Live Design's first column aren't using the correct font: those images are rendered as SVGs, which means that the font will only be correct if the user has Arimo installed as a system-wide font. If not, the web browser doesn't know enough about Arimo to even know that it's sans serif, so it winds up replacing it with a serif font. To fix this, I've added a list of fallback fonts, including Arial and Helvetica, to the SVG file. We're only including the font name in the SVG file, not the font itself, so we don't need to worry about font licensing. With this change, the generated SVGs look correct if I open them up in my web browser, and @juzerzarif confirmed that he sees the same thing. My first attempt at this was to specify the alternate fonts as QFont families, but QSvgGenerator ignores these. (I checked in the Qt source code and confirmed that's the expected, but unfortunate, behavior.) As a result, I added some logic to our SVG post processing to manually add in the additional font names. I'm assuming that we'll want to add this commit to the release branch in both `sketcher` and `mmshare`. I don't think I have permissions to merge a PR directly into the release branch on `sketcher`, but I can cherry-pick and manually push after this gets merged into `main`. When I put up an `mmshare` PR, I'll do that against the release branch so it can go through engineering approval. ### Testing Done I saved an SVG from Sketcher and confirmed that it looks correct. I also updated the SVG unit test to include a check for the font list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
@rachelnwalker finally figured out why the images in Live Design's first column aren't using the correct font: those images are rendered as SVGs, which means that the font will only be correct if the user has Arimo installed as a system-wide font. If not, the web browser doesn't know enough about Arimo to even know that it's sans serif, so it winds up replacing it with a serif font. To fix this, I've added a list of fallback fonts, including Arial and Helvetica, to the SVG file. We're only including the font name in the SVG file, not the font itself, so we don't need to worry about font licensing. With this change, the generated SVGs look correct if I open them up in my web browser, and @juzerzarif confirmed that he sees the same thing.
My first attempt at this was to specify the alternate fonts as QFont families, but QSvgGenerator ignores these. (I checked in the Qt source code and confirmed that's the expected, but unfortunate, behavior.) As a result, I added some logic to our SVG post processing to manually add in the additional font names.
I'm assuming that we'll want to add this commit to the release branch in both
sketcherandmmshare. I don't think I have permissions to merge a PR directly into the release branch onsketcher, but I can cherry-pick and manually push after this gets merged intomain. When I put up anmmsharePR, I'll do that against the release branch so it can go through engineering approval.Testing Done
I saved an SVG from Sketcher and confirmed that it looks correct. I also updated the SVG unit test to include a check for the font list.