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 simple example to render text using fontdue #312

Closed
wants to merge 3 commits into from

Conversation

Nevsden
Copy link

@Nevsden Nevsden commented Jan 22, 2023

Added text rendering in the most simple way using fontdue to create a text bitmap on request. Also added a simple example to render text on a sprite. Related to #152

  • Added a text module under crate::renderer. Not sure, if this is the correct level.
  • Added a Font class, which reads in a ttf font using fontdue and can rasterize characters.
  • Added a TextEffect holding information on the text and text size to be rendered.

Issues so far with this solution:

  • Text is created by accessing Font::rasterize, which could be expensive. An interim struct to hold all possible characters in a texture atlas is probably the more efficient way.
  • Not sure, on which level in the crate to implement the text functionality.
  • Don't yet know, how to render text on a transparent background, such that the text is the only colorized object in its own visual scope.

@Nevsden Nevsden mentioned this pull request Jan 22, 2023
@Nevsden
Copy link
Author

Nevsden commented Jan 23, 2023

Changed the struct TextEffect to hold a string instead of a single char. Further changed function rasterize to turn string instead of a char into a CpuTexture. Computation of the correct permutation from the bitmap for each char in the string to the unified TextureData::RgbaU8 brought a little confusion but I solved it.

  • Further investigation needed on how to render the text with a CpuTexture without using Sprites.
  • Also need to look how to stretch text appropriately on the three-d::Texture2D level, once the CpuTexture has been consumed by the ColorMaterial::new_transparent function.

Also, todos from @asny still ongoing.

@guija
Copy link

guija commented Oct 26, 2023

I'm interested in this change, what is the status of this? Is someone working on it?
I could support if necessary.

@asny
Copy link
Owner

asny commented Nov 14, 2023

I'm interested in this change, what is the status of this? Is someone working on it? I could support if necessary.

I think this is mostly replaced by #376, so I'm closing this.

@asny asny closed this Nov 14, 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.

4 participants