Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set degree symbol as default, handle hyphens and minus #206

Merged
merged 2 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc_classic/examples/anim01/anim_01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ps=${name}.ps
angle_step=`gmt math -Q 360 ${n_frames} DIV =`
angle_inc=`gmt math -Q ${angle_step} 10 DIV =`
gmt psbasemap -R0/360/-1.2/1.6 -JX3.5i/1.65i -P -K -X0.35i -Y0.25i \
-BWSne+glightgreen -Bxa90g90f30+u\\312 -Bya0.5f0.1g1 \
-BWSne+glightgreen -Bxa90g90f30+u@. -Bya0.5f0.1g1 \
--PS_MEDIA=${width}x${height} --FONT_ANNOT_PRIMARY=9p > $$.map.ps
# 2. Main frame loop
mkdir -p $$
Expand Down
6 changes: 3 additions & 3 deletions doc_classic/examples/ex30/example_30.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo GMT EXAMPLE 30
set ps=example_30.ps
gmt set PS_CHAR_ENCODING Standard+

gmt psbasemap -R0/360/-1.25/1.75 -JX8i/6i -Bx90f30+u"\312" -By1g10 -BWS+t"Two Trigonometric Functions" -K --MAP_FRAME_TYPE=graph --MAP_VECTOR_SHAPE=0.5 > %ps%
gmt psbasemap -R0/360/-1.25/1.75 -JX8i/6i -Bx90f30+u@. -By1g10 -BWS+t"Two Trigonometric Functions" -K --MAP_FRAME_TYPE=graph --MAP_VECTOR_SHAPE=0.5 > %ps%

REM Draw sine an cosine curves

Expand All @@ -23,7 +23,7 @@ gmt psxy -R -J -O -K -W0.5p,- tmp >> %ps%

echo 360 1 18p,Times-Roman RB x = cos(@%%12%%a@%%%%) > tmp
echo 360 0 18p,Times-Roman RB y = sin(@%%12%%a@%%%%) >> tmp
echo 120 -1.25 14p,Times-Roman LB 120\312 >> tmp
echo 120 -1.25 14p,Times-Roman LB 120@. >> tmp
echo 370 -1.35 24p,Symbol LT a >> tmp
echo -5 1.85 24p,Times-Roman RT x,y >> tmp
gmt pstext -R -J -O -K -Dj0.2c -N tmp -F+f+j >> %ps%
Expand Down Expand Up @@ -53,7 +53,7 @@ gmt psxy -R -J -O -K -W2p tmp >> %ps%
echo -0.16666 0 12p,5 0 CT x > tmp
echo -0.3333 0.2888675 12p,Times-Roman 0 RM y >> tmp
echo 0.22 0.27 12p,Symbol -30 CB a >> tmp
echo -0.33333 0.6 12p,Times-Roman 30 LB 120\312 >> tmp
echo -0.33333 0.6 12p,Times-Roman 30 LB 120@. >> tmp
gmt pstext -R -J -O -K -Dj0.05i tmp -F+f+a+j >> %ps%

echo 0 0 0.5i 0 120 | gmt psxy -R -J -O -Sm0.15i+e -W1p -Gblack >> %ps%
Expand Down
6 changes: 3 additions & 3 deletions doc_classic/examples/ex30/example_30.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Draw generic x-y axes with arrows
ps=example_30.ps

gmt psbasemap -R0/360/-1.25/1.75 -JX8i/6i -Bx90f30+u"\\312" -By1g10 -BWS+t"Two Trigonometric Functions" \
gmt psbasemap -R0/360/-1.25/1.75 -JX8i/6i -Bx90f30+u@. -By1g10 -BWS+t"Two Trigonometric Functions" \
-K --MAP_FRAME_TYPE=graph --MAP_VECTOR_SHAPE=0.5 > $ps

# Draw sine an cosine curves
Expand All @@ -25,7 +25,7 @@ EOF
gmt pstext -R -J -O -K -Dj0.2c -N -F+f+j << EOF >> $ps
360 1 18p,Times-Roman RB x = cos(@%12%a@%%)
360 0 18p,Times-Roman RB y = sin(@%12%a@%%)
120 -1.25 14p,Times-Roman LB 120\\312
120 -1.25 14p,Times-Roman LB 120@.
370 -1.35 24p,Symbol LT a
-5 1.85 24p,Times-Roman RT x,y
EOF
Expand Down Expand Up @@ -58,7 +58,7 @@ gmt pstext -R -J -O -K -Dj0.05i -F+f+a+j << EOF >> $ps
-0.16666 0 12p,Times-Roman 0 CT x
-0.3333 0.2888675 12p,Times-Roman 0 RM y
0.22 0.27 12p,Symbol -30 CB a
-0.33333 0.6 12p,Times-Roman 30 LB 120\\312
-0.33333 0.6 12p,Times-Roman 30 LB 120@.
EOF

echo 0 0 0.5 0 120 | gmt psxy -R -J -O -Sm0.15i+e -W1p -Gblack --PROJ_LENGTH_UNIT=inch >> $ps
4 changes: 3 additions & 1 deletion doc_classic/rst/source/GMT_Docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3125,6 +3125,8 @@ sequence for font switching.
+-------------------+----------------------------------------------------------------+
| @! | Creates one composite character of the next two characters |
+-------------------+----------------------------------------------------------------+
| @. | Prints the degree symbol |
+-------------------+----------------------------------------------------------------+
| @@ | Prints the @ sign itself |
+-------------------+----------------------------------------------------------------+

Expand Down Expand Up @@ -8796,7 +8798,7 @@ inverse-video the label:
gmt pscoast -R50/160/-15/15 -JM5.3i -Gburlywood -Sazure -A500 -K -P > GMT_App_O_7.ps
gmt grdcontour geoid.nc -J -O -K -B20f10 -BWSne -C10 -A20+d+u" m"+f8p -Gl50/10S/160/10S -S10 \
-T+l"-+" >> GMT_App_O_7.ps
gmt psxy -R -J -O -SqD15d:+gblack+fwhite+Ld+o+u\\260 -Wthick transect.txt >> GMT_App_O_7.ps
gmt psxy -R -J -O -SqD15d:+gblack+fwhite+Ld+o+u@. -Wthick transect.txt >> GMT_App_O_7.ps

The output is presented as Figure :ref:`Contour label 7 <Contour_label_7>`.

Expand Down
2 changes: 1 addition & 1 deletion doc_classic/scripts/GMT_App_O_7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
gmt pscoast -R50/160/-15/15 -JM5.3i -Gburlywood -Sazure -A500 -K -P > GMT_App_O_7.ps
gmt grdcontour @App_O_geoid.nc -J -O -K -B20f10 -BWSne -C10 -A20+d+u" m"+f8p -Gl50/10S/160/10S -S10 \
-T+l >> GMT_App_O_7.ps
gmt psxy -R -J -O -SqD15d:+gblack+fwhite+Ld+o+u\\260 -Wthick @App_O_transect.txt >> GMT_App_O_7.ps
gmt psxy -R -J -O -SqD15d:+gblack+fwhite+Ld+o+u@. -Wthick @App_O_transect.txt >> GMT_App_O_7.ps
6 changes: 3 additions & 3 deletions doc_modern/examples/ex30/example_30.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo GMT EXAMPLE 30
set ps=example_30.ps
gmt set PS_CHAR_ENCODING Standard+

gmt psbasemap -R0/360/-1.25/1.75 -JX8i/6i -Bx90f30+u"\312" -By1g10 -BWS+t"Two Trigonometric Functions" -K --MAP_FRAME_TYPE=graph --MAP_VECTOR_SHAPE=0.5 > %ps%
gmt psbasemap -R0/360/-1.25/1.75 -JX8i/6i -Bx90f30+u@. -By1g10 -BWS+t"Two Trigonometric Functions" -K --MAP_FRAME_TYPE=graph --MAP_VECTOR_SHAPE=0.5 > %ps%

REM Draw sine an cosine curves

Expand All @@ -23,7 +23,7 @@ gmt psxy -R -J -O -K -W0.5p,- tmp >> %ps%

echo 360 1 18p,Times-Roman RB x = cos(@%%12%%a@%%%%) > tmp
echo 360 0 18p,Times-Roman RB y = sin(@%%12%%a@%%%%) >> tmp
echo 120 -1.25 14p,Times-Roman LB 120\312 >> tmp
echo 120 -1.25 14p,Times-Roman LB 120@. >> tmp
echo 370 -1.35 24p,Symbol LT a >> tmp
echo -5 1.85 24p,Times-Roman RT x,y >> tmp
gmt pstext -R -J -O -K -Dj0.2c -N tmp -F+f+j >> %ps%
Expand Down Expand Up @@ -53,7 +53,7 @@ gmt psxy -R -J -O -K -W2p tmp >> %ps%
echo -0.16666 0 12p,5 0 CT x > tmp
echo -0.3333 0.2888675 12p,Times-Roman 0 RM y >> tmp
echo 0.22 0.27 12p,Symbol -30 CB a >> tmp
echo -0.33333 0.6 12p,Times-Roman 30 LB 120\312 >> tmp
echo -0.33333 0.6 12p,Times-Roman 30 LB 120@. >> tmp
gmt pstext -R -J -O -K -Dj0.05i tmp -F+f+a+j >> %ps%

echo 0 0 0.5i 0 120 | gmt psxy -R -J -O -Sm0.15i+e -W1p -Gblack >> %ps%
Expand Down
6 changes: 3 additions & 3 deletions doc_modern/examples/ex30/example_30.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Draw generic x-y axes with arrows
ps=example_30.ps

gmt psbasemap -R0/360/-1.25/1.75 -JX8i/6i -Bx90f30+u"\\312" -By1g10 -BWS+t"Two Trigonometric Functions" \
gmt psbasemap -R0/360/-1.25/1.75 -JX8i/6i -Bx90f30+u@. -By1g10 -BWS+t"Two Trigonometric Functions" \
-K --MAP_FRAME_TYPE=graph --MAP_VECTOR_SHAPE=0.5 > $ps

# Draw sine an cosine curves
Expand All @@ -25,7 +25,7 @@ EOF
gmt pstext -R -J -O -K -Dj0.2c -N -F+f+j << EOF >> $ps
360 1 18p,Times-Roman RB x = cos(@%12%a@%%)
360 0 18p,Times-Roman RB y = sin(@%12%a@%%)
120 -1.25 14p,Times-Roman LB 120\\312
120 -1.25 14p,Times-Roman LB 120@.
370 -1.35 24p,Symbol LT a
-5 1.85 24p,Times-Roman RT x,y
EOF
Expand Down Expand Up @@ -58,7 +58,7 @@ gmt pstext -R -J -O -K -Dj0.05i -F+f+a+j << EOF >> $ps
-0.16666 0 12p,Times-Roman 0 CT x
-0.3333 0.2888675 12p,Times-Roman 0 RM y
0.22 0.27 12p,Symbol -30 CB a
-0.33333 0.6 12p,Times-Roman 30 LB 120\\312
-0.33333 0.6 12p,Times-Roman 30 LB 120@.
EOF

echo 0 0 0.5 0 120 | gmt psxy -R -J -O -Sm0.15i+e -W1p -Gblack --PROJ_LENGTH_UNIT=inch >> $ps
4 changes: 3 additions & 1 deletion doc_modern/rst/source/GMT_Docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3065,6 +3065,8 @@ sequence for font switching.
+-------------------+----------------------------------------------------------------+
| @! | Creates one composite character of the next two characters |
+-------------------+----------------------------------------------------------------+
| @. | Prints the degree symbol |
+-------------------+----------------------------------------------------------------+
| @@ | Prints the @ sign itself |
+-------------------+----------------------------------------------------------------+

Expand Down Expand Up @@ -8742,7 +8744,7 @@ inverse-video the label:
gmt coast -R50/160/-15/15 -JM5.3i -Gburlywood -Sazure -A500 -K -P > GMT_App_O_7.ps
gmt grdcontour geoid.nc -J -O -K -B20f10 -BWSne -C10 -A20+d+u" m"+f8p -Gl50/10S/160/10S -S10 \
-T+l"-+" >> GMT_App_O_7.ps
gmt plot -R -J -O -SqD15d:+gblack+fwhite+Ld+o+u\\260 -Wthick transect.txt >> GMT_App_O_7.ps
gmt plot -R -J -O -SqD15d:+gblack+fwhite+Ld+o+u@. -Wthick transect.txt >> GMT_App_O_7.ps

The output is presented as Figure :ref:`Contour label 7 <Contour_label_7>`.

Expand Down
2 changes: 1 addition & 1 deletion doc_modern/scripts/GMT_App_O_7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
gmt begin GMT_App_O_7 ps
gmt coast -R50/160/-15/15 -JM5.3i -Gburlywood -Sazure -A500
gmt grdcontour @App_O_geoid.nc -B20f10 -BWSne -C10 -A20+d+u" m"+f8p -Gl50/10S/160/10S -S10 -T+l
gmt plot -SqD15d:+gblack+fwhite+Ld+o+u\\260 -Wthick @App_O_transect.txt
gmt plot -SqD15d:+gblack+fwhite+Ld+o+u@. -Wthick @App_O_transect.txt
gmt end
10 changes: 5 additions & 5 deletions src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -5039,8 +5039,8 @@ void gmtinit_conf (struct GMT_CTRL *GMT) {
GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_MIN_SPACING] = 'p';
/* MAP_ANNOT_ORTHO */
strcpy (GMT->current.setting.map_annot_ortho, "we");
/* MAP_DEGREE_SYMBOL (ring) */
GMT->current.setting.map_degree_symbol = gmt_ring;
/* MAP_DEGREE_SYMBOL (degree) */
GMT->current.setting.map_degree_symbol = gmt_degree;
/* MAP_FRAME_AXES */
strcpy (GMT->current.setting.map_frame_axes, "WESNZ");
for (i = 0; i < 5; i++) GMT->current.map.frame.side[i] = 0; /* Unset default settings */
Expand Down Expand Up @@ -8384,10 +8384,10 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha
GMT_COMPAT_TRANSLATE ("MAP_DEGREE_SYMBOL");
break;
case GMTCASE_MAP_DEGREE_SYMBOL:
if (value[0] == '\0' || !strcmp (lower_value, "ring")) /* Default */
GMT->current.setting.map_degree_symbol = gmt_ring;
else if (!strcmp (lower_value, "degree"))
if (value[0] == '\0' || !strcmp (lower_value, "degree")) /* Default */
GMT->current.setting.map_degree_symbol = gmt_degree;
else if (!strcmp (lower_value, "ring"))
GMT->current.setting.map_degree_symbol = gmt_ring;
else if (!strcmp (lower_value, "colon"))
GMT->current.setting.map_degree_symbol = gmt_colon;
else if (!strcmp (lower_value, "none"))
Expand Down
7 changes: 6 additions & 1 deletion src/gmt_plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,12 @@ GMT_LOCAL void plot_map_annotate (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, do
if (gmt_M_is_geographic (GMT, GMT_IN) || GMT->current.map.frame.side[N_SIDE] & GMT_AXIS_ANNOT) {
PSL_setfont (PSL, GMT->current.setting.font_annot[GMT_PRIMARY].id);
PSL_command (PSL, "/PSL_H_y %d ", PSL_IZ (PSL, GMT->current.setting.map_tick_length[GMT_PRIMARY] + GMT->current.setting.map_annot_offset[GMT_PRIMARY] + GMT->current.setting.map_title_offset));
PSL_deftextdim (PSL, "-h", GMT->current.setting.font_annot[GMT_PRIMARY].size, "100\\312");
if (GMT->current.setting.map_degree_symbol == gmt_none)
PSL_deftextdim (PSL, "-h", GMT->current.setting.font_annot[GMT_PRIMARY].size, "100");
else {
snprintf (label, GMT_LEN16, "100%c", (int)GMT->current.setting.ps_encoding.code[GMT->current.setting.map_degree_symbol]);
PSL_deftextdim (PSL, "-h", GMT->current.setting.font_annot[GMT_PRIMARY].size, label);
}
PSL_command (PSL, "add def\n");
}
else
Expand Down
96 changes: 53 additions & 43 deletions src/postscriptlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,13 @@ static void *psl_memory (struct PSL_CTRL *PSL, void *prev_addr, size_t nelem, si
* This depends on which character set we have. We will limit this to just
* Standard, Standard+, ISOILatin1, and ISOLatin1+. Of these, Standard will
* only work for some of the encoded letters while the three others should
* all be fine. */
* all be fine. We also handle the differences bewteen hyphens and minus symbol.
* In ISOLatin1 the hyphen key on the keyboard results in a minus sign while
* in Standard it gives a hyphen. In GMT we want minus signs in annotations
* contours and other numerical negative values. We assume that if a string
* begins with a hyphen then a minus sign is implied. Likewise, if a hyphen
* is found later on in the string we assume it is a hyphen and under ISOLatin1
* we must insert the octal code for the hyphen (0255). */


static unsigned int psl_ut8_code_to_ISOLatin (char code) {
Expand All @@ -620,38 +626,40 @@ static unsigned int psl_ut8_code_to_ISOLatin (char code) {
return (kode >= 0200 && kode <= 0277) ? kode += 64 : 0;
}

void psl_fix_utf8 (struct PSL_CTRL *PSL, char *string) {
/* Given string check if UTF8 characters are present and if so replace with PSL octal codes. Assumes ISOLatin1+ */
unsigned int k, k2 = 0, use, utf8_codes = 0;
char *out = NULL, tmp[8] = {""};
static void psl_fix_utf8 (struct PSL_CTRL *PSL, char *in_string) {
/* Given in_string check if UTF8 characters are present and if so replace with PSL octal codes. Assumes ISOLatin1+ */
unsigned int k, kout, use, utf8_codes = 0;
char *out_string = NULL;

if (!strncmp (PSL->init.encoding, "Standard+", 9U)) { /* For Standard+ encoding we need to swap leading minus values encoded as hyphen with the actual minus symbol */
if (in_string[0] == 0055) /* Found leading hyphen which we interpret to be a minus sign */
in_string[0] = 0224; /* Minus is octal 224 in Standard+ but not present in just Standard */
}
if (strncmp (PSL->init.encoding, "ISOLatin1", 9U)) return; /* Do nothing unless ISOLatin[+] */

for (k = 0; string[k]; k++) {
if ((unsigned char)(string[k]) == 0303 || (unsigned char)(string[k]) == 0305)
for (k = 0; in_string[k]; k++) {
if ((unsigned char)(in_string[k]) == 0303 || (unsigned char)(in_string[k]) == 0305)
utf8_codes++; /* Count them up */
else if (in_string[k] == 0055 && k && in_string[k-1] != '@') /* A hyphen needs something before it (k > 0) unlike a negative number (but watch out for @- for subscript) */
in_string[k] = 0255; /* Hyphen is octal 255 in ISOLatin1 */
}
if (utf8_codes == 0) return; /* Nothing to do */

out = PSL_memory (PSL, NULL, 2 * PSL_BUFSIZ, char); /* Get a new string of double length */
out_string = PSL_memory (PSL, NULL, strlen(in_string), char); /* Get a new string of same length */

for (k = k2 = 0; string[k]; k++) {
if ((unsigned char)(string[k]) == 0303) { /* Found octal 303 */
for (k = kout = 0; in_string[k]; k++) {
if ((unsigned char)(in_string[k]) == 0303) { /* Found octal 303 */
k++; /* Skip the control code */
if ((use = psl_ut8_code_to_ISOLatin (string[k]))) { /* Found a 2-char utf8 combo, replace with single octal code from our table */
sprintf (tmp, "\\%o", use);
strcat (out, tmp);
}
else { /* Not a recognized code - just output both as they were given */
tmp[0] = string[k-1];
tmp[1] = string[k];
tmp[2] = '\0';
strcat (out, tmp);
if ((use = psl_ut8_code_to_ISOLatin (in_string[k]))) /* Found a 2-char utf8 combo, replace with single octal code from our table */
out_string[kout++] = use;
else { /* Not a recognized code - just output both as they were given */
out_string[kout++] = in_string[k-1];
out_string[kout++] = in_string[k];
}
}
else if ((unsigned char)(string[k]) == 0305) { /* Found Ydieresis, ae, AE, L&l-slash and the S,Z,s,z carons */
else if ((unsigned char)(in_string[k]) == 0305) { /* Found Ydieresis, ae, AE, L&l-slash and the S,Z,s,z carons */
k++; /* Skip the control code */
switch ((unsigned char)string[k]) { /* These 9 chars are placed all over the table so must have individual cases */
switch ((unsigned char)in_string[k]) { /* These 9 chars are placed all over the table so must have individual cases */
case 0201: use = 0203; break; /* Lslash */
case 0202: use = 0213; break; /* lslash */
case 0222: use = 0200; break; /* ae */
Expand All @@ -663,26 +671,19 @@ void psl_fix_utf8 (struct PSL_CTRL *PSL, char *string) {
case 0276: use = 0037; break; /* zcaron */
default: use = 0; break; /* Not one of the recognized ones in our table */
}
if (use) { /* Found a 2-char utf8 combo */
sprintf (tmp, "\\%o", use);
strcat (out, tmp);
if (use) /* Found a 2-char utf8 combo */
out_string[kout++] = use;
else { /* Not a recognized code - just output both as they were given */
out_string[kout++] = in_string[k-1];
out_string[kout++] = in_string[k];
}
else { /* Not a recognized code - just output both as they were given */
tmp[0] = string[k-1];
tmp[1] = string[k];
tmp[2] = '\0';
strcat (out, tmp);
}
}
else { /* Just output char as was given */
tmp[0] = string[k];
tmp[1] = '\0';
strcat (out, tmp);
}
else /* Just output char as was given */
out_string[kout++] = in_string[k];
}
memset (string, 0, strlen (string)); /* Set old string to NULL */
strncpy (string, out, strlen (out)); /* Overwrite old string with possibly adjusted string */
PSL_free (out);
memset (in_string, 0, strlen (in_string)); /* Set old in_string to NULL */
strncpy (in_string, out_string, strlen (out_string)); /* Overwrite old string with possibly adjusted string */
PSL_free (out_string);
}

/* This one is NOT static since needed in psimage, at least for now */
Expand Down Expand Up @@ -856,8 +857,12 @@ void psl_set_int_array (struct PSL_CTRL *PSL, const char *prefix, int *array, in

void psl_set_txt_array (struct PSL_CTRL *PSL, const char *prefix, char *array[], int n) {
int i;
char *outtext = NULL;
PSL_command (PSL, "/PSL_%s [\n", prefix);
for (i = 0; i < n; i++) PSL_command (PSL, "\t(%s)\n", array[i]);
for (i = 0; i < n; i++) {
outtext = psl_prepare_text (PSL, array[i]); /* Expand escape codes and fix utf-8 characters */
PSL_command (PSL, "\t(%s)\n", outtext);
}
PSL_command (PSL, "] def\n", n);
}

Expand Down Expand Up @@ -1433,13 +1438,13 @@ static int psl_encodefont (struct PSL_CTRL *PSL, int font_no) {
return (PSL_NO_ERROR);
}

static char *psl_prepare_text (struct PSL_CTRL *PSL, char *text) {
char *psl_prepare_text (struct PSL_CTRL *PSL, char *text) {

/* Adds escapes for misc parenthesis, brackets etc.
Will also translate to some European characters such as the @a, @e
etc escape sequences. Calling function must REMEMBER to free memory
allocated by string */
const char *psl_scandcodes[15][5] = { /* Short-hand conversion for some European characters in both Undefined [0], Standard [1], Standard+ [2], ISOLatin1 [3], and ISOLatin1+ [4] encoding */
const char *psl_scandcodes[16][5] = { /* Short-hand conversion for some European characters in both Undefined [0], Standard [1], Standard+ [2], ISOLatin1 [3], and ISOLatin1+ [4] encoding */
{ "AA", "AA" , "\\375", "\\305", "\\305"}, /* Aring */
{ "AE", "\\341", "\\341", "\\306", "\\306"}, /* AE */
{ "OE", "\\351", "\\351", "\\330", "\\330"}, /* Oslash */
Expand All @@ -1454,10 +1459,11 @@ static char *psl_prepare_text (struct PSL_CTRL *PSL, char *text) {
{ "ss", "\\373", "\\373", "\\337", "\\337"}, /* germandbls */
{ "u" , "ue" , "\\370", "\\374", "\\374"}, /* udieresis */
{ "i" , "i" , "\\354", "\\355", "\\355"}, /* iaccute */
{ "@" , "\\100", "\\100", "\\100", "\\100"} /* atsign */
{ "@" , "\\100", "\\100", "\\100", "\\100"}, /* atsign */
{ "*" , "\\312", "\\217", "\\260", "\\260"} /* degree */
};
char *string = NULL;
int i=0, j=0, font;
int i = 0, j = 0, font;
int he = 0; /* PSL Historical Encoding (if any) */

if (!text) return NULL;
Expand Down Expand Up @@ -1538,6 +1544,10 @@ static char *psl_prepare_text (struct PSL_CTRL *PSL, char *text) {
strcat (string, psl_scandcodes[14][he]);
j += (int)strlen(psl_scandcodes[14][he]); i++;
break;
case '.':
strcat (string, psl_scandcodes[15][he]);
j += (int)strlen(psl_scandcodes[15][he]); i++;
break;
case '%': /* Font switcher */
if (isdigit ((int)text[i+1])) { /* Got a font */
font = atoi (&text[i+1]);
Expand Down
1 change: 1 addition & 0 deletions src/postscriptlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ EXTERN_MSC int PSL_defunits (struct PSL_CTRL *PSL, const char *param, double val
EXTERN_MSC unsigned char *psl_gray_encode (struct PSL_CTRL *PSL, size_t *nbytes, unsigned char *input);
EXTERN_MSC void psl_set_txt_array (struct PSL_CTRL *PSL, const char *param, char *array[], int n);
EXTERN_MSC void psl_set_int_array (struct PSL_CTRL *PSL, const char *param, int *array, int n);
EXTERN_MSC char *psl_prepare_text (struct PSL_CTRL *PSL, char *text);

/* Used indirectly by FORTRAN wrapper PSL_free_ . */
EXTERN_MSC int PSL_free_nonmacro (void *addr);
Expand Down
Loading