summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/display_server_android.cpp22
-rw-r--r--platform/android/display_server_android.h5
-rw-r--r--platform/android/export/export_plugin.cpp4
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt5
-rw-r--r--platform/android/os_android.cpp226
-rw-r--r--platform/android/os_android.h21
-rw-r--r--platform/ios/display_server_ios.h5
-rw-r--r--platform/ios/display_server_ios.mm8
-rw-r--r--platform/ios/os_ios.h7
-rw-r--r--platform/ios/os_ios.mm140
-rw-r--r--platform/linuxbsd/fontconfig-so_wrap.c380
-rw-r--r--platform/linuxbsd/fontconfig-so_wrap.h142
-rw-r--r--platform/linuxbsd/joypad_linux.cpp2
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp152
-rw-r--r--platform/linuxbsd/os_linuxbsd.h13
-rw-r--r--platform/linuxbsd/x11/display_server_x11.cpp77
-rw-r--r--platform/linuxbsd/x11/display_server_x11.h6
-rw-r--r--platform/macos/display_server_macos.h3
-rw-r--r--platform/macos/display_server_macos.mm23
-rw-r--r--platform/macos/export/export_plugin.cpp131
-rw-r--r--platform/macos/export/plist.cpp2
-rw-r--r--platform/macos/os_macos.h7
-rw-r--r--platform/macos/os_macos.mm140
-rw-r--r--platform/web/display_server_web.cpp12
-rw-r--r--platform/web/display_server_web.h5
-rw-r--r--platform/windows/detect.py11
-rw-r--r--platform/windows/display_server_windows.cpp34
-rw-r--r--platform/windows/display_server_windows.h3
-rw-r--r--platform/windows/os_windows.cpp303
-rw-r--r--platform/windows/os_windows.h20
30 files changed, 1777 insertions, 132 deletions
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index f76f3844e9..9c796a8c07 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -221,7 +221,7 @@ float DisplayServerAndroid::screen_get_refresh_rate(int p_screen) const {
return godot_io_java->get_screen_refresh_rate(SCREEN_REFRESH_RATE_FALLBACK);
}
-bool DisplayServerAndroid::screen_is_touchscreen(int p_screen) const {
+bool DisplayServerAndroid::is_touchscreen_available() const {
return true;
}
@@ -316,9 +316,6 @@ DisplayServer::WindowID DisplayServerAndroid::get_window_at_screen_position(cons
int64_t DisplayServerAndroid::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const {
ERR_FAIL_COND_V(p_window != MAIN_WINDOW_ID, 0);
switch (p_handle_type) {
- case DISPLAY_HANDLE: {
- return 0; // Not supported.
- }
case WINDOW_HANDLE: {
return reinterpret_cast<int64_t>(static_cast<OS_Android *>(OS::get_singleton())->get_godot_java()->get_activity());
}
@@ -326,8 +323,17 @@ int64_t DisplayServerAndroid::window_get_native_handle(HandleType p_handle_type,
return 0; // Not supported.
}
#ifdef GLES3_ENABLED
+ case DISPLAY_HANDLE: {
+ if (rendering_driver == "opengl3") {
+ return reinterpret_cast<int64_t>(eglGetCurrentDisplay());
+ }
+ return 0;
+ }
case OPENGL_CONTEXT: {
- return reinterpret_cast<int64_t>(eglGetCurrentContext());
+ if (rendering_driver == "opengl3") {
+ return reinterpret_cast<int64_t>(eglGetCurrentContext());
+ }
+ return 0;
}
#endif
default: {
@@ -360,6 +366,10 @@ Point2i DisplayServerAndroid::window_get_position(DisplayServer::WindowID p_wind
return Point2i();
}
+Point2i DisplayServerAndroid::window_get_position_with_decorations(DisplayServer::WindowID p_window) const {
+ return Point2i();
+}
+
void DisplayServerAndroid::window_set_position(const Point2i &p_position, DisplayServer::WindowID p_window) {
// Not supported on Android.
}
@@ -392,7 +402,7 @@ Size2i DisplayServerAndroid::window_get_size(DisplayServer::WindowID p_window) c
return OS_Android::get_singleton()->get_display_size();
}
-Size2i DisplayServerAndroid::window_get_real_size(DisplayServer::WindowID p_window) const {
+Size2i DisplayServerAndroid::window_get_size_with_decorations(DisplayServer::WindowID p_window) const {
return OS_Android::get_singleton()->get_display_size();
}
diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h
index c7f4d8046f..9ed07ca971 100644
--- a/platform/android/display_server_android.h
+++ b/platform/android/display_server_android.h
@@ -121,7 +121,7 @@ public:
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
- virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
+ virtual bool is_touchscreen_available() const override;
virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), VirtualKeyboardType p_type = KEYBOARD_TYPE_DEFAULT, int p_max_length = -1, int p_cursor_start = -1, int p_cursor_end = -1) override;
virtual void virtual_keyboard_hide() override;
@@ -150,6 +150,7 @@ public:
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Point2i window_get_position_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
@@ -162,7 +163,7 @@ public:
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
- virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Size2i window_get_size_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 737e25b270..795a542ed5 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -703,7 +703,7 @@ Error EditorExportPlatformAndroid::save_apk_so(void *p_userdata, const SharedObj
exported = true;
String abi = abis[abi_index].abi;
String dst_path = String("lib").path_join(abi).path_join(p_so.path.get_file());
- Vector<uint8_t> array = FileAccess::get_file_as_array(p_so.path);
+ Vector<uint8_t> array = FileAccess::get_file_as_bytes(p_so.path);
Error store_err = store_in_apk(ed, dst_path, array);
ERR_FAIL_COND_V_MSG(store_err, store_err, "Cannot store in apk file '" + dst_path + "'.");
}
@@ -748,7 +748,7 @@ Error EditorExportPlatformAndroid::copy_gradle_so(void *p_userdata, const Shared
String abi = abis[abi_index].abi;
String filename = p_so.path.get_file();
String dst_path = base.path_join(type).path_join(abi).path_join(filename);
- Vector<uint8_t> data = FileAccess::get_file_as_array(p_so.path);
+ Vector<uint8_t> data = FileAccess::get_file_as_bytes(p_so.path);
print_verbose("Copying .so file from " + p_so.path + " to " + dst_path);
Error err = store_file_at_path(dst_path, data);
ERR_FAIL_COND_V_MSG(err, err, "Failed to copy .so file from " + p_so.path + " to " + dst_path);
diff --git a/platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt b/platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt
index c9282dd247..1a3576a6a9 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt
@@ -90,6 +90,11 @@ internal enum class StorageScope {
return APP
}
+ var rootDir: String? = System.getenv("ANDROID_ROOT")
+ if (rootDir != null && canonicalPathFile.startsWith(rootDir)) {
+ return APP
+ }
+
if (sharedDir != null && canonicalPathFile.startsWith(sharedDir)) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
// Before R, apps had access to shared storage so long as they have the right
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 4f81e4bccd..317a63f21f 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -337,6 +337,229 @@ String OS_Android::get_data_path() const {
return get_user_data_dir();
}
+void OS_Android::_load_system_font_config() {
+ font_aliases.clear();
+ fonts.clear();
+ font_names.clear();
+
+ Ref<XMLParser> parser;
+ parser.instantiate();
+
+ Error err = parser->open(String(getenv("ANDROID_ROOT")).path_join("/etc/fonts.xml"));
+ if (err == OK) {
+ bool in_font_node = false;
+ String fb, fn;
+ FontInfo fi;
+
+ while (parser->read() == OK) {
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
+ in_font_node = false;
+ if (parser->get_node_name() == "familyset") {
+ int ver = parser->has_attribute("version") ? parser->get_attribute_value("version").to_int() : 0;
+ if (ver < 21) {
+ ERR_PRINT(vformat("Unsupported font config version %s", ver));
+ break;
+ }
+ } else if (parser->get_node_name() == "alias") {
+ String name = parser->has_attribute("name") ? parser->get_attribute_value("name").strip_edges() : String();
+ String to = parser->has_attribute("to") ? parser->get_attribute_value("to").strip_edges() : String();
+ if (!name.is_empty() && !to.is_empty()) {
+ font_aliases[name] = to;
+ }
+ } else if (parser->get_node_name() == "family") {
+ fn = parser->has_attribute("name") ? parser->get_attribute_value("name").strip_edges() : String();
+ String lang_code = parser->has_attribute("lang") ? parser->get_attribute_value("lang").strip_edges() : String();
+ Vector<String> lang_codes = lang_code.split(",");
+ for (int i = 0; i < lang_codes.size(); i++) {
+ Vector<String> lang_code_elements = lang_codes[i].split("-");
+ if (lang_code_elements.size() >= 1 && lang_code_elements[0] != "und") {
+ // Add missing script codes.
+ if (lang_code_elements[0] == "ko") {
+ fi.script.insert("Hani");
+ fi.script.insert("Hang");
+ }
+ if (lang_code_elements[0] == "ja") {
+ fi.script.insert("Hani");
+ fi.script.insert("Kana");
+ fi.script.insert("Hira");
+ }
+ if (!lang_code_elements[0].is_empty()) {
+ fi.lang.insert(lang_code_elements[0]);
+ }
+ }
+ if (lang_code_elements.size() >= 2) {
+ // Add common codes for variants and remove variants not supported by HarfBuzz/ICU.
+ if (lang_code_elements[1] == "Aran") {
+ fi.script.insert("Arab");
+ }
+ if (lang_code_elements[1] == "Cyrs") {
+ fi.script.insert("Cyrl");
+ }
+ if (lang_code_elements[1] == "Hanb") {
+ fi.script.insert("Hani");
+ fi.script.insert("Bopo");
+ }
+ if (lang_code_elements[1] == "Hans" || lang_code_elements[1] == "Hant") {
+ fi.script.insert("Hani");
+ }
+ if (lang_code_elements[1] == "Syrj" || lang_code_elements[1] == "Syre" || lang_code_elements[1] == "Syrn") {
+ fi.script.insert("Syrc");
+ }
+ if (!lang_code_elements[1].is_empty() && lang_code_elements[1] != "Zsym" && lang_code_elements[1] != "Zsye" && lang_code_elements[1] != "Zmth") {
+ fi.script.insert(lang_code_elements[1]);
+ }
+ }
+ }
+ } else if (parser->get_node_name() == "font") {
+ in_font_node = true;
+ fb = parser->has_attribute("fallbackFor") ? parser->get_attribute_value("fallbackFor").strip_edges() : String();
+ fi.weight = parser->has_attribute("weight") ? parser->get_attribute_value("weight").to_int() : 400;
+ fi.italic = parser->has_attribute("style") && parser->get_attribute_value("style").strip_edges() == "italic";
+ }
+ }
+ if (parser->get_node_type() == XMLParser::NODE_TEXT) {
+ if (in_font_node) {
+ fi.filename = parser->get_node_data().strip_edges();
+ fi.font_name = fn;
+ if (!fb.is_empty() && fn.is_empty()) {
+ fi.font_name = fb;
+ fi.priority = 2;
+ }
+ if (fi.font_name.is_empty()) {
+ fi.font_name = "sans-serif";
+ fi.priority = 5;
+ }
+ if (fi.font_name.ends_with("-condensed")) {
+ fi.stretch = 75;
+ fi.font_name = fi.font_name.trim_suffix("-condensed");
+ }
+ fonts.push_back(fi);
+ font_names.insert(fi.font_name);
+ }
+ }
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END) {
+ in_font_node = false;
+ if (parser->get_node_name() == "font") {
+ fb = String();
+ fi.font_name = String();
+ fi.priority = 0;
+ fi.weight = 400;
+ fi.stretch = 100;
+ fi.italic = false;
+ } else if (parser->get_node_name() == "family") {
+ fi = FontInfo();
+ fn = String();
+ }
+ }
+ }
+ parser->close();
+ } else {
+ ERR_PRINT("Unable to load font config");
+ }
+
+ font_config_loaded = true;
+}
+
+Vector<String> OS_Android::get_system_fonts() const {
+ if (!font_config_loaded) {
+ const_cast<OS_Android *>(this)->_load_system_font_config();
+ }
+ Vector<String> ret;
+ for (const String &E : font_names) {
+ ret.push_back(E);
+ }
+ return ret;
+}
+
+Vector<String> OS_Android::get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale, const String &p_script, int p_weight, int p_stretch, bool p_italic) const {
+ if (!font_config_loaded) {
+ const_cast<OS_Android *>(this)->_load_system_font_config();
+ }
+ String font_name = p_font_name.to_lower();
+ if (font_aliases.has(font_name)) {
+ font_name = font_aliases[font_name];
+ }
+ String root = String(getenv("ANDROID_ROOT")).path_join("fonts");
+ String lang_prefix = p_locale.split("_")[0];
+ Vector<String> ret;
+ int best_score = 0;
+ for (const List<FontInfo>::Element *E = fonts.front(); E; E = E->next()) {
+ int score = 0;
+ if (!E->get().script.is_empty() && !p_script.is_empty() && !E->get().script.has(p_script)) {
+ continue;
+ }
+ float sim = E->get().font_name.similarity(font_name);
+ if (sim > 0.0) {
+ score += (60 * sim + 5 - E->get().priority);
+ }
+ if (E->get().lang.has(p_locale)) {
+ score += 120;
+ } else if (E->get().lang.has(lang_prefix)) {
+ score += 115;
+ }
+ if (E->get().script.has(p_script)) {
+ score += 240;
+ }
+ score += (20 - Math::abs(E->get().weight - p_weight) / 50);
+ score += (20 - Math::abs(E->get().stretch - p_stretch) / 10);
+ if (E->get().italic == p_italic) {
+ score += 30;
+ }
+ if (score > best_score) {
+ best_score = score;
+ if (ret.find(root.path_join(E->get().filename)) < 0) {
+ ret.insert(0, root.path_join(E->get().filename));
+ }
+ } else if (score == best_score || E->get().script.is_empty()) {
+ if (ret.find(root.path_join(E->get().filename)) < 0) {
+ ret.push_back(root.path_join(E->get().filename));
+ }
+ }
+ if (score >= 490) {
+ break; // Perfect match.
+ }
+ }
+
+ return ret;
+}
+
+String OS_Android::get_system_font_path(const String &p_font_name, int p_weight, int p_stretch, bool p_italic) const {
+ if (!font_config_loaded) {
+ const_cast<OS_Android *>(this)->_load_system_font_config();
+ }
+ String font_name = p_font_name.to_lower();
+ if (font_aliases.has(font_name)) {
+ font_name = font_aliases[font_name];
+ }
+ String root = String(getenv("ANDROID_ROOT")).path_join("fonts");
+
+ int best_score = 0;
+ const List<FontInfo>::Element *best_match = nullptr;
+
+ for (const List<FontInfo>::Element *E = fonts.front(); E; E = E->next()) {
+ int score = 0;
+ if (E->get().font_name == font_name) {
+ score += (65 - E->get().priority);
+ }
+ score += (20 - Math::abs(E->get().weight - p_weight) / 50);
+ score += (20 - Math::abs(E->get().stretch - p_stretch) / 10);
+ if (E->get().italic == p_italic) {
+ score += 30;
+ }
+ if (score >= 60 && score > best_score) {
+ best_score = score;
+ best_match = E;
+ }
+ if (score >= 140) {
+ break; // Perfect match.
+ }
+ }
+ if (best_match) {
+ return root.path_join(best_match->get().filename);
+ }
+ return String();
+}
+
String OS_Android::get_executable_path() const {
// Since unix process creation is restricted on Android, we bypass
// OS_Unix::get_executable_path() so we can return ANDROID_EXEC_PATH.
@@ -449,6 +672,9 @@ String OS_Android::get_config_path() const {
}
bool OS_Android::_check_internal_feature_support(const String &p_feature) {
+ if (p_feature == "system_fonts") {
+ return true;
+ }
if (p_feature == "mobile") {
return true;
}
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index d6546a3507..9034615fc4 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -62,9 +62,26 @@ private:
MainLoop *main_loop = nullptr;
+ struct FontInfo {
+ String font_name;
+ HashSet<String> lang;
+ HashSet<String> script;
+ int weight = 400;
+ int stretch = 100;
+ bool italic = false;
+ int priority = 0;
+ String filename;
+ };
+
+ HashMap<String, String> font_aliases;
+ List<FontInfo> fonts;
+ HashSet<String> font_names;
+ bool font_config_loaded = false;
+
GodotJavaWrapper *godot_java = nullptr;
GodotIOJavaWrapper *godot_io_java = nullptr;
+ void _load_system_font_config();
String get_system_property(const char *key) const;
public:
@@ -114,6 +131,10 @@ public:
ANativeWindow *get_native_window() const;
virtual Error shell_open(String p_uri) override;
+
+ virtual Vector<String> get_system_fonts() const override;
+ virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
+ virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
virtual String get_executable_path() const override;
virtual String get_user_data_dir() const override;
virtual String get_data_path() const override;
diff --git a/platform/ios/display_server_ios.h b/platform/ios/display_server_ios.h
index 447f919139..4901eeefaf 100644
--- a/platform/ios/display_server_ios.h
+++ b/platform/ios/display_server_ios.h
@@ -162,6 +162,7 @@ public:
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Point2i window_get_position_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
@@ -174,7 +175,7 @@ public:
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
- virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Size2i window_get_size_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
@@ -199,7 +200,7 @@ public:
virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override;
virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override;
- virtual bool screen_is_touchscreen(int p_screen) const override;
+ virtual bool is_touchscreen_available() const override;
virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_length, int p_cursor_start, int p_cursor_end) override;
virtual void virtual_keyboard_hide() override;
diff --git a/platform/ios/display_server_ios.mm b/platform/ios/display_server_ios.mm
index 6793b40dd4..ed1bc499ed 100644
--- a/platform/ios/display_server_ios.mm
+++ b/platform/ios/display_server_ios.mm
@@ -496,6 +496,10 @@ Point2i DisplayServerIOS::window_get_position(WindowID p_window) const {
return Point2i();
}
+Point2i DisplayServerIOS::window_get_position_with_decorations(WindowID p_window) const {
+ return Point2i();
+}
+
void DisplayServerIOS::window_set_position(const Point2i &p_position, WindowID p_window) {
// Probably not supported for single window iOS app
}
@@ -529,7 +533,7 @@ Size2i DisplayServerIOS::window_get_size(WindowID p_window) const {
return Size2i(screenBounds.size.width, screenBounds.size.height) * screen_get_max_scale();
}
-Size2i DisplayServerIOS::window_get_real_size(WindowID p_window) const {
+Size2i DisplayServerIOS::window_get_size_with_decorations(WindowID p_window) const {
return window_get_size(p_window);
}
@@ -581,7 +585,7 @@ bool DisplayServerIOS::can_any_window_draw() const {
return true;
}
-bool DisplayServerIOS::screen_is_touchscreen(int p_screen) const {
+bool DisplayServerIOS::is_touchscreen_available() const {
return true;
}
diff --git a/platform/ios/os_ios.h b/platform/ios/os_ios.h
index 3560de7486..186efd14a8 100644
--- a/platform/ios/os_ios.h
+++ b/platform/ios/os_ios.h
@@ -73,6 +73,10 @@ private:
bool is_focused = false;
+ CGFloat _weight_to_ct(int p_weight) const;
+ CGFloat _stretch_to_ct(int p_stretch) const;
+ String _get_default_fontname(const String &p_font_name) const;
+
void deinitialize_modules();
public:
@@ -90,7 +94,8 @@ public:
virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override;
virtual Vector<String> get_system_fonts() const override;
- virtual String get_system_font_path(const String &p_font_name, bool p_bold = false, bool p_italic = false) const override;
+ virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
+ virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false, String *r_resolved_path = nullptr) override;
virtual Error close_dynamic_library(void *p_library_handle) override;
diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm
index 9a8cfc2593..9617627b6f 100644
--- a/platform/ios/os_ios.mm
+++ b/platform/ios/os_ios.mm
@@ -334,9 +334,7 @@ Vector<String> OS_IOS::get_system_fonts() const {
return ret;
}
-String OS_IOS::get_system_font_path(const String &p_font_name, bool p_bold, bool p_italic) const {
- String ret;
-
+String OS_IOS::_get_default_fontname(const String &p_font_name) const {
String font_name = p_font_name;
if (font_name.to_lower() == "sans-serif") {
font_name = "Helvetica";
@@ -349,21 +347,153 @@ String OS_IOS::get_system_font_path(const String &p_font_name, bool p_bold, bool
} else if (font_name.to_lower() == "cursive") {
font_name = "Apple Chancery";
};
+ return font_name;
+}
+
+CGFloat OS_IOS::_weight_to_ct(int p_weight) const {
+ if (p_weight < 150) {
+ return -0.80;
+ } else if (p_weight < 250) {
+ return -0.60;
+ } else if (p_weight < 350) {
+ return -0.40;
+ } else if (p_weight < 450) {
+ return 0.0;
+ } else if (p_weight < 550) {
+ return 0.23;
+ } else if (p_weight < 650) {
+ return 0.30;
+ } else if (p_weight < 750) {
+ return 0.40;
+ } else if (p_weight < 850) {
+ return 0.56;
+ } else if (p_weight < 925) {
+ return 0.62;
+ } else {
+ return 1.00;
+ }
+}
+
+CGFloat OS_IOS::_stretch_to_ct(int p_stretch) const {
+ if (p_stretch < 56) {
+ return -0.5;
+ } else if (p_stretch < 69) {
+ return -0.37;
+ } else if (p_stretch < 81) {
+ return -0.25;
+ } else if (p_stretch < 93) {
+ return -0.13;
+ } else if (p_stretch < 106) {
+ return 0.0;
+ } else if (p_stretch < 137) {
+ return 0.13;
+ } else if (p_stretch < 144) {
+ return 0.25;
+ } else if (p_stretch < 162) {
+ return 0.37;
+ } else {
+ return 0.5;
+ }
+}
+
+Vector<String> OS_IOS::get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale, const String &p_script, int p_weight, int p_stretch, bool p_italic) const {
+ Vector<String> ret;
+ String font_name = _get_default_fontname(p_font_name);
+
+ CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, font_name.utf8().get_data(), kCFStringEncodingUTF8);
+ CTFontSymbolicTraits traits = 0;
+ if (p_weight >= 700) {
+ traits |= kCTFontBoldTrait;
+ }
+ if (p_italic) {
+ traits |= kCTFontItalicTrait;
+ }
+ if (p_stretch < 100) {
+ traits |= kCTFontCondensedTrait;
+ } else if (p_stretch > 100) {
+ traits |= kCTFontExpandedTrait;
+ }
+
+ CFNumberRef sym_traits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &traits);
+ CFMutableDictionaryRef traits_dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
+ CFDictionaryAddValue(traits_dict, kCTFontSymbolicTrait, sym_traits);
+
+ CGFloat weight = _weight_to_ct(p_weight);
+ CFNumberRef font_weight = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &weight);
+ CFDictionaryAddValue(traits_dict, kCTFontWeightTrait, font_weight);
+
+ CGFloat stretch = _stretch_to_ct(p_stretch);
+ CFNumberRef font_stretch = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &stretch);
+ CFDictionaryAddValue(traits_dict, kCTFontWidthTrait, font_stretch);
+
+ CFMutableDictionaryRef attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
+ CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, name);
+ CFDictionaryAddValue(attributes, kCTFontTraitsAttribute, traits_dict);
+
+ CTFontDescriptorRef font = CTFontDescriptorCreateWithAttributes(attributes);
+ if (font) {
+ CTFontRef family = CTFontCreateWithFontDescriptor(font, 0, nullptr);
+ CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, p_text.utf8().get_data(), kCFStringEncodingUTF8);
+ CFRange range = CFRangeMake(0, CFStringGetLength(string));
+ CTFontRef fallback_family = CTFontCreateForString(family, string, range);
+ if (fallback_family) {
+ CTFontDescriptorRef fallback_font = CTFontCopyFontDescriptor(fallback_family);
+ if (fallback_font) {
+ CFURLRef url = (CFURLRef)CTFontDescriptorCopyAttribute(fallback_font, kCTFontURLAttribute);
+ if (url) {
+ NSString *font_path = [NSString stringWithString:[(__bridge NSURL *)url path]];
+ ret.push_back(String::utf8([font_path UTF8String]));
+ CFRelease(url);
+ }
+ CFRelease(fallback_font);
+ }
+ CFRelease(fallback_family);
+ }
+ CFRelease(string);
+ CFRelease(font);
+ }
+
+ CFRelease(attributes);
+ CFRelease(traits_dict);
+ CFRelease(sym_traits);
+ CFRelease(font_stretch);
+ CFRelease(font_weight);
+ CFRelease(name);
+
+ return ret;
+}
+
+String OS_IOS::get_system_font_path(const String &p_font_name, int p_weight, int p_stretch, bool p_italic) const {
+ String ret;
+ String font_name = _get_default_fontname(p_font_name);
CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, font_name.utf8().get_data(), kCFStringEncodingUTF8);
CTFontSymbolicTraits traits = 0;
- if (p_bold) {
+ if (p_weight >= 700) {
traits |= kCTFontBoldTrait;
}
if (p_italic) {
traits |= kCTFontItalicTrait;
}
+ if (p_stretch < 100) {
+ traits |= kCTFontCondensedTrait;
+ } else if (p_stretch > 100) {
+ traits |= kCTFontExpandedTrait;
+ }
CFNumberRef sym_traits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &traits);
CFMutableDictionaryRef traits_dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
CFDictionaryAddValue(traits_dict, kCTFontSymbolicTrait, sym_traits);
+ CGFloat weight = _weight_to_ct(p_weight);
+ CFNumberRef font_weight = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &weight);
+ CFDictionaryAddValue(traits_dict, kCTFontWeightTrait, font_weight);
+
+ CGFloat stretch = _stretch_to_ct(p_stretch);
+ CFNumberRef font_stretch = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &stretch);
+ CFDictionaryAddValue(traits_dict, kCTFontWidthTrait, font_stretch);
+
CFMutableDictionaryRef attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, name);
CFDictionaryAddValue(attributes, kCTFontTraitsAttribute, traits_dict);
@@ -382,6 +512,8 @@ String OS_IOS::get_system_font_path(const String &p_font_name, bool p_bold, bool
CFRelease(attributes);
CFRelease(traits_dict);
CFRelease(sym_traits);
+ CFRelease(font_stretch);
+ CFRelease(font_weight);
CFRelease(name);
return ret;
diff --git a/platform/linuxbsd/fontconfig-so_wrap.c b/platform/linuxbsd/fontconfig-so_wrap.c
index 1a915faf98..a428cf1fb4 100644
--- a/platform/linuxbsd/fontconfig-so_wrap.c
+++ b/platform/linuxbsd/fontconfig-so_wrap.c
@@ -1,7 +1,7 @@
// This file is generated. Do not edit!
// see https://github.com/hpvb/dynload-wrapper for details
-// generated by ./generate-wrapper.py 0.3 on 2022-07-29 05:40:07
-// flags: ./generate-wrapper.py --include /usr/include/fontconfig/fontconfig.h --sys-include <fontconfig/fontconfig.h> --soname libfontconfig.so --init-name fontconfig --output-header fontconfig-so_wrap.h --output-implementation fontconfig-so_wrap.c --omit-prefix FcCharSet
+// generated by ./generate-wrapper.py 0.3 on 2022-11-22 10:28:00
+// flags: ./generate-wrapper.py --include /usr/include/fontconfig/fontconfig.h --sys-include <fontconfig/fontconfig.h> --soname libfontconfig.so --init-name fontconfig --output-header fontconfig-so_wrap.h --output-implementation fontconfig-so_wrap.c --omit-prefix FcCharSetFirst --omit-prefix FcCharSetNext
//
#include <stdint.h>
@@ -18,6 +18,8 @@
#define FcDirCacheValid FcDirCacheValid_dylibloader_orig_fontconfig
#define FcDirCacheClean FcDirCacheClean_dylibloader_orig_fontconfig
#define FcCacheCreateTagFile FcCacheCreateTagFile_dylibloader_orig_fontconfig
+#define FcDirCacheCreateUUID FcDirCacheCreateUUID_dylibloader_orig_fontconfig
+#define FcDirCacheDeleteUUID FcDirCacheDeleteUUID_dylibloader_orig_fontconfig
#define FcConfigHome FcConfigHome_dylibloader_orig_fontconfig
#define FcConfigEnableHome FcConfigEnableHome_dylibloader_orig_fontconfig
#define FcConfigFilename FcConfigFilename_dylibloader_orig_fontconfig
@@ -44,6 +46,26 @@
#define FcConfigSubstitute FcConfigSubstitute_dylibloader_orig_fontconfig
#define FcConfigGetSysRoot FcConfigGetSysRoot_dylibloader_orig_fontconfig
#define FcConfigSetSysRoot FcConfigSetSysRoot_dylibloader_orig_fontconfig
+#define FcConfigFileInfoIterInit FcConfigFileInfoIterInit_dylibloader_orig_fontconfig
+#define FcConfigFileInfoIterNext FcConfigFileInfoIterNext_dylibloader_orig_fontconfig
+#define FcConfigFileInfoIterGet FcConfigFileInfoIterGet_dylibloader_orig_fontconfig
+#define FcCharSetCreate FcCharSetCreate_dylibloader_orig_fontconfig
+#define FcCharSetNew FcCharSetNew_dylibloader_orig_fontconfig
+#define FcCharSetDestroy FcCharSetDestroy_dylibloader_orig_fontconfig
+#define FcCharSetAddChar FcCharSetAddChar_dylibloader_orig_fontconfig
+#define FcCharSetDelChar FcCharSetDelChar_dylibloader_orig_fontconfig
+#define FcCharSetCopy FcCharSetCopy_dylibloader_orig_fontconfig
+#define FcCharSetEqual FcCharSetEqual_dylibloader_orig_fontconfig
+#define FcCharSetIntersect FcCharSetIntersect_dylibloader_orig_fontconfig
+#define FcCharSetUnion FcCharSetUnion_dylibloader_orig_fontconfig
+#define FcCharSetSubtract FcCharSetSubtract_dylibloader_orig_fontconfig
+#define FcCharSetMerge FcCharSetMerge_dylibloader_orig_fontconfig
+#define FcCharSetHasChar FcCharSetHasChar_dylibloader_orig_fontconfig
+#define FcCharSetCount FcCharSetCount_dylibloader_orig_fontconfig
+#define FcCharSetIntersectCount FcCharSetIntersectCount_dylibloader_orig_fontconfig
+#define FcCharSetSubtractCount FcCharSetSubtractCount_dylibloader_orig_fontconfig
+#define FcCharSetIsSubset FcCharSetIsSubset_dylibloader_orig_fontconfig
+#define FcCharSetCoverage FcCharSetCoverage_dylibloader_orig_fontconfig
#define FcValuePrint FcValuePrint_dylibloader_orig_fontconfig
#define FcPatternPrint FcPatternPrint_dylibloader_orig_fontconfig
#define FcFontSetPrint FcFontSetPrint_dylibloader_orig_fontconfig
@@ -59,6 +81,7 @@
#define FcDirCacheLoadFile FcDirCacheLoadFile_dylibloader_orig_fontconfig
#define FcDirCacheUnload FcDirCacheUnload_dylibloader_orig_fontconfig
#define FcFreeTypeQuery FcFreeTypeQuery_dylibloader_orig_fontconfig
+#define FcFreeTypeQueryAll FcFreeTypeQueryAll_dylibloader_orig_fontconfig
#define FcFontSetCreate FcFontSetCreate_dylibloader_orig_fontconfig
#define FcFontSetDestroy FcFontSetDestroy_dylibloader_orig_fontconfig
#define FcFontSetAdd FcFontSetAdd_dylibloader_orig_fontconfig
@@ -129,6 +152,7 @@
#define FcValueEqual FcValueEqual_dylibloader_orig_fontconfig
#define FcValueSave FcValueSave_dylibloader_orig_fontconfig
#define FcPatternDestroy FcPatternDestroy_dylibloader_orig_fontconfig
+#define FcPatternObjectCount FcPatternObjectCount_dylibloader_orig_fontconfig
#define FcPatternEqual FcPatternEqual_dylibloader_orig_fontconfig
#define FcPatternEqualSubset FcPatternEqualSubset_dylibloader_orig_fontconfig
#define FcPatternHash FcPatternHash_dylibloader_orig_fontconfig
@@ -162,8 +186,18 @@
#define FcRangeDestroy FcRangeDestroy_dylibloader_orig_fontconfig
#define FcRangeCopy FcRangeCopy_dylibloader_orig_fontconfig
#define FcRangeGetDouble FcRangeGetDouble_dylibloader_orig_fontconfig
+#define FcPatternIterStart FcPatternIterStart_dylibloader_orig_fontconfig
+#define FcPatternIterNext FcPatternIterNext_dylibloader_orig_fontconfig
+#define FcPatternIterEqual FcPatternIterEqual_dylibloader_orig_fontconfig
+#define FcPatternFindIter FcPatternFindIter_dylibloader_orig_fontconfig
+#define FcPatternIterIsValid FcPatternIterIsValid_dylibloader_orig_fontconfig
+#define FcPatternIterGetObject FcPatternIterGetObject_dylibloader_orig_fontconfig
+#define FcPatternIterValueCount FcPatternIterValueCount_dylibloader_orig_fontconfig
+#define FcPatternIterGetValue FcPatternIterGetValue_dylibloader_orig_fontconfig
#define FcWeightFromOpenType FcWeightFromOpenType_dylibloader_orig_fontconfig
+#define FcWeightFromOpenTypeDouble FcWeightFromOpenTypeDouble_dylibloader_orig_fontconfig
#define FcWeightToOpenType FcWeightToOpenType_dylibloader_orig_fontconfig
+#define FcWeightToOpenTypeDouble FcWeightToOpenTypeDouble_dylibloader_orig_fontconfig
#define FcStrCopy FcStrCopy_dylibloader_orig_fontconfig
#define FcStrCopyFilename FcStrCopyFilename_dylibloader_orig_fontconfig
#define FcStrPlus FcStrPlus_dylibloader_orig_fontconfig
@@ -207,6 +241,8 @@
#undef FcDirCacheValid
#undef FcDirCacheClean
#undef FcCacheCreateTagFile
+#undef FcDirCacheCreateUUID
+#undef FcDirCacheDeleteUUID
#undef FcConfigHome
#undef FcConfigEnableHome
#undef FcConfigFilename
@@ -233,6 +269,26 @@
#undef FcConfigSubstitute
#undef FcConfigGetSysRoot
#undef FcConfigSetSysRoot
+#undef FcConfigFileInfoIterInit
+#undef FcConfigFileInfoIterNext
+#undef FcConfigFileInfoIterGet
+#undef FcCharSetCreate
+#undef FcCharSetNew
+#undef FcCharSetDestroy
+#undef FcCharSetAddChar
+#undef FcCharSetDelChar
+#undef FcCharSetCopy
+#undef FcCharSetEqual
+#undef FcCharSetIntersect
+#undef FcCharSetUnion
+#undef FcCharSetSubtract
+#undef FcCharSetMerge
+#undef FcCharSetHasChar
+#undef FcCharSetCount
+#undef FcCharSetIntersectCount
+#undef FcCharSetSubtractCount
+#undef FcCharSetIsSubset
+#undef FcCharSetCoverage
#undef FcValuePrint
#undef FcPatternPrint
#undef FcFontSetPrint
@@ -248,6 +304,7 @@
#undef FcDirCacheLoadFile
#undef FcDirCacheUnload
#undef FcFreeTypeQuery
+#undef FcFreeTypeQueryAll
#undef FcFontSetCreate
#undef FcFontSetDestroy
#undef FcFontSetAdd
@@ -318,6 +375,7 @@
#undef FcValueEqual
#undef FcValueSave
#undef FcPatternDestroy
+#undef FcPatternObjectCount
#undef FcPatternEqual
#undef FcPatternEqualSubset
#undef FcPatternHash
@@ -351,8 +409,18 @@
#undef FcRangeDestroy
#undef FcRangeCopy
#undef FcRangeGetDouble
+#undef FcPatternIterStart
+#undef FcPatternIterNext
+#undef FcPatternIterEqual
+#undef FcPatternFindIter
+#undef FcPatternIterIsValid
+#undef FcPatternIterGetObject
+#undef FcPatternIterValueCount
+#undef FcPatternIterGetValue
#undef FcWeightFromOpenType
+#undef FcWeightFromOpenTypeDouble
#undef FcWeightToOpenType
+#undef FcWeightToOpenTypeDouble
#undef FcStrCopy
#undef FcStrCopyFilename
#undef FcStrPlus
@@ -397,6 +465,8 @@ FcBool (*FcDirCacheUnlink_dylibloader_wrapper_fontconfig)(const FcChar8*, FcConf
FcBool (*FcDirCacheValid_dylibloader_wrapper_fontconfig)(const FcChar8*);
FcBool (*FcDirCacheClean_dylibloader_wrapper_fontconfig)(const FcChar8*, FcBool);
void (*FcCacheCreateTagFile_dylibloader_wrapper_fontconfig)(const FcConfig*);
+FcBool (*FcDirCacheCreateUUID_dylibloader_wrapper_fontconfig)( FcChar8*, FcBool, FcConfig*);
+FcBool (*FcDirCacheDeleteUUID_dylibloader_wrapper_fontconfig)(const FcChar8*, FcConfig*);
FcChar8* (*FcConfigHome_dylibloader_wrapper_fontconfig)( void);
FcBool (*FcConfigEnableHome_dylibloader_wrapper_fontconfig)( FcBool);
FcChar8* (*FcConfigFilename_dylibloader_wrapper_fontconfig)(const FcChar8*);
@@ -423,6 +493,26 @@ FcBool (*FcConfigSubstituteWithPat_dylibloader_wrapper_fontconfig)( FcConfig*, F
FcBool (*FcConfigSubstitute_dylibloader_wrapper_fontconfig)( FcConfig*, FcPattern*, FcMatchKind);
const FcChar8* (*FcConfigGetSysRoot_dylibloader_wrapper_fontconfig)(const FcConfig*);
void (*FcConfigSetSysRoot_dylibloader_wrapper_fontconfig)( FcConfig*,const FcChar8*);
+void (*FcConfigFileInfoIterInit_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*);
+FcBool (*FcConfigFileInfoIterNext_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*);
+FcBool (*FcConfigFileInfoIterGet_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*, FcChar8**, FcChar8**, FcBool*);
+FcCharSet* (*FcCharSetCreate_dylibloader_wrapper_fontconfig)( void);
+FcCharSet* (*FcCharSetNew_dylibloader_wrapper_fontconfig)( void);
+void (*FcCharSetDestroy_dylibloader_wrapper_fontconfig)( FcCharSet*);
+FcBool (*FcCharSetAddChar_dylibloader_wrapper_fontconfig)( FcCharSet*, FcChar32);
+FcBool (*FcCharSetDelChar_dylibloader_wrapper_fontconfig)( FcCharSet*, FcChar32);
+FcCharSet* (*FcCharSetCopy_dylibloader_wrapper_fontconfig)( FcCharSet*);
+FcBool (*FcCharSetEqual_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+FcCharSet* (*FcCharSetIntersect_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+FcCharSet* (*FcCharSetUnion_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+FcCharSet* (*FcCharSetSubtract_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+FcBool (*FcCharSetMerge_dylibloader_wrapper_fontconfig)( FcCharSet*,const FcCharSet*, FcBool*);
+FcBool (*FcCharSetHasChar_dylibloader_wrapper_fontconfig)(const FcCharSet*, FcChar32);
+FcChar32 (*FcCharSetCount_dylibloader_wrapper_fontconfig)(const FcCharSet*);
+FcChar32 (*FcCharSetIntersectCount_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+FcChar32 (*FcCharSetSubtractCount_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+FcBool (*FcCharSetIsSubset_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+FcChar32 (*FcCharSetCoverage_dylibloader_wrapper_fontconfig)(const FcCharSet*, FcChar32, FcChar32*);
void (*FcValuePrint_dylibloader_wrapper_fontconfig)(const FcValue);
void (*FcPatternPrint_dylibloader_wrapper_fontconfig)(const FcPattern*);
void (*FcFontSetPrint_dylibloader_wrapper_fontconfig)(const FcFontSet*);
@@ -437,7 +527,8 @@ FcCache* (*FcDirCacheRescan_dylibloader_wrapper_fontconfig)(const FcChar8*, FcCo
FcCache* (*FcDirCacheRead_dylibloader_wrapper_fontconfig)(const FcChar8*, FcBool, FcConfig*);
FcCache* (*FcDirCacheLoadFile_dylibloader_wrapper_fontconfig)(const FcChar8*,struct stat*);
void (*FcDirCacheUnload_dylibloader_wrapper_fontconfig)( FcCache*);
-FcPattern* (*FcFreeTypeQuery_dylibloader_wrapper_fontconfig)(const FcChar8*, int, FcBlanks*, int*);
+FcPattern* (*FcFreeTypeQuery_dylibloader_wrapper_fontconfig)(const FcChar8*, unsigned int, FcBlanks*, int*);
+unsigned int (*FcFreeTypeQueryAll_dylibloader_wrapper_fontconfig)(const FcChar8*, unsigned int, FcBlanks*, int*, FcFontSet*);
FcFontSet* (*FcFontSetCreate_dylibloader_wrapper_fontconfig)( void);
void (*FcFontSetDestroy_dylibloader_wrapper_fontconfig)( FcFontSet*);
FcBool (*FcFontSetAdd_dylibloader_wrapper_fontconfig)( FcFontSet*, FcPattern*);
@@ -508,6 +599,7 @@ void (*FcValueDestroy_dylibloader_wrapper_fontconfig)( FcValue);
FcBool (*FcValueEqual_dylibloader_wrapper_fontconfig)( FcValue, FcValue);
FcValue (*FcValueSave_dylibloader_wrapper_fontconfig)( FcValue);
void (*FcPatternDestroy_dylibloader_wrapper_fontconfig)( FcPattern*);
+int (*FcPatternObjectCount_dylibloader_wrapper_fontconfig)(const FcPattern*);
FcBool (*FcPatternEqual_dylibloader_wrapper_fontconfig)(const FcPattern*,const FcPattern*);
FcBool (*FcPatternEqualSubset_dylibloader_wrapper_fontconfig)(const FcPattern*,const FcPattern*,const FcObjectSet*);
FcChar32 (*FcPatternHash_dylibloader_wrapper_fontconfig)(const FcPattern*);
@@ -541,8 +633,18 @@ FcRange* (*FcRangeCreateInteger_dylibloader_wrapper_fontconfig)( FcChar32, FcCha
void (*FcRangeDestroy_dylibloader_wrapper_fontconfig)( FcRange*);
FcRange* (*FcRangeCopy_dylibloader_wrapper_fontconfig)(const FcRange*);
FcBool (*FcRangeGetDouble_dylibloader_wrapper_fontconfig)(const FcRange*, double*, double*);
+void (*FcPatternIterStart_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+FcBool (*FcPatternIterNext_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+FcBool (*FcPatternIterEqual_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*,const FcPattern*, FcPatternIter*);
+FcBool (*FcPatternFindIter_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*,const char*);
+FcBool (*FcPatternIterIsValid_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+const char* (*FcPatternIterGetObject_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+int (*FcPatternIterValueCount_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+FcResult (*FcPatternIterGetValue_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*, int, FcValue*, FcValueBinding*);
int (*FcWeightFromOpenType_dylibloader_wrapper_fontconfig)( int);
+double (*FcWeightFromOpenTypeDouble_dylibloader_wrapper_fontconfig)( double);
int (*FcWeightToOpenType_dylibloader_wrapper_fontconfig)( int);
+double (*FcWeightToOpenTypeDouble_dylibloader_wrapper_fontconfig)( double);
FcChar8* (*FcStrCopy_dylibloader_wrapper_fontconfig)(const FcChar8*);
FcChar8* (*FcStrCopyFilename_dylibloader_wrapper_fontconfig)(const FcChar8*);
FcChar8* (*FcStrPlus_dylibloader_wrapper_fontconfig)(const FcChar8*,const FcChar8*);
@@ -687,6 +789,22 @@ int initialize_fontconfig(int verbose) {
fprintf(stderr, "%s\n", error);
}
}
+// FcDirCacheCreateUUID
+ *(void **) (&FcDirCacheCreateUUID_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcDirCacheCreateUUID");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcDirCacheDeleteUUID
+ *(void **) (&FcDirCacheDeleteUUID_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcDirCacheDeleteUUID");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
// FcConfigHome
*(void **) (&FcConfigHome_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcConfigHome");
if (verbose) {
@@ -895,6 +1013,166 @@ int initialize_fontconfig(int verbose) {
fprintf(stderr, "%s\n", error);
}
}
+// FcConfigFileInfoIterInit
+ *(void **) (&FcConfigFileInfoIterInit_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcConfigFileInfoIterInit");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcConfigFileInfoIterNext
+ *(void **) (&FcConfigFileInfoIterNext_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcConfigFileInfoIterNext");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcConfigFileInfoIterGet
+ *(void **) (&FcConfigFileInfoIterGet_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcConfigFileInfoIterGet");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetCreate
+ *(void **) (&FcCharSetCreate_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetCreate");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetNew
+ *(void **) (&FcCharSetNew_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetNew");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetDestroy
+ *(void **) (&FcCharSetDestroy_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetDestroy");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetAddChar
+ *(void **) (&FcCharSetAddChar_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetAddChar");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetDelChar
+ *(void **) (&FcCharSetDelChar_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetDelChar");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetCopy
+ *(void **) (&FcCharSetCopy_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetCopy");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetEqual
+ *(void **) (&FcCharSetEqual_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetEqual");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetIntersect
+ *(void **) (&FcCharSetIntersect_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetIntersect");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetUnion
+ *(void **) (&FcCharSetUnion_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetUnion");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetSubtract
+ *(void **) (&FcCharSetSubtract_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetSubtract");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetMerge
+ *(void **) (&FcCharSetMerge_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetMerge");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetHasChar
+ *(void **) (&FcCharSetHasChar_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetHasChar");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetCount
+ *(void **) (&FcCharSetCount_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetCount");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetIntersectCount
+ *(void **) (&FcCharSetIntersectCount_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetIntersectCount");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetSubtractCount
+ *(void **) (&FcCharSetSubtractCount_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetSubtractCount");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetIsSubset
+ *(void **) (&FcCharSetIsSubset_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetIsSubset");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcCharSetCoverage
+ *(void **) (&FcCharSetCoverage_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetCoverage");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
// FcValuePrint
*(void **) (&FcValuePrint_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcValuePrint");
if (verbose) {
@@ -1015,6 +1293,14 @@ int initialize_fontconfig(int verbose) {
fprintf(stderr, "%s\n", error);
}
}
+// FcFreeTypeQueryAll
+ *(void **) (&FcFreeTypeQueryAll_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcFreeTypeQueryAll");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
// FcFontSetCreate
*(void **) (&FcFontSetCreate_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcFontSetCreate");
if (verbose) {
@@ -1575,6 +1861,14 @@ int initialize_fontconfig(int verbose) {
fprintf(stderr, "%s\n", error);
}
}
+// FcPatternObjectCount
+ *(void **) (&FcPatternObjectCount_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternObjectCount");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
// FcPatternEqual
*(void **) (&FcPatternEqual_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternEqual");
if (verbose) {
@@ -1839,6 +2133,70 @@ int initialize_fontconfig(int verbose) {
fprintf(stderr, "%s\n", error);
}
}
+// FcPatternIterStart
+ *(void **) (&FcPatternIterStart_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterStart");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcPatternIterNext
+ *(void **) (&FcPatternIterNext_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterNext");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcPatternIterEqual
+ *(void **) (&FcPatternIterEqual_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterEqual");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcPatternFindIter
+ *(void **) (&FcPatternFindIter_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternFindIter");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcPatternIterIsValid
+ *(void **) (&FcPatternIterIsValid_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterIsValid");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcPatternIterGetObject
+ *(void **) (&FcPatternIterGetObject_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterGetObject");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcPatternIterValueCount
+ *(void **) (&FcPatternIterValueCount_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterValueCount");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
+// FcPatternIterGetValue
+ *(void **) (&FcPatternIterGetValue_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterGetValue");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
// FcWeightFromOpenType
*(void **) (&FcWeightFromOpenType_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcWeightFromOpenType");
if (verbose) {
@@ -1847,6 +2205,14 @@ int initialize_fontconfig(int verbose) {
fprintf(stderr, "%s\n", error);
}
}
+// FcWeightFromOpenTypeDouble
+ *(void **) (&FcWeightFromOpenTypeDouble_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcWeightFromOpenTypeDouble");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
// FcWeightToOpenType
*(void **) (&FcWeightToOpenType_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcWeightToOpenType");
if (verbose) {
@@ -1855,6 +2221,14 @@ int initialize_fontconfig(int verbose) {
fprintf(stderr, "%s\n", error);
}
}
+// FcWeightToOpenTypeDouble
+ *(void **) (&FcWeightToOpenTypeDouble_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcWeightToOpenTypeDouble");
+ if (verbose) {
+ error = dlerror();
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error);
+ }
+ }
// FcStrCopy
*(void **) (&FcStrCopy_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcStrCopy");
if (verbose) {
diff --git a/platform/linuxbsd/fontconfig-so_wrap.h b/platform/linuxbsd/fontconfig-so_wrap.h
index f0794cce8b..0c8259deb7 100644
--- a/platform/linuxbsd/fontconfig-so_wrap.h
+++ b/platform/linuxbsd/fontconfig-so_wrap.h
@@ -2,8 +2,8 @@
#define DYLIBLOAD_WRAPPER_FONTCONFIG
// This file is generated. Do not edit!
// see https://github.com/hpvb/dynload-wrapper for details
-// generated by ./generate-wrapper.py 0.3 on 2022-07-29 05:40:07
-// flags: ./generate-wrapper.py --include /usr/include/fontconfig/fontconfig.h --sys-include <fontconfig/fontconfig.h> --soname libfontconfig.so --init-name fontconfig --output-header fontconfig-so_wrap.h --output-implementation fontconfig-so_wrap.c --omit-prefix FcCharSet
+// generated by ./generate-wrapper.py 0.3 on 2022-11-22 10:28:00
+// flags: ./generate-wrapper.py --include /usr/include/fontconfig/fontconfig.h --sys-include <fontconfig/fontconfig.h> --soname libfontconfig.so --init-name fontconfig --output-header fontconfig-so_wrap.h --output-implementation fontconfig-so_wrap.c --omit-prefix FcCharSetFirst --omit-prefix FcCharSetNext
//
#include <stdint.h>
@@ -20,6 +20,8 @@
#define FcDirCacheValid FcDirCacheValid_dylibloader_orig_fontconfig
#define FcDirCacheClean FcDirCacheClean_dylibloader_orig_fontconfig
#define FcCacheCreateTagFile FcCacheCreateTagFile_dylibloader_orig_fontconfig
+#define FcDirCacheCreateUUID FcDirCacheCreateUUID_dylibloader_orig_fontconfig
+#define FcDirCacheDeleteUUID FcDirCacheDeleteUUID_dylibloader_orig_fontconfig
#define FcConfigHome FcConfigHome_dylibloader_orig_fontconfig
#define FcConfigEnableHome FcConfigEnableHome_dylibloader_orig_fontconfig
#define FcConfigFilename FcConfigFilename_dylibloader_orig_fontconfig
@@ -46,6 +48,26 @@
#define FcConfigSubstitute FcConfigSubstitute_dylibloader_orig_fontconfig
#define FcConfigGetSysRoot FcConfigGetSysRoot_dylibloader_orig_fontconfig
#define FcConfigSetSysRoot FcConfigSetSysRoot_dylibloader_orig_fontconfig
+#define FcConfigFileInfoIterInit FcConfigFileInfoIterInit_dylibloader_orig_fontconfig
+#define FcConfigFileInfoIterNext FcConfigFileInfoIterNext_dylibloader_orig_fontconfig
+#define FcConfigFileInfoIterGet FcConfigFileInfoIterGet_dylibloader_orig_fontconfig
+#define FcCharSetCreate FcCharSetCreate_dylibloader_orig_fontconfig
+#define FcCharSetNew FcCharSetNew_dylibloader_orig_fontconfig
+#define FcCharSetDestroy FcCharSetDestroy_dylibloader_orig_fontconfig
+#define FcCharSetAddChar FcCharSetAddChar_dylibloader_orig_fontconfig
+#define FcCharSetDelChar FcCharSetDelChar_dylibloader_orig_fontconfig
+#define FcCharSetCopy FcCharSetCopy_dylibloader_orig_fontconfig
+#define FcCharSetEqual FcCharSetEqual_dylibloader_orig_fontconfig
+#define FcCharSetIntersect FcCharSetIntersect_dylibloader_orig_fontconfig
+#define FcCharSetUnion FcCharSetUnion_dylibloader_orig_fontconfig
+#define FcCharSetSubtract FcCharSetSubtract_dylibloader_orig_fontconfig
+#define FcCharSetMerge FcCharSetMerge_dylibloader_orig_fontconfig
+#define FcCharSetHasChar FcCharSetHasChar_dylibloader_orig_fontconfig
+#define FcCharSetCount FcCharSetCount_dylibloader_orig_fontconfig
+#define FcCharSetIntersectCount FcCharSetIntersectCount_dylibloader_orig_fontconfig
+#define FcCharSetSubtractCount FcCharSetSubtractCount_dylibloader_orig_fontconfig
+#define FcCharSetIsSubset FcCharSetIsSubset_dylibloader_orig_fontconfig
+#define FcCharSetCoverage FcCharSetCoverage_dylibloader_orig_fontconfig
#define FcValuePrint FcValuePrint_dylibloader_orig_fontconfig
#define FcPatternPrint FcPatternPrint_dylibloader_orig_fontconfig
#define FcFontSetPrint FcFontSetPrint_dylibloader_orig_fontconfig
@@ -61,6 +83,7 @@
#define FcDirCacheLoadFile FcDirCacheLoadFile_dylibloader_orig_fontconfig
#define FcDirCacheUnload FcDirCacheUnload_dylibloader_orig_fontconfig
#define FcFreeTypeQuery FcFreeTypeQuery_dylibloader_orig_fontconfig
+#define FcFreeTypeQueryAll FcFreeTypeQueryAll_dylibloader_orig_fontconfig
#define FcFontSetCreate FcFontSetCreate_dylibloader_orig_fontconfig
#define FcFontSetDestroy FcFontSetDestroy_dylibloader_orig_fontconfig
#define FcFontSetAdd FcFontSetAdd_dylibloader_orig_fontconfig
@@ -131,6 +154,7 @@
#define FcValueEqual FcValueEqual_dylibloader_orig_fontconfig
#define FcValueSave FcValueSave_dylibloader_orig_fontconfig
#define FcPatternDestroy FcPatternDestroy_dylibloader_orig_fontconfig
+#define FcPatternObjectCount FcPatternObjectCount_dylibloader_orig_fontconfig
#define FcPatternEqual FcPatternEqual_dylibloader_orig_fontconfig
#define FcPatternEqualSubset FcPatternEqualSubset_dylibloader_orig_fontconfig
#define FcPatternHash FcPatternHash_dylibloader_orig_fontconfig
@@ -164,8 +188,18 @@
#define FcRangeDestroy FcRangeDestroy_dylibloader_orig_fontconfig
#define FcRangeCopy FcRangeCopy_dylibloader_orig_fontconfig
#define FcRangeGetDouble FcRangeGetDouble_dylibloader_orig_fontconfig
+#define FcPatternIterStart FcPatternIterStart_dylibloader_orig_fontconfig
+#define FcPatternIterNext FcPatternIterNext_dylibloader_orig_fontconfig
+#define FcPatternIterEqual FcPatternIterEqual_dylibloader_orig_fontconfig
+#define FcPatternFindIter FcPatternFindIter_dylibloader_orig_fontconfig
+#define FcPatternIterIsValid FcPatternIterIsValid_dylibloader_orig_fontconfig
+#define FcPatternIterGetObject FcPatternIterGetObject_dylibloader_orig_fontconfig
+#define FcPatternIterValueCount FcPatternIterValueCount_dylibloader_orig_fontconfig
+#define FcPatternIterGetValue FcPatternIterGetValue_dylibloader_orig_fontconfig
#define FcWeightFromOpenType FcWeightFromOpenType_dylibloader_orig_fontconfig
+#define FcWeightFromOpenTypeDouble FcWeightFromOpenTypeDouble_dylibloader_orig_fontconfig
#define FcWeightToOpenType FcWeightToOpenType_dylibloader_orig_fontconfig
+#define FcWeightToOpenTypeDouble FcWeightToOpenTypeDouble_dylibloader_orig_fontconfig
#define FcStrCopy FcStrCopy_dylibloader_orig_fontconfig
#define FcStrCopyFilename FcStrCopyFilename_dylibloader_orig_fontconfig
#define FcStrPlus FcStrPlus_dylibloader_orig_fontconfig
@@ -209,6 +243,8 @@
#undef FcDirCacheValid
#undef FcDirCacheClean
#undef FcCacheCreateTagFile
+#undef FcDirCacheCreateUUID
+#undef FcDirCacheDeleteUUID
#undef FcConfigHome
#undef FcConfigEnableHome
#undef FcConfigFilename
@@ -235,6 +271,26 @@
#undef FcConfigSubstitute
#undef FcConfigGetSysRoot
#undef FcConfigSetSysRoot
+#undef FcConfigFileInfoIterInit
+#undef FcConfigFileInfoIterNext
+#undef FcConfigFileInfoIterGet
+#undef FcCharSetCreate
+#undef FcCharSetNew
+#undef FcCharSetDestroy
+#undef FcCharSetAddChar
+#undef FcCharSetDelChar
+#undef FcCharSetCopy
+#undef FcCharSetEqual
+#undef FcCharSetIntersect
+#undef FcCharSetUnion
+#undef FcCharSetSubtract
+#undef FcCharSetMerge
+#undef FcCharSetHasChar
+#undef FcCharSetCount
+#undef FcCharSetIntersectCount
+#undef FcCharSetSubtractCount
+#undef FcCharSetIsSubset
+#undef FcCharSetCoverage
#undef FcValuePrint
#undef FcPatternPrint
#undef FcFontSetPrint
@@ -250,6 +306,7 @@
#undef FcDirCacheLoadFile
#undef FcDirCacheUnload
#undef FcFreeTypeQuery
+#undef FcFreeTypeQueryAll
#undef FcFontSetCreate
#undef FcFontSetDestroy
#undef FcFontSetAdd
@@ -320,6 +377,7 @@
#undef FcValueEqual
#undef FcValueSave
#undef FcPatternDestroy
+#undef FcPatternObjectCount
#undef FcPatternEqual
#undef FcPatternEqualSubset
#undef FcPatternHash
@@ -353,8 +411,18 @@
#undef FcRangeDestroy
#undef FcRangeCopy
#undef FcRangeGetDouble
+#undef FcPatternIterStart
+#undef FcPatternIterNext
+#undef FcPatternIterEqual
+#undef FcPatternFindIter
+#undef FcPatternIterIsValid
+#undef FcPatternIterGetObject
+#undef FcPatternIterValueCount
+#undef FcPatternIterGetValue
#undef FcWeightFromOpenType
+#undef FcWeightFromOpenTypeDouble
#undef FcWeightToOpenType
+#undef FcWeightToOpenTypeDouble
#undef FcStrCopy
#undef FcStrCopyFilename
#undef FcStrPlus
@@ -400,6 +468,8 @@ extern "C" {
#define FcDirCacheValid FcDirCacheValid_dylibloader_wrapper_fontconfig
#define FcDirCacheClean FcDirCacheClean_dylibloader_wrapper_fontconfig
#define FcCacheCreateTagFile FcCacheCreateTagFile_dylibloader_wrapper_fontconfig
+#define FcDirCacheCreateUUID FcDirCacheCreateUUID_dylibloader_wrapper_fontconfig
+#define FcDirCacheDeleteUUID FcDirCacheDeleteUUID_dylibloader_wrapper_fontconfig
#define FcConfigHome FcConfigHome_dylibloader_wrapper_fontconfig
#define FcConfigEnableHome FcConfigEnableHome_dylibloader_wrapper_fontconfig
#define FcConfigFilename FcConfigFilename_dylibloader_wrapper_fontconfig
@@ -426,6 +496,26 @@ extern "C" {
#define FcConfigSubstitute FcConfigSubstitute_dylibloader_wrapper_fontconfig
#define FcConfigGetSysRoot FcConfigGetSysRoot_dylibloader_wrapper_fontconfig
#define FcConfigSetSysRoot FcConfigSetSysRoot_dylibloader_wrapper_fontconfig
+#define FcConfigFileInfoIterInit FcConfigFileInfoIterInit_dylibloader_wrapper_fontconfig
+#define FcConfigFileInfoIterNext FcConfigFileInfoIterNext_dylibloader_wrapper_fontconfig
+#define FcConfigFileInfoIterGet FcConfigFileInfoIterGet_dylibloader_wrapper_fontconfig
+#define FcCharSetCreate FcCharSetCreate_dylibloader_wrapper_fontconfig
+#define FcCharSetNew FcCharSetNew_dylibloader_wrapper_fontconfig
+#define FcCharSetDestroy FcCharSetDestroy_dylibloader_wrapper_fontconfig
+#define FcCharSetAddChar FcCharSetAddChar_dylibloader_wrapper_fontconfig
+#define FcCharSetDelChar FcCharSetDelChar_dylibloader_wrapper_fontconfig
+#define FcCharSetCopy FcCharSetCopy_dylibloader_wrapper_fontconfig
+#define FcCharSetEqual FcCharSetEqual_dylibloader_wrapper_fontconfig
+#define FcCharSetIntersect FcCharSetIntersect_dylibloader_wrapper_fontconfig
+#define FcCharSetUnion FcCharSetUnion_dylibloader_wrapper_fontconfig
+#define FcCharSetSubtract FcCharSetSubtract_dylibloader_wrapper_fontconfig
+#define FcCharSetMerge FcCharSetMerge_dylibloader_wrapper_fontconfig
+#define FcCharSetHasChar FcCharSetHasChar_dylibloader_wrapper_fontconfig
+#define FcCharSetCount FcCharSetCount_dylibloader_wrapper_fontconfig
+#define FcCharSetIntersectCount FcCharSetIntersectCount_dylibloader_wrapper_fontconfig
+#define FcCharSetSubtractCount FcCharSetSubtractCount_dylibloader_wrapper_fontconfig
+#define FcCharSetIsSubset FcCharSetIsSubset_dylibloader_wrapper_fontconfig
+#define FcCharSetCoverage FcCharSetCoverage_dylibloader_wrapper_fontconfig
#define FcValuePrint FcValuePrint_dylibloader_wrapper_fontconfig
#define FcPatternPrint FcPatternPrint_dylibloader_wrapper_fontconfig
#define FcFontSetPrint FcFontSetPrint_dylibloader_wrapper_fontconfig
@@ -441,6 +531,7 @@ extern "C" {
#define FcDirCacheLoadFile FcDirCacheLoadFile_dylibloader_wrapper_fontconfig
#define FcDirCacheUnload FcDirCacheUnload_dylibloader_wrapper_fontconfig
#define FcFreeTypeQuery FcFreeTypeQuery_dylibloader_wrapper_fontconfig
+#define FcFreeTypeQueryAll FcFreeTypeQueryAll_dylibloader_wrapper_fontconfig
#define FcFontSetCreate FcFontSetCreate_dylibloader_wrapper_fontconfig
#define FcFontSetDestroy FcFontSetDestroy_dylibloader_wrapper_fontconfig
#define FcFontSetAdd FcFontSetAdd_dylibloader_wrapper_fontconfig
@@ -511,6 +602,7 @@ extern "C" {
#define FcValueEqual FcValueEqual_dylibloader_wrapper_fontconfig
#define FcValueSave FcValueSave_dylibloader_wrapper_fontconfig
#define FcPatternDestroy FcPatternDestroy_dylibloader_wrapper_fontconfig
+#define FcPatternObjectCount FcPatternObjectCount_dylibloader_wrapper_fontconfig
#define FcPatternEqual FcPatternEqual_dylibloader_wrapper_fontconfig
#define FcPatternEqualSubset FcPatternEqualSubset_dylibloader_wrapper_fontconfig
#define FcPatternHash FcPatternHash_dylibloader_wrapper_fontconfig
@@ -544,8 +636,18 @@ extern "C" {
#define FcRangeDestroy FcRangeDestroy_dylibloader_wrapper_fontconfig
#define FcRangeCopy FcRangeCopy_dylibloader_wrapper_fontconfig
#define FcRangeGetDouble FcRangeGetDouble_dylibloader_wrapper_fontconfig
+#define FcPatternIterStart FcPatternIterStart_dylibloader_wrapper_fontconfig
+#define FcPatternIterNext FcPatternIterNext_dylibloader_wrapper_fontconfig
+#define FcPatternIterEqual FcPatternIterEqual_dylibloader_wrapper_fontconfig
+#define FcPatternFindIter FcPatternFindIter_dylibloader_wrapper_fontconfig
+#define FcPatternIterIsValid FcPatternIterIsValid_dylibloader_wrapper_fontconfig
+#define FcPatternIterGetObject FcPatternIterGetObject_dylibloader_wrapper_fontconfig
+#define FcPatternIterValueCount FcPatternIterValueCount_dylibloader_wrapper_fontconfig
+#define FcPatternIterGetValue FcPatternIterGetValue_dylibloader_wrapper_fontconfig
#define FcWeightFromOpenType FcWeightFromOpenType_dylibloader_wrapper_fontconfig
+#define FcWeightFromOpenTypeDouble FcWeightFromOpenTypeDouble_dylibloader_wrapper_fontconfig
#define FcWeightToOpenType FcWeightToOpenType_dylibloader_wrapper_fontconfig
+#define FcWeightToOpenTypeDouble FcWeightToOpenTypeDouble_dylibloader_wrapper_fontconfig
#define FcStrCopy FcStrCopy_dylibloader_wrapper_fontconfig
#define FcStrCopyFilename FcStrCopyFilename_dylibloader_wrapper_fontconfig
#define FcStrPlus FcStrPlus_dylibloader_wrapper_fontconfig
@@ -588,6 +690,8 @@ extern FcBool (*FcDirCacheUnlink_dylibloader_wrapper_fontconfig)(const FcChar8*,
extern FcBool (*FcDirCacheValid_dylibloader_wrapper_fontconfig)(const FcChar8*);
extern FcBool (*FcDirCacheClean_dylibloader_wrapper_fontconfig)(const FcChar8*, FcBool);
extern void (*FcCacheCreateTagFile_dylibloader_wrapper_fontconfig)(const FcConfig*);
+extern FcBool (*FcDirCacheCreateUUID_dylibloader_wrapper_fontconfig)( FcChar8*, FcBool, FcConfig*);
+extern FcBool (*FcDirCacheDeleteUUID_dylibloader_wrapper_fontconfig)(const FcChar8*, FcConfig*);
extern FcChar8* (*FcConfigHome_dylibloader_wrapper_fontconfig)( void);
extern FcBool (*FcConfigEnableHome_dylibloader_wrapper_fontconfig)( FcBool);
extern FcChar8* (*FcConfigFilename_dylibloader_wrapper_fontconfig)(const FcChar8*);
@@ -614,6 +718,26 @@ extern FcBool (*FcConfigSubstituteWithPat_dylibloader_wrapper_fontconfig)( FcCon
extern FcBool (*FcConfigSubstitute_dylibloader_wrapper_fontconfig)( FcConfig*, FcPattern*, FcMatchKind);
extern const FcChar8* (*FcConfigGetSysRoot_dylibloader_wrapper_fontconfig)(const FcConfig*);
extern void (*FcConfigSetSysRoot_dylibloader_wrapper_fontconfig)( FcConfig*,const FcChar8*);
+extern void (*FcConfigFileInfoIterInit_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*);
+extern FcBool (*FcConfigFileInfoIterNext_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*);
+extern FcBool (*FcConfigFileInfoIterGet_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*, FcChar8**, FcChar8**, FcBool*);
+extern FcCharSet* (*FcCharSetCreate_dylibloader_wrapper_fontconfig)( void);
+extern FcCharSet* (*FcCharSetNew_dylibloader_wrapper_fontconfig)( void);
+extern void (*FcCharSetDestroy_dylibloader_wrapper_fontconfig)( FcCharSet*);
+extern FcBool (*FcCharSetAddChar_dylibloader_wrapper_fontconfig)( FcCharSet*, FcChar32);
+extern FcBool (*FcCharSetDelChar_dylibloader_wrapper_fontconfig)( FcCharSet*, FcChar32);
+extern FcCharSet* (*FcCharSetCopy_dylibloader_wrapper_fontconfig)( FcCharSet*);
+extern FcBool (*FcCharSetEqual_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+extern FcCharSet* (*FcCharSetIntersect_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+extern FcCharSet* (*FcCharSetUnion_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+extern FcCharSet* (*FcCharSetSubtract_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+extern FcBool (*FcCharSetMerge_dylibloader_wrapper_fontconfig)( FcCharSet*,const FcCharSet*, FcBool*);
+extern FcBool (*FcCharSetHasChar_dylibloader_wrapper_fontconfig)(const FcCharSet*, FcChar32);
+extern FcChar32 (*FcCharSetCount_dylibloader_wrapper_fontconfig)(const FcCharSet*);
+extern FcChar32 (*FcCharSetIntersectCount_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+extern FcChar32 (*FcCharSetSubtractCount_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+extern FcBool (*FcCharSetIsSubset_dylibloader_wrapper_fontconfig)(const FcCharSet*,const FcCharSet*);
+extern FcChar32 (*FcCharSetCoverage_dylibloader_wrapper_fontconfig)(const FcCharSet*, FcChar32, FcChar32*);
extern void (*FcValuePrint_dylibloader_wrapper_fontconfig)(const FcValue);
extern void (*FcPatternPrint_dylibloader_wrapper_fontconfig)(const FcPattern*);
extern void (*FcFontSetPrint_dylibloader_wrapper_fontconfig)(const FcFontSet*);
@@ -628,7 +752,8 @@ extern FcCache* (*FcDirCacheRescan_dylibloader_wrapper_fontconfig)(const FcChar8
extern FcCache* (*FcDirCacheRead_dylibloader_wrapper_fontconfig)(const FcChar8*, FcBool, FcConfig*);
extern FcCache* (*FcDirCacheLoadFile_dylibloader_wrapper_fontconfig)(const FcChar8*,struct stat*);
extern void (*FcDirCacheUnload_dylibloader_wrapper_fontconfig)( FcCache*);
-extern FcPattern* (*FcFreeTypeQuery_dylibloader_wrapper_fontconfig)(const FcChar8*, int, FcBlanks*, int*);
+extern FcPattern* (*FcFreeTypeQuery_dylibloader_wrapper_fontconfig)(const FcChar8*, unsigned int, FcBlanks*, int*);
+extern unsigned int (*FcFreeTypeQueryAll_dylibloader_wrapper_fontconfig)(const FcChar8*, unsigned int, FcBlanks*, int*, FcFontSet*);
extern FcFontSet* (*FcFontSetCreate_dylibloader_wrapper_fontconfig)( void);
extern void (*FcFontSetDestroy_dylibloader_wrapper_fontconfig)( FcFontSet*);
extern FcBool (*FcFontSetAdd_dylibloader_wrapper_fontconfig)( FcFontSet*, FcPattern*);
@@ -699,6 +824,7 @@ extern void (*FcValueDestroy_dylibloader_wrapper_fontconfig)( FcValue);
extern FcBool (*FcValueEqual_dylibloader_wrapper_fontconfig)( FcValue, FcValue);
extern FcValue (*FcValueSave_dylibloader_wrapper_fontconfig)( FcValue);
extern void (*FcPatternDestroy_dylibloader_wrapper_fontconfig)( FcPattern*);
+extern int (*FcPatternObjectCount_dylibloader_wrapper_fontconfig)(const FcPattern*);
extern FcBool (*FcPatternEqual_dylibloader_wrapper_fontconfig)(const FcPattern*,const FcPattern*);
extern FcBool (*FcPatternEqualSubset_dylibloader_wrapper_fontconfig)(const FcPattern*,const FcPattern*,const FcObjectSet*);
extern FcChar32 (*FcPatternHash_dylibloader_wrapper_fontconfig)(const FcPattern*);
@@ -732,8 +858,18 @@ extern FcRange* (*FcRangeCreateInteger_dylibloader_wrapper_fontconfig)( FcChar32
extern void (*FcRangeDestroy_dylibloader_wrapper_fontconfig)( FcRange*);
extern FcRange* (*FcRangeCopy_dylibloader_wrapper_fontconfig)(const FcRange*);
extern FcBool (*FcRangeGetDouble_dylibloader_wrapper_fontconfig)(const FcRange*, double*, double*);
+extern void (*FcPatternIterStart_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+extern FcBool (*FcPatternIterNext_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+extern FcBool (*FcPatternIterEqual_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*,const FcPattern*, FcPatternIter*);
+extern FcBool (*FcPatternFindIter_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*,const char*);
+extern FcBool (*FcPatternIterIsValid_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+extern const char* (*FcPatternIterGetObject_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+extern int (*FcPatternIterValueCount_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*);
+extern FcResult (*FcPatternIterGetValue_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*, int, FcValue*, FcValueBinding*);
extern int (*FcWeightFromOpenType_dylibloader_wrapper_fontconfig)( int);
+extern double (*FcWeightFromOpenTypeDouble_dylibloader_wrapper_fontconfig)( double);
extern int (*FcWeightToOpenType_dylibloader_wrapper_fontconfig)( int);
+extern double (*FcWeightToOpenTypeDouble_dylibloader_wrapper_fontconfig)( double);
extern FcChar8* (*FcStrCopy_dylibloader_wrapper_fontconfig)(const FcChar8*);
extern FcChar8* (*FcStrCopyFilename_dylibloader_wrapper_fontconfig)(const FcChar8*);
extern FcChar8* (*FcStrPlus_dylibloader_wrapper_fontconfig)(const FcChar8*,const FcChar8*);
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index bc018e366b..4eaf6965c9 100644
--- a/platform/linuxbsd/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -218,8 +218,8 @@ void JoypadLinux::monitor_joypads() {
}
}
closedir(input_directory);
+ usleep(1000000); // 1s
}
- usleep(1000000); // 1s
}
void JoypadLinux::close_joypads() {
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index e14e4fb52d..d5a75edeea 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -56,10 +56,6 @@
#include <sys/utsname.h>
#include <unistd.h>
-#ifdef FONTCONFIG_ENABLED
-#include "fontconfig-so_wrap.h"
-#endif
-
void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) {
const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" };
@@ -585,15 +581,9 @@ Vector<String> OS_LinuxBSD::get_system_fonts() const {
if (!font_config_initialized) {
ERR_FAIL_V_MSG(Vector<String>(), "Unable to load fontconfig, system font support is disabled.");
}
+
HashSet<String> font_names;
Vector<String> ret;
-
- FcConfig *config = FcInitLoadConfigAndFonts();
- ERR_FAIL_COND_V(!config, ret);
-
- FcObjectSet *object_set = FcObjectSetBuild(FC_FAMILY, nullptr);
- ERR_FAIL_COND_V(!object_set, ret);
-
static const char *allowed_formats[] = { "TrueType", "CFF" };
for (size_t i = 0; i < sizeof(allowed_formats) / sizeof(const char *); i++) {
FcPattern *pattern = FcPatternCreate();
@@ -616,8 +606,6 @@ Vector<String> OS_LinuxBSD::get_system_fonts() const {
}
FcPatternDestroy(pattern);
}
- FcObjectSetDestroy(object_set);
- FcConfigDestroy(config);
for (const String &E : font_names) {
ret.push_back(E);
@@ -628,27 +616,122 @@ Vector<String> OS_LinuxBSD::get_system_fonts() const {
#endif
}
-String OS_LinuxBSD::get_system_font_path(const String &p_font_name, bool p_bold, bool p_italic) const {
+#ifdef FONTCONFIG_ENABLED
+int OS_LinuxBSD::_weight_to_fc(int p_weight) const {
+ if (p_weight < 150) {
+ return FC_WEIGHT_THIN;
+ } else if (p_weight < 250) {
+ return FC_WEIGHT_EXTRALIGHT;
+ } else if (p_weight < 325) {
+ return FC_WEIGHT_LIGHT;
+ } else if (p_weight < 375) {
+ return FC_WEIGHT_DEMILIGHT;
+ } else if (p_weight < 390) {
+ return FC_WEIGHT_BOOK;
+ } else if (p_weight < 450) {
+ return FC_WEIGHT_REGULAR;
+ } else if (p_weight < 550) {
+ return FC_WEIGHT_MEDIUM;
+ } else if (p_weight < 650) {
+ return FC_WEIGHT_DEMIBOLD;
+ } else if (p_weight < 750) {
+ return FC_WEIGHT_BOLD;
+ } else if (p_weight < 850) {
+ return FC_WEIGHT_EXTRABOLD;
+ } else if (p_weight < 925) {
+ return FC_WEIGHT_BLACK;
+ } else {
+ return FC_WEIGHT_EXTRABLACK;
+ }
+}
+
+int OS_LinuxBSD::_stretch_to_fc(int p_stretch) const {
+ if (p_stretch < 56) {
+ return FC_WIDTH_ULTRACONDENSED;
+ } else if (p_stretch < 69) {
+ return FC_WIDTH_EXTRACONDENSED;
+ } else if (p_stretch < 81) {
+ return FC_WIDTH_CONDENSED;
+ } else if (p_stretch < 93) {
+ return FC_WIDTH_SEMICONDENSED;
+ } else if (p_stretch < 106) {
+ return FC_WIDTH_NORMAL;
+ } else if (p_stretch < 137) {
+ return FC_WIDTH_SEMIEXPANDED;
+ } else if (p_stretch < 144) {
+ return FC_WIDTH_EXPANDED;
+ } else if (p_stretch < 162) {
+ return FC_WIDTH_EXTRAEXPANDED;
+ } else {
+ return FC_WIDTH_ULTRAEXPANDED;
+ }
+}
+#endif // FONTCONFIG_ENABLED
+
+Vector<String> OS_LinuxBSD::get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale, const String &p_script, int p_weight, int p_stretch, bool p_italic) const {
#ifdef FONTCONFIG_ENABLED
if (!font_config_initialized) {
- ERR_FAIL_V_MSG(String(), "Unable to load fontconfig, system font support is disabled.");
+ ERR_FAIL_V_MSG(Vector<String>(), "Unable to load fontconfig, system font support is disabled.");
}
- bool allow_substitutes = (p_font_name.to_lower() == "sans-serif") || (p_font_name.to_lower() == "serif") || (p_font_name.to_lower() == "monospace") || (p_font_name.to_lower() == "cursive") || (p_font_name.to_lower() == "fantasy");
+ Vector<String> ret;
+ FcPattern *pattern = FcPatternCreate();
+ if (pattern) {
+ FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8 *>(p_font_name.utf8().get_data()));
+ FcPatternAddInteger(pattern, FC_WEIGHT, _weight_to_fc(p_weight));
+ FcPatternAddInteger(pattern, FC_WIDTH, _stretch_to_fc(p_stretch));
+ FcPatternAddInteger(pattern, FC_SLANT, p_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN);
- String ret;
+ FcCharSet *char_set = FcCharSetCreate();
+ for (int i = 0; i < p_text.size(); i++) {
+ FcCharSetAddChar(char_set, p_text[i]);
+ }
+ FcPatternAddCharSet(pattern, FC_CHARSET, char_set);
- FcConfig *config = FcInitLoadConfigAndFonts();
- ERR_FAIL_COND_V(!config, ret);
+ FcLangSet *lang_set = FcLangSetCreate();
+ FcLangSetAdd(lang_set, reinterpret_cast<const FcChar8 *>(p_locale.utf8().get_data()));
+ FcPatternAddLangSet(pattern, FC_LANG, lang_set);
- FcObjectSet *object_set = FcObjectSetBuild(FC_FAMILY, FC_FILE, nullptr);
- ERR_FAIL_COND_V(!object_set, ret);
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+ FcResult result;
+ FcPattern *match = FcFontMatch(0, pattern, &result);
+ if (match) {
+ char *file_name = nullptr;
+ if (FcPatternGetString(match, FC_FILE, 0, reinterpret_cast<FcChar8 **>(&file_name)) == FcResultMatch) {
+ if (file_name) {
+ ret.push_back(String::utf8(file_name));
+ }
+ }
+ FcPatternDestroy(match);
+ }
+ FcPatternDestroy(pattern);
+ FcCharSetDestroy(char_set);
+ FcLangSetDestroy(lang_set);
+ }
+
+ return ret;
+#else
+ ERR_FAIL_V_MSG(Vector<String>(), "Godot was compiled without fontconfig, system font support is disabled.");
+#endif
+}
+
+String OS_LinuxBSD::get_system_font_path(const String &p_font_name, int p_weight, int p_stretch, bool p_italic) const {
+#ifdef FONTCONFIG_ENABLED
+ if (!font_config_initialized) {
+ ERR_FAIL_V_MSG(String(), "Unable to load fontconfig, system font support is disabled.");
+ }
+
+ String ret;
FcPattern *pattern = FcPatternCreate();
if (pattern) {
+ bool allow_substitutes = (p_font_name.to_lower() == "sans-serif") || (p_font_name.to_lower() == "serif") || (p_font_name.to_lower() == "monospace") || (p_font_name.to_lower() == "cursive") || (p_font_name.to_lower() == "fantasy");
+
FcPatternAddBool(pattern, FC_SCALABLE, FcTrue);
FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8 *>(p_font_name.utf8().get_data()));
- FcPatternAddInteger(pattern, FC_WEIGHT, p_bold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL);
+ FcPatternAddInteger(pattern, FC_WEIGHT, _weight_to_fc(p_weight));
+ FcPatternAddInteger(pattern, FC_WIDTH, _stretch_to_fc(p_stretch));
FcPatternAddInteger(pattern, FC_SLANT, p_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN);
FcConfigSubstitute(0, pattern, FcMatchPattern);
@@ -663,8 +746,6 @@ String OS_LinuxBSD::get_system_font_path(const String &p_font_name, bool p_bold,
if (family_name && String::utf8(family_name).to_lower() != p_font_name.to_lower()) {
FcPatternDestroy(match);
FcPatternDestroy(pattern);
- FcObjectSetDestroy(object_set);
- FcConfigDestroy(config);
return String();
}
@@ -681,8 +762,6 @@ String OS_LinuxBSD::get_system_font_path(const String &p_font_name, bool p_bold,
}
FcPatternDestroy(pattern);
}
- FcObjectSetDestroy(object_set);
- FcConfigDestroy(config);
return ret;
#else
@@ -1008,5 +1087,26 @@ OS_LinuxBSD::OS_LinuxBSD() {
int dylibloader_verbose = 0;
#endif
font_config_initialized = (initialize_fontconfig(dylibloader_verbose) == 0);
+ if (font_config_initialized) {
+ config = FcInitLoadConfigAndFonts();
+ if (!config) {
+ font_config_initialized = false;
+ }
+ object_set = FcObjectSetBuild(FC_FAMILY, FC_FILE, nullptr);
+ if (!object_set) {
+ font_config_initialized = false;
+ }
+ }
+#endif // FONTCONFIG_ENABLED
+}
+
+OS_LinuxBSD::~OS_LinuxBSD() {
+#ifdef FONTCONFIG_ENABLED
+ if (object_set) {
+ FcObjectSetDestroy(object_set);
+ }
+ if (config) {
+ FcConfigDestroy(config);
+ }
#endif // FONTCONFIG_ENABLED
}
diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h
index aa7af92aa1..bf469af568 100644
--- a/platform/linuxbsd/os_linuxbsd.h
+++ b/platform/linuxbsd/os_linuxbsd.h
@@ -40,11 +40,20 @@
#include "joypad_linux.h"
#include "servers/audio_server.h"
+#ifdef FONTCONFIG_ENABLED
+#include "fontconfig-so_wrap.h"
+#endif
+
class OS_LinuxBSD : public OS_Unix {
virtual void delete_main_loop() override;
#ifdef FONTCONFIG_ENABLED
bool font_config_initialized = false;
+ FcConfig *config = nullptr;
+ FcObjectSet *object_set = nullptr;
+
+ int _weight_to_fc(int p_weight) const;
+ int _stretch_to_fc(int p_stretch) const;
#endif
#ifdef JOYDEV_ENABLED
@@ -94,7 +103,8 @@ public:
virtual uint64_t get_embedded_pck_offset() const override;
virtual Vector<String> get_system_fonts() const override;
- virtual String get_system_font_path(const String &p_font_name, bool p_bold = false, bool p_italic = false) const override;
+ virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
+ virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
virtual String get_config_path() const override;
virtual String get_data_path() const override;
@@ -119,6 +129,7 @@ public:
virtual Error move_to_trash(const String &p_path) override;
OS_LinuxBSD();
+ ~OS_LinuxBSD();
};
#endif // OS_LINUXBSD_H
diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp
index a5e3e60775..1c5c8b2d19 100644
--- a/platform/linuxbsd/x11/display_server_x11.cpp
+++ b/platform/linuxbsd/x11/display_server_x11.cpp
@@ -1397,8 +1397,8 @@ void DisplayServerX11::window_set_mouse_passthrough(const Vector<Vector2> &p_reg
XRectangle rect;
rect.x = 0;
rect.y = 0;
- rect.width = window_get_real_size(p_window).x;
- rect.height = window_get_real_size(p_window).y;
+ rect.width = window_get_size_with_decorations(p_window).x;
+ rect.height = window_get_size_with_decorations(p_window).y;
XUnionRectWithRegion(&rect, region, region);
} else {
XPoint *points = (XPoint *)memalloc(sizeof(XPoint) * p_region.size());
@@ -1582,7 +1582,7 @@ void DisplayServerX11::_update_size_hints(WindowID p_window) {
xsh->width = wd.size.width;
xsh->height = wd.size.height;
- if (window_mode == WINDOW_MODE_FULLSCREEN) {
+ if (window_mode == WINDOW_MODE_FULLSCREEN || window_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
// Do not set any other hints to prevent the window manager from ignoring the fullscreen flags
} else if (window_get_flag(WINDOW_FLAG_RESIZE_DISABLED, p_window)) {
// If resizing is disabled, use the forced size
@@ -1618,6 +1618,40 @@ Point2i DisplayServerX11::window_get_position(WindowID p_window) const {
return wd.position;
}
+Point2i DisplayServerX11::window_get_position_with_decorations(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+
+ if (wd.fullscreen) {
+ return wd.position;
+ }
+
+ XWindowAttributes xwa;
+ XSync(x11_display, False);
+ XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
+ int x = wd.position.x;
+ int y = wd.position.y;
+ Atom prop = XInternAtom(x11_display, "_NET_FRAME_EXTENTS", True);
+ if (prop != None) {
+ Atom type;
+ int format;
+ unsigned long len;
+ unsigned long remaining;
+ unsigned char *data = nullptr;
+ if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
+ if (format == 32 && len == 4 && data) {
+ long *extents = (long *)data;
+ x -= extents[0]; // left
+ y -= extents[2]; // top
+ }
+ XFree(data);
+ }
+ }
+ return Size2i(x, y);
+}
+
void DisplayServerX11::window_set_position(const Point2i &p_position, WindowID p_window) {
_THREAD_SAFE_METHOD_
@@ -1762,12 +1796,16 @@ Size2i DisplayServerX11::window_get_size(WindowID p_window) const {
return wd.size;
}
-Size2i DisplayServerX11::window_get_real_size(WindowID p_window) const {
+Size2i DisplayServerX11::window_get_size_with_decorations(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
const WindowData &wd = windows[p_window];
+ if (wd.fullscreen) {
+ return wd.size;
+ }
+
XWindowAttributes xwa;
XSync(x11_display, False);
XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
@@ -1949,7 +1987,7 @@ void DisplayServerX11::_validate_mode_on_map(WindowID p_window) {
// Check if we applied any window modes that didn't take effect while unmapped
const WindowData &wd = windows[p_window];
if (wd.fullscreen && !_window_fullscreen_check(p_window)) {
- _set_wm_fullscreen(p_window, true);
+ _set_wm_fullscreen(p_window, true, wd.exclusive_fullscreen);
} else if (wd.maximized && !_window_maximize_check(p_window, "_NET_WM_STATE")) {
_set_wm_maximized(p_window, true);
} else if (wd.minimized && !_window_minimize_check(p_window)) {
@@ -2024,7 +2062,7 @@ void DisplayServerX11::_set_wm_minimized(WindowID p_window, bool p_enabled) {
wd.minimized = p_enabled;
}
-void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled) {
+void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled, bool p_exclusive) {
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
@@ -2063,7 +2101,14 @@ void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled) {
// set bypass compositor hint
Atom bypass_compositor = XInternAtom(x11_display, "_NET_WM_BYPASS_COMPOSITOR", False);
- unsigned long compositing_disable_on = p_enabled ? 1 : 0;
+ unsigned long compositing_disable_on = 0; // Use default.
+ if (p_enabled) {
+ if (p_exclusive) {
+ compositing_disable_on = 1; // Force composition OFF to reduce overhead.
+ } else {
+ compositing_disable_on = 2; // Force composition ON to allow popup windows.
+ }
+ }
if (bypass_compositor != None) {
XChangeProperty(x11_display, wd.x11_window, bypass_compositor, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&compositing_disable_on, 1);
}
@@ -2109,8 +2154,9 @@ void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
case WINDOW_MODE_FULLSCREEN: {
//Remove full-screen
wd.fullscreen = false;
+ wd.exclusive_fullscreen = false;
- _set_wm_fullscreen(p_window, false);
+ _set_wm_fullscreen(p_window, false, false);
//un-maximize required for always on top
bool on_top = window_get_flag(WINDOW_FLAG_ALWAYS_ON_TOP, p_window);
@@ -2143,7 +2189,13 @@ void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
}
wd.fullscreen = true;
- _set_wm_fullscreen(p_window, true);
+ if (p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
+ wd.exclusive_fullscreen = true;
+ _set_wm_fullscreen(p_window, true, true);
+ } else {
+ wd.exclusive_fullscreen = false;
+ _set_wm_fullscreen(p_window, true, false);
+ }
} break;
case WINDOW_MODE_MAXIMIZED: {
_set_wm_maximized(p_window, true);
@@ -2158,7 +2210,11 @@ DisplayServer::WindowMode DisplayServerX11::window_get_mode(WindowID p_window) c
const WindowData &wd = windows[p_window];
if (wd.fullscreen) { //if fullscreen, it's not in another mode
- return WINDOW_MODE_FULLSCREEN;
+ if (wd.exclusive_fullscreen) {
+ return WINDOW_MODE_EXCLUSIVE_FULLSCREEN;
+ } else {
+ return WINDOW_MODE_FULLSCREEN;
+ }
}
// Test maximized.
@@ -3947,7 +4003,6 @@ void DisplayServerX11::process_events() {
mb->set_window_id(window_id_other);
mb->set_position(Vector2(x, y));
mb->set_global_position(mb->get_position());
- Input::get_singleton()->parse_input_event(mb);
}
break;
}
diff --git a/platform/linuxbsd/x11/display_server_x11.h b/platform/linuxbsd/x11/display_server_x11.h
index c88a6b466a..2578ca06fd 100644
--- a/platform/linuxbsd/x11/display_server_x11.h
+++ b/platform/linuxbsd/x11/display_server_x11.h
@@ -159,6 +159,7 @@ class DisplayServerX11 : public DisplayServer {
//better to guess on the fly, given WM can change it
//WindowMode mode;
bool fullscreen = false; //OS can't exit from this mode
+ bool exclusive_fullscreen = false;
bool on_top = false;
bool borderless = false;
bool resize_disabled = false;
@@ -283,7 +284,7 @@ class DisplayServerX11 : public DisplayServer {
bool _window_minimize_check(WindowID p_window) const;
void _validate_mode_on_map(WindowID p_window);
void _update_size_hints(WindowID p_window);
- void _set_wm_fullscreen(WindowID p_window, bool p_enabled);
+ void _set_wm_fullscreen(WindowID p_window, bool p_enabled, bool p_exclusive);
void _set_wm_maximized(WindowID p_window, bool p_enabled);
void _set_wm_minimized(WindowID p_window, bool p_enabled);
@@ -392,6 +393,7 @@ public:
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Point2i window_get_position_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
@@ -405,7 +407,7 @@ public:
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
- virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Size2i window_get_size_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h
index 8f315f736b..bd26f6e417 100644
--- a/platform/macos/display_server_macos.h
+++ b/platform/macos/display_server_macos.h
@@ -355,6 +355,7 @@ public:
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Point2i window_get_position_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
@@ -368,7 +369,7 @@ public:
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
- virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Size2i window_get_size_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm
index ad6143e16e..5c979dbf22 100644
--- a/platform/macos/display_server_macos.mm
+++ b/platform/macos/display_server_macos.mm
@@ -2414,6 +2414,27 @@ Point2i DisplayServerMacOS::window_get_position(WindowID p_window) const {
return pos;
}
+Point2i DisplayServerMacOS::window_get_position_with_decorations(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
+ const WindowData &wd = windows[p_window];
+
+ const NSRect nsrect = [wd.window_object frame];
+ Point2i pos;
+
+ // Return the position of the top-left corner, for OS X the y starts at the bottom.
+ const float scale = screen_get_max_scale();
+ pos.x = nsrect.origin.x;
+ pos.y = (nsrect.origin.y + nsrect.size.height);
+ pos *= scale;
+ pos -= _get_screens_origin();
+ // OS X native y-coordinate relative to _get_screens_origin() is negative,
+ // Godot expects a positive value.
+ pos.y *= -1;
+ return pos;
+}
+
void DisplayServerMacOS::window_set_position(const Point2i &p_position, WindowID p_window) {
_THREAD_SAFE_METHOD_
@@ -2573,7 +2594,7 @@ Size2i DisplayServerMacOS::window_get_size(WindowID p_window) const {
return wd.size;
}
-Size2i DisplayServerMacOS::window_get_real_size(WindowID p_window) const {
+Size2i DisplayServerMacOS::window_get_size_with_decorations(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index 5e71d10a3f..49c8c7758d 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -91,11 +91,14 @@ bool EditorExportPlatformMacOS::get_export_option_visibility(const EditorExportP
return false;
}
} break;
- case 2: { // "altool"
+ case 2: { // "notarytool"
+ // All options are visible.
+ } break;
+ case 3: { // "altool"
// All options are visible.
} break;
default: { // disabled
- if (p_option == "notarization/apple_id_name" || p_option == "notarization/apple_id_password" || p_option == "notarization/apple_team_id" || p_option == "notarization/api_uuid" || p_option == "notarization/api_key") {
+ if (p_option == "notarization/apple_id_name" || p_option == "notarization/apple_id_password" || p_option == "notarization/apple_team_id" || p_option == "notarization/api_uuid" || p_option == "notarization/api_key" || p_option == "notarization/api_key_id") {
return false;
}
} break;
@@ -129,9 +132,9 @@ void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "display/high_res"), false));
#ifdef MACOS_ENABLED
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/codesign", PROPERTY_HINT_ENUM, "Disabled,Built-in (ad-hoc only),PyOxidizer rcodesign,Xcode codesign"), 3, true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/codesign", PROPERTY_HINT_ENUM, "Disabled,Built-in (ad-hoc only),rcodesign,Xcode codesign"), 3, true));
#else
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/codesign", PROPERTY_HINT_ENUM, "Disabled,Built-in (ad-hoc only),PyOxidizer rcodesign"), 1, true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/codesign", PROPERTY_HINT_ENUM, "Disabled,Built-in (ad-hoc only),rcodesign"), 1, true));
#endif
// "codesign" only options:
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/identity", PROPERTY_HINT_PLACEHOLDER_TEXT, "Type: Name (ID)"), ""));
@@ -165,17 +168,18 @@ void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options
r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "codesign/custom_options"), PackedStringArray()));
#ifdef MACOS_ENABLED
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "notarization/notarization", PROPERTY_HINT_ENUM, "Disabled,PyOxidizer rcodesign,Xcode altool"), 0, true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "notarization/notarization", PROPERTY_HINT_ENUM, "Disabled,rcodesign,Xcode notarytool,Xcode altool (deprecated)"), 0, true));
#else
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "notarization/notarization", PROPERTY_HINT_ENUM, "Disabled,PyOxidizer rcodesign"), 0, true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "notarization/notarization", PROPERTY_HINT_ENUM, "Disabled,rcodesign"), 0, true));
#endif
- // "altool" only options:
+ // "altool" and "notarytool" only options:
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_id_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Apple ID email"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_id_password", PROPERTY_HINT_PASSWORD, "Enable two-factor authentication and provide app-specific password"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_team_id", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide team ID if your Apple ID belongs to multiple teams"), ""));
- // "altool" and "rcodesign" only options:
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/api_uuid", PROPERTY_HINT_PLACEHOLDER_TEXT, "App Store Connect issuer ID"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/api_key", PROPERTY_HINT_PLACEHOLDER_TEXT, "App Store Connect API key ID"), ""));
+ // "altool", "notarytool" and "rcodesign" only options:
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/api_uuid", PROPERTY_HINT_PLACEHOLDER_TEXT, "App Store Connect issuer ID UUID"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/api_key", PROPERTY_HINT_GLOBAL_FILE, "*.p8"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/api_key_id", PROPERTY_HINT_PLACEHOLDER_TEXT, "App Store Connect API key ID"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/microphone_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
@@ -498,7 +502,12 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
args.push_back(p_preset->get("notarization/api_uuid"));
args.push_back("--api-key");
- args.push_back(p_preset->get("notarization/api_key"));
+ args.push_back(p_preset->get("notarization/api_key_id"));
+
+ if (!p_preset->get("notarization/api_key").operator String().is_empty()) {
+ args.push_back("--api-key-path");
+ args.push_back(p_preset->get("notarization/api_key"));
+ }
args.push_back(p_path);
@@ -519,7 +528,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
} else {
print_verbose("rcodesign (" + p_path + "):\n" + str);
int next_nl = str.find("\n", rq_offset);
- String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 14, -1) : str.substr(rq_offset + 14, next_nl - rq_offset - 14);
+ String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 23, -1) : str.substr(rq_offset + 23, next_nl - rq_offset - 23);
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour."));
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("You can check progress manually by opening a Terminal and running the following command:"));
@@ -529,7 +538,91 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
}
} break;
#ifdef MACOS_ENABLED
- case 2: { // "altool"
+ case 2: { // "notarytool"
+ print_verbose("using notarytool notarization...");
+
+ if (!FileAccess::exists("/usr/bin/xcrun") && !FileAccess::exists("/bin/xcrun")) {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("Xcode command line tools are not installed."));
+ return Error::FAILED;
+ }
+
+ List<String> args;
+
+ args.push_back("notarytool");
+ args.push_back("submit");
+
+ args.push_back(p_path);
+
+ if (p_preset->get("notarization/apple_id_name") == "" && p_preset->get("notarization/api_uuid") == "") {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("Neither Apple ID name nor App Store Connect issuer ID name not specified."));
+ return Error::FAILED;
+ }
+ if (p_preset->get("notarization/apple_id_name") != "" && p_preset->get("notarization/api_uuid") != "") {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("Both Apple ID name and App Store Connect issuer ID name are specified, only one should be set at the same time."));
+ return Error::FAILED;
+ }
+
+ if (p_preset->get("notarization/apple_id_name") != "") {
+ if (p_preset->get("notarization/apple_id_password") == "") {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("Apple ID password not specified."));
+ return Error::FAILED;
+ }
+ args.push_back("--apple-id");
+ args.push_back(p_preset->get("notarization/apple_id_name"));
+
+ args.push_back("--password");
+ args.push_back(p_preset->get("notarization/apple_id_password"));
+ } else {
+ if (p_preset->get("notarization/api_key_id") == "") {
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("App Store Connect API key ID not specified."));
+ return Error::FAILED;
+ }
+ args.push_back("--issuer");
+ args.push_back(p_preset->get("notarization/api_uuid"));
+
+ if (!p_preset->get("notarization/api_key").operator String().is_empty()) {
+ args.push_back("--key");
+ args.push_back(p_preset->get("notarization/api_key"));
+ }
+
+ args.push_back("--key-id");
+ args.push_back(p_preset->get("notarization/api_key_id"));
+ }
+
+ args.push_back("--no-progress");
+
+ if (p_preset->get("notarization/apple_team_id")) {
+ args.push_back("--team-id");
+ args.push_back(p_preset->get("notarization/apple_team_id"));
+ }
+
+ String str;
+ int exitcode = 0;
+ Error err = OS::get_singleton()->execute("xcrun", args, &str, &exitcode, true);
+ if (err != OK) {
+ add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Could not start xcrun executable."));
+ return err;
+ }
+
+ int rq_offset = str.find("id:");
+ if (exitcode != 0 || rq_offset == -1) {
+ print_line("notarytool (" + p_path + "):\n" + str);
+ add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Notarization failed, see editor log for details."));
+ return Error::FAILED;
+ } else {
+ print_verbose("notarytool (" + p_path + "):\n" + str);
+ int next_nl = str.find("\n", rq_offset);
+ String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 4, -1) : str.substr(rq_offset + 4, next_nl - rq_offset - 4);
+ add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
+ add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour."));
+ add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("You can check progress manually by opening a Terminal and running the following command:"));
+ add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"xcrun notarytool log <request uuid> --issuer <api uuid> --key-id <api key id> --key <api key path>\" or");
+ add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"xcrun notarytool log <request uuid> --apple-id <your email> --password <app-specific pwd>>\"");
+ add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("Run the following command to staple the notarization ticket to the exported application (optional):"));
+ add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"xcrun stapler staple <app path>\"");
+ }
+ } break;
+ case 3: { // "altool"
print_verbose("using altool notarization...");
if (!FileAccess::exists("/usr/bin/xcrun") && !FileAccess::exists("/bin/xcrun")) {
@@ -573,7 +666,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
args.push_back(p_preset->get("notarization/api_uuid"));
args.push_back("--apiKey");
- args.push_back(p_preset->get("notarization/api_key"));
+ args.push_back(p_preset->get("notarization/api_key_id"));
}
args.push_back("--type");
@@ -595,7 +688,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
return err;
}
- int rq_offset = str.find("RequestUUID");
+ int rq_offset = str.find("RequestUUID:");
if (exitcode != 0 || rq_offset == -1) {
print_line("xcrun altool (" + p_path + "):\n" + str);
add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Notarization failed, see editor log for details."));
@@ -603,7 +696,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
} else {
print_verbose("xcrun altool (" + p_path + "):\n" + str);
int next_nl = str.find("\n", rq_offset);
- String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 14, -1) : str.substr(rq_offset + 14, next_nl - rq_offset - 14);
+ String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 13, -1) : str.substr(rq_offset + 13, next_nl - rq_offset - 13);
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour. When the process is completed, you'll receive an email."));
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("You can check progress manually by opening a Terminal and running the following command:"));
@@ -1819,7 +1912,7 @@ bool EditorExportPlatformMacOS::has_valid_project_configuration(const Ref<Editor
err += TTR("Notarization: Code signing is required for notarization.") + "\n";
valid = false;
}
- if (notary_tool == 2) {
+ if (notary_tool == 2 || notary_tool == 3) {
if (!FileAccess::exists("/usr/bin/xcrun") && !FileAccess::exists("/bin/xcrun")) {
err += TTR("Notarization: Xcode command line tools are not installed.") + "\n";
valid = false;
@@ -1838,7 +1931,7 @@ bool EditorExportPlatformMacOS::has_valid_project_configuration(const Ref<Editor
}
}
if (p_preset->get("notarization/api_uuid") != "") {
- if (p_preset->get("notarization/api_key") == "") {
+ if (p_preset->get("notarization/api_key_id") == "") {
err += TTR("Notarization: App Store Connect API key ID not specified.") + "\n";
valid = false;
}
@@ -1849,7 +1942,7 @@ bool EditorExportPlatformMacOS::has_valid_project_configuration(const Ref<Editor
err += TTR("Notarization: App Store Connect issuer ID name not specified.") + "\n";
valid = false;
}
- if (p_preset->get("notarization/api_key") == "") {
+ if (p_preset->get("notarization/api_key_id") == "") {
err += TTR("Notarization: App Store Connect API key ID not specified.") + "\n";
valid = false;
}
diff --git a/platform/macos/export/plist.cpp b/platform/macos/export/plist.cpp
index cad014e65b..82ecd41d9c 100644
--- a/platform/macos/export/plist.cpp
+++ b/platform/macos/export/plist.cpp
@@ -353,7 +353,7 @@ bool PList::load_file(const String &p_filename) {
} else {
// Load text plist.
Error err;
- Vector<uint8_t> array = FileAccess::get_file_as_array(p_filename, &err);
+ Vector<uint8_t> array = FileAccess::get_file_as_bytes(p_filename, &err);
ERR_FAIL_COND_V(err != OK, false);
String ret;
diff --git a/platform/macos/os_macos.h b/platform/macos/os_macos.h
index 46e7c17ebe..b2734e57cc 100644
--- a/platform/macos/os_macos.h
+++ b/platform/macos/os_macos.h
@@ -57,6 +57,10 @@ class OS_MacOS : public OS_Unix {
List<String> launch_service_args;
+ CGFloat _weight_to_ct(int p_weight) const;
+ CGFloat _stretch_to_ct(int p_stretch) const;
+ String _get_default_fontname(const String &p_font_name) const;
+
static _FORCE_INLINE_ String get_framework_executable(const String &p_path);
static void pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context);
@@ -98,7 +102,8 @@ public:
virtual String get_locale() const override;
virtual Vector<String> get_system_fonts() const override;
- virtual String get_system_font_path(const String &p_font_name, bool p_bold = false, bool p_italic = false) const override;
+ virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
+ virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
virtual String get_executable_path() const override;
virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) override;
virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) override;
diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm
index e620b058d3..ebba96ceb1 100644
--- a/platform/macos/os_macos.mm
+++ b/platform/macos/os_macos.mm
@@ -336,9 +336,7 @@ Vector<String> OS_MacOS::get_system_fonts() const {
return ret;
}
-String OS_MacOS::get_system_font_path(const String &p_font_name, bool p_bold, bool p_italic) const {
- String ret;
-
+String OS_MacOS::_get_default_fontname(const String &p_font_name) const {
String font_name = p_font_name;
if (font_name.to_lower() == "sans-serif") {
font_name = "Helvetica";
@@ -351,21 +349,153 @@ String OS_MacOS::get_system_font_path(const String &p_font_name, bool p_bold, bo
} else if (font_name.to_lower() == "cursive") {
font_name = "Apple Chancery";
};
+ return font_name;
+}
+
+CGFloat OS_MacOS::_weight_to_ct(int p_weight) const {
+ if (p_weight < 150) {
+ return -0.80;
+ } else if (p_weight < 250) {
+ return -0.60;
+ } else if (p_weight < 350) {
+ return -0.40;
+ } else if (p_weight < 450) {
+ return 0.0;
+ } else if (p_weight < 550) {
+ return 0.23;
+ } else if (p_weight < 650) {
+ return 0.30;
+ } else if (p_weight < 750) {
+ return 0.40;
+ } else if (p_weight < 850) {
+ return 0.56;
+ } else if (p_weight < 925) {
+ return 0.62;
+ } else {
+ return 1.00;
+ }
+}
+
+CGFloat OS_MacOS::_stretch_to_ct(int p_stretch) const {
+ if (p_stretch < 56) {
+ return -0.5;
+ } else if (p_stretch < 69) {
+ return -0.37;
+ } else if (p_stretch < 81) {
+ return -0.25;
+ } else if (p_stretch < 93) {
+ return -0.13;
+ } else if (p_stretch < 106) {
+ return 0.0;
+ } else if (p_stretch < 137) {
+ return 0.13;
+ } else if (p_stretch < 144) {
+ return 0.25;
+ } else if (p_stretch < 162) {
+ return 0.37;
+ } else {
+ return 0.5;
+ }
+}
+
+Vector<String> OS_MacOS::get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale, const String &p_script, int p_weight, int p_stretch, bool p_italic) const {
+ Vector<String> ret;
+ String font_name = _get_default_fontname(p_font_name);
+
+ CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, font_name.utf8().get_data(), kCFStringEncodingUTF8);
+ CTFontSymbolicTraits traits = 0;
+ if (p_weight >= 700) {
+ traits |= kCTFontBoldTrait;
+ }
+ if (p_italic) {
+ traits |= kCTFontItalicTrait;
+ }
+ if (p_stretch < 100) {
+ traits |= kCTFontCondensedTrait;
+ } else if (p_stretch > 100) {
+ traits |= kCTFontExpandedTrait;
+ }
+
+ CFNumberRef sym_traits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &traits);
+ CFMutableDictionaryRef traits_dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
+ CFDictionaryAddValue(traits_dict, kCTFontSymbolicTrait, sym_traits);
+
+ CGFloat weight = _weight_to_ct(p_weight);
+ CFNumberRef font_weight = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &weight);
+ CFDictionaryAddValue(traits_dict, kCTFontWeightTrait, font_weight);
+
+ CGFloat stretch = _stretch_to_ct(p_stretch);
+ CFNumberRef font_stretch = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &stretch);
+ CFDictionaryAddValue(traits_dict, kCTFontWidthTrait, font_stretch);
+
+ CFMutableDictionaryRef attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
+ CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, name);
+ CFDictionaryAddValue(attributes, kCTFontTraitsAttribute, traits_dict);
+
+ CTFontDescriptorRef font = CTFontDescriptorCreateWithAttributes(attributes);
+ if (font) {
+ CTFontRef family = CTFontCreateWithFontDescriptor(font, 0, nullptr);
+ CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, p_text.utf8().get_data(), kCFStringEncodingUTF8);
+ CFRange range = CFRangeMake(0, CFStringGetLength(string));
+ CTFontRef fallback_family = CTFontCreateForString(family, string, range);
+ if (fallback_family) {
+ CTFontDescriptorRef fallback_font = CTFontCopyFontDescriptor(fallback_family);
+ if (fallback_font) {
+ CFURLRef url = (CFURLRef)CTFontDescriptorCopyAttribute(fallback_font, kCTFontURLAttribute);
+ if (url) {
+ NSString *font_path = [NSString stringWithString:[(__bridge NSURL *)url path]];
+ ret.push_back(String::utf8([font_path UTF8String]));
+ CFRelease(url);
+ }
+ CFRelease(fallback_font);
+ }
+ CFRelease(fallback_family);
+ }
+ CFRelease(string);
+ CFRelease(font);
+ }
+
+ CFRelease(attributes);
+ CFRelease(traits_dict);
+ CFRelease(sym_traits);
+ CFRelease(font_stretch);
+ CFRelease(font_weight);
+ CFRelease(name);
+
+ return ret;
+}
+
+String OS_MacOS::get_system_font_path(const String &p_font_name, int p_weight, int p_stretch, bool p_italic) const {
+ String ret;
+ String font_name = _get_default_fontname(p_font_name);
CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, font_name.utf8().get_data(), kCFStringEncodingUTF8);
CTFontSymbolicTraits traits = 0;
- if (p_bold) {
+ if (p_weight > 700) {
traits |= kCTFontBoldTrait;
}
if (p_italic) {
traits |= kCTFontItalicTrait;
}
+ if (p_stretch < 100) {
+ traits |= kCTFontCondensedTrait;
+ } else if (p_stretch > 100) {
+ traits |= kCTFontExpandedTrait;
+ }
CFNumberRef sym_traits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &traits);
CFMutableDictionaryRef traits_dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
CFDictionaryAddValue(traits_dict, kCTFontSymbolicTrait, sym_traits);
+ CGFloat weight = _weight_to_ct(p_weight);
+ CFNumberRef font_weight = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &weight);
+ CFDictionaryAddValue(traits_dict, kCTFontWeightTrait, font_weight);
+
+ CGFloat stretch = _stretch_to_ct(p_stretch);
+ CFNumberRef font_stretch = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &stretch);
+ CFDictionaryAddValue(traits_dict, kCTFontWidthTrait, font_stretch);
+
CFMutableDictionaryRef attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, name);
CFDictionaryAddValue(attributes, kCTFontTraitsAttribute, traits_dict);
@@ -384,6 +514,8 @@ String OS_MacOS::get_system_font_path(const String &p_font_name, bool p_bold, bo
CFRelease(attributes);
CFRelease(traits_dict);
CFRelease(sym_traits);
+ CFRelease(font_stretch);
+ CFRelease(font_weight);
CFRelease(name);
return ret;
diff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp
index f704124704..d057010c02 100644
--- a/platform/web/display_server_web.cpp
+++ b/platform/web/display_server_web.cpp
@@ -579,8 +579,8 @@ void DisplayServerWeb::touch_callback(int p_type, int p_count) {
}
}
-bool DisplayServerWeb::screen_is_touchscreen(int p_screen) const {
- return godot_js_display_touchscreen_is_available();
+bool DisplayServerWeb::is_touchscreen_available() const {
+ return godot_js_display_touchscreen_is_available() || (Input::get_singleton() && Input::get_singleton()->is_emulating_touch_from_mouse());
}
// Virtual Keyboard
@@ -943,7 +943,11 @@ void DisplayServerWeb::window_set_current_screen(int p_screen, WindowID p_window
}
Point2i DisplayServerWeb::window_get_position(WindowID p_window) const {
- return Point2i(); // TODO Does this need implementation?
+ return Point2i();
+}
+
+Point2i DisplayServerWeb::window_get_position_with_decorations(WindowID p_window) const {
+ return Point2i();
}
void DisplayServerWeb::window_set_position(const Point2i &p_position, WindowID p_window) {
@@ -980,7 +984,7 @@ Size2i DisplayServerWeb::window_get_size(WindowID p_window) const {
return Size2i(size[0], size[1]);
}
-Size2i DisplayServerWeb::window_get_real_size(WindowID p_window) const {
+Size2i DisplayServerWeb::window_get_size_with_decorations(WindowID p_window) const {
return window_get_size(p_window);
}
diff --git a/platform/web/display_server_web.h b/platform/web/display_server_web.h
index 1919736802..fce98ec3d0 100644
--- a/platform/web/display_server_web.h
+++ b/platform/web/display_server_web.h
@@ -143,7 +143,7 @@ public:
virtual Point2i mouse_get_position() const override;
// touch
- virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
+ virtual bool is_touchscreen_available() const override;
// clipboard
virtual void clipboard_set(const String &p_text) override;
@@ -182,6 +182,7 @@ public:
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Point2i window_get_position_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
@@ -194,7 +195,7 @@ public:
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
- virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Size2i window_get_size_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 705e83dace..1b55574b19 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -188,6 +188,7 @@ def get_opts():
BoolVariable("use_llvm", "Use the LLVM compiler", False),
BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True),
BoolVariable("use_asan", "Use address sanitizer (ASAN)", False),
+ BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False),
]
@@ -339,10 +340,14 @@ def configure_msvc(env, vcvars_msvc_config):
## Compile/link flags
- if env["use_static_cpp"]:
- env.AppendUnique(CCFLAGS=["/MT"])
+ if env["debug_crt"]:
+ # Always use dynamic runtime, static debug CRT breaks thread_local.
+ env.AppendUnique(CCFLAGS=["/MDd"])
else:
- env.AppendUnique(CCFLAGS=["/MD"])
+ if env["use_static_cpp"]:
+ env.AppendUnique(CCFLAGS=["/MT"])
+ else:
+ env.AppendUnique(CCFLAGS=["/MD"])
if env["arch"] == "x86_32":
env["x86_libtheora_opt_vc"] = True
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index c704a26b7a..e7864ebac0 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -909,6 +909,24 @@ Point2i DisplayServerWindows::window_get_position(WindowID p_window) const {
return Point2i(point.x, point.y);
}
+Point2i DisplayServerWindows::window_get_position_with_decorations(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
+ const WindowData &wd = windows[p_window];
+
+ if (wd.minimized) {
+ return wd.last_pos;
+ }
+
+ RECT r;
+ if (GetWindowRect(wd.hWnd, &r)) {
+ return Point2i(r.left, r.top);
+ }
+
+ return Point2i();
+}
+
void DisplayServerWindows::_update_real_mouse_position(WindowID p_window) {
ERR_FAIL_COND(!windows.has(p_window));
@@ -1124,7 +1142,7 @@ Size2i DisplayServerWindows::window_get_size(WindowID p_window) const {
return Size2();
}
-Size2i DisplayServerWindows::window_get_real_size(WindowID p_window) const {
+Size2i DisplayServerWindows::window_get_size_with_decorations(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
@@ -2414,7 +2432,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_GETMINMAXINFO: {
if (windows[window_id].resizable && !windows[window_id].fullscreen) {
// Size of window decorations.
- Size2 decor = window_get_real_size(window_id) - window_get_size(window_id);
+ Size2 decor = window_get_size_with_decorations(window_id) - window_get_size(window_id);
MINMAXINFO *min_max_info = (MINMAXINFO *)lParam;
if (windows[window_id].min_size != Size2()) {
@@ -2473,7 +2491,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
window_mouseover_id = INVALID_WINDOW_ID;
_send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT);
- } else if (window_mouseover_id != INVALID_WINDOW_ID) {
+ } else if (window_mouseover_id != INVALID_WINDOW_ID && windows.has(window_mouseover_id)) {
// This is reached during drag and drop, after dropping in a different window.
// Once-off notification, must call again.
track_mouse_leave_event(windows[window_mouseover_id].hWnd);
@@ -2712,7 +2730,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
// Mouse enter.
if (mouse_mode != MOUSE_MODE_CAPTURED) {
- if (window_mouseover_id != INVALID_WINDOW_ID) {
+ if (window_mouseover_id != INVALID_WINDOW_ID && windows.has(window_mouseover_id)) {
// Leave previous window.
_send_window_event(windows[window_mouseover_id], WINDOW_EVENT_MOUSE_EXIT);
}
@@ -2814,7 +2832,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
DisplayServer::WindowID over_id = get_window_at_screen_position(mouse_get_position());
- if (!Rect2(window_get_position(over_id), Point2(windows[over_id].width, windows[over_id].height)).has_point(mouse_get_position())) {
+ if (windows.has(over_id) && !Rect2(window_get_position(over_id), Point2(windows[over_id].width, windows[over_id].height)).has_point(mouse_get_position())) {
// Don't consider the windowborder as part of the window.
over_id = INVALID_WINDOW_ID;
}
@@ -2822,12 +2840,12 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
// Mouse enter.
if (mouse_mode != MOUSE_MODE_CAPTURED) {
- if (window_mouseover_id != INVALID_WINDOW_ID) {
+ if (window_mouseover_id != INVALID_WINDOW_ID && windows.has(window_mouseover_id)) {
// Leave previous window.
_send_window_event(windows[window_mouseover_id], WINDOW_EVENT_MOUSE_EXIT);
}
- if (over_id != INVALID_WINDOW_ID) {
+ if (over_id != INVALID_WINDOW_ID && windows.has(over_id)) {
_send_window_event(windows[over_id], WINDOW_EVENT_MOUSE_ENTER);
}
}
@@ -3520,7 +3538,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
DWORD dwExStyle;
DWORD dwStyle;
- _get_window_style(window_id_counter == MAIN_WINDOW_ID, (p_mode == WINDOW_MODE_FULLSCREEN || p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN), p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN, p_flags & WINDOW_FLAG_BORDERLESS_BIT, !(p_flags & WINDOW_FLAG_RESIZE_DISABLED_BIT), p_mode == WINDOW_MODE_MAXIMIZED, (p_flags & WINDOW_FLAG_NO_FOCUS_BIT), dwStyle, dwExStyle);
+ _get_window_style(window_id_counter == MAIN_WINDOW_ID, (p_mode == WINDOW_MODE_FULLSCREEN || p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN), p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN, p_flags & WINDOW_FLAG_BORDERLESS_BIT, !(p_flags & WINDOW_FLAG_RESIZE_DISABLED_BIT), p_mode == WINDOW_MODE_MAXIMIZED, (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) | (p_flags & WINDOW_FLAG_POPUP), dwStyle, dwExStyle);
RECT WindowRect;
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index 8ac0086d69..4702bb7765 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -555,6 +555,7 @@ public:
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
+ virtual Point2i window_get_position_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
@@ -568,7 +569,7 @@ public:
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
- virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override; //wtf is this? should probable use proper name
+ virtual Size2i window_get_size_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index d8548eb545..e957a25e87 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -43,12 +43,12 @@
#include "platform/windows/display_server_windows.h"
#include "servers/audio_server.h"
#include "servers/rendering/rendering_server_default.h"
+#include "servers/text_server.h"
#include "windows_terminal_logger.h"
#include <avrt.h>
#include <bcrypt.h>
#include <direct.h>
-#include <dwrite.h>
#include <knownfolders.h>
#include <process.h>
#include <regstr.h>
@@ -189,6 +189,27 @@ void OS_Windows::initialize() {
IPUnix::make_default();
main_loop = nullptr;
+
+ CoInitialize(nullptr);
+ HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&dwrite_factory));
+ if (SUCCEEDED(hr)) {
+ hr = dwrite_factory->GetSystemFontCollection(&font_collection, false);
+ if (SUCCEEDED(hr)) {
+ dwrite_init = true;
+ hr = dwrite_factory->QueryInterface(&dwrite_factory2);
+ if (SUCCEEDED(hr)) {
+ hr = dwrite_factory2->GetSystemFontFallback(&system_font_fallback);
+ if (SUCCEEDED(hr)) {
+ dwrite2_init = true;
+ }
+ }
+ }
+ }
+ if (!dwrite_init) {
+ print_verbose("Unable to load IDWriteFactory, system font support is disabled.");
+ } else if (!dwrite2_init) {
+ print_verbose("Unable to load IDWriteFactory2, automatic system font fallback is disabled.");
+ }
}
void OS_Windows::delete_main_loop() {
@@ -203,6 +224,22 @@ void OS_Windows::set_main_loop(MainLoop *p_main_loop) {
}
void OS_Windows::finalize() {
+ if (dwrite_factory2) {
+ dwrite_factory2->Release();
+ dwrite_factory2 = nullptr;
+ }
+ if (font_collection) {
+ font_collection->Release();
+ font_collection = nullptr;
+ }
+ if (system_font_fallback) {
+ system_font_fallback->Release();
+ system_font_fallback = nullptr;
+ }
+ if (dwrite_factory) {
+ dwrite_factory->Release();
+ dwrite_factory = nullptr;
+ }
#ifdef WINMIDI_ENABLED
driver_midi.close();
#endif
@@ -726,21 +763,17 @@ Error OS_Windows::set_cwd(const String &p_cwd) {
}
Vector<String> OS_Windows::get_system_fonts() const {
+ if (!dwrite_init) {
+ return Vector<String>();
+ }
+
Vector<String> ret;
HashSet<String> font_names;
- ComAutoreleaseRef<IDWriteFactory> dwrite_factory;
- HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&dwrite_factory.reference));
- ERR_FAIL_COND_V(FAILED(hr) || dwrite_factory.is_null(), ret);
-
- ComAutoreleaseRef<IDWriteFontCollection> font_collection;
- hr = dwrite_factory->GetSystemFontCollection(&font_collection.reference, false);
- ERR_FAIL_COND_V(FAILED(hr) || font_collection.is_null(), ret);
-
UINT32 family_count = font_collection->GetFontFamilyCount();
for (UINT32 i = 0; i < family_count; i++) {
ComAutoreleaseRef<IDWriteFontFamily> family;
- hr = font_collection->GetFontFamily(i, &family.reference);
+ HRESULT hr = font_collection->GetFontFamily(i, &family.reference);
ERR_CONTINUE(FAILED(hr) || family.is_null());
ComAutoreleaseRef<IDWriteLocalizedStrings> family_names;
@@ -771,7 +804,98 @@ Vector<String> OS_Windows::get_system_fonts() const {
return ret;
}
-String OS_Windows::get_system_font_path(const String &p_font_name, bool p_bold, bool p_italic) const {
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+#endif
+
+class FallbackTextAnalysisSource : public IDWriteTextAnalysisSource {
+ LONG _cRef = 1;
+
+ bool rtl = false;
+ Char16String string;
+ Char16String locale;
+ IDWriteNumberSubstitution *n_sub = nullptr;
+
+public:
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID **ppvInterface) {
+ if (IID_IUnknown == riid) {
+ AddRef();
+ *ppvInterface = (IUnknown *)this;
+ } else if (__uuidof(IMMNotificationClient) == riid) {
+ AddRef();
+ *ppvInterface = (IMMNotificationClient *)this;
+ } else {
+ *ppvInterface = nullptr;
+ return E_NOINTERFACE;
+ }
+ return S_OK;
+ }
+
+ ULONG STDMETHODCALLTYPE AddRef() {
+ return InterlockedIncrement(&_cRef);
+ }
+
+ ULONG STDMETHODCALLTYPE Release() {
+ ULONG ulRef = InterlockedDecrement(&_cRef);
+ if (0 == ulRef) {
+ delete this;
+ }
+ return ulRef;
+ }
+
+ HRESULT STDMETHODCALLTYPE GetTextAtPosition(UINT32 p_text_position, WCHAR const **r_text_string, UINT32 *r_text_length) override {
+ if (p_text_position >= (UINT32)string.length()) {
+ *r_text_string = nullptr;
+ *r_text_length = 0;
+ return S_OK;
+ }
+ *r_text_string = reinterpret_cast<const wchar_t *>(string.get_data()) + p_text_position;
+ *r_text_length = string.length() - p_text_position;
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE GetTextBeforePosition(UINT32 p_text_position, WCHAR const **r_text_string, UINT32 *r_text_length) override {
+ if (p_text_position < 1 || p_text_position >= (UINT32)string.length()) {
+ *r_text_string = nullptr;
+ *r_text_length = 0;
+ return S_OK;
+ }
+ *r_text_string = reinterpret_cast<const wchar_t *>(string.get_data());
+ *r_text_length = p_text_position;
+ return S_OK;
+ }
+
+ DWRITE_READING_DIRECTION STDMETHODCALLTYPE GetParagraphReadingDirection() override {
+ return (rtl) ? DWRITE_READING_DIRECTION_RIGHT_TO_LEFT : DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
+ }
+
+ HRESULT STDMETHODCALLTYPE GetLocaleName(UINT32 p_text_position, UINT32 *r_text_length, WCHAR const **r_locale_name) override {
+ *r_locale_name = reinterpret_cast<const wchar_t *>(locale.get_data());
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE GetNumberSubstitution(UINT32 p_text_position, UINT32 *r_text_length, IDWriteNumberSubstitution **r_number_substitution) override {
+ *r_number_substitution = n_sub;
+ return S_OK;
+ }
+
+ FallbackTextAnalysisSource(const Char16String &p_text, const Char16String &p_locale, bool p_rtl, IDWriteNumberSubstitution *p_nsub) {
+ _cRef = 1;
+ string = p_text;
+ locale = p_locale;
+ n_sub = p_nsub;
+ rtl = p_rtl;
+ };
+
+ virtual ~FallbackTextAnalysisSource() {}
+};
+
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
+String OS_Windows::_get_default_fontname(const String &p_font_name) const {
String font_name = p_font_name;
if (font_name.to_lower() == "sans-serif") {
font_name = "Arial";
@@ -784,18 +908,157 @@ String OS_Windows::get_system_font_path(const String &p_font_name, bool p_bold,
} else if (font_name.to_lower() == "fantasy") {
font_name = "Gabriola";
}
+ return font_name;
+}
+
+DWRITE_FONT_WEIGHT OS_Windows::_weight_to_dw(int p_weight) const {
+ if (p_weight < 150) {
+ return DWRITE_FONT_WEIGHT_THIN;
+ } else if (p_weight < 250) {
+ return DWRITE_FONT_WEIGHT_EXTRA_LIGHT;
+ } else if (p_weight < 325) {
+ return DWRITE_FONT_WEIGHT_LIGHT;
+ } else if (p_weight < 375) {
+ return DWRITE_FONT_WEIGHT_SEMI_LIGHT;
+ } else if (p_weight < 450) {
+ return DWRITE_FONT_WEIGHT_NORMAL;
+ } else if (p_weight < 550) {
+ return DWRITE_FONT_WEIGHT_MEDIUM;
+ } else if (p_weight < 650) {
+ return DWRITE_FONT_WEIGHT_DEMI_BOLD;
+ } else if (p_weight < 750) {
+ return DWRITE_FONT_WEIGHT_BOLD;
+ } else if (p_weight < 850) {
+ return DWRITE_FONT_WEIGHT_EXTRA_BOLD;
+ } else if (p_weight < 925) {
+ return DWRITE_FONT_WEIGHT_BLACK;
+ } else {
+ return DWRITE_FONT_WEIGHT_EXTRA_BLACK;
+ }
+}
+
+DWRITE_FONT_STRETCH OS_Windows::_stretch_to_dw(int p_stretch) const {
+ if (p_stretch < 56) {
+ return DWRITE_FONT_STRETCH_ULTRA_CONDENSED;
+ } else if (p_stretch < 69) {
+ return DWRITE_FONT_STRETCH_EXTRA_CONDENSED;
+ } else if (p_stretch < 81) {
+ return DWRITE_FONT_STRETCH_CONDENSED;
+ } else if (p_stretch < 93) {
+ return DWRITE_FONT_STRETCH_SEMI_CONDENSED;
+ } else if (p_stretch < 106) {
+ return DWRITE_FONT_STRETCH_NORMAL;
+ } else if (p_stretch < 137) {
+ return DWRITE_FONT_STRETCH_SEMI_EXPANDED;
+ } else if (p_stretch < 144) {
+ return DWRITE_FONT_STRETCH_EXPANDED;
+ } else if (p_stretch < 162) {
+ return DWRITE_FONT_STRETCH_EXTRA_EXPANDED;
+ } else {
+ return DWRITE_FONT_STRETCH_ULTRA_EXPANDED;
+ }
+}
+
+Vector<String> OS_Windows::get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale, const String &p_script, int p_weight, int p_stretch, bool p_italic) const {
+ if (!dwrite2_init) {
+ return Vector<String>();
+ }
+
+ String font_name = _get_default_fontname(p_font_name);
+
+ bool rtl = TS->is_locale_right_to_left(p_locale);
+ Char16String text = p_text.utf16();
+ Char16String locale = p_locale.utf16();
+
+ ComAutoreleaseRef<IDWriteNumberSubstitution> number_substitution;
+ HRESULT hr = dwrite_factory->CreateNumberSubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, reinterpret_cast<const wchar_t *>(locale.get_data()), true, &number_substitution.reference);
+ ERR_FAIL_COND_V(FAILED(hr) || number_substitution.is_null(), Vector<String>());
+
+ FallbackTextAnalysisSource fs = FallbackTextAnalysisSource(text, locale, rtl, number_substitution.reference);
+ UINT32 mapped_length = 0;
+ FLOAT scale = 0.0;
+ ComAutoreleaseRef<IDWriteFont> dwrite_font;
+ hr = system_font_fallback->MapCharacters(
+ &fs,
+ 0,
+ (UINT32)text.length(),
+ font_collection,
+ reinterpret_cast<const wchar_t *>(font_name.utf16().get_data()),
+ _weight_to_dw(p_weight),
+ p_italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL,
+ _stretch_to_dw(p_stretch),
+ &mapped_length,
+ &dwrite_font.reference,
+ &scale);
+
+ if (FAILED(hr) || dwrite_font.is_null()) {
+ return Vector<String>();
+ }
+
+ ComAutoreleaseRef<IDWriteFontFace> dwrite_face;
+ hr = dwrite_font->CreateFontFace(&dwrite_face.reference);
+ if (FAILED(hr) || dwrite_face.is_null()) {
+ return Vector<String>();
+ }
+
+ UINT32 number_of_files = 0;
+ hr = dwrite_face->GetFiles(&number_of_files, nullptr);
+ if (FAILED(hr)) {
+ return Vector<String>();
+ }
+ Vector<ComAutoreleaseRef<IDWriteFontFile>> files;
+ files.resize(number_of_files);
+ hr = dwrite_face->GetFiles(&number_of_files, (IDWriteFontFile **)files.ptrw());
+ if (FAILED(hr)) {
+ return Vector<String>();
+ }
+
+ Vector<String> ret;
+ for (UINT32 i = 0; i < number_of_files; i++) {
+ void const *reference_key = nullptr;
+ UINT32 reference_key_size = 0;
+ ComAutoreleaseRef<IDWriteLocalFontFileLoader> loader;
+
+ hr = files.write[i]->GetLoader((IDWriteFontFileLoader **)&loader.reference);
+ if (FAILED(hr) || loader.is_null()) {
+ continue;
+ }
+ hr = files.write[i]->GetReferenceKey(&reference_key, &reference_key_size);
+ if (FAILED(hr)) {
+ continue;
+ }
+
+ WCHAR file_path[MAX_PATH];
+ hr = loader->GetFilePathFromKey(reference_key, reference_key_size, &file_path[0], MAX_PATH);
+ if (FAILED(hr)) {
+ continue;
+ }
+ String fpath = String::utf16((const char16_t *)&file_path[0]);
+
+ WIN32_FIND_DATAW d;
+ HANDLE fnd = FindFirstFileW((LPCWSTR)&file_path[0], &d);
+ if (fnd != INVALID_HANDLE_VALUE) {
+ String fname = String::utf16((const char16_t *)d.cFileName);
+ if (!fname.is_empty()) {
+ fpath = fpath.get_base_dir().path_join(fname);
+ }
+ FindClose(fnd);
+ }
+ ret.push_back(fpath);
+ }
+ return ret;
+}
- ComAutoreleaseRef<IDWriteFactory> dwrite_factory;
- HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&dwrite_factory.reference));
- ERR_FAIL_COND_V(FAILED(hr) || dwrite_factory.is_null(), String());
+String OS_Windows::get_system_font_path(const String &p_font_name, int p_weight, int p_stretch, bool p_italic) const {
+ if (!dwrite_init) {
+ return String();
+ }
- ComAutoreleaseRef<IDWriteFontCollection> font_collection;
- hr = dwrite_factory->GetSystemFontCollection(&font_collection.reference, false);
- ERR_FAIL_COND_V(FAILED(hr) || font_collection.is_null(), String());
+ String font_name = _get_default_fontname(p_font_name);
UINT32 index = 0;
BOOL exists = false;
- font_collection->FindFamilyName((const WCHAR *)font_name.utf16().get_data(), &index, &exists);
+ HRESULT hr = font_collection->FindFamilyName((const WCHAR *)font_name.utf16().get_data(), &index, &exists);
if (FAILED(hr)) {
return String();
}
@@ -807,7 +1070,7 @@ String OS_Windows::get_system_font_path(const String &p_font_name, bool p_bold,
}
ComAutoreleaseRef<IDWriteFont> dwrite_font;
- hr = family->GetFirstMatchingFont(p_bold ? DWRITE_FONT_WEIGHT_BOLD : DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL, p_italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, &dwrite_font.reference);
+ hr = family->GetFirstMatchingFont(_weight_to_dw(p_weight), _stretch_to_dw(p_stretch), p_italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, &dwrite_font.reference);
if (FAILED(hr) || dwrite_font.is_null()) {
return String();
}
@@ -1192,7 +1455,7 @@ String OS_Windows::get_unique_id() const {
bool OS_Windows::_check_internal_feature_support(const String &p_feature) {
if (p_feature == "system_fonts") {
- return true;
+ return dwrite_init;
}
if (p_feature == "pc") {
return true;
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 6f89be699a..1db2b5880d 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -55,6 +55,8 @@
#include <stdio.h>
#define WIN32_LEAN_AND_MEAN
+#include <dwrite.h>
+#include <dwrite_2.h>
#include <windows.h>
#include <windowsx.h>
@@ -79,6 +81,9 @@ public:
_FORCE_INLINE_ bool is_valid() const { return reference != nullptr; }
_FORCE_INLINE_ bool is_null() const { return reference == nullptr; }
ComAutoreleaseRef() {}
+ ComAutoreleaseRef(T *p_ref) {
+ reference = p_ref;
+ }
~ComAutoreleaseRef() {
if (reference != nullptr) {
reference->Release();
@@ -114,6 +119,18 @@ class OS_Windows : public OS {
HWND main_window;
+ IDWriteFactory *dwrite_factory = nullptr;
+ IDWriteFactory2 *dwrite_factory2 = nullptr;
+ IDWriteFontCollection *font_collection = nullptr;
+ IDWriteFontFallback *system_font_fallback = nullptr;
+
+ bool dwrite_init = false;
+ bool dwrite2_init = false;
+
+ String _get_default_fontname(const String &p_font_name) const;
+ DWRITE_FONT_WEIGHT _weight_to_dw(int p_weight) const;
+ DWRITE_FONT_STRETCH _stretch_to_dw(int p_stretch) const;
+
// functions used by main to initialize/deinitialize the OS
protected:
virtual void initialize() override;
@@ -172,7 +189,8 @@ public:
virtual bool set_environment(const String &p_var, const String &p_value) const override;
virtual Vector<String> get_system_fonts() const override;
- virtual String get_system_font_path(const String &p_font_name, bool p_bold = false, bool p_italic = false) const override;
+ virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
+ virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override;
virtual String get_executable_path() const override;