Skip to content

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

Closed
gendx wants to merge 1 commit into
yeslogic:masterfrom
gendx:table-provider-tags
Closed

Add a function to list tags to the FontTableProvider trait.#99
gendx wants to merge 1 commit into
yeslogic:masterfrom
gendx:table-provider-tags

Conversation

@gendx
Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants