summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-07-08 15:38:30 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-07-26 08:38:05 +0300
commit36ef8f29dcea579aab058e1778303e10360c7e83 (patch)
treea8206b91fb0d26e5ec550bcbdaaaf151eb3b80ab /core
parent3e0e84a54c1c5666c32dbc2abd419b61e071ba33 (diff)
Implement support for loading system fonts on Linux, macOS / iOS and Windows.
Diffstat (limited to 'core')
-rw-r--r--core/core_bind.cpp10
-rw-r--r--core/core_bind.h2
-rw-r--r--core/os/os.h2
3 files changed, 14 insertions, 0 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 26ecd41353..f54ca8de63 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -231,6 +231,14 @@ void OS::crash(const String &p_message) {
CRASH_NOW_MSG(p_message);
}
+Vector<String> OS::get_system_fonts() const {
+ return ::OS::get_singleton()->get_system_fonts();
+}
+
+String OS::get_system_font_path(const String &p_font_name, bool p_bold, bool p_italic) const {
+ return ::OS::get_singleton()->get_system_font_path(p_font_name, p_bold, p_italic);
+}
+
String OS::get_executable_path() const {
return ::OS::get_singleton()->get_executable_path();
}
@@ -589,6 +597,8 @@ void OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_processor_count"), &OS::get_processor_count);
ClassDB::bind_method(D_METHOD("get_processor_name"), &OS::get_processor_name);
+ ClassDB::bind_method(D_METHOD("get_system_fonts"), &OS::get_system_fonts);
+ ClassDB::bind_method(D_METHOD("get_system_font_path", "font_name", "bold", "italic"), &OS::get_system_font_path, DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_executable_path"), &OS::get_executable_path);
ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "output", "read_stderr", "open_console"), &OS::execute, DEFVAL(Array()), DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("create_process", "path", "arguments", "open_console"), &OS::create_process, DEFVAL(false));
diff --git a/core/core_bind.h b/core/core_bind.h
index c116ac4986..e222a220f0 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -170,6 +170,8 @@ public:
void alert(const String &p_alert, const String &p_title = "ALERT!");
void crash(const String &p_message);
+ Vector<String> get_system_fonts() const;
+ String get_system_font_path(const String &p_font_name, bool p_bold = false, bool p_italic = false) const;
String get_executable_path() const;
int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = Array(), bool p_read_stderr = false, bool p_open_console = false);
int create_process(const String &p_path, const Vector<String> &p_arguments, bool p_open_console = false);
diff --git a/core/os/os.h b/core/os/os.h
index 0428f6df2a..b9f7328929 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -142,6 +142,8 @@ public:
virtual void set_low_processor_usage_mode_sleep_usec(int p_usec);
virtual int get_low_processor_usage_mode_sleep_usec() const;
+ virtual Vector<String> get_system_fonts() const { return Vector<String>(); };
+ virtual String get_system_font_path(const String &p_font_name, bool p_bold = false, bool p_italic = false) const { return String(); };
virtual String get_executable_path() const;
virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) = 0;
virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) = 0;