Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-apply-transforms-to-text.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

3.6 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Apply Transforms to Text 03/30/2017
typography [WPF], rotated text
typography [WPF], scaled text
skewed text [WPF]
typography [WPF], translated text
typography [WPF], shadowed text
rotated text [WPF]
translated text [WPF]
shadowed text [WPF]
transforms in text [WPF]
typography [WPF], transforms
scaled text [WPF]
typography [WPF], skewed text
0d61678a-4185-4f2a-85c6-c1d020f96fa0

How to: Apply Transforms to Text

Transforms can alter the display of text in your application. The following examples use different types of rendering transforms to affect the display of text in a xref:System.Windows.Controls.TextBlock control.

Example

The following example shows text rotated about a specified point in the two-dimensional x-y plane.

Text rotated using a RotateTransform

The following code example uses a xref:System.Windows.Media.RotateTransform to rotate text. An xref:System.Windows.Media.RotateTransform.Angle%2A value of 90 rotates the element 90 degrees clockwise.

[!code-xamlTextTransformSample#TextTransformSample1]

The following example shows the second line of text scaled by 150% along the x-axis, and the third line of text scaled by 150% along the y-axis.

Text scaled using a ScaleTransform

The following code example uses a xref:System.Windows.Media.ScaleTransform to scale text from its original size.

[!code-xamlTextTransformSample#TextTransformSample2]

Note

Scaling text is not the same as increasing the font size of text. Font sizes are calculated independently of each other in order to provide the best resolution at different sizes. Scaled text, on the other hand, preserves the proportions of the original-sized text.

The following example shows text skewed along the x-axis.

Text skewed using a SkewTransform

The following code example uses a xref:System.Windows.Media.SkewTransform to skew text. A skew, also known as a shear, is a transformation that stretches the coordinate space in a non-uniform manner. In this example, the two text strings are skewed -30° and 30° along the x-coordinate.

[!code-xamlTextTransformSample#TextTransformSample3]

The following example shows text translated, or moved, along the x- and y-axis.

Text offset using a TranslateTransform

The following code example uses a xref:System.Windows.Media.TranslateTransform to offset text. In this example, a slightly offset copy of text below the primary text creates a shadow effect.

[!code-xamlTextTransformSample#TextTransformSample4]

Note

The xref:System.Windows.Media.Effects.DropShadowBitmapEffect provides a rich set of features for providing shadow effects. For more information, see Create Text with a Shadow.

See also