Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
A font is a set of characters with a certain size, color, and design. Aspose.Words allows you to work with fonts using the fonts module and the Font class.
The current font formatting is represented by the Font object returned by the Font property. The Font class contains a wide variety of font properties, replicating those available in Microsoft Word.
The following code example shows how to set font formatting:
# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET | |
doc = aw.Document() | |
builder = aw.DocumentBuilder(doc) | |
font = builder.font | |
font.bold = True | |
font.color = drawing.Color.dark_blue | |
font.italic = True | |
font.name = "Arial" | |
font.size = 24 | |
font.spacing = 5 | |
font.underline = aw.Underline.DOUBLE | |
builder.writeln("I'm a very nice formatted string.") | |
doc.save(docs_base.artifacts_dir + "WorkingWithFonts.set_font_formatting.docx") |
Fill properties now are also available for fonts to set fill formatting of text. It gives an ability to change, for example, the foreground color or transparency of text fill.
Font line spacing is the vertical distance between the baselines of two consecutive lines of text. So line spacing includes the blank space between lines along with the height of the character itself.
The line_spacing property was introduced in the Font class to obtain this value as shown in the example given below:
# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET | |
doc = aw.Document() | |
builder = aw.DocumentBuilder(doc) | |
builder.font.name = "Calibri" | |
builder.writeln("qText") | |
font = builder.document.first_section.body.first_paragraph.runs[0].font | |
print(f"lineSpacing = {font.line_spacing}") |
Some East Asian languages use a special emphasis mark to indicate an emphasis. The Font class provides the emphasis_mark property to get or set EmphasisMark enumeration values to be applied in the formatting.
The following code example shows how to set the EphasisMark property:
# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET | |
document = aw.Document() | |
builder = aw.DocumentBuilder(document) | |
builder.font.emphasis_mark = aw.EmphasisMark.UNDER_SOLID_CIRCLE | |
builder.write("Emphasis text") | |
builder.writeln() | |
builder.font.clear_formatting() | |
builder.write("Simple text") | |
document.save(docs_base.artifacts_dir + "WorkingWithFonts.set_font_emphasis_mark.docx") |
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.