Skip to content

Conversation

@cmyr
Copy link
Member

@cmyr cmyr commented Dec 11, 2025

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.

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.
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
Copy link
Contributor

Choose a reason for hiding this comment

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

This smells, I didn't spot it at a glance, why can't this be normal code?

Copy link
Contributor

@wmedrano wmedrano Dec 15, 2025

Choose a reason for hiding this comment

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

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

Copy link
Member Author

@cmyr cmyr Dec 16, 2025

Choose a reason for hiding this comment

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

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.

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.

3 participants