Giter Site home page Giter Site logo

Comments (3)

bruvzg avatar bruvzg commented on June 26, 2024

All Godot controls can act as a container, for the buttons (and similar controls) you can always add TLLabel as a child, set it to fill parent control size and ignore mouse input and get fully functional controls.


Another option without porting controls (this will work as module, won't work as GDNative and essentially what was done in shaping PRs) is to add a wrapper for the new font system, most controls draw text by calling .draw(text) from the font and do not care about font internals.

Here's test branch: https://github.com/bruvzg/godot_tl/tree/font_wrapper, but it requires tiny change to the core engine:

diff --git a/scene/resources/font.h b/scene/resources/font.h
index 9b99b85d22..dcedc602ee 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -49,12 +49,12 @@ public:
 	virtual float get_descent() const = 0;
 
 	virtual Size2 get_char_size(CharType p_char, CharType p_next = 0) const = 0;
-	Size2 get_string_size(const String &p_string) const;
+	virtual Size2 get_string_size(const String &p_string) const;
 	Size2 get_wordwrap_string_size(const String &p_string, float p_width) const;
 
 	virtual bool is_distance_field_hint() const = 0;
 
-	void draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1, const Color &p_outline_modulate = Color(1, 1, 1)) const;
+	virtual void draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1, const Color &p_outline_modulate = Color(1, 1, 1)) const;
 	void draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, float p_width, const String &p_text, const Color &p_modulate = Color(1, 1, 1), const Color &p_outline_modulate = Color(1, 1, 1)) const;
 
 	virtual bool has_outline() const { return false; }

This should work with everything except ItemList in the icon view mode, Label, LineEdit, TextEdit and RichTextLabel.

from godot_tl.

mrezai avatar mrezai commented on June 26, 2024

You are very productive, I'm speechless so I'm typing:)
I will test font_wrapper branch tomorrow.
Thanks

from godot_tl.

mrezai avatar mrezai commented on June 26, 2024

I tested font_wrapper branch and I got these errors when I want to set custom fonts but text rendered fine:

ERROR: set_base_font: Type mismatch
   At: modules/godot_tl/src/resources/tl_shaped_string.cpp:838.
ERROR: load: Can't open dynamic font file: ""
   At: modules/godot_tl/src/resources/tl_dynamic_font.cpp:466.

Maybe it's a good idea to mention this branch in README of project because I think using libgdtl as module with this patch is best option for someone that want support CTL languages in games.

from godot_tl.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.