summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/label.cpp4
-rw-r--r--scene/resources/font.cpp17
-rw-r--r--scene/resources/font.h4
3 files changed, 24 insertions, 1 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index d2e1e7f0b9..892e4c9bc7 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -72,6 +72,7 @@ void Label::_notification(int p_what) {
if (clip && !autowrap)
VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
+
if (word_cache_dirty)
regenerate_word_cache();
@@ -87,7 +88,8 @@ void Label::_notification(int p_what) {
bool use_outlinde = get_constant("shadow_as_outline");
Point2 shadow_ofs(get_constant("shadow_offset_x"),get_constant("shadow_offset_y"));
-
+ VisualServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(),font.is_valid() && font->is_distance_field_hint());
+
int font_h = font->get_height();
int line_from=(int)get_val(); // + p_exposed.pos.y / font_h;
int lines_visible = size.y/font_h;
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 49ee3ee017..24d413ed60 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -398,6 +398,17 @@ int Font::get_kerning_pair(CharType p_A,CharType p_B) const {
return 0;
}
+void Font::set_distance_field_hint(bool p_distance_field) {
+
+ distance_field_hint=p_distance_field;
+ emit_changed();
+}
+
+bool Font::is_distance_field_hint() const{
+
+ return distance_field_hint;
+}
+
void Font::clear() {
@@ -406,6 +417,7 @@ void Font::clear() {
char_map.clear();
textures.clear();
kerning_map.clear();
+ distance_field_hint=false;
}
Size2 Font::get_string_size(const String& p_string) const {
@@ -514,6 +526,9 @@ void Font::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_char_size","char","next"),&Font::get_char_size,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
+ ObjectTypeDB::bind_method(_MD("set_distance_field_hint","enable"),&Font::set_distance_field_hint);
+ ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
+
ObjectTypeDB::bind_method(_MD("clear"),&Font::clear);
ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
@@ -535,12 +550,14 @@ void Font::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint") );
}
Font::Font() {
clear();
+
}
diff --git a/scene/resources/font.h b/scene/resources/font.h
index a64ec1ef7a..498bc6863a 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -75,6 +75,7 @@ private:
float height;
float ascent;
+ bool distance_field_hint;
void _set_chars(const DVector<int>& p_chars);
DVector<int> _get_chars() const;
@@ -116,6 +117,9 @@ public:
Size2 get_string_size(const String& p_string) const;
void clear();
+
+ void set_distance_field_hint(bool p_distance_field);
+ bool is_distance_field_hint() const;
void draw(RID p_canvas_item, const Point2& p_pos, const String& p_text,const Color& p_modulate=Color(1,1,1),int p_clip_w=-1) const;
void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const;