Skip to content
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

Add a function to list tags to the FontTableProvider trait. #99

Closed
wants to merge 1 commit into from

Conversation

gendx
Copy link
Contributor

@gendx gendx commented Dec 21, 2023

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.

@wezm
Copy link
Contributor

wezm commented Dec 21, 2023

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.

@wezm wezm closed this Dec 21, 2023
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.

None yet

2 participants