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
Wiki Markup
{description}
{excerpt}The [Font|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.{excerpt}
{signature:C#}
 public sealed class Font
{signature}{signature:vb.net}
Public NotInheritable Class Font
{signature}
{remarks}There are two ways to obtain an instance of this class.  The [Document.CreateFont\(\)|Document.CreateFont()] method creates a new {{Font}} object based on the Normal style. Alternately, using [NamedStyle.Font|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|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.

{remarks}
{example}{code:csharp|title=C#}

          //--- 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}
{code:vb.net|title=vb.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
        {code}

{example}
{properties}
||Name||Description||
|[Animation|Font.Animation]|{excerpt-include:Font.Animation|nopanel=true}|
|[Bold|Font.Bold]|{excerpt-include:Font.Bold|nopanel=true}|
|[Border|Font.Border]|{excerpt-include:Font.Border|nopanel=true}|
|[Caps|Font.Caps]|{excerpt-include:Font.Caps|nopanel=true}|
|[CharacterScaling|Font.CharacterScaling]|{excerpt-include:Font.CharacterScaling|nopanel=true}|
|[CharacterSpacing|Font.CharacterSpacing]|{excerpt-include:Font.CharacterSpacing|nopanel=true}|
|[DoubleStrike|Font.DoubleStrike]|{excerpt-include:Font.DoubleStrike|nopanel=true}|
|[Embossed|Font.Embossed]|{excerpt-include:Font.Embossed|nopanel=true}|
|[Engraved|Font.Engraved]|{excerpt-include:Font.Engraved|nopanel=true}|
|[FontName|Font.FontName]|{excerpt-include:Font.FontName|nopanel=true}|
|[FontSize|Font.FontSize]|{excerpt-include:Font.FontSize|nopanel=true}|
|[Hidden|Font.Hidden]|{excerpt-include:Font.Hidden|nopanel=true}|
|[Highlight|Font.Highlight]|{excerpt-include:Font.Highlight|nopanel=true}|
|[HyphenationRule|Font.HyphenationRule]|{excerpt-include:Font.HyphenationRule|nopanel=true}|
|[Italic|Font.Italic]|{excerpt-include:Font.Italic|nopanel=true}|
|[Kerning|Font.Kerning]|{excerpt-include:Font.Kerning|nopanel=true}|
|[NoProofChecking|Font.NoProofChecking]|{excerpt-include:Font.NoProofChecking|nopanel=true}|
|[Outlined|Font.Outlined]|{excerpt-include:Font.Outlined|nopanel=true}|
|[Shading|Font.Shading]|{excerpt-include:Font.Shading|nopanel=true}|
|[Shadow|Font.Shadow]|{excerpt-include:Font.Shadow|nopanel=true}|
|[SmallCaps|Font.SmallCaps]|{excerpt-include:Font.SmallCaps|nopanel=true}|
|[SuperSubScript|Font.SuperSubScript]|{excerpt-include:Font.SuperSubScript|nopanel=true}|
|[Strike|Font.Strike]|{excerpt-include:Font.Strike|nopanel=true}|
|[TextColor|Font.TextColor]|{excerpt-include:Font.TextColor|nopanel=true}|
|[Underline|Font.Underline]|{excerpt-include:Font.Underline|nopanel=true}|
|[UnderlineColor|Font.UnderlineColor]|{excerpt-include:Font.UnderlineColor|nopanel=true}|
|[VerticalPosition|Font.VerticalPosition]|{excerpt-include:Font.VerticalPosition|nopanel=true}|
{classes}
||Name||Description||
|[Hyphenation|Font.Hyphenation]|{excerpt-include:Font.Hyphenation|nopanel=true}|
|[ScriptType|Font.ScriptType]|{excerpt-include:Font.ScriptType|nopanel=true}|
|[TextAnimation|Font.TextAnimation]|{excerpt-include:Font.TextAnimation|nopanel=true}|
|[UnderlineType|Font.UnderlineType (no attachments)]|{excerpt-include:Font.UnderlineType|nopanel=true}|