0 votes

exampleCurrently the text looks like this. I set a custom font for the RichTextLabel of font size 48, and the underlined and strikethrough text don't look good. How do I fix this?

asked Mar 15 in Engine by exuin (508 points)

I am honestly no expert on fonts and there might be a quick solution in code, but the best way to start would be this project: https://github.com/Eoin-ONeill-Yokai/Godot-RichTextEffect-SampleProject

and to check out this: https://docs.godotengine.org/en/3.2/classes/class_charfxtransform.html#class-charfxtransform

But looking over it quickly there doesn't seem to be a way to influence underlining or strikethrough text. I guess choosing a different font (or changing the font yourself) would be the fastest way?

I tried opening the scene files in the project and got an "Unexpected end of file" error. But it doesn't seem it has any way of changing line width regardless.

I changed the font, but the lines stayed the same.alice strikethroughMaybe Godot just doesn't have support for this kind of thing yet?

It was pretty long-shot, true. Sorry that it doesn't work; I can't open it myself either anymore.

It really does seem like Godot doesn't have support for this kind of thing yet. Maybe add a feature request on the github page?

Potential solutions I could think of:
You could draw custom shapes in Godot, this page is your friend for that: https://docs.godotengine.org/en/3.2/tutorials/2d/custom_drawing_in_2d.html
It would be a lot of work, but you could do something like add a layer on top of your text and draw shapes that mimic underlined texts and strikethroughs. Not a great solution though, tbh.

A simpler solution might be to have three separate fonts: A normal one, one that is underlined and one that is strikethrough. And then you change the font whenever needed. BBCode does allow you to override the custom font in specific places, I guess that would be the most straightforward approach. You can find lots of tutorials online on making your own fonts, still not a great solution; but I guess an acceptable workaround.

Alright, I'll try out some of your suggestions. Thanks for answering.

1 Answer

0 votes

The underline thickness is currently hardcoded to 1 pixel. There's a pull request that sources the underline position and thickness from the font metadata, but it hasn't been merged yet.

answered Mar 17 by Calinou (6,560 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.