New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subsetting variable COLRv1 produces invalid font without ItemVarStore #4085
Comments
I tried adding the following, replicating the line where the DeltaSetIndexMap is copied over for the ItemVariationStore, however I get these compile errors, which I don't understand. But I'm sure you can figure it out. diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh
index d45dc4f03..c82f8c220 100644
--- a/src/OT/Color/COLR/COLR.hh
+++ b/src/OT/Color/COLR/COLR.hh
@@ -1969,6 +1969,7 @@ struct COLR
colr_prime->clipList.serialize_subset (c, clipList, this);
colr_prime->varIdxMap.serialize_copy (c->serializer, varIdxMap, this);
//TODO: subset varStore once it's implemented in fonttools
+ colr_prime->varStore.serialize_copy (c->serializer, varStore, this);
return_trace (true);
}
|
Which browser, and was the subsetted font installed locally or loaded as a @font-face resource? (Sounds like this may be something that COLR validation in OTS needs to check...) |
Chrome 109, but it's already fixed in beta/canary (I believe since 110). Firefox did not crash, simply does not variate the COLR table. OTS doesn't complain either about the missing VarStore, since it is technically an optional field. Generally the problem is not its presence/absence, but the fact that some variable paints may contain VarIndexBase that ultimately point out-of-range. In this case, since the VarStore is absent all remaining VarIndex are out of range. |
yes, loaded as a font-face |
That's because the |
It has a |
cc @qxliu76 |
Actually, @qxliu76 can you work on this? |
yes I'll work on this. |
@qxliu76 I fixed it. Would be good if you can add a test. And ideally implement actual subsetting. |
Oh, thanks! That's impressively fast! |
Take FoldIt[wght].ttf font at https://github.com/google/fonts/tree/main/ofl/foldit, and run it through hb-subset, e.g.
$ hb-subset --output-file=Foldit.subset.hb.ttf 'FoldIt[wght].ttf' ABC
The subset font's COLR table still contains variable paints with VarIndexes and a DeltaSetIndexMap, however the ItemVariationStore has been deleted, so these indices point nowhere (which sometimes leads the browser tab to crash..).
I think the problem is here, where COLR is subsetted, you'll notice the DeltaSetIndexMap is copied as is, but the VarStore is not:
harfbuzz/src/OT/Color/COLR/COLR.hh
Lines 1970 to 1972 in 6c46da7
The TODO in the comment refers to the fact that the python fonttools subsetter doesn't yet support subsetting COLR's VarStore and VarIndexMap: fonttools/fonttools#2698
However, even if it can't subset it, the fonttools subsetter keeps the entire VarStore. E.g.
$ fonttools subset --output-file=Foldit.subset.ft.ttf --text=ABC 'FoldIt[wght].ttf'
Compare the two font, the only difference is the fonttools-subsetted one contains a VarStore, the hb-subsetted one does not.
The text was updated successfully, but these errors were encountered: