Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Description

Excerpt

The Font class is used to specify formatting that should be applied to a character run. It also represents the fonts of named styles in the document.

Signature
C#
C#
 public sealed class Font
Signature
vb.net
vb.net
Public NotInheritable Class Font
Remarks

There are two ways to obtain an instance of this class. The Document.CreateFont() method creates a new Font object based on the Normal style. Alternately, using NamedStyle.Font, you can create a Font object that is a copy of a particular style's font. The Font object that is returned can then be used in conjunction with methods in the Element class to create character runs, paragraphs, etc, with specific fonts.

The following example demonstrates both ways of getting a font, first by retrieving the Normal style's font from the document, second by retrieving a copy of the Heading1 style's font.

Example
Code Block
csharp
csharp
titleC#

          //--- Get Normal font from Document
          WordApplication app = new WordApplication();
          Document doc = app.Create();
          Font normalFont = doc.CreateFont();

          //--- Get font from Heading1 Style
          WordApplication app = new WordApplication();
          Document doc = app.Create();
          Font heading1Font = doc.Styles[NamedStyle.BuiltIn.Heading1].Font;
        
Code Block
vb.net
vb.net
titlevb.net

          '--- Get Normal font from Document
          Dim app As New WordApplication()
          Dim doc As Document = app.Create()
          Dim normalFont As Font = doc.CreateFont()

          '--- Get font from Heading1 Style
          Dim app As New WordApplication()
          Dim doc As Document = app.Create()
          Dim heading1Font As Font = doc.Styles(NamedStyle.BuiltIn.Heading1).Font
        
Properties

Name

Description

Animation

Excerpt Include
Font.Animation
Font.Animation
nopaneltrue

Bold

Excerpt Include
Font.Bold
Font.Bold
nopaneltrue

Border

Excerpt Include
Font.Border
Font.Border
nopaneltrue

Caps

Excerpt Include
Font.Caps
Font.Caps
nopaneltrue

CharacterScaling

Excerpt Include
Font.CharacterScaling
Font.CharacterScaling
nopaneltrue

CharacterSpacing

Excerpt Include
Font.CharacterSpacing
Font.CharacterSpacing
nopaneltrue

DoubleStrike

Excerpt Include
Font.DoubleStrike
Font.DoubleStrike
nopaneltrue

Embossed

Excerpt Include
Font.Embossed
Font.Embossed
nopaneltrue

Engraved

Excerpt Include
Font.Engraved
Font.Engraved
nopaneltrue

FontName

Excerpt Include
Font.FontName
Font.FontName
nopaneltrue

FontSize

Excerpt Include
Font.FontSize
Font.FontSize
nopaneltrue

Hidden

Excerpt Include
Font.Hidden
Font.Hidden
nopaneltrue

Highlight

Excerpt Include
Font.Highlight
Font.Highlight
nopaneltrue

HyphenationRule

Excerpt Include
Font.HyphenationRule
Font.HyphenationRule
nopaneltrue

Italic

Excerpt Include
Font.Italic
Font.Italic
nopaneltrue

Kerning

Excerpt Include
Font.Kerning
Font.Kerning
nopaneltrue

NoProofChecking

Excerpt Include
Font.NoProofChecking
Font.NoProofChecking
nopaneltrue

Outlined

Excerpt Include
Font.Outlined
Font.Outlined
nopaneltrue

Shading

Excerpt Include
Font.Shading
Font.Shading
nopaneltrue

Shadow

Excerpt Include
Font.Shadow
Font.Shadow
nopaneltrue

SmallCaps

Excerpt Include
Font.SmallCaps
Font.SmallCaps
nopaneltrue

SuperSubScript

Excerpt Include
Font.SuperSubScript
Font.SuperSubScript
nopaneltrue

Strike

Excerpt Include
Font.Strike
Font.Strike
nopaneltrue

TextColor

Excerpt Include
Font.TextColor
Font.TextColor
nopaneltrue

Underline

Excerpt Include
Font.Underline
Font.Underline
nopaneltrue

UnderlineColor

Excerpt Include
Font.UnderlineColor
Font.UnderlineColor
nopaneltrue

VerticalPosition

Excerpt Include
Font.VerticalPosition
Font.VerticalPosition
nopaneltrue
Classes

Name

Description

Hyphenation

Excerpt Include
Font.Hyphenation
Font.Hyphenation
nopaneltrue

ScriptType

Excerpt Include
Font.ScriptType
Font.ScriptType
nopaneltrue

TextAnimation

Excerpt Include
Font.TextAnimation
Font.TextAnimation
nopaneltrue

UnderlineType

Excerpt Include
Font.UnderlineType
Font.UnderlineType
nopaneltrue