From 4bb34179bcddf7e821c2cd780f54a4d933854f8e Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Tue, 30 Jun 2026 23:06:25 -0300 Subject: [PATCH 1/6] Add GMT_SYMBOL_FRONT --- src/gmt_init.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gmt_init.c b/src/gmt_init.c index 4bae4ac294c..cd4cbbb492c 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -20454,6 +20454,14 @@ void gmt_add_legend_item (struct GMTAPI_CTRL *API, struct GMT_SYMBOL *S, bool do else if (symbol == GMT_SYMBOL_CUSTOM) { /* Custom symbol */ fprintf (fp, "S - %c%s %s %s %s - %s\n", GMT_SYMBOL_CUSTOM, S->custom->name, size_string, (do_fill) ? gmtlib_putfill (API->GMT, fill) : "-", (do_line) ? gmt_putpen (API->GMT, pen) : "-", label); } + else if (symbol == GMT_SYMBOL_FRONT) { /* Front symbol: must pass along the front-type and sense modifiers or pslegend will default to +l+b (left box) for all entries */ + char scode[GMT_LEN64] = {""}; + static char f_type[7] = {'f', 'v', 't', 's', 'S', 'c', 'b'}; /* Maps GMT_FRONT_* enum to its -Sf modifier letter */ + sprintf (scode, "f+%c", f_type[S->f.f_symbol]); + if (S->f.f_sense == GMT_FRONT_LEFT) strcat (scode, "+l"); + else if (S->f.f_sense == GMT_FRONT_RIGHT) strcat (scode, "+r"); + fprintf (fp, "S - %s %s %s %s - %s\n", scode, size_string, (do_fill) ? gmtlib_putfill (API->GMT, fill) : "-", (do_line) ? gmt_putpen (API->GMT, pen) : "-", label); + } else fprintf (fp, "S - %c %s %s %s - %s\n", symbol, size_string, (do_fill) ? gmtlib_putfill (API->GMT, fill) : "-", (do_line) ? gmt_putpen (API->GMT, pen) : "-", label); } From a523346f21e99e2c21eb44a35ecbd373cfd7e064 Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Wed, 1 Jul 2026 14:48:43 -0300 Subject: [PATCH 2/6] fix pen --- src/pslegend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pslegend.c b/src/pslegend.c index a1c4adc1683..6c8cc4c89f2 100644 --- a/src/pslegend.c +++ b/src/pslegend.c @@ -1602,7 +1602,7 @@ EXTERN_MSC int GMT_pslegend (void *V_API, int mode, void *args) { /* Place pen and fill colors in segment header */ sprintf (buffer, "-Sf%s/%gi%s", B, tlen, sub); if (txt_c[0] != '-') {strcat (buffer, " -G"); strcat (buffer, txt_c);} - if (txt_d[0] != '-') {strcat (buffer, " -W"); strcat (buffer, txt_d);} + strcat (buffer, " -W"); strcat (buffer, (txt_d[0] != '-') ? txt_d : gmt_putpen (GMT, &GMT->current.setting.map_default_pen)); /* Always give an explicit pen (given or default) so this segment does not inherit the previous entry's pen */ /* Prepare next output segment */ if ((D[FRONT] = pslegend_get_dataset_pointer (API, D[FRONT], GMT_IS_LINE, GMT_SMALL_CHUNK, 2U, 2U, false)) == NULL) return (API->error); S[FRONT] = pslegend_get_segment (D, FRONT, n_fronts); /* Next front segment */ @@ -1623,7 +1623,7 @@ EXTERN_MSC int GMT_pslegend (void *V_API, int mode, void *args) { x = 0.5 * length; /* Place pen and fill colors in segment header */ sprintf (buffer, "-S%s", symbol); - if (txt_d[0] != '-') {strcat (buffer, " -W"); strcat (buffer, txt_d);} + strcat (buffer, " -W"); strcat (buffer, (txt_d[0] != '-') ? txt_d : gmt_putpen (GMT, &GMT->current.setting.map_default_pen)); /* Always give an explicit pen (given or default) so this segment does not inherit the previous entry's pen */ S[QLINE] = pslegend_get_segment (D, QLINE, n_quoted_lines); /* Next quoted line segment */ S[QLINE]->header = strdup (buffer); GMT_Report (API, GMT_MSG_DEBUG, "QLINE: %s\n", buffer); @@ -1642,7 +1642,7 @@ EXTERN_MSC int GMT_pslegend (void *V_API, int mode, void *args) { x = 0.5 * length; /* Place pen and fill colors in segment header */ sprintf (buffer, "-S%s", symbol); - if (txt_d[0] != '-') {strcat (buffer, " -W"); strcat (buffer, txt_d);} + strcat (buffer, " -W"); strcat (buffer, (txt_d[0] != '-') ? txt_d : gmt_putpen (GMT, &GMT->current.setting.map_default_pen)); /* Always give an explicit pen (given or default) so this segment does not inherit the previous entry's pen */ S[DLINE] = pslegend_get_segment (D, DLINE, n_decorated_lines); /* Next decorated line segment */ S[DLINE]->header = strdup (buffer); GMT_Report (API, GMT_MSG_DEBUG, "DLINE: %s\n", buffer); From 2da0c4c3622f88ad14ca6d1f5c7d53ef25f8f289 Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Wed, 1 Jul 2026 19:31:32 -0300 Subject: [PATCH 3/6] Add test --- test/pslegend/autolegendfront.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/pslegend/autolegendfront.sh diff --git a/test/pslegend/autolegendfront.sh b/test/pslegend/autolegendfront.sh new file mode 100644 index 00000000000..434a57d5484 --- /dev/null +++ b/test/pslegend/autolegendfront.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# +# Test auto-legend for front (fault) symbols (-Sf). +# +# Regression test for issue #9066: +# 1) Each auto-legend entry must show the correct front sub-type +# (e.g., +c circle vs +b box), not always a box. +# 2) An entry with no explicit -W must not inherit the pen from a +# previous entry that did specify one (here, "circle thick" uses +# an explicit thick red pen, while "box" specifies no pen at all +# and must fall back to the default pen, not thick red). +cat << EOF > t1.txt +0 1 +1 1 +EOF +cat << EOF > t2.txt +0 2 +1 2 +EOF +gmt begin autolegendfront ps + gmt basemap -R0/1/0/5 -JX5c -Bf + gmt plot -Wthick,red -Gblack -Sf2+c+r t2.txt -l"circle thick" + gmt plot -Gpurple -Sf2+b+r t1.txt -l"box" +gmt end + +rm t*.txt \ No newline at end of file From 9b70c70fbc8ae64ae83f9e868d1acde099d9c997 Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Wed, 1 Jul 2026 19:40:03 -0300 Subject: [PATCH 4/6] Add GRAPHICSMAGICK_RMS --- test/pslegend/autolegendfront.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/pslegend/autolegendfront.sh b/test/pslegend/autolegendfront.sh index 434a57d5484..f4cdab25209 100644 --- a/test/pslegend/autolegendfront.sh +++ b/test/pslegend/autolegendfront.sh @@ -2,6 +2,8 @@ # # Test auto-legend for front (fault) symbols (-Sf). # +# GRAPHICSMAGICK_RMS = 0.02 +# # Regression test for issue #9066: # 1) Each auto-legend entry must show the correct front sub-type # (e.g., +c circle vs +b box), not always a box. From 6bdbbdf1a9d2a89164bd3a67b2d7ccf90017c564 Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Wed, 1 Jul 2026 21:41:29 -0300 Subject: [PATCH 5/6] Add #GMT_KNOWN_FAILURE --- test/pslegend/autolegendfront.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/pslegend/autolegendfront.sh b/test/pslegend/autolegendfront.sh index f4cdab25209..5b563db32c4 100644 --- a/test/pslegend/autolegendfront.sh +++ b/test/pslegend/autolegendfront.sh @@ -3,6 +3,7 @@ # Test auto-legend for front (fault) symbols (-Sf). # # GRAPHICSMAGICK_RMS = 0.02 +# GMT_KNOWN_FAILURE # # Regression test for issue #9066: # 1) Each auto-legend entry must show the correct front sub-type From 53b863861ef2519d9f64eeae026e7d27e1bbf8c4 Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Wed, 1 Jul 2026 21:45:40 -0300 Subject: [PATCH 6/6] Change access permission. --- test/pslegend/autolegendfront.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/pslegend/autolegendfront.sh diff --git a/test/pslegend/autolegendfront.sh b/test/pslegend/autolegendfront.sh old mode 100644 new mode 100755