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

Combine canvas::drawText() and Font.draw() into one function #192

Closed
vtereshkov opened this issue Jul 7, 2024 · 5 comments
Closed

Combine canvas::drawText() and Font.draw() into one function #192

vtereshkov opened this issue Jul 7, 2024 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@vtereshkov
Copy link
Contributor

Can canvas::drawText() take an optional ^Font parameter?

@skejeton
Copy link
Member

skejeton commented Jul 7, 2024

Instead I think there should be canvas::font.draw which is an instance of Font, but that means Font is an interface. We need @marekmaskarinec to weigh in.

@skejeton skejeton added enhancement New feature or request help wanted Extra attention is needed labels Jul 7, 2024
@marekmaskarinec
Copy link
Member

My proposed solution:

  • change font::Font to an interface
  • add font::TrueType (name subject to change) which implements font::Font
  • add canvas::PixelFont (name subject to change) which is an empty struct that implements font::Font using existing canvas functions

This both prevents breaking and opens up possibilities for other types of fonts like bitmap fonts. What are your thoughts?

@vtereshkov
Copy link
Contributor Author

@marekmaskarinec What function will finally draw the text? The interface method Font.draw()?

@skejeton
Copy link
Member

skejeton commented Jul 8, 2024

@marekmaskarinec What function will finally draw the text? The interface method Font.draw()?

Yes

@skejeton
Copy link
Member

skejeton commented Jul 8, 2024

My proposed solution:

  • change font::Font to an interface
  • add font::TrueType (name subject to change) which implements font::Font
  • add canvas::PixelFont (name subject to change) which is an empty struct that implements font::Font using existing canvas functions

This both prevents breaking and opens up possibilities for other types of fonts like bitmap fonts. What are your thoughts?

I agree. But how do we access the PixelFont?

marekmaskarinec added a commit that referenced this issue Jul 14, 2024
Signed-off-by: Marek Maškarinec <marek@mrms.cz>
marekmaskarinec added a commit that referenced this issue Jul 16, 2024
Signed-off-by: Marek Maškarinec <marek@mrms.cz>
marekmaskarinec added a commit that referenced this issue Jul 16, 2024
Signed-off-by: Marek Maškarinec <marek@mrms.cz>
skejeton pushed a commit that referenced this issue Jul 16, 2024
Signed-off-by: Marek Maškarinec <marek@mrms.cz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants