This documentation is archived and is not being maintained.

FormattedText.BuildGeometry Method

Returns a Geometry object that represents the formatted text, including all glyphs and text decorations.

Namespace: System.Windows.Media
Assembly: PresentationCore (in presentationcore.dll)

public Geometry BuildGeometry (
	Point origin
public Geometry BuildGeometry (
	Point origin
public function BuildGeometry (
	origin : Point
) : Geometry
You cannot use methods in XAML.



The top-left origin of the resulting geometry.

Return Value

The Geometry object representation of the formatted text.

When text is converted to a Geometry object, it is no longer a collection of characters—you cannot modify the characters in the text string. However, you can affect the appearance of the converted text by modifying its stroke and fill properties.

The following examples illustrate several ways of creating visual effects by modifying the stroke and fill of converted text.

Example of setting stroke and fill to different colors

Text with different colors for fill and stroke

Example of an image brush applied to the stroke

Text with image brush applied to stroke

Text that is converted to and rendered as a Geometry object may not look the same as text rendered directly:

  • Text converted to a Geometry object is not rendered using ClearType. In addition, the baseline of the converted is not snapped to a whole display pixel.

  • Small fonts, such as those commonly used in body text, may lose legibility, appear blurred, and vary in appearance.

The following code example shows how to create a FormattedText object and to retrieve the geometries of the formatted text and its bounding box.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0