Skip to content

Commit eb1a5b5

Browse files
Edward Browndoutriaux1
authored andcommitted
fixes #2118 (#2120)
* Update CMakeLists.txt * Fixes #2118: vcs.Canvas.switchfonts() now works. Added test to ensure it works correctly. * Fixed error in test file. * Added newline at end of test file.
1 parent e2f5e68 commit eb1a5b5

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Packages/vcs/vcs/Canvas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5548,7 +5548,9 @@ def switchfonts(self, font1, font2):
55485548
raise vcsError(
55495549
"Error you must pass either a number or font name!, you passed for font 2: %s" %
55505550
font2)
5551-
return self.canvas.switchfontnumbers(*(index1, index2))
5551+
tmp = vcs.elements['fontNumber'][index1]
5552+
vcs.elements['fontNumber'][index1] = vcs.elements['fontNumber'][index2]
5553+
vcs.elements['fontNumber'][index2] = tmp
55525554

55535555
def copyfontto(self, font1, font2):
55545556
"""

testing/vcs/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ cdat_add_test(test_vcs_export_text
433433
"${PYTHON_EXECUTABLE}"
434434
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_export_text.py
435435
)
436+
cdat_add_test(test_vcs_canvas_switchfonts
437+
"${PYTHON_EXECUTABLE}"
438+
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_canvas_switchfonts.py
439+
)
436440
##############################################################################
437441
#
438442
# These tests perform plotting and need sample data
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import vcs
2+
3+
a=vcs.init()
4+
font1 = a.getfont(1)
5+
font2 = a.getfont(2)
6+
7+
# switchfont() by number
8+
a.switchfonts(1,2)
9+
new_font1 = a.getfont(1)
10+
new_font2 = a.getfont(2)
11+
assert(font1 == new_font2)
12+
assert(font2 == new_font1)
13+
14+
# switchfont() by name
15+
a.switchfonts(font1,font2)
16+
new_font1 = a.getfont(1)
17+
new_font2 = a.getfont(2)
18+
assert(font1 == new_font1)
19+
assert(font2 == new_font2)

0 commit comments

Comments
 (0)