Problem solve Get help with specific problems with your technologies, process and projects.

Simulating hand stenciled signs with TextEffect

With the advent of TrueType fonts on the computer, it's easy to find a stencil font on the Internet. Learn about TextEffect for manipulating text.

I'll bet you seen hand stenciled signs advertising garage sales or school events. All you need in the real world is a stencil kit and a can of spray paint and you can make an instant sign. With the advent of TrueType fonts on the computer, it's easy to find a stencil font on the Internet to do the same with a computer. Here's an example of one that's installed on my laptop.

TextEffect for manipulating text
When you place text within a TextBlock you can change the appearance of the text by manipulating the font size, forecolor or fontweight and other similar properties. Changing a setting like a font size affects all text within the text block unless you wrap the text within multipe  elements. A less familiar approach to changing parts of the TextBlock is the TextEffect property. This property allows you to apply a clip region or transform to a section of the text. Many of these effects can be accomplished by using the run element too.

What I want to happen in this example is spell out a word in a TextBlock, apply the stencil font and then adjust the positioning of individual letters within the TextBlock to look as if they were laid out by hand. Here's a screenshot to show what I mean. The second TextBlock is using the TextEffect property.

Digging into the TextEffect XAML
The  element has two properties that are of interest to us. PositionStart indicates where to start the effect within the text and PositionCount denotes how many characters to manipulate.

Dig Deeper on .NET Framework development with XML and XAML

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.