summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authorAntoine ELIAS <antoine.elias@esi-group.com>2021-02-05 00:03:12 +0100
committerClément David <clement.david@esi-group.com>2021-03-17 11:12:43 +0100
commite19c04f10e3b3a993d536dd72d5ed7affd06dbe2 (patch)
tree0184372813d7a526a6717c4235d54f5a5e71b05a /scilab
parent7955c23a7e7973c6bbce84192592125288ec0bfd (diff)
downloadscilab-e19c04f10e3b3a993d536dd72d5ed7affd06dbe2.zip
scilab-e19c04f10e3b3a993d536dd72d5ed7affd06dbe2.tar.gz
fix xlfont to correctly manage 3rd parameter when it is called with 4 inputs
Change-Id: Ieb0f522dd354001dd434984cbe157cac2810ad54
Diffstat (limited to 'scilab')
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/graphics/sci_gateway/c/sci_xlfont.c4
-rw-r--r--scilab/modules/graphics/tests/unit_tests/xlfont.tst28
3 files changed, 25 insertions, 8 deletions
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index 5fdac88..11da378 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -203,6 +203,7 @@ Feature changes and additions
203* `interp1` is upgraded: 203* `interp1` is upgraded:
204 - complex numbers `y` now supported: the real and imaginary parts are interpolated separately. 204 - complex numbers `y` now supported: the real and imaginary parts are interpolated separately.
205 - extrapolation option extended: `edgevalue` mode added for all interpolations; `periodic` mode added for linear and spline interpolations. `linear` mode added for the spline interpolations. 205 - extrapolation option extended: `edgevalue` mode added for all interpolations; `periodic` mode added for linear and spline interpolations. `linear` mode added for the spline interpolations.
206* `xlfont` did not support the documented 4th argument.
206 207
207Help pages: 208Help pages:
208----------- 209-----------
diff --git a/scilab/modules/graphics/sci_gateway/c/sci_xlfont.c b/scilab/modules/graphics/sci_gateway/c/sci_xlfont.c
index 16f970e..95809cd 100644
--- a/scilab/modules/graphics/sci_gateway/c/sci_xlfont.c
+++ b/scilab/modules/graphics/sci_gateway/c/sci_xlfont.c
@@ -203,7 +203,7 @@ static int xlfont_n_rhs(char * fname, void* pvApiCtx)
203 BOOL isBold = FALSE; 203 BOOL isBold = FALSE;
204 BOOL isItalic = FALSE; 204 BOOL isItalic = FALSE;
205 205
206 if (nbInputArgument(pvApiCtx) == 3) 206 if (nbInputArgument(pvApiCtx) >= 3)
207 { 207 {
208 int m3 = 0, n3 = 0; 208 int m3 = 0, n3 = 0;
209 int* piAddrl3 = NULL; 209 int* piAddrl3 = NULL;
@@ -240,7 +240,7 @@ static int xlfont_n_rhs(char * fname, void* pvApiCtx)
240 int* l4 = NULL; 240 int* l4 = NULL;
241 if ((!checkInputArgumentType(pvApiCtx, 4, sci_boolean))) 241 if ((!checkInputArgumentType(pvApiCtx, 4, sci_boolean)))
242 { 242 {
243 Scierror(999, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 3); 243 Scierror(999, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 4);
244 return 0; 244 return 0;
245 } 245 }
246 sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddrl4); 246 sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddrl4);
diff --git a/scilab/modules/graphics/tests/unit_tests/xlfont.tst b/scilab/modules/graphics/tests/unit_tests/xlfont.tst
index 5121ee8..ac94304 100644
--- a/scilab/modules/graphics/tests/unit_tests/xlfont.tst
+++ b/scilab/modules/graphics/tests/unit_tests/xlfont.tst
@@ -5,15 +5,17 @@
5// This file is distributed under the same license as the Scilab package. 5// This file is distributed under the same license as the Scilab package.
6// ============================================================================= 6// =============================================================================
7 7
8
9// <-- TEST WITH GRAPHIC --> 8// <-- TEST WITH GRAPHIC -->
9// <-- NO CHECK REF -->
10
10 11
11xlfont('reset') 12xlfont('reset')
12initialfonts = xlfont(); 13initialfonts = xlfont();
13if size(initialfonts,'*') <> 11 then pause,end 14assert_checkequal(size(initialfonts,'*'), 11);
14 15
15availablefonts = xlfont('AVAILABLE_FONTS'); 16availablefonts = xlfont('AVAILABLE_FONTS');
16if size(availablefonts,'*') < 11 then pause,end 17assert_checktrue(size(availablefonts,'*') >= 11);
18
17 19
18for i=1:11:1 20for i=1:11:1
19 xlfont(availablefonts(i),i); 21 xlfont(availablefonts(i),i);
@@ -30,7 +32,7 @@ end
30xlfont('reset'); 32xlfont('reset');
31 33
32afterresetfonts = xlfont(); 34afterresetfonts = xlfont();
33if ~and(initialfonts == afterresetfonts) then pause,end 35assert_checkequal(initialfonts, afterresetfonts);
34 36
35cd(TMPDIR); 37cd(TMPDIR);
36 38
@@ -52,9 +54,23 @@ for i = 1 : size(tab_ref,'*')
52 fonttemp = pathtemp + filesep() + fontname; 54 fonttemp = pathtemp + filesep() + fontname;
53 copyfile(fontfull, fonttemp); 55 copyfile(fontfull, fonttemp);
54 ierr = execstr('r = xlfont(fonttemp);','errcatch'); 56 ierr = execstr('r = xlfont(fonttemp);','errcatch');
55 if ierr <> 0 then pause, end 57 assert_checkequal(ierr, 0);
56 if ~isdef('r') then pause, end 58 assert_checktrue(isdef('r'));
57 clear r; 59 clear r;
58end 60end
59 61
60xlfont('reset') 62xlfont('reset')
63
64xlfont("Verdana", size(xlfont(), "*"), %f, %f);
65assert_checkequal(xlfont()($), "Verdana");
66
67xlfont("Verdana", size(xlfont(), "*"), %f, %t);
68assert_checkequal(xlfont()($), "Verdana Italic");
69
70xlfont("Verdana", size(xlfont(), "*"), %t, %f);
71assert_checkequal(xlfont()($), "Verdana Bold");
72
73xlfont("Verdana", size(xlfont(), "*"), %t, %t);
74assert_checkequal(xlfont()($), "Verdana Bold Italic");
75
76xlfont('reset')