Don't use skrifa interjector if provided variation coordinates map to default coordinates#28
Conversation
| let interjector = interjector::skrifa::SkrifaInterjector::new( | ||
| data, | ||
| index, | ||
| variation_coordinates, | ||
| ) | ||
| .ok_or(MalformedFont)?; |
There was a problem hiding this comment.
A bit unfortunate to always construct it and then not use it, but this is very cheap anyway, just requires the construction of a FontRef.
|
Perhaps we should also check whether the font even is a variable font? 🤔 Just to be safe. |
|
We could also filter out unsupported axes for the purposes of the check. Or does |
|
I'm not sure whether the |
|
It checks that the normalized coordinate is zero, which should be the case if it matches the default no? Otherwise, it also wouldn’t make sense that the noto test was changed. |
|
We are deriving the locaiton here: Lines 42 to 44 in ab3dc07 Basically, skrifa takes the tags, maps them against the font in some way and then returns the It's also explicitly documented that garbage tags are ignored, so that doesn't need special treatment I think: https://docs.rs/skrifa/latest/skrifa/struct.AxisCollection.html#method.location I guess this means we might not even need the explicit check whether the font is variable, and what is implemented in this PR is enough. |
|
Makes sense! |
|
Thanks! |
In general, we want to avoid using the interjector since it requires completely rewriting all font outlines. Right now, we decide whether to use the skrifa interjector based on whether the variation coordinates are empty or not. However, we can take this a step further by instead just checking whether the variation coordinates map to the default. So if the user for example provides the axis
wght=400, we can still use the dummy interjector if this is the default axis of the font anyway.Not super urgent to have in a new release because we can just do the same detection on the krilla side, but I think it's pretty important to have it in some place at least. And in the long term, it's definitely better to have it in subsetter than krilla.