@@ -431,13 +431,13 @@ inline void draw_glyph_shadow(const Glyph &p_gl, const RID &p_canvas, const Colo
431431 }
432432}
433433
434- inline void draw_glyph_shadow_outline (const Glyph &p_gl, const RID &p_canvas, const Color &p_font_shadow_color, int p_shadow_outline_size, const Vector2 &p_ofs, const Vector2 &shadow_ofs) {
434+ inline void draw_glyph_shadow_outline (const Glyph &p_gl, const RID &p_canvas, const Color &p_font_shadow_color, const Vector2 &p_ofs, int p_shadow_outline_size , const Vector2 &shadow_ofs) {
435435 if (p_gl.font_rid != RID ()) {
436436 TS->font_draw_glyph_outline (p_gl.font_rid , p_canvas, p_gl.font_size , p_shadow_outline_size, p_ofs + Vector2 (p_gl.x_off , p_gl.y_off ) + shadow_ofs, p_gl.index , p_font_shadow_color);
437437 }
438438}
439439
440- inline void draw_glyph_outline (const Glyph &p_gl, const RID &p_canvas, const Color &p_font_outline_color, int p_outline_size, const Vector2 &p_ofs) {
440+ inline void draw_glyph_outline (const Glyph &p_gl, const RID &p_canvas, const Color &p_font_outline_color, const Vector2 &p_ofs, int p_outline_size ) {
441441 if (p_gl.font_rid != RID ()) {
442442 if (p_font_outline_color.a != 0.0 && p_outline_size > 0 ) {
443443 TS->font_draw_glyph_outline (p_gl.font_rid , p_canvas, p_gl.font_size , p_outline_size, p_ofs + Vector2 (p_gl.x_off , p_gl.y_off ), p_gl.index , p_font_outline_color);
@@ -758,6 +758,8 @@ void Label::_notification(int p_what) {
758758 Color font_outline_color = has_settings ? settings->get_outline_color () : theme_cache.font_outline_color ;
759759 int outline_size = has_settings ? settings->get_outline_size () : theme_cache.font_outline_size ;
760760 int shadow_outline_size = has_settings ? settings->get_shadow_size () : theme_cache.font_shadow_outline_size ;
761+ Vector<LabelSettings::StackedOutlineData> stacked_outline_datas = has_settings ? settings->get_stacked_outline_data () : Vector<LabelSettings::StackedOutlineData>();
762+ Vector<LabelSettings::StackedShadowData> stacked_shadow_datas = has_settings ? settings->get_stacked_shadow_data () : Vector<LabelSettings::StackedShadowData>();
761763 bool rtl_layout = is_layout_rtl ();
762764
763765 if (has_focus ()) {
@@ -813,95 +815,67 @@ void Label::_notification(int p_what) {
813815
814816 ofs.y += asc;
815817
816- // Draw shadow, outline and text . Note: Do not merge this into the single loop iteration, to prevent overlaps.
818+ // Draw text effects and main texts . Note: Do not merge this into the single loop iteration, to prevent overlaps.
817819 int processed_glyphs_step = 0 ;
818- for (int step = DRAW_STEP_SHADOW_OUTLINE; step < DRAW_STEP_MAX; step++) {
819- if (step == DRAW_STEP_SHADOW_OUTLINE && (font_shadow_color.a == 0 || shadow_outline_size <= 0 )) {
820- continue ;
821- }
822- if (step == DRAW_STEP_SHADOW && (font_shadow_color.a == 0 )) {
823- continue ;
824- }
825- if (step == DRAW_STEP_OUTLINE && (outline_size <= 0 || font_outline_color.a == 0 )) {
826- continue ;
827- }
828820
829- processed_glyphs_step = processed_glyphs;
830- Vector2 offset_step = ofs;
831- // Draw RTL ellipsis string when necessary.
832- if (rtl && ellipsis_pos >= 0 ) {
833- for (int gl_idx = ellipsis_gl_size - 1 ; gl_idx >= 0 ; gl_idx--) {
834- for (int j = 0 ; j < ellipsis_glyphs[gl_idx].repeat ; j++) {
835- bool skip = (trim_chars && ellipsis_glyphs[gl_idx].end + para.start > visible_chars) || (trim_glyphs_ltr && (processed_glyphs_step >= visible_glyphs)) || (trim_glyphs_rtl && (processed_glyphs_step < total_glyphs - visible_glyphs));
836- if (!skip) {
837- if (step == DRAW_STEP_SHADOW_OUTLINE) {
838- draw_glyph_shadow_outline (ellipsis_glyphs[gl_idx], ci, font_shadow_color, shadow_outline_size, offset_step, shadow_ofs);
839- } else if (step == DRAW_STEP_SHADOW) {
840- draw_glyph_shadow (ellipsis_glyphs[gl_idx], ci, font_shadow_color, offset_step, shadow_ofs);
841- } else if (step == DRAW_STEP_OUTLINE) {
842- draw_glyph_outline (ellipsis_glyphs[gl_idx], ci, font_outline_color, outline_size, offset_step);
843- } else if (step == DRAW_STEP_TEXT) {
844- draw_glyph (ellipsis_glyphs[gl_idx], ci, font_color, offset_step);
845- }
846- }
847- processed_glyphs_step++;
848- offset_step.x += ellipsis_glyphs[gl_idx].advance ;
849- }
821+ // Draw shadow outline.
822+ if (font_shadow_color.a != 0 && shadow_outline_size > 0 ) {
823+ draw_text (rtl, ellipsis_pos, ellipsis_gl_size, ellipsis_glyphs, trim_chars, para.start , visible_chars, trim_glyphs_ltr, processed_glyphs_step, processed_glyphs, visible_glyphs, trim_glyphs_rtl, total_glyphs, ci, ofs, gl_size, trim_pos, glyphs, font_shadow_color, draw_glyph_shadow_outline, shadow_outline_size, shadow_ofs);
824+ }
825+
826+ // Draw shadow.
827+ if (font_shadow_color.a > 0 ) {
828+ draw_text (rtl, ellipsis_pos, ellipsis_gl_size, ellipsis_glyphs, trim_chars, para.start , visible_chars, trim_glyphs_ltr, processed_glyphs_step, processed_glyphs, visible_glyphs, trim_glyphs_rtl, total_glyphs, ci, ofs, gl_size, trim_pos, glyphs, font_shadow_color, draw_glyph_shadow, shadow_ofs);
829+ }
830+
831+ // Draw stacked shadow.
832+ if (stacked_shadow_datas.size () != 0 ) {
833+ int draw_iterations = stacked_shadow_datas.size ();
834+
835+ for (int draw_iteration_index = draw_iterations - 1 ; draw_iteration_index >= 0 ; --draw_iteration_index) {
836+ LabelSettings::StackedShadowData stacked_shadow_data = stacked_shadow_datas[draw_iteration_index];
837+ if (stacked_shadow_data.outline_size > 0 ) {
838+ draw_text (rtl, ellipsis_pos, ellipsis_gl_size, ellipsis_glyphs, trim_chars, para.start , visible_chars, trim_glyphs_ltr, processed_glyphs_step, processed_glyphs, visible_glyphs, trim_glyphs_rtl, total_glyphs, ci, ofs, gl_size, trim_pos, glyphs, stacked_shadow_data.color , draw_glyph_shadow_outline, stacked_shadow_data.outline_size , stacked_shadow_data.offset );
850839 }
840+
841+ draw_text (rtl, ellipsis_pos, ellipsis_gl_size, ellipsis_glyphs, trim_chars, para.start , visible_chars, trim_glyphs_ltr, processed_glyphs_step, processed_glyphs, visible_glyphs, trim_glyphs_rtl, total_glyphs, ci, ofs, gl_size, trim_pos, glyphs, stacked_shadow_data.color , draw_glyph_shadow, stacked_shadow_data.offset );
851842 }
852- // Draw main text.
853- for (int j = 0 ; j < gl_size; j++) {
854- // Trim when necessary.
855- if (trim_pos >= 0 ) {
856- if (rtl) {
857- if (j < trim_pos) {
858- continue ;
859- }
860- } else {
861- if (j >= trim_pos) {
862- break ;
863- }
864- }
865- }
866- for (int k = 0 ; k < glyphs[j].repeat ; k++) {
867- bool skip = (trim_chars && glyphs[j].end + para.start > visible_chars) || (trim_glyphs_ltr && (processed_glyphs_step >= visible_glyphs)) || (trim_glyphs_rtl && (processed_glyphs_step < total_glyphs - visible_glyphs));
868- if (!skip) {
869- if (step == DRAW_STEP_SHADOW_OUTLINE) {
870- draw_glyph_shadow_outline (glyphs[j], ci, font_shadow_color, shadow_outline_size, offset_step, shadow_ofs);
871- } else if (step == DRAW_STEP_SHADOW) {
872- draw_glyph_shadow (glyphs[j], ci, font_shadow_color, offset_step, shadow_ofs);
873- } else if (step == DRAW_STEP_OUTLINE) {
874- draw_glyph_outline (glyphs[j], ci, font_outline_color, outline_size, offset_step);
875- } else if (step == DRAW_STEP_TEXT) {
876- draw_glyph (glyphs[j], ci, font_color, offset_step);
877- }
878- }
879- processed_glyphs_step++;
880- offset_step.x += glyphs[j].advance ;
843+ }
844+
845+ // Draw stacked outline.
846+ if (stacked_outline_datas.size () != 0 ) {
847+ int stacked_outline_draw_size = outline_size;
848+
849+ int draw_iterations = stacked_outline_datas.size ();
850+
851+ for (int j = 0 ; j < draw_iterations; j++) {
852+ int stacked_outline_size = stacked_outline_datas[j].size ;
853+ if (stacked_outline_size <= 0 ) {
854+ continue ;
881855 }
856+ stacked_outline_draw_size += stacked_outline_size;
882857 }
883- // Draw LTR ellipsis string when necessary.
884- if (!rtl && ellipsis_pos >= 0 ) {
885- for (int gl_idx = 0 ; gl_idx < ellipsis_gl_size; gl_idx++) {
886- for (int j = 0 ; j < ellipsis_glyphs[gl_idx].repeat ; j++) {
887- bool skip = (trim_chars && ellipsis_glyphs[gl_idx].end + para.start > visible_chars) || (trim_glyphs_ltr && (processed_glyphs_step >= visible_glyphs)) || (trim_glyphs_rtl && (processed_glyphs_step < total_glyphs - visible_glyphs));
888- if (!skip) {
889- if (step == DRAW_STEP_SHADOW_OUTLINE) {
890- draw_glyph_shadow_outline (ellipsis_glyphs[gl_idx], ci, font_shadow_color, shadow_outline_size, offset_step, shadow_ofs);
891- } else if (step == DRAW_STEP_SHADOW) {
892- draw_glyph_shadow (ellipsis_glyphs[gl_idx], ci, font_shadow_color, offset_step, shadow_ofs);
893- } else if (step == DRAW_STEP_OUTLINE) {
894- draw_glyph_outline (ellipsis_glyphs[gl_idx], ci, font_outline_color, outline_size, offset_step);
895- } else if (step == DRAW_STEP_TEXT) {
896- draw_glyph (ellipsis_glyphs[gl_idx], ci, font_color, offset_step);
897- }
898- }
899- processed_glyphs_step++;
900- offset_step.x += ellipsis_glyphs[gl_idx].advance ;
901- }
858+
859+ for (int draw_iteration_index = draw_iterations - 1 ; draw_iteration_index >= 0 ; --draw_iteration_index) {
860+ LabelSettings::StackedOutlineData stacked_outline_data = stacked_outline_datas[draw_iteration_index];
861+ if (stacked_outline_data.size <= 0 ) {
862+ continue ;
902863 }
864+ draw_text (rtl, ellipsis_pos, ellipsis_gl_size, ellipsis_glyphs, trim_chars, para.start , visible_chars, trim_glyphs_ltr, processed_glyphs_step, processed_glyphs, visible_glyphs, trim_glyphs_rtl, total_glyphs, ci, ofs, gl_size, trim_pos, glyphs, stacked_outline_data.color , draw_glyph_outline, stacked_outline_draw_size);
865+ stacked_outline_draw_size -= stacked_outline_data.size ;
903866 }
904867 }
868+
869+ // Draw outline.
870+ if (outline_size > 0 && font_outline_color.a != 0 ) {
871+ draw_text (rtl, ellipsis_pos, ellipsis_gl_size, ellipsis_glyphs, trim_chars, para.start , visible_chars, trim_glyphs_ltr, processed_glyphs_step, processed_glyphs, visible_glyphs, trim_glyphs_rtl, total_glyphs, ci, ofs, gl_size, trim_pos, glyphs, font_outline_color, draw_glyph_outline, outline_size);
872+ }
873+
874+ // Draw text.
875+ {
876+ draw_text (rtl, ellipsis_pos, ellipsis_gl_size, ellipsis_glyphs, trim_chars, para.start , visible_chars, trim_glyphs_ltr, processed_glyphs_step, processed_glyphs, visible_glyphs, trim_glyphs_rtl, total_glyphs, ci, ofs, gl_size, trim_pos, glyphs, font_color, draw_glyph);
877+ }
878+
905879 processed_glyphs = processed_glyphs_step;
906880 ofs.y += dsc + line_spacing;
907881 }
0 commit comments