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

Preloaded characters in the GlyphCache cannot be easily retrieved with opt_character() #331

Open
AleCamara opened this issue Dec 27, 2020 · 0 comments

Comments

@AleCamara
Copy link

Preloading characters in a GlyphCache creates the new characters, storing them in the cache. However, the characters get their size converted from points to pixels in character():

let size = ((size as f32) * 1.333).round() as u32; // convert points to pixels

This makes it impossible for external users to retrieve preloaded characters without reproducing the points -> pixels conversion themselves.
I personally think that it'd be nice for users to not have to bother with this, so instead we could just do the size conversion when requesting the opt_character(). That way users could just pass in the same font size.

pub fn opt_character(&self, size: FontSize, ch: char) -> Option<Character<T>> {
    let size = ((size as f32) * 1.333).round() as u32; // convert points to pixels
    // ... rest
}

What do you think?

Happy to put up a PR if this is something that is useful!

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

No branches or pull requests

1 participant