Skip to content

Commit 9c724c2

Browse files
authored
Handle font values with equal signs in them (#3192)
* Hande font values with equal signs in them From the olden days, we are allowing the deprecated syntax PAR = value and even PAR=value given to gmt set, despite the syntax being PAR value. This caused trouble for fonts with outline pens which contains an equal sign. WHile being bakwards compatible, I removed the [=] from the docs to discourage the use of that old syntax. We still allow it, but not PAR=value for FONTS. * Opps, plus remove two gv calls * Update gmt_init.c * Update putfont
1 parent ee933ef commit 9c724c2

6 files changed

Lines changed: 9 additions & 7 deletions

File tree

doc/rst/source/gmtset.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Synopsis
1414

1515
**gmt set** [ |-C| \| |-D|\ [**s**\|\ **u**] \|
1616
|-G|\ *defaultsfile* ] [ **-**\ [**BJRXYp**]\ *value* ]
17-
PARAMETER1 [=] *value1* PARAMETER2 [=] *value2* PARAMETER3 [=] *value3*
17+
PARAMETER1 *value1* PARAMETER2 *value2* PARAMETER3 *value3*
1818
...
1919

2020
|No-spaces|

src/gmt_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9222,7 +9222,7 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options)
92229222
for (opt = options; opt; opt = opt->next) {
92239223
if (!(opt->option == '<' || opt->option == '#') || !opt->arg) continue; /* Skip other and empty options */
92249224
if (!strcmp (opt->arg, "=")) continue; /* User forgot and gave parameter = value (3 words) */
9225-
if (opt->arg[0] != '=' && strchr (opt->arg, '=')) { /* User forgot and gave parameter=value (1 word) */
9225+
if (opt->arg[0] != '=' && strchr (opt->arg, '=') && (!param || !strstr (param, "FONT_"))) { /* User forgot and gave parameter=value (1 word); OK except for FONTS */
92269226
p = 0;
92279227
while (opt->arg[p] && opt->arg[p] != '=') p++;
92289228
opt->arg[p] = '\0'; /* Temporarily remove the equal sign */

src/gmt_support.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6499,8 +6499,12 @@ char *gmt_putfont (struct GMT_CTRL *GMT, struct GMT_FONT *F) {
64996499

65006500
static char text[GMT_BUFSIZ];
65016501

6502-
if (F->form & 2)
6503-
snprintf (text, GMT_BUFSIZ, "%gp,%s,%s=%s", F->size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill), gmt_putpen (GMT, &F->pen));
6502+
if (F->form & 2) {
6503+
if (F->form & 8)
6504+
snprintf (text, GMT_BUFSIZ, "%gp,%s,%s=~%s", F->size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill), gmt_putpen (GMT, &F->pen));
6505+
else
6506+
snprintf (text, GMT_BUFSIZ, "%gp,%s,%s=%s", F->size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill), gmt_putpen (GMT, &F->pen));
6507+
}
65046508
else
65056509
snprintf (text, GMT_BUFSIZ, "%gp,%s,%s", F->size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill));
65066510
return (text);

src/gmtset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ GMT_LOCAL void Free_Ctrl (struct GMT_CTRL *GMT, struct GMTSET_CTRL *C) { /* Deal
6565
GMT_LOCAL int usage (struct GMTAPI_CTRL *API, int level) {
6666
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
6767
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
68-
GMT_Message (API, GMT_TIME_NONE, "usage: %s [-C | -D[s|u] | -G<defaultsfile>] [-[" GMT_SHORTHAND_OPTIONS "]<value>] PARAMETER1 [=] value1 PARAMETER2 [=] value2 PARAMETER3 [=] value3 ...\n", name);
68+
GMT_Message (API, GMT_TIME_NONE, "usage: %s [-C | -D[s|u] | -G<defaultsfile>] [-[" GMT_SHORTHAND_OPTIONS "]<value>] PARAMETER1 value1 PARAMETER2 value2 PARAMETER3 value3 ...\n", name);
6969
GMT_Message (API, GMT_TIME_NONE, "\n\tFor available PARAMETERS, see gmt.conf man page.\n\n");
7070

7171
if (level == GMT_SYNOPSIS) return (GMT_MODULE_SYNOPSIS);

test/psxy/variable_z.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ gmt psxy -R -J pol.txt -B0 -Ct.cpt -Zz.txt -W2p+z -O -K -X-8.5c -Y8.5c >> $ps
3636
echo "-Zz.txt -W2p+z" | gmt pstext -R -J -O -K -F+f12p+cTL -Dj0.1i >> $ps
3737
gmt psxy -R -J pol.txt -B0 -Ct.cpt -Z3 -G+z -W2p -O -K -X8.5c >> $ps
3838
echo "-Z3 -G+z -W2p" | gmt pstext -R -J -O -F+f12p+cTL -Dj0.1i >> $ps
39-
gv $ps

test/psxyz/variable_z.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ gmt psxy -R -J pol.txt -B0 -Ct.cpt -Zz.txt -W2p+z -O -K -X-8.5c -Y8.5c -p >> $ps
3636
echo "-Zz.txt -W2p+z" | gmt pstext -R -J -O -K -F+f12p+cTL -Dj0.1i -p >> $ps
3737
gmt psxy -R -J pol.txt -B0 -Ct.cpt -Z3 -G+z -W2p -O -K -X8.5c -p >> $ps
3838
echo "-Z3 -G+z -W2p" | gmt pstext -R -J -O -F+f12p+cTL -Dj0.1i -p >> $ps
39-
gv $ps

0 commit comments

Comments
 (0)