1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-30 18:30:54 +00:00

Merge pull request #111062 from bruvzg/ts_autoinculde_data

Automatically include text server data if project includes translations requiring it.
This commit is contained in:
Rémi Verschelde
2025-12-18 23:30:49 +01:00
11 changed files with 85 additions and 31 deletions

View File

@@ -522,6 +522,15 @@ PackedByteArray TextServerAdvanced::_get_support_data() const {
#endif
}
bool TextServerAdvanced::_is_locale_using_support_data(const String &p_locale) const {
String l = p_locale.get_slicec('_', 0);
if ((l == "my") || (l == "zh") || (l == "ja") || (l == "ko") || (l == "km") || (l == "lo") || (l == "th")) {
return true;
} else {
return false;
}
}
bool TextServerAdvanced::_is_locale_right_to_left(const String &p_locale) const {
String l = p_locale.get_slicec('_', 0);
if ((l == "ar") || (l == "dv") || (l == "he") || (l == "fa") || (l == "ff") || (l == "ku") || (l == "ur")) {
@@ -5747,6 +5756,7 @@ RID TextServerAdvanced::_find_sys_font_for_text(const RID &p_fdef, const String
String locale = (p_language.is_empty()) ? TranslationServer::get_singleton()->get_tool_locale() : p_language;
PackedStringArray fallback_font_name = OS::get_singleton()->get_system_font_path_for_text(font_name, p_text, locale, p_script_code, font_weight, font_stretch, font_style & TextServer::FONT_ITALIC);
print_line("sysf x ", p_text, " --> ", fallback_font_name);
#ifdef GDEXTENSION
for (int fb = 0; fb < fallback_font_name.size(); fb++) {
const String &E = fallback_font_name[fb];

View File

@@ -835,6 +835,7 @@ public:
MODBIND0RC(String, get_support_data_info);
MODBIND1RC(bool, save_support_data, const String &);
MODBIND0RC(PackedByteArray, get_support_data);
MODBIND1RC(bool, is_locale_using_support_data, const String &);
MODBIND1RC(bool, is_locale_right_to_left, const String &);

View File

@@ -183,6 +183,10 @@ PackedByteArray TextServerFallback::_get_support_data() const {
return PackedByteArray(); // No extra data used.
}
bool TextServerFallback::_is_locale_using_support_data(const String &p_locale) const {
return false; // No data support.
}
bool TextServerFallback::_is_locale_right_to_left(const String &p_locale) const {
return false; // No RTL support.
}

View File

@@ -616,6 +616,7 @@ public:
MODBIND0RC(String, get_support_data_info);
MODBIND1RC(bool, save_support_data, const String &);
MODBIND0RC(PackedByteArray, get_support_data);
MODBIND1RC(bool, is_locale_using_support_data, const String &);
MODBIND1RC(bool, is_locale_right_to_left, const String &);