def create_floating_run(text, font_name, font_size, bold, italic, underline, color, **kwargs): """ Create a new run in a floating paragraph. TODO: Add kwargs to be added Parameters ---------- text : str The run's text font_name : str The name of the font to be applied. font_size : int or float Pt size for the font. bold : bool Whether or not to apply bold to the run. italic : bool Whether or not to apply italics to the run. underline : bool Whether or not to apply underline to the run. color : tuple A 3-tuple containing the RGB of the color to apply to the run. Returns ------- run : docx.text.run.Run The newly created run. """ run = Document().add_paragraph().add_run(text) run.bold, run.italic, run.underline = bold, italic, underline run.font.name, run.font.size, run.font.color.rgb = font_name, Pt( font_size), RGBColor(*color) return run
def given_a_run_having_bold_set_on(context): run = Document().add_paragraph().add_run() run.bold = True context.run = run
def given_a_run_having_known_text_and_formatting(context): run = Document().add_paragraph().add_run('foobar') run.bold = True run.italic = True context.run = run