Merge pull request #64156 from bruvzg/sys_msdf
Allow MSDF rendering for system fonts, fix crash on loading damaged / unsupported font files.
This commit is contained in:
@@ -2714,6 +2714,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_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);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_oversampling", "oversampling"), &SystemFont::set_oversampling);
|
||||
ClassDB::bind_method(D_METHOD("get_oversampling"), &SystemFont::get_oversampling);
|
||||
|
||||
@@ -2729,6 +2732,7 @@ void SystemFont::_bind_methods() {
|
||||
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::BOOL, "multichannel_signed_distance_field"), "set_multichannel_signed_distance_field", "is_multichannel_signed_distance_field");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), "set_oversampling", "get_oversampling");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "fallbacks", PROPERTY_HINT_ARRAY_TYPE, vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "Font")), "set_fallbacks", "get_fallbacks");
|
||||
}
|
||||
@@ -2805,6 +2809,7 @@ void SystemFont::_update_base_font() {
|
||||
file->set_force_autohinter(force_autohinter);
|
||||
file->set_hinting(hinting);
|
||||
file->set_subpixel_positioning(subpixel_positioning);
|
||||
file->set_multichannel_signed_distance_field(msdf);
|
||||
file->set_oversampling(oversampling);
|
||||
|
||||
base_font = file;
|
||||
@@ -2842,6 +2847,7 @@ void SystemFont::reset_state() {
|
||||
hinting = TextServer::HINTING_LIGHT;
|
||||
subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_DISABLED;
|
||||
oversampling = 0.f;
|
||||
msdf = false;
|
||||
|
||||
Font::reset_state();
|
||||
}
|
||||
@@ -2971,6 +2977,20 @@ TextServer::SubpixelPositioning SystemFont::get_subpixel_positioning() const {
|
||||
return subpixel_positioning;
|
||||
}
|
||||
|
||||
void SystemFont::set_multichannel_signed_distance_field(bool p_msdf) {
|
||||
if (msdf != p_msdf) {
|
||||
msdf = p_msdf;
|
||||
if (base_font.is_valid()) {
|
||||
base_font->set_multichannel_signed_distance_field(msdf);
|
||||
}
|
||||
emit_changed();
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemFont::is_multichannel_signed_distance_field() const {
|
||||
return msdf;
|
||||
}
|
||||
|
||||
void SystemFont::set_oversampling(real_t p_oversampling) {
|
||||
if (oversampling != p_oversampling) {
|
||||
oversampling = p_oversampling;
|
||||
|
||||
@@ -404,6 +404,7 @@ class SystemFont : public Font {
|
||||
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
|
||||
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
|
||||
real_t oversampling = 0.f;
|
||||
bool msdf = false;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@@ -434,6 +435,9 @@ public:
|
||||
virtual void set_oversampling(real_t p_oversampling);
|
||||
virtual real_t get_oversampling() const;
|
||||
|
||||
virtual void set_multichannel_signed_distance_field(bool p_msdf);
|
||||
virtual bool is_multichannel_signed_distance_field() const;
|
||||
|
||||
virtual void set_font_names(const PackedStringArray &p_names);
|
||||
virtual PackedStringArray get_font_names() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user