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 font support #581

Merged
merged 28 commits into from
Apr 16, 2020
Merged

Add font support #581

merged 28 commits into from
Apr 16, 2020

Conversation

ryanisaacg
Copy link
Owner

@ryanisaacg ryanisaacg commented Feb 24, 2020

This change adds a new Font API to version 0.4, using glyph caching rather than rendering entire strings at once as in the 0.3 API. Because the new API relies less directly on rusttype, it can also support bitmap fonts.

Motivation and Context

See #552

Checks

  • Implement basic font rendering
  • Implement some basic layout options (line wrapping, getting the total width / height of some text to be rendered, etc.)
    - [ ] Add a way to create / load bitmap fonts (Delayed for a future change)
  • Create a font rendering example
  • Returned rendered text extents from draw_text
  • I have updated CHANGES.md, with [BREAKING] next to all breaking changes
  • I have updated the documentation if necessary

@lenscas
Copy link
Contributor

lenscas commented Mar 2, 2020

Would it be possible for font's to implement Clone?

I ask because I hit a blocker while porting Mergui. Mergui used to take an piece of text that was already rendered for the components that dealt with text.

With the changes it feels like Mergui should also stop working with pre-rendered pieces of text. This means that every widget needs some way to get a mutable reference to the correct font. The easiest (and in my eyes, most logical) way is to add a Font field to Mergui's widgets. However, this isn't really an option as there is no easy way to get multiple copies of a Font. (Only way I can think of is by loading the font for every widget)

@ryanisaacg
Copy link
Owner Author

@lenscas Would it not be possible to throw the font in an Rc<RefCell<Font>> for your usecase?

@lenscas
Copy link
Contributor

lenscas commented Mar 2, 2020

I guess it would, it makes the interface a bit uglier (As the user would need to wrap every font into that) so I am still a fan of having this tucked away into Font itself (or have it have some other way to be cloneable) but as it isn't really needed for quicksilver I can see why it isn't.

@ryanisaacg ryanisaacg marked this pull request as ready for review April 16, 2020 22:36
@ryanisaacg ryanisaacg merged commit 8d475e7 into master Apr 16, 2020
@ryanisaacg ryanisaacg deleted the add-font-support branch April 16, 2020 22:49
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