font property

ShapeBase.font property

Provides access to the font formatting of this object.

@property
def font(self) -> aspose.words.Font:
    ...

Examples

Shows how to insert a text box, and set the font of its contents.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
builder.writeln('Hello world!')
shape = builder.insert_shape(shape_type=aw.drawing.ShapeType.TEXT_BOX, width=300, height=50)
builder.move_to(shape.last_paragraph)
builder.write('This text is inside the text box.')
# Set the "Hidden" property of the shape's "Font" object to "true" to hide the text box from sight
# and collapse the space that it would normally occupy.
# Set the "Hidden" property of the shape's "Font" object to "false" to leave the text box visible.
shape.font.hidden = hide_shape
# If the shape is visible, we will modify its appearance via the font object.
if not hide_shape:
    shape.font.highlight_color = aspose.pydrawing.Color.light_gray
    shape.font.color = aspose.pydrawing.Color.red
    shape.font.underline = aw.Underline.DASH
# Move the builder out of the text box back into the main document.
builder.move_to(shape.parent_paragraph)
builder.writeln('\nThis text is outside the text box.')
doc.save(file_name=ARTIFACTS_DIR + 'Shape.Font.docx')

See Also