summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-03-21 00:43:33 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-03-21 00:43:33 -0300
commitacc6f3b285f058104fd6431bed2c4cfe4dc05a58 (patch)
tree91374cb7cb30f5dcee42236e60598b3cf694a3fe /scene/resources
parent90a84b4ddb64f4adc024766435f3fc75605f9aab (diff)
signed distance field font support
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/font.cpp17
-rw-r--r--scene/resources/font.h4
2 files changed, 21 insertions, 0 deletions
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;