@@ -43,6 +43,17 @@ def given_a_font_having_type_underline(context, underline_type):
4343 context .font = document .styles [style_name ].font
4444
4545
46+ @given ('a font having {vertAlign_state} vertical alignment' )
47+ def given_a_font_having_vertAlign_state (context , vertAlign_state ):
48+ style_name = {
49+ 'inherited' : 'Normal' ,
50+ 'subscript' : 'Subscript' ,
51+ 'superscript' : 'Superscript' ,
52+ }[vertAlign_state ]
53+ document = Document (test_docx ('txt-font-props' ))
54+ context .font = document .styles [style_name ].font
55+
56+
4657@given ('a font of size {size}' )
4758def given_a_font_of_size (context , size ):
4859 document = Document (test_docx ('txt-font-props' ))
@@ -208,6 +219,22 @@ def when_I_assign_value_to_font_underline(context, value_key):
208219 font .underline = value
209220
210221
222+ @when ('I assign {value_key} to font.{sub_super}script' )
223+ def when_I_assign_value_to_font_sub_super (context , value_key , sub_super ):
224+ font = context .font
225+ name = {
226+ 'sub' : 'subscript' ,
227+ 'super' : 'superscript' ,
228+ }[sub_super ]
229+ value = {
230+ 'None' : None ,
231+ 'True' : True ,
232+ 'False' : False ,
233+ }[value_key ]
234+
235+ setattr (font , name , value )
236+
237+
211238@when ('I assign {value_str} to its {bool_prop_name} property' )
212239def when_assign_true_to_bool_run_prop (context , value_str , bool_prop_name ):
213240 value = {'True' : True , 'False' : False , 'None' : None }[value_str ]
@@ -266,6 +293,22 @@ def then_font_underline_is_value(context, value_key):
266293 assert font .underline == value
267294
268295
296+ @then ('font.{sub_super}script is {value_key}' )
297+ def then_font_sub_super_is_value (context , sub_super , value_key ):
298+ name = {
299+ 'sub' : 'subscript' ,
300+ 'super' : 'superscript' ,
301+ }[sub_super ]
302+ expected_value = {
303+ 'None' : None ,
304+ 'True' : True ,
305+ 'False' : False ,
306+ }[value_key ]
307+ font = context .font
308+ actual_value = getattr (font , name )
309+ assert actual_value == expected_value
310+
311+
269312@then ('it is a column break' )
270313def then_type_is_column_break (context ):
271314 attrib = context .last_child .attrib
0 commit comments