Until now, the FontTableProvider only allowed to find the table for a specific tag. This adds a function to list all the tags present in the font.
The proposed API is fn table_tags(&self) -> Vec<u32>.
It could also be fn table_tags(&self) -> impl Iterator<Item = u32>, but that would require return-position impl Trait in trait (RPITIT) syntax that will stabilize in Rust 1.75 next week. Using RPITIT would also prevent the FontTableProvider trait from being "object safe", which would mean that the DynamicFontTableProvider would not be able to use a dyn FontTableProvider (it could use an enum over all possible providers though).
It could also be useful to have a function directly returning a collection of (tag, table) (or an impl Iterator), so that one wouldn't need to find the table for each tag after listing the tags. Currently Woff2TableProvider provides the into_tables(self) -> HashMap<u32, Box<[u8]>> function, but it's not clear to me whether a HashMap is the best type for all font providers.
Thanks for this. However, I have made the same change in some unreleased work to add some preliminary variable fonts support. That should be done early in the new year. I'll close this PR for now.
Until now, the
FontTableProvider
only allowed to find the table for a specific tag. This adds a function to list all the tags present in the font.The proposed API is
fn table_tags(&self) -> Vec<u32>
.fn table_tags(&self) -> impl Iterator<Item = u32>
, but that would require return-positionimpl Trait
in trait (RPITIT) syntax that will stabilize in Rust 1.75 next week. Using RPITIT would also prevent theFontTableProvider
trait from being "object safe", which would mean that theDynamicFontTableProvider
would not be able to use adyn FontTableProvider
(it could use an enum over all possible providers though).It could also be useful to have a function directly returning a collection of
(tag, table)
(or animpl Iterator
), so that one wouldn't need to find the table for each tag after listing the tags. CurrentlyWoff2TableProvider
provides theinto_tables(self) -> HashMap<u32, Box<[u8]>>
function, but it's not clear to me whether aHashMap
is the best type for all font providers.