From ae855438069e16a0da6d569404cff11f9c8c7bd6 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 21 Jun 2016 10:41:13 -0300 Subject: [PATCH] Ability to premultiply alpha on font import, fixes #5231 --- .../io_plugins/editor_font_import_plugin.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 97ccb766c01..70bc44ba7dc 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -102,6 +102,7 @@ public: bool disable_filter; bool round_advance; + bool premultiply_alpha; @@ -167,6 +168,8 @@ public: round_advance=p_value; else if (n=="advanced/disable_filter") disable_filter=p_value; + else if (n=="advanced/premultiply_alpha") + premultiply_alpha=p_value; else return false; @@ -235,6 +238,8 @@ public: r_ret=round_advance; else if (n=="advanced/disable_filter") r_ret=disable_filter; + else if (n=="advanced/premultiply_alpha") + r_ret=premultiply_alpha; else return false; @@ -297,6 +302,7 @@ public: p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/round_advance")); p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/disable_filter")); + p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/premultiply_alpha")); } @@ -336,6 +342,7 @@ public: font_mode=FONT_BITMAP; round_advance=true; disable_filter=false; + premultiply_alpha=false; } @@ -368,6 +375,7 @@ public: round_advance=true; disable_filter=false; + premultiply_alpha=false; } @@ -1542,12 +1550,30 @@ Ref EditorFontImportPlugin::generate_font(const Refhas_option("advanced/premultiply_alpha") && bool(from->get_option("advanced/premultiply_alpha"))) { + + DVector data = atlas.get_data(); + int dl = data.size(); + { + DVector::Write w = data.write(); + + for(int i=0;ihas_option("color/monochrome") && bool(from->get_option("color/monochrome"))) { atlas.convert(Image::FORMAT_GRAYSCALE_ALPHA); } + if (0) { //debug the texture Ref atlast = memnew( ImageTexture );