This topic has not yet been rated - Rate this topic

FlowDocument.FontFamily Property

Gets or sets the preferred top-level font family for the FlowDocument. This is a dependency property.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
[LocalizabilityAttribute(LocalizationCategory.Font, Modifiability = Modifiability.Unmodifiable)]
public FontFamily FontFamily { get; set; }
<object>
  <object.FontFamily>
    <FontFamily .../>
  </object.FontFamily>
</object>
<object FontFamily="fontFamilyName"/>
- or -
<object FontFamily="fontFamilyNamesList"/>
- or -
<object FontFamily="fontFamilyFolderReference"/>
- or -
<object FontFamily="fontFamilyUriReference"/>

XAML Values

fontFamilyName

A string specifying a font family name. For example, "Arial" or "Century Gothic".

fontFamilyNamesList

A string specifying multiple font family names, each separated by a comma (any whitespace following a comma is ignored). The first font family specified serves as the primary font family; subsequent font families serve as fallback families to be used in cases where the primary font family is unavailable or not applicable. For example, "Arial, Century Gothic" specifies Arial as the primary font family, with Century Gothic as the fallback font family.

fontFamilyFolderReference

A string specifying a folder containing the font, along with a font family name. The folder and font family name are delimited by a # character. The folder reference may be absolute, or relative. For example, "Custom Fonts\#My Custom Font".

fontFamilyUriReference

A string specifying a uniform resource identifier (URI) for the font, along with a font family name. The URI and font family name are delimited by a # character. For example, "http://MyFontServer/Fonts/#My Custom Font".

Property Value

Type: System.Windows.Media.FontFamily
A FontFamily object specifying the preferred font family, or a primary preferred font family with one or more fallback font families. The default is the font determined by the SystemFonts.MessageFontFamily value.

Any FontFamily settings on child elements will override this top-level setting.

When multiple families are specified, the second and subsequent font families serve as fallback families to be used in cases where the primary font family is unavailable or not applicable.

This property specifies a preference only. If the specified font family is not available, the FlowDocument will silently fall back to the font determined by the SystemFonts.MessageFontFamily value.

The following example shows how to set the FontFamily attribute of a FlowDocument element.

<FlowDocumentReader>
  <FlowDocument
    FontFamily="Century Gothic"
    FontSize="12"
    FontStretch="UltraExpanded"
    FontStyle="Italic"
    FontWeight="UltraBold"
  >
    <Paragraph>
      Any font settings on this paragraph would override the font settings
      for the FlowDocument.
    </Paragraph>
  </FlowDocument>
</FlowDocumentReader>

The following example shows how to set the FontFamily property programmatically.

FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));
// Set the desired column gap to 10 device independend pixels.
flowDoc.FontFamily = new FontFamily("Century Gothic");
flowDoc.FontSize = 12.0;
flowDoc.FontStretch = FontStretches.UltraExpanded;
flowDoc.FontStyle = FontStyles.Italic;
flowDoc.FontWeight = FontWeights.UltraBold;

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.