godot_tl icon indicating copy to clipboard operation
godot_tl copied to clipboard

How to use this module in a `Label` control ?

Open slevy85 opened this issue 5 years ago • 2 comments

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 in modules 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.

slevy85 avatar Apr 06 '19 18:04 slevy85

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.

bruvzg avatar Apr 06 '19 18:04 bruvzg

Thank you very much, I had misunderstood then. Now it is clear.

slevy85 avatar Apr 07 '19 09:04 slevy85