Font Class
Contains font attributes (font name, font size, color, and so on) for an object.
Inheritance Hierarchy
SystemObject
  Aspose.WordsFont

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public class Font

The Font type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleAllCaps
True if the font is formatted as all capital letters.
Public propertyCode exampleAutoColor
Returns the present calculated color of the text (black or white) to be used for 'auto color'. If the color is not 'auto' then returns Color.
Public propertyCode exampleBidi
Specifies whether the contents of this run shall have right-to-left characteristics.
Public propertyCode exampleBold
True if the font is formatted as bold.
Public propertyCode exampleBoldBi
True if the right-to-left text is formatted as bold.
Public propertyCode exampleBorder
Returns a Border object that specifies border for the font.
Public propertyCode exampleColor
Gets or sets the color of the font.
Public propertyCode exampleComplexScript
Specifies whether the contents of this run shall be treated as complex script text regardless of their Unicode character values when determining the formatting for this run.
Public propertyCode exampleDoubleStrikeThrough
True if the font is formatted as double strikethrough text.
Public propertyCode exampleEmboss
True if the font is formatted as embossed.
Public propertyCode exampleEngrave
True if the font is formatted as engraved.
Public propertyCode exampleHidden
True if the font is formatted as hidden text.
Public propertyCode exampleHighlightColor
Gets or sets the highlight (marker) color.
Public propertyCode exampleItalic
True if the font is formatted as italic.
Public propertyCode exampleItalicBi
True if the right-to-left text is formatted as italic.
Public propertyCode exampleKerning
Gets or sets the font size at which kerning starts.
Public propertyCode exampleLineSpacing
Returns line spacing of this font (in points).
Public propertyCode exampleLocaleId
Gets or sets the locale identifier (language) of the formatted characters.
Public propertyCode exampleLocaleIdBi
Gets or sets the locale identifier (language) of the formatted right-to-left characters.
Public propertyCode exampleLocaleIdFarEast
Gets or sets the locale identifier (language) of the formatted Asian characters.
Public propertyCode exampleName
Gets or sets the name of the font.
Public propertyCode exampleNameAscii
Returns or sets the font used for Latin text (characters with character codes from 0 (zero) through 127).
Public propertyCode exampleNameBi
Returns or sets the name of the font in a right-to-left language document.
Public propertyCode exampleNameFarEast
Returns or sets an East Asian font name.
Public propertyCode exampleNameOther
Returns or sets the font used for characters with character codes from 128 through 255.
Public propertyCode exampleNoProofing
True when the formatted characters are not to be spell checked.
Public propertyCode exampleOutline
True if the font is formatted as outline.
Public propertyCode examplePosition
Gets or sets the position of text (in points) relative to the base line. A positive number raises the text, and a negative number lowers it.
Public propertyCode exampleScaling
Gets or sets character width scaling in percent.
Public propertyCode exampleShading
Returns a Shading object that refers to the shading formatting for the font.
Public propertyCode exampleShadow
True if the font is formatted as shadowed.
Public propertyCode exampleSize
Gets or sets the font size in points.
Public propertyCode exampleSizeBi
Gets or sets the font size in points used in a right-to-left document.
Public propertyCode exampleSmallCaps
True if the font is formatted as small capital letters.
Public propertyCode exampleSpacing
Returns or sets the spacing (in points) between characters .
Public propertyCode exampleStrikeThrough
True if the font is formatted as strikethrough text.
Public propertyCode exampleStyle
Gets or sets the character style applied to this formatting.
Public propertyCode exampleStyleIdentifier
Gets or sets the locale independent style identifier of the character style applied to this formatting.
Public propertyCode exampleStyleName
Gets or sets the name of the character style applied to this formatting.
Public propertyCode exampleSubscript
True if the font is formatted as subscript.
Public propertyCode exampleSuperscript
True if the font is formatted as superscript.
Public propertyCode exampleTextEffect
Gets or sets the font animation effect.
Public propertyCode exampleUnderline
Gets or sets the type of underline applied to the font.
Public propertyCode exampleUnderlineColor
Gets or sets the color of the underline applied to the font.
Methods
  NameDescription
Public methodCode exampleClearFormatting
Resets to default font formatting.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Public methodCode exampleHasDmlEffect
Checks if particular DrawingML text effect is applied.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Remarks

You do not create instances of the Font class directly. You just use Font to access the font properties of the various objects such as Run, Paragraph, Style, DocumentBuilder.

Examples
Inserts a String surrounded by a border into a document.
[C#]

DocumentBuilder builder = new DocumentBuilder();

builder.Font.Border.Color = Color.Green;
builder.Font.Border.LineWidth = 2.5;
builder.Font.Border.LineStyle = LineStyle.DashDotStroker;

builder.Write("run of text in a green border");
Examples
Shows how to add a formatted run of text to a document using the object model.
[C#]

// Create an empty document. It contains one empty paragraph.
Document doc = new Document();

// Create a new run of text.
Run run = new Run(doc, "Hello");

// Specify character formatting for the run of text.
Aspose.Words.Font f = run.Font;
f.Name = "Courier New";
f.Size = 36;
f.HighlightColor = Color.Yellow;

// Append the run of text to the end of the first paragraph
// in the body of the first section of the document.
doc.FirstSection.Body.FirstParagraph.AppendChild(run);
Examples
Shows how to create and use a paragraph style with list formatting.
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a paragraph style and specify some formatting for it.
Style style = doc.Styles.Add(StyleType.Paragraph, "MyStyle1");
style.Font.Size = 24;
style.Font.Name = "Verdana";
style.ParagraphFormat.SpaceAfter = 12;

// Create a list and make sure the paragraphs that use this style will use this list.
style.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDefault);
style.ListFormat.ListLevelNumber = 0;

// Apply the paragraph style to the current paragraph in the document and add some text.
builder.ParagraphFormat.Style = style;
builder.Writeln("Hello World: MyStyle1, bulleted.");

// Change to a paragraph style that has no list formatting.
builder.ParagraphFormat.Style = doc.Styles["Normal"];
builder.Writeln("Hello World: Normal.");

builder.Document.Save(ArtifactsDir + "Lists.ParagraphStyleBulleted.doc");
See Also