Tip

Simulating hand stenciled signs with TextEffect

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.


This was first published in July 2010

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.