godot_tl
godot_tl copied to clipboard
How to use this module in a `Label` control ?
Hi, first of all thank you for this huge amount of work and this great module.
I am trying to make it work and I am not sure I understand everything, maybe you can help me.
I would like my Label
component to display arabic (RTL) so here is what I did:
- rebuild godot with the
godot-tl
inmodules
folders : OK - make a new project with a simpe Label
- make the Label arabic
- add a Dynamic Font and a DynamicFontData arabic (NotoSansArabic-Regular.ttf)
It didn't display right.
I have tried to use the code in the demos you gave and it prints arabic good :
var font1
var sstring1 : TLShapedString
func _init():
var face1 = TLDynamicFontFace.new()
face1.load("res://NotoSansArabic-Regular.ttf")
font1 = TLFontFamily.new()
font1.set_face("Default", face1)
sstring1 = TLShapedString.new()
sstring1.set_base_font_size(72)
sstring1.set_base_font(font1)
sstring1.set_base_font_style("Default")
sstring1.set_text("اجري")
func _draw():
var ofs = sstring1.get_ascent() + 20
sstring1.draw(get_canvas_item(), Vector2(20, ofs), Color(0, 0, 1))
I can see that the text is correctly displayed, but I don't how to integrate this in an existing project which has mostly Label
controls.
Thanks for your help.
You can't. This module doesn't affect any of existing Godot controls, it's only provide TLShapedString
/TLShapedAttributedString
interfaces, and it's own TLProtoControl
control (which is mostly intended as a demo).
Or you can try to use https://github.com/godotengine/godot/pull/21791 PR instead, it uses same codebase, and have integration for Label
and LineEdit
.
Thank you very much, I had misunderstood then. Now it is clear.