2424
2525# given ===================================================
2626
27- @given ('a font having typeface name {name}' )
28- def given_a_font_having_typeface_name (context , name ):
29- document = Document (test_docx ('txt-font-props' ))
30- style_name = {
31- 'not specified' : 'Normal' ,
32- 'Avenir Black' : 'Having Typeface' ,
33- }[name ]
34- context .font = document .styles [style_name ].font
35-
36-
37- @given ('a font having {underline_type} underline' )
38- def given_a_font_having_type_underline (context , underline_type ):
39- style_name = {
40- 'inherited' : 'Normal' ,
41- 'no' : 'None Underlined' ,
42- 'single' : 'Underlined' ,
43- 'double' : 'Double Underlined' ,
44- }[underline_type ]
45- document = Document (test_docx ('txt-font-props' ))
46- context .font = document .styles [style_name ].font
47-
48-
49- @given ('a font having {vertAlign_state} vertical alignment' )
50- def given_a_font_having_vertAlign_state (context , vertAlign_state ):
51- style_name = {
52- 'inherited' : 'Normal' ,
53- 'subscript' : 'Subscript' ,
54- 'superscript' : 'Superscript' ,
55- }[vertAlign_state ]
56- document = Document (test_docx ('txt-font-props' ))
57- context .font = document .styles [style_name ].font
58-
59-
60- @given ('a font of size {size}' )
61- def given_a_font_of_size (context , size ):
62- document = Document (test_docx ('txt-font-props' ))
63- style_name = {
64- 'unspecified' : 'Normal' ,
65- '14 pt' : 'Having Typeface' ,
66- '18 pt' : 'Large Size' ,
67- }[size ]
68- context .font = document .styles [style_name ].font
69-
70-
7127@given ('a paragraph format having {prop_name} set {setting}' )
7228def given_a_paragraph_format_having_prop_set (context , prop_name , setting ):
7329 style_name = {
@@ -250,33 +206,6 @@ def when_I_assign_mixed_text_to_the_text_property(context):
250206 context .run .text = 'abc\t def\n ghi\r jkl'
251207
252208
253- @when ('I assign {value} to font.name' )
254- def when_I_assign_value_to_font_name (context , value ):
255- font = context .font
256- value = None if value == 'None' else value
257- font .name = value
258-
259-
260- @when ('I assign {value} to font.size' )
261- def when_I_assign_value_str_to_font_size (context , value ):
262- value = None if value == 'None' else int (value )
263- font = context .font
264- font .size = value
265-
266-
267- @when ('I assign {value_key} to font.underline' )
268- def when_I_assign_value_to_font_underline (context , value_key ):
269- value = {
270- 'True' : True ,
271- 'False' : False ,
272- 'None' : None ,
273- 'WD_UNDERLINE.SINGLE' : WD_UNDERLINE .SINGLE ,
274- 'WD_UNDERLINE.DOUBLE' : WD_UNDERLINE .DOUBLE ,
275- }[value_key ]
276- font = context .font
277- font .underline = value
278-
279-
280209@when ('I assign {value_key} to paragraph_format.line_spacing' )
281210def when_I_assign_value_to_paragraph_format_line_spacing (context , value_key ):
282211 value = {
@@ -302,22 +231,6 @@ def when_I_assign_value_to_paragraph_format_line_rule(context, value_key):
302231 paragraph_format .line_spacing_rule = value
303232
304233
305- @when ('I assign {value_key} to font.{sub_super}script' )
306- def when_I_assign_value_to_font_sub_super (context , value_key , sub_super ):
307- font = context .font
308- name = {
309- 'sub' : 'subscript' ,
310- 'super' : 'superscript' ,
311- }[sub_super ]
312- value = {
313- 'None' : None ,
314- 'True' : True ,
315- 'False' : False ,
316- }[value_key ]
317-
318- setattr (font , name , value )
319-
320-
321234@when ('I assign {value_key} to paragraph_format.alignment' )
322235def when_I_assign_value_to_paragraph_format_alignment (context , value_key ):
323236 value = {
@@ -392,47 +305,6 @@ def when_I_set_the_run_underline_to_value(context, underline_value):
392305
393306# then =====================================================
394307
395- @then ('font.name is {value}' )
396- def then_font_name_is_value (context , value ):
397- font = context .font
398- value = None if value == 'None' else value
399- assert font .name == value
400-
401-
402- @then ('font.size is {value}' )
403- def then_font_size_is_value (context , value ):
404- value = None if value == 'None' else int (value )
405- font = context .font
406- assert font .size == value
407-
408-
409- @then ('font.underline is {value_key}' )
410- def then_font_underline_is_value (context , value_key ):
411- value = {
412- 'None' : None ,
413- 'True' : True ,
414- 'False' : False ,
415- 'WD_UNDERLINE.DOUBLE' : WD_UNDERLINE .DOUBLE ,
416- }[value_key ]
417- font = context .font
418- assert font .underline == value
419-
420-
421- @then ('font.{sub_super}script is {value_key}' )
422- def then_font_sub_super_is_value (context , sub_super , value_key ):
423- name = {
424- 'sub' : 'subscript' ,
425- 'super' : 'superscript' ,
426- }[sub_super ]
427- expected_value = {
428- 'None' : None ,
429- 'True' : True ,
430- 'False' : False ,
431- }[value_key ]
432- font = context .font
433- actual_value = getattr (font , name )
434- assert actual_value == expected_value
435-
436308
437309@then ('it is a column break' )
438310def then_type_is_column_break (context ):
0 commit comments