Fixup sub/superscript metric fallback logic#1823
Merged
Conversation
wmedrano
approved these changes
Dec 15, 2025
rsheeter
reviewed
Dec 15, 2025
| let units_per_em = units_per_em as f64; | ||
|
|
||
| let mut set_if_absent = |metric, value| self.set_if_absent(metric, pos.clone(), value); | ||
| // a macro instead of a closure to avoid borrowck |
Contributor
There was a problem hiding this comment.
This smells, I didn't spot it at a glance, why can't this be normal code?
Contributor
There was a problem hiding this comment.
Personally, I think calling self.set_if_absent(metric, pos.clone(), value); directly is fine.
- set_if_absent can also take an
Into<Cow<NormalizedLocation>>if you want to avoid the explicit clone
Member
Author
There was a problem hiding this comment.
The whole reason this exists afaict is because always calling self.set ends up just... being a bunch of extra lines? And the closure doesn't work with this patch because you can't call self.get because the closure has an &mut ref to self.
If there are explicit values in a font for the 'Os2Subscript___' metrics, we want to reuse those for the corresponding superscript metrics. This means that we need to query metrics in this routine, which ran into borrowck issues due to the long-lived closure that had a mutable ref to self, so I've removed that.
930710a to
ad3af28
Compare
Member
Author
|
oops forgot about this. I did something similar to @wmedrano's suggestion and tweaked the signature of |
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.
If there are explicit values in a font for the 'Os2Subscript___' metrics, we want to reuse those for the corresponding superscript metrics.
This means that we need to query metrics in this routine, which ran into borrowck issues due to the long-lived closure that had a mutable ref to self. To work around that, I've replaced that closure with a macro.