diff --git a/doc/classes/FontFile.xml b/doc/classes/FontFile.xml
index 1b8fa0077285..12072ac56463 100644
--- a/doc/classes/FontFile.xml
+++ b/doc/classes/FontFile.xml
@@ -631,6 +631,9 @@
Font hinting mode. Used by dynamic fonts only.
+
+ LCD subpixel layout used for font anti-aliasing. See [enum TextServer.FontLCDSubpixelLayout].
+
The width of the range around the shape between the minimum and maximum representable signed distance. If using font outlines, [member msdf_pixel_range] must be set to at least [i]twice[/i] the size of the largest font outline. The default [member msdf_pixel_range] value of [code]16[/code] allows outline sizes up to [code]8[/code] to look correct.
diff --git a/doc/classes/SystemFont.xml b/doc/classes/SystemFont.xml
index 38d6e27c8565..d43a727f97ed 100644
--- a/doc/classes/SystemFont.xml
+++ b/doc/classes/SystemFont.xml
@@ -43,6 +43,9 @@
Font hinting mode.
+
+ LCD subpixel layout used for font anti-aliasing. See [enum TextServer.FontLCDSubpixelLayout].
+
The width of the range around the shape between the minimum and maximum representable signed distance. If using font outlines, [member msdf_pixel_range] must be set to at least [i]twice[/i] the size of the largest font outline. The default [member msdf_pixel_range] value of [code]16[/code] allows outline sizes up to [code]8[/code] to look correct.
diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml
index 4fa9700f9cfc..be51f8df4db0 100644
--- a/doc/classes/TextServer.xml
+++ b/doc/classes/TextServer.xml
@@ -344,6 +344,13 @@
Returns list of language support overrides.
+
+
+
+
+ Returns the LCD subpixel layout used for font anti-aliasing. See [enum TextServer.FontLCDSubpixelLayout].
+
+
@@ -831,6 +838,14 @@
Adds override for [method font_is_language_supported].
+
+
+
+
+
+ Sets the LCD subpixel layout used for font anti-aliasing. See [enum TextServer.FontLCDSubpixelLayout].
+
+
diff --git a/doc/classes/TextServerExtension.xml b/doc/classes/TextServerExtension.xml
index c148cdad528d..f12424903b1b 100644
--- a/doc/classes/TextServerExtension.xml
+++ b/doc/classes/TextServerExtension.xml
@@ -365,6 +365,13 @@
Returns list of language support overrides.
+
+
+
+
+ LCD subpixel layout used for font anti-aliasing. See [enum TextServer.FontLCDSubpixelLayout].
+
+
@@ -917,6 +924,14 @@
Adds override for [method _font_is_language_supported].
+
+
+
+
+
+ LCD subpixel layout used for font anti-aliasing. See [enum TextServer.FontLCDSubpixelLayout].
+
+
diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp
index b0f7e7cfb438..3627b34581ed 100644
--- a/editor/import/dynamic_font_import_settings.cpp
+++ b/editor/import/dynamic_font_import_settings.cpp
@@ -490,6 +490,8 @@ void DynamicFontImportSettingsDialog::_main_prop_changed(const String &p_edited_
font_preview->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int());
} else if (p_edited_property == "subpixel_positioning") {
font_preview->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int());
+ } else if (p_edited_property == "lcd_subpixel_layout") {
+ font_preview->set_lcd_subpixel_layout((TextServer::FontLCDSubpixelLayout)import_settings_data->get("lcd_subpixel_layout").operator int());
} else if (p_edited_property == "oversampling") {
font_preview->set_oversampling(import_settings_data->get("oversampling"));
}
@@ -956,6 +958,7 @@ void DynamicFontImportSettingsDialog::_re_import() {
main_settings["force_autohinter"] = import_settings_data->get("force_autohinter");
main_settings["hinting"] = import_settings_data->get("hinting");
main_settings["subpixel_positioning"] = import_settings_data->get("subpixel_positioning");
+ main_settings["lcd_subpixel_layout"] = import_settings_data->get("lcd_subpixel_layout");
main_settings["oversampling"] = import_settings_data->get("oversampling");
main_settings["fallbacks"] = import_settings_data->get("fallbacks");
main_settings["compress"] = import_settings_data->get("compress");
@@ -1232,6 +1235,7 @@ void DynamicFontImportSettingsDialog::open_settings(const String &p_path) {
font_preview->set_force_autohinter(import_settings_data->get("force_autohinter"));
font_preview->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int());
font_preview->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int());
+ font_preview->set_lcd_subpixel_layout((TextServer::FontLCDSubpixelLayout)import_settings_data->get("lcd_subpixel_layout").operator int());
font_preview->set_oversampling(import_settings_data->get("oversampling"));
}
font_preview_label->add_theme_font_override(SceneStringName(font), font_preview);
@@ -1264,6 +1268,7 @@ DynamicFontImportSettingsDialog::DynamicFontImportSettingsDialog() {
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel"), 1));
+ options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "lcd_subpixel_layout", PROPERTY_HINT_ENUM, "Disabled,Horizontal RGB,Horizontal BGR,Vertical RGB,Vertical BGR"), 1));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0));
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::NIL, "Metadata Overrides", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP), Variant()));
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp
index 499ddb703b0f..6acd2ccbc7e7 100644
--- a/modules/text_server_adv/text_server_adv.cpp
+++ b/modules/text_server_adv/text_server_adv.cpp
@@ -35,19 +35,15 @@
#include
#include
-#include
#include
#include
#include
using namespace godot;
-#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get_setting_with_override(m_var)
-
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.
-#include "core/config/project_settings.h"
#include "core/error/error_macros.h"
#include "core/object/worker_thread_pool.h"
#include "core/string/print_string.h"
@@ -2215,6 +2211,27 @@ TextServer::FontAntialiasing TextServerAdvanced::_font_get_antialiasing(const RI
return fd->antialiasing;
}
+void TextServerAdvanced::_font_set_lcd_subpixel_layout(const RID &p_font_rid, TextServer::FontLCDSubpixelLayout p_lcd_subpixel_layout) {
+ FontAdvanced *fd = _get_font_data(p_font_rid);
+ ERR_FAIL_NULL(fd);
+
+ MutexLock lock(fd->mutex);
+ if (fd->lcd_subpixel_layout != p_lcd_subpixel_layout) {
+ if (fd->antialiasing == TextServer::FONT_ANTIALIASING_LCD) {
+ _font_clear_cache(fd);
+ }
+ fd->lcd_subpixel_layout = p_lcd_subpixel_layout;
+ }
+}
+
+TextServer::FontLCDSubpixelLayout TextServerAdvanced::_font_get_lcd_subpixel_layout(const RID &p_font_rid) const {
+ FontAdvanced *fd = _get_font_data(p_font_rid);
+ ERR_FAIL_NULL_V(fd, TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_NONE);
+
+ MutexLock lock(fd->mutex);
+ return fd->lcd_subpixel_layout;
+}
+
void TextServerAdvanced::_font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) {
FontAdvanced *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);
@@ -2944,9 +2961,8 @@ Vector2 TextServerAdvanced::_font_get_glyph_advance(const RID &p_font_rid, int64
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -3003,9 +3019,8 @@ Vector2 TextServerAdvanced::_font_get_glyph_offset(const RID &p_font_rid, const
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -3054,9 +3069,8 @@ Vector2 TextServerAdvanced::_font_get_glyph_size(const RID &p_font_rid, const Ve
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -3105,9 +3119,8 @@ Rect2 TextServerAdvanced::_font_get_glyph_uv_rect(const RID &p_font_rid, const V
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -3145,9 +3158,8 @@ int64_t TextServerAdvanced::_font_get_glyph_texture_idx(const RID &p_font_rid, c
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -3185,9 +3197,8 @@ RID TextServerAdvanced::_font_get_glyph_texture_rid(const RID &p_font_rid, const
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -3232,9 +3243,8 @@ Size2 TextServerAdvanced::_font_get_glyph_texture_size(const RID &p_font_rid, co
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -3612,10 +3622,9 @@ void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
if (!fd->msdf && fd->cache[size]->face) {
// LCD layout, bits 24, 25, 26
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
lcd_aa = true;
- index = index | (layout << 24);
+ index = index | (fd->lcd_subpixel_layout << 24);
}
}
// Subpixel X-shift, bits 27, 28
@@ -3720,10 +3729,9 @@ void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const R
if (!fd->msdf && fd->cache[size]->face) {
// LCD layout, bits 24, 25, 26
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
lcd_aa = true;
- index = index | (layout << 24);
+ index = index | (fd->lcd_subpixel_layout << 24);
}
}
// Subpixel X-shift, bits 27, 28
@@ -6037,9 +6045,8 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h
index 92bdb93bcf17..a3eed6710a5a 100644
--- a/modules/text_server_adv/text_server_adv.h
+++ b/modules/text_server_adv/text_server_adv.h
@@ -303,6 +303,7 @@ class TextServerAdvanced : public TextServerExtension {
Mutex mutex;
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
+ TextServer::FontLCDSubpixelLayout lcd_subpixel_layout = TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_NONE;
bool disable_embedded_bitmaps = true;
bool mipmaps = false;
bool msdf = false;
@@ -755,6 +756,9 @@ class TextServerAdvanced : public TextServerExtension {
MODBIND2(font_set_antialiasing, const RID &, TextServer::FontAntialiasing);
MODBIND1RC(TextServer::FontAntialiasing, font_get_antialiasing, const RID &);
+ MODBIND2(font_set_lcd_subpixel_layout, const RID &, TextServer::FontLCDSubpixelLayout);
+ MODBIND1RC(TextServer::FontLCDSubpixelLayout, font_get_lcd_subpixel_layout, const RID &);
+
MODBIND2(font_set_disable_embedded_bitmaps, const RID &, bool);
MODBIND1RC(bool, font_get_disable_embedded_bitmaps, const RID &);
diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index b45c004011a1..b390aa79aa04 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -35,7 +35,6 @@
#include
#include
-#include
#include
#include
#include
@@ -44,12 +43,9 @@
using namespace godot;
-#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get_setting_with_override(m_var)
-
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.
-#include "core/config/project_settings.h"
#include "core/error/error_macros.h"
#include "core/string/print_string.h"
#include "core/string/translation.h"
@@ -1222,6 +1218,27 @@ TextServer::FontAntialiasing TextServerFallback::_font_get_antialiasing(const RI
return fd->antialiasing;
}
+void TextServerFallback::_font_set_lcd_subpixel_layout(const RID &p_font_rid, TextServer::FontLCDSubpixelLayout p_lcd_subpixel_layout) {
+ FontFallback *fd = _get_font_data(p_font_rid);
+ ERR_FAIL_NULL(fd);
+
+ MutexLock lock(fd->mutex);
+ if (fd->lcd_subpixel_layout != p_lcd_subpixel_layout) {
+ if (fd->antialiasing == TextServer::FONT_ANTIALIASING_LCD) {
+ _font_clear_cache(fd);
+ }
+ fd->lcd_subpixel_layout = p_lcd_subpixel_layout;
+ }
+}
+
+TextServer::FontLCDSubpixelLayout TextServerFallback::_font_get_lcd_subpixel_layout(const RID &p_font_rid) const {
+ FontFallback *fd = _get_font_data(p_font_rid);
+ ERR_FAIL_NULL_V(fd, TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_NONE);
+
+ MutexLock lock(fd->mutex);
+ return fd->lcd_subpixel_layout;
+}
+
void TextServerFallback::_font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) {
FontFallback *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);
@@ -1938,9 +1955,8 @@ Vector2 TextServerFallback::_font_get_glyph_advance(const RID &p_font_rid, int64
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -1997,9 +2013,8 @@ Vector2 TextServerFallback::_font_get_glyph_offset(const RID &p_font_rid, const
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -2048,9 +2063,8 @@ Vector2 TextServerFallback::_font_get_glyph_size(const RID &p_font_rid, const Ve
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -2099,9 +2113,8 @@ Rect2 TextServerFallback::_font_get_glyph_uv_rect(const RID &p_font_rid, const V
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -2139,9 +2152,8 @@ int64_t TextServerFallback::_font_get_glyph_texture_idx(const RID &p_font_rid, c
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -2179,9 +2191,8 @@ RID TextServerFallback::_font_get_glyph_texture_rid(const RID &p_font_rid, const
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -2226,9 +2237,8 @@ Size2 TextServerFallback::_font_get_glyph_texture_size(const RID &p_font_rid, co
int mod = 0;
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
- mod = (layout << 24);
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ mod = (fd->lcd_subpixel_layout << 24);
}
}
@@ -2561,10 +2571,9 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
if (!fd->msdf && fd->cache[size]->face) {
// LCD layout, bits 24, 25, 26
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
lcd_aa = true;
- index = index | (layout << 24);
+ index = index | (fd->lcd_subpixel_layout << 24);
}
}
// Subpixel X-shift, bits 27, 28
@@ -2669,10 +2678,9 @@ void TextServerFallback::_font_draw_glyph_outline(const RID &p_font_rid, const R
if (!fd->msdf && fd->cache[size]->face) {
// LCD layout, bits 24, 25, 26
if (fd->antialiasing == FONT_ANTIALIASING_LCD) {
- TextServer::FontLCDSubpixelLayout layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout");
- if (layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
+ if (fd->lcd_subpixel_layout != FONT_LCD_SUBPIXEL_LAYOUT_NONE) {
lcd_aa = true;
- index = index | (layout << 24);
+ index = index | (fd->lcd_subpixel_layout << 24);
}
}
// Subpixel X-shift, bits 27, 28
diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h
index 2235247b31a0..4bb21db3f056 100644
--- a/modules/text_server_fb/text_server_fb.h
+++ b/modules/text_server_fb/text_server_fb.h
@@ -254,6 +254,7 @@ class TextServerFallback : public TextServerExtension {
Mutex mutex;
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
+ TextServer::FontLCDSubpixelLayout lcd_subpixel_layout = TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_NONE;
bool disable_embedded_bitmaps = true;
bool mipmaps = false;
bool msdf = false;
@@ -623,6 +624,9 @@ class TextServerFallback : public TextServerExtension {
MODBIND2(font_set_antialiasing, const RID &, TextServer::FontAntialiasing);
MODBIND1RC(TextServer::FontAntialiasing, font_get_antialiasing, const RID &);
+ MODBIND2(font_set_lcd_subpixel_layout, const RID &, TextServer::FontLCDSubpixelLayout);
+ MODBIND1RC(TextServer::FontLCDSubpixelLayout, font_get_lcd_subpixel_layout, const RID &);
+
MODBIND2(font_set_disable_embedded_bitmaps, const RID &, bool);
MODBIND1RC(bool, font_get_disable_embedded_bitmaps, const RID &);
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 6b65ea4cfb97..3d9344a23661 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -605,6 +605,7 @@ _FORCE_INLINE_ void FontFile::_ensure_rid(int p_cache_index, int p_make_linked_f
TS->font_set_allow_system_fallback(cache[p_cache_index], allow_system_fallback);
TS->font_set_hinting(cache[p_cache_index], hinting);
TS->font_set_subpixel_positioning(cache[p_cache_index], subpixel_positioning);
+ TS->font_set_lcd_subpixel_layout(cache[p_cache_index], lcd_subpixel_layout);
TS->font_set_oversampling(cache[p_cache_index], oversampling);
}
}
@@ -934,6 +935,9 @@ void FontFile::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_subpixel_positioning", "subpixel_positioning"), &FontFile::set_subpixel_positioning);
ClassDB::bind_method(D_METHOD("get_subpixel_positioning"), &FontFile::get_subpixel_positioning);
+ ClassDB::bind_method(D_METHOD("set_lcd_subpixel_layout", "subpixel_layout"), &FontFile::set_lcd_subpixel_layout);
+ ClassDB::bind_method(D_METHOD("get_lcd_subpixel_layout"), &FontFile::get_lcd_subpixel_layout);
+
ClassDB::bind_method(D_METHOD("set_oversampling", "oversampling"), &FontFile::set_oversampling);
ClassDB::bind_method(D_METHOD("get_oversampling"), &FontFile::get_oversampling);
@@ -1044,6 +1048,7 @@ void FontFile::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_stretch", PROPERTY_HINT_RANGE, "50,200,25", PROPERTY_USAGE_STORAGE), "set_font_stretch", "get_font_stretch");
ADD_PROPERTY(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel", PROPERTY_USAGE_STORAGE), "set_subpixel_positioning", "get_subpixel_positioning");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "lcd_subpixel_layout", PROPERTY_HINT_ENUM, "Disabled,Horizontal RGB,Horizontal BGR,Vertical RGB,Vertical BGR", PROPERTY_USAGE_STORAGE), "set_lcd_subpixel_layout", "get_lcd_subpixel_layout");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_multichannel_signed_distance_field", "is_multichannel_signed_distance_field");
ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_msdf_pixel_range", "get_msdf_pixel_range");
ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_msdf_size", "get_msdf_size");
@@ -1411,6 +1416,7 @@ void FontFile::reset_state() {
allow_system_fallback = true;
hinting = TextServer::HINTING_LIGHT;
subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_DISABLED;
+ lcd_subpixel_layout = TextServer::FONT_LCD_SUBPIXEL_LAYOUT_NONE;
msdf_pixel_range = 14;
msdf_size = 128;
fixed_size = 0;
@@ -2281,9 +2287,9 @@ TextServer::Hinting FontFile::get_hinting() const {
return hinting;
}
-void FontFile::set_subpixel_positioning(TextServer::SubpixelPositioning p_subpixel) {
- if (subpixel_positioning != p_subpixel) {
- subpixel_positioning = p_subpixel;
+void FontFile::set_subpixel_positioning(TextServer::SubpixelPositioning p_subpixel_positioning) {
+ if (subpixel_positioning != p_subpixel_positioning) {
+ subpixel_positioning = p_subpixel_positioning;
for (int i = 0; i < cache.size(); i++) {
_ensure_rid(i);
TS->font_set_subpixel_positioning(cache[i], subpixel_positioning);
@@ -2296,6 +2302,21 @@ TextServer::SubpixelPositioning FontFile::get_subpixel_positioning() const {
return subpixel_positioning;
}
+void FontFile::set_lcd_subpixel_layout(TextServer::FontLCDSubpixelLayout p_subpixel_layout) {
+ if (lcd_subpixel_layout != p_subpixel_layout) {
+ lcd_subpixel_layout = p_subpixel_layout;
+ for (int i = 0; i < cache.size(); i++) {
+ _ensure_rid(i);
+ TS->font_set_lcd_subpixel_layout(cache[i], lcd_subpixel_layout);
+ }
+ emit_changed();
+ }
+}
+
+TextServer::FontLCDSubpixelLayout FontFile::get_lcd_subpixel_layout() const {
+ return lcd_subpixel_layout;
+}
+
void FontFile::set_oversampling(real_t p_oversampling) {
if (oversampling != p_oversampling) {
oversampling = p_oversampling;
@@ -3085,6 +3106,9 @@ void SystemFont::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_subpixel_positioning", "subpixel_positioning"), &SystemFont::set_subpixel_positioning);
ClassDB::bind_method(D_METHOD("get_subpixel_positioning"), &SystemFont::get_subpixel_positioning);
+ ClassDB::bind_method(D_METHOD("set_lcd_subpixel_layout", "subpixel_layout"), &SystemFont::set_lcd_subpixel_layout);
+ ClassDB::bind_method(D_METHOD("get_lcd_subpixel_layout"), &SystemFont::get_lcd_subpixel_layout);
+
ClassDB::bind_method(D_METHOD("set_multichannel_signed_distance_field", "msdf"), &SystemFont::set_multichannel_signed_distance_field);
ClassDB::bind_method(D_METHOD("is_multichannel_signed_distance_field"), &SystemFont::is_multichannel_signed_distance_field);
@@ -3109,13 +3133,14 @@ void SystemFont::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "font_italic"), "set_font_italic", "get_font_italic");
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_weight", PROPERTY_HINT_RANGE, "100,999,25"), "set_font_weight", "get_font_weight");
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_stretch", PROPERTY_HINT_RANGE, "50,200,25"), "set_font_stretch", "get_font_stretch");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel", PROPERTY_USAGE_STORAGE), "set_antialiasing", "get_antialiasing");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel"), "set_antialiasing", "get_antialiasing");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "generate_mipmaps"), "set_generate_mipmaps", "get_generate_mipmaps");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_embedded_bitmaps"), "set_disable_embedded_bitmaps", "get_disable_embedded_bitmaps");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_system_fallback"), "set_allow_system_fallback", "is_allow_system_fallback");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "force_autohinter"), "set_force_autohinter", "is_force_autohinter");
ADD_PROPERTY(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), "set_hinting", "get_hinting");
ADD_PROPERTY(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel"), "set_subpixel_positioning", "get_subpixel_positioning");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "lcd_subpixel_layout", PROPERTY_HINT_ENUM, "Disabled,Horizontal RGB,Horizontal BGR,Vertical RGB,Vertical BGR"), "set_lcd_subpixel_layout", "get_lcd_subpixel_layout");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field"), "set_multichannel_signed_distance_field", "is_multichannel_signed_distance_field");
ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_pixel_range"), "set_msdf_pixel_range", "get_msdf_pixel_range");
ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_size"), "set_msdf_size", "get_msdf_size");
@@ -3220,6 +3245,7 @@ void SystemFont::_update_base_font() {
file->set_allow_system_fallback(allow_system_fallback);
file->set_hinting(hinting);
file->set_subpixel_positioning(subpixel_positioning);
+ file->set_lcd_subpixel_layout(lcd_subpixel_layout);
file->set_multichannel_signed_distance_field(msdf);
file->set_msdf_pixel_range(msdf_pixel_range);
file->set_msdf_size(msdf_size);
@@ -3263,6 +3289,7 @@ void SystemFont::reset_state() {
allow_system_fallback = true;
hinting = TextServer::HINTING_LIGHT;
subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_DISABLED;
+ lcd_subpixel_layout = TextServer::FONT_LCD_SUBPIXEL_LAYOUT_NONE;
oversampling = 0.f;
msdf = false;
@@ -3402,9 +3429,9 @@ TextServer::Hinting SystemFont::get_hinting() const {
return hinting;
}
-void SystemFont::set_subpixel_positioning(TextServer::SubpixelPositioning p_subpixel) {
- if (subpixel_positioning != p_subpixel) {
- subpixel_positioning = p_subpixel;
+void SystemFont::set_subpixel_positioning(TextServer::SubpixelPositioning p_subpixel_positioning) {
+ if (subpixel_positioning != p_subpixel_positioning) {
+ subpixel_positioning = p_subpixel_positioning;
if (base_font.is_valid()) {
base_font->set_subpixel_positioning(subpixel_positioning);
}
@@ -3416,6 +3443,20 @@ TextServer::SubpixelPositioning SystemFont::get_subpixel_positioning() const {
return subpixel_positioning;
}
+void SystemFont::set_lcd_subpixel_layout(TextServer::FontLCDSubpixelLayout p_subpixel_layout) {
+ if (lcd_subpixel_layout != p_subpixel_layout) {
+ lcd_subpixel_layout = p_subpixel_layout;
+ if (base_font.is_valid()) {
+ base_font->set_lcd_subpixel_layout(lcd_subpixel_layout);
+ }
+ emit_changed();
+ }
+}
+
+TextServer::FontLCDSubpixelLayout SystemFont::get_lcd_subpixel_layout() const {
+ return lcd_subpixel_layout;
+}
+
void SystemFont::set_multichannel_signed_distance_field(bool p_msdf) {
if (msdf != p_msdf) {
msdf = p_msdf;
diff --git a/scene/resources/font.h b/scene/resources/font.h
index 68c391c35e4e..3a8949b4174a 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -197,6 +197,7 @@ class FontFile : public Font {
bool allow_system_fallback = true;
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
+ TextServer::FontLCDSubpixelLayout lcd_subpixel_layout = TextServer::FONT_LCD_SUBPIXEL_LAYOUT_HRGB;
real_t oversampling = 0.f;
#ifndef DISABLE_DEPRECATED
@@ -280,6 +281,9 @@ class FontFile : public Font {
virtual void set_subpixel_positioning(TextServer::SubpixelPositioning p_subpixel);
virtual TextServer::SubpixelPositioning get_subpixel_positioning() const;
+ virtual void set_lcd_subpixel_layout(TextServer::FontLCDSubpixelLayout p_subpixel_layout);
+ virtual TextServer::FontLCDSubpixelLayout get_lcd_subpixel_layout() const;
+
virtual void set_oversampling(real_t p_oversampling);
virtual real_t get_oversampling() const;
@@ -480,6 +484,7 @@ class SystemFont : public Font {
bool allow_system_fallback = true;
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
+ TextServer::FontLCDSubpixelLayout lcd_subpixel_layout = TextServer::FONT_LCD_SUBPIXEL_LAYOUT_HRGB;
real_t oversampling = 0.f;
bool msdf = false;
int msdf_pixel_range = 16;
@@ -515,9 +520,12 @@ class SystemFont : public Font {
virtual void set_hinting(TextServer::Hinting p_hinting);
virtual TextServer::Hinting get_hinting() const;
- virtual void set_subpixel_positioning(TextServer::SubpixelPositioning p_subpixel);
+ virtual void set_subpixel_positioning(TextServer::SubpixelPositioning p_subpixel_positioning);
virtual TextServer::SubpixelPositioning get_subpixel_positioning() const;
+ virtual void set_lcd_subpixel_layout(TextServer::FontLCDSubpixelLayout p_subpixel_layout);
+ virtual TextServer::FontLCDSubpixelLayout get_lcd_subpixel_layout() const;
+
virtual void set_oversampling(real_t p_oversampling);
virtual real_t get_oversampling() const;
diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp
index 11549a54de5a..d1de19a90c9a 100644
--- a/scene/theme/default_theme.cpp
+++ b/scene/theme/default_theme.cpp
@@ -1250,7 +1250,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const
default_style = make_flat_stylebox(Color(1, 0.365, 0.365), 4, 4, 4, 4, 0, false, 2);
}
-void make_default_theme(float p_scale, Ref p_font, TextServer::SubpixelPositioning p_font_subpixel, TextServer::Hinting p_font_hinting, TextServer::FontAntialiasing p_font_antialiasing, bool p_font_msdf, bool p_font_generate_mipmaps) {
+void make_default_theme(float p_scale, Ref p_font, TextServer::SubpixelPositioning p_font_subpixel, TextServer::Hinting p_font_hinting, TextServer::FontAntialiasing p_font_antialiasing, TextServer::FontLCDSubpixelLayout p_lcd_subpixel_layout, bool p_font_msdf, bool p_font_generate_mipmaps) {
Ref t;
t.instantiate();
@@ -1275,6 +1275,7 @@ void make_default_theme(float p_scale, Ref p_font, TextServer::SubpixelPos
dynamic_font->set_subpixel_positioning(p_font_subpixel);
dynamic_font->set_hinting(p_font_hinting);
dynamic_font->set_antialiasing(p_font_antialiasing);
+ dynamic_font->set_lcd_subpixel_layout(p_lcd_subpixel_layout);
dynamic_font->set_multichannel_signed_distance_field(p_font_msdf);
dynamic_font->set_generate_mipmaps(p_font_generate_mipmaps);
diff --git a/scene/theme/default_theme.h b/scene/theme/default_theme.h
index 55fc32a3d3f1..50723a5ddefd 100644
--- a/scene/theme/default_theme.h
+++ b/scene/theme/default_theme.h
@@ -34,6 +34,6 @@
#include "scene/resources/theme.h"
void fill_default_theme(Ref &theme, const Ref &default_font, const Ref &bold_font, const Ref &bold_italics_font, const Ref &italics_font, Ref &default_icon, Ref &default_style, float p_scale);
-void make_default_theme(float p_scale, Ref p_font, TextServer::SubpixelPositioning p_font_subpixel = TextServer::SUBPIXEL_POSITIONING_AUTO, TextServer::Hinting p_font_hinting = TextServer::HINTING_LIGHT, TextServer::FontAntialiasing p_font_antialiased = TextServer::FONT_ANTIALIASING_GRAY, bool p_font_msdf = false, bool p_font_generate_mipmaps = false);
+void make_default_theme(float p_scale, Ref p_font, TextServer::SubpixelPositioning p_font_subpixel = TextServer::SUBPIXEL_POSITIONING_AUTO, TextServer::Hinting p_font_hinting = TextServer::HINTING_LIGHT, TextServer::FontAntialiasing p_font_antialiased = TextServer::FONT_ANTIALIASING_GRAY, TextServer::FontLCDSubpixelLayout p_lcd_subpixel_layout = TextServer::FONT_LCD_SUBPIXEL_LAYOUT_HRGB, bool p_font_msdf = false, bool p_font_generate_mipmaps = false);
#endif // DEFAULT_THEME_H
diff --git a/scene/theme/theme_db.cpp b/scene/theme/theme_db.cpp
index 7249fd7ba82b..1a487fe3e356 100644
--- a/scene/theme/theme_db.cpp
+++ b/scene/theme/theme_db.cpp
@@ -55,13 +55,11 @@ void ThemeDB::initialize_theme() {
TextServer::FontAntialiasing font_antialiasing = (TextServer::FontAntialiasing)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/default_font_antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), 1);
TextServer::Hinting font_hinting = (TextServer::Hinting)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/default_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), TextServer::HINTING_LIGHT);
TextServer::SubpixelPositioning font_subpixel_positioning = (TextServer::SubpixelPositioning)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/default_font_subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), TextServer::SUBPIXEL_POSITIONING_AUTO);
+ TextServer::FontLCDSubpixelLayout lcd_subpixel_layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/lcd_subpixel_layout", PROPERTY_HINT_ENUM, "Disabled,Horizontal RGB,Horizontal BGR,Vertical RGB,Vertical BGR"), 1);
const bool font_msdf = GLOBAL_DEF_RST("gui/theme/default_font_multichannel_signed_distance_field", false);
const bool font_generate_mipmaps = GLOBAL_DEF_RST("gui/theme/default_font_generate_mipmaps", false);
- GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/lcd_subpixel_layout", PROPERTY_HINT_ENUM, "Disabled,Horizontal RGB,Horizontal BGR,Vertical RGB,Vertical BGR"), 1);
- ProjectSettings::get_singleton()->set_restart_if_changed("gui/theme/lcd_subpixel_layout", false);
-
// Attempt to load custom project theme and font.
if (!project_theme_path.is_empty()) {
@@ -86,7 +84,7 @@ void ThemeDB::initialize_theme() {
// Always generate the default theme to serve as a fallback for all required theme definitions.
if (RenderingServer::get_singleton()) {
- make_default_theme(default_theme_scale, project_font, font_subpixel_positioning, font_hinting, font_antialiasing, font_msdf, font_generate_mipmaps);
+ make_default_theme(default_theme_scale, project_font, font_subpixel_positioning, font_hinting, font_antialiasing, lcd_subpixel_layout, font_msdf, font_generate_mipmaps);
}
_init_default_theme_context();
diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp
index 509d49a1e42a..6a56d21b6eb6 100644
--- a/servers/text/text_server_extension.cpp
+++ b/servers/text/text_server_extension.cpp
@@ -80,6 +80,9 @@ void TextServerExtension::_bind_methods() {
GDVIRTUAL_BIND(_font_set_antialiasing, "font_rid", "antialiasing");
GDVIRTUAL_BIND(_font_get_antialiasing, "font_rid");
+ GDVIRTUAL_BIND(_font_set_lcd_subpixel_layout, "font_rid", "subpixel_layout")
+ GDVIRTUAL_BIND(_font_get_lcd_subpixel_layout, "font_rid")
+
GDVIRTUAL_BIND(_font_set_disable_embedded_bitmaps, "font_rid", "disable_embedded_bitmaps");
GDVIRTUAL_BIND(_font_get_disable_embedded_bitmaps, "font_rid");
@@ -529,6 +532,16 @@ TextServer::FontAntialiasing TextServerExtension::font_get_antialiasing(const RI
return ret;
}
+void TextServerExtension::font_set_lcd_subpixel_layout(const RID &p_font_rid, TextServer::FontLCDSubpixelLayout p_lcd_subpixel_layout) {
+ GDVIRTUAL_CALL(_font_set_lcd_subpixel_layout, p_font_rid, p_lcd_subpixel_layout);
+}
+
+TextServer::FontLCDSubpixelLayout TextServerExtension::font_get_lcd_subpixel_layout(const RID &p_font_rid) const {
+ TextServer::FontLCDSubpixelLayout ret = TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_NONE;
+ GDVIRTUAL_CALL(_font_get_lcd_subpixel_layout, p_font_rid, ret);
+ return ret;
+}
+
void TextServerExtension::font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) {
GDVIRTUAL_CALL(_font_set_disable_embedded_bitmaps, p_font_rid, p_disable_embedded_bitmaps);
}
diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h
index 16a03b65928b..7d59be65af03 100644
--- a/servers/text/text_server_extension.h
+++ b/servers/text/text_server_extension.h
@@ -128,6 +128,11 @@ class TextServerExtension : public TextServer {
GDVIRTUAL2(_font_set_antialiasing, RID, TextServer::FontAntialiasing);
GDVIRTUAL1RC(TextServer::FontAntialiasing, _font_get_antialiasing, RID);
+ virtual void font_set_lcd_subpixel_layout(const RID &p_font_rid, TextServer::FontLCDSubpixelLayout p_lcd_subpixel_layout) override;
+ virtual TextServer::FontLCDSubpixelLayout font_get_lcd_subpixel_layout(const RID &p_font_rid) const override;
+ GDVIRTUAL2(_font_set_lcd_subpixel_layout, RID, TextServer::FontLCDSubpixelLayout);
+ GDVIRTUAL1RC(TextServer::FontLCDSubpixelLayout, _font_get_lcd_subpixel_layout, RID);
+
virtual void font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) override;
virtual bool font_get_disable_embedded_bitmaps(const RID &p_font_rid) const override;
GDVIRTUAL2(_font_set_disable_embedded_bitmaps, RID, bool);
diff --git a/servers/text_server.cpp b/servers/text_server.cpp
index 7b1e37a6cc3d..a526481282ec 100644
--- a/servers/text_server.cpp
+++ b/servers/text_server.cpp
@@ -236,6 +236,9 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("font_set_antialiasing", "font_rid", "antialiasing"), &TextServer::font_set_antialiasing);
ClassDB::bind_method(D_METHOD("font_get_antialiasing", "font_rid"), &TextServer::font_get_antialiasing);
+ ClassDB::bind_method(D_METHOD("font_set_lcd_subpixel_layout", "font_rid", "lcd_subpixel_layout"), &TextServer::font_set_lcd_subpixel_layout);
+ ClassDB::bind_method(D_METHOD("font_get_lcd_subpixel_layout", "font_rid"), &TextServer::font_get_lcd_subpixel_layout);
+
ClassDB::bind_method(D_METHOD("font_set_disable_embedded_bitmaps", "font_rid", "disable_embedded_bitmaps"), &TextServer::font_set_disable_embedded_bitmaps);
ClassDB::bind_method(D_METHOD("font_get_disable_embedded_bitmaps", "font_rid"), &TextServer::font_get_disable_embedded_bitmaps);
diff --git a/servers/text_server.h b/servers/text_server.h
index a77953e6f2a5..0ff1153e9365 100644
--- a/servers/text_server.h
+++ b/servers/text_server.h
@@ -281,6 +281,9 @@ class TextServer : public RefCounted {
virtual void font_set_antialiasing(const RID &p_font_rid, FontAntialiasing p_antialiasing) = 0;
virtual FontAntialiasing font_get_antialiasing(const RID &p_font_rid) const = 0;
+ virtual void font_set_lcd_subpixel_layout(const RID &p_font_rid, FontLCDSubpixelLayout p_lcd_subpixel_layout) = 0;
+ virtual FontLCDSubpixelLayout font_get_lcd_subpixel_layout(const RID &p_font_rid) const = 0;
+
virtual void font_set_disable_embedded_bitmaps(const RID &p_font_rid, bool p_disable_embedded_bitmaps) = 0;
virtual bool font_get_disable_embedded_bitmaps(const RID &p_font_rid) const = 0;