diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/dynamic_font.cpp | 18 | ||||
-rw-r--r-- | scene/resources/dynamic_font.h | 3 |
2 files changed, 20 insertions, 1 deletions
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index d6b40766a2..ad22d6530c 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -82,11 +82,14 @@ void DynamicFontData::set_force_autohinter(bool p_force) { } void DynamicFontData::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &DynamicFontData::set_antialiased); + ClassDB::bind_method(D_METHOD("is_antialiased"), &DynamicFontData::is_antialiased); ClassDB::bind_method(D_METHOD("set_font_path", "path"), &DynamicFontData::set_font_path); ClassDB::bind_method(D_METHOD("get_font_path"), &DynamicFontData::get_font_path); ClassDB::bind_method(D_METHOD("set_hinting", "mode"), &DynamicFontData::set_hinting); ClassDB::bind_method(D_METHOD("get_hinting"), &DynamicFontData::get_hinting); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "is_antialiased"); ADD_PROPERTY(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), "set_hinting", "get_hinting"); BIND_ENUM_CONSTANT(HINTING_NONE); @@ -98,6 +101,7 @@ void DynamicFontData::_bind_methods() { DynamicFontData::DynamicFontData() { + antialiased = true; force_autohinter = false; hinting = DynamicFontData::HINTING_NORMAL; font_mem = NULL; @@ -632,7 +636,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { if (id.outline_size > 0) { character = _make_outline_char(p_char); } else { - error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL); + error = FT_Render_Glyph(face->glyph, font->antialiased ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO); if (!error) character = _bitmap_to_character(slot->bitmap, slot->bitmap_top, slot->bitmap_left, slot->advance.x / 64.0); } @@ -785,6 +789,18 @@ void DynamicFont::set_use_filter(bool p_enable) { _reload_cache(); } +bool DynamicFontData::is_antialiased() const { + + return antialiased; +} + +void DynamicFontData::set_antialiased(bool p_antialiased) { + + if (antialiased == p_antialiased) + return; + antialiased = p_antialiased; +} + DynamicFontData::Hinting DynamicFontData::get_hinting() const { return hinting; diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index bd3f84d62c..96437e8982 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -71,12 +71,15 @@ public: HINTING_NORMAL }; + bool is_antialiased() const; + void set_antialiased(bool p_antialiased); Hinting get_hinting() const; void set_hinting(Hinting p_hinting); private: const uint8_t *font_mem; int font_mem_size; + bool antialiased; bool force_autohinter; Hinting hinting; |