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

CharFXTransform missing "character" property for RichTextEffects in v4 #73985

Closed
naturally-intelligent opened this issue Feb 26, 2023 · 9 comments
Labels

Comments

@naturally-intelligent
Copy link

Godot version

4.0.rc5

System information

Ubuntu 20.04 LTS (not relevant)

Issue description

In 4.0 class CharFXTransform:
https://docs.godotengine.org/en/latest/classes/class_charfxtransform.html

We're missing the property "character" that was in v3:
https://docs.godotengine.org/en/stable/classes/class_charfxtransform.html#class-charfxtransform-property-character

Text effects such as Matrix will not work without this data...
https://docs.godotengine.org/en/stable/tutorials/ui/bbcode_in_richtextlabel.html#custom-bbcode-tags-and-text-effects

Or is there is another way to access it? If so it doesn't seem to be documented.

Steps to reproduce

Not applicable

Minimal reproduction project

Documentation is sufficient

@mrcdk
Copy link
Contributor

mrcdk commented Feb 26, 2023

It looks like it changed to glyph_index

@naturally-intelligent
Copy link
Author

It looks like it changed to glyph_index

You're right, thanks. I'll close this issue

@bruvzg
Copy link
Member

bruvzg commented Feb 26, 2023

It's changed to font and glyph_index. Glyph index is font specific and not necessarily correspond to the single character (e.g., multiple characters combined int the ligature will have single CharFXTransform and index of the ligature glyph).

Check latest version of documentation for the updated Matrix example - https://docs.godotengine.org/en/latest/tutorials/ui/bbcode_in_richtextlabel.html

@naturally-intelligent
Copy link
Author

naturally-intelligent commented Feb 26, 2023

The new Matrix bbcode doesn't fully work for me. The scramble happens but the end result text is different than original.

Possibly a bug:

char_fx.glyph_index = get_text_server().font_get_glyph_index(char_fx.font, 1, char_fx.glyph_index, 0)

Shouldn't this "do nothing"? I get scrambled text here due to different characters being returned. Tried a number of fonts...

I'll look into this more and maybe submit a different issue

@bruvzg
Copy link
Member

bruvzg commented Feb 26, 2023

char_fx.glyph_index = get_text_server().font_get_glyph_index(char_fx.font, 1, char_fx.glyph_index, 0)

This should not work, font_get_glyph_index takes character code and returns glyph index (these are different things).

@naturally-intelligent
Copy link
Author

@bruvzg

Wouldn't that mean that var value = char_fx.glyph_index is a mistake in the matrix bbcode? Shouldn't it be getting a character instead of the glyph index? I'm not sure how to get the character from the glyph index...

@naturally-intelligent
Copy link
Author

If I change the last in matrix to char_fx.glyph_index = value instead of calling font_get_glyph_index then it works

@bruvzg
Copy link
Member

bruvzg commented Feb 26, 2023

Wouldn't that mean that var value = char_fx.glyph_index is a mistake

This is a mistake, I think code supposed to use time and character range to generate matrix effect, ignoring original glyph index.

I'm not sure how to get the character from the glyph index

In general, it's not possible to get it in character. Glyph index is content dependent and not always corresponds to the exact character.

@naturally-intelligent
Copy link
Author

naturally-intelligent commented Feb 26, 2023

Seems like there should be a font_get_glyph_index equivalent function, such as font_get_character(glyph_index)?

edit: I'm guessing that isn't possible (I don't quite get why), but if it isn't, then the fix to matrix bbcode would be char_fx.glyph_index = value at the end

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

No branches or pull requests

4 participants