예제 #1
0
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
예제 #2
0
파일: text.py 프로젝트: ajf58/python-docx
def given_a_run_having_bold_set_on(context):
    run = Document().add_paragraph().add_run()
    run.bold = True
    context.run = run
예제 #3
0
파일: text.py 프로젝트: wtayyeb/python-docx
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
예제 #4
0
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