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

[img] richtextlabel BBCode does not display with "Image" resource #79729

Closed
FireCatMagic opened this issue Jul 20, 2023 · 6 comments · Fixed by godotengine/godot-docs#7704
Closed

Comments

@FireCatMagic
Copy link

Godot version

4.1.1 stable

System information

Godot v4.1.1.stable - Windows 10.0.19045 - Vulkan (Compatibility) - NVIDIA GeForce GTX 750 Ti (NVIDIA; 31.0.15.3179) - 12th Gen Intel(R) Core(TM) i5-12400F (12 Threads)

Issue description

They simply do not display.
image
image

I started typing random junk in, and it displays the "resource not found" error for all of it. Except it is successful for the image, proving it accepts it as valid.
image

Steps to reproduce

  1. Create a RichTextLabel
  2. Enable bbcode on the richtextlabel
  3. Load a png file and change the import type to "Image"
  4. . Enter it into the text slot with [img] PATH [/img]
  5. Watch as it does not show up

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented Jul 21, 2023

@FireCatMagic Please upload a minimal reproduction project to make this easier to troubleshoot.

@FireCatMagic
Copy link
Author

@FireCatMagic Please upload a minimal reproduction project to make this easier to troubleshoot.

here
broken_bbcode.zip

@Calinou
Copy link
Member

Calinou commented Jul 21, 2023

I can confirm this on 4.2.dev 0f7625a and 4.0.3.stable (Linux). I'm not sure why it's not working on your end, considering it works in the Rich Text BBCode demo.

@ghost
Copy link

ghost commented Jul 21, 2023

I'm not sure why it's not working on your end, considering it works in the Rich Text BBCode demo.

The difference is the "import type" of the asset, Image is being used here, causing the error, instead of Texture2D.

@FireCatMagic
Copy link
Author

I'm not sure why it's not working on your end, considering it works in the Rich Text BBCode demo.

The difference is the "import type" of the asset, Image is being used here, causing the error, instead of Texture2D.

I made it an Image resource rather than a Texture2D because of the docs:
image

https://docs.godotengine.org/en/stable/tutorials/ui/bbcode_in_richtextlabel.html#reference

@FireCatMagic FireCatMagic changed the title [img] richtextlabel BBCode does not display [img] richtextlabel BBCode does not display with "Image" resource Jul 21, 2023
@Calinou
Copy link
Member

Calinou commented Jul 21, 2023

I made it an Image resource rather than a Texture2D because of the docs:

That's why it doesn't work 🙂

Image resources can't be displayed as-is; only their pixel data can be queried on the CPU. Use the default Texture2D import type instead.

See the RichTextLabel implementation, which references Texture2D:

void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region) {

#79737 will help with troubleshooting these issues in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants