Silverlight Brass Tacks

Bill Reiss' Silverlight Ramblings
My upcoming Silverlight book for beginners Hello! Silverlight 2 with Dave Campbell, available online now!



Pages

Recent posts

Navigation

Archive

Blogroll

Tampa Divorce Lawyer

North of Tampa in Lutz, Florida. A Tampa Divorce Lawyer focusing on family, divorce, and real estate law.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

The best laid plans...and some cool text stuff

Well that didn't last long, trying to post once a day about Silverlight...I'll try to do a double post to make up for it later, but here's a little teaser to what took up too much of my time last night and I didn't get a post in.

http://www.bluerosegames.com/fontpathsampleweb/fontpathsampletestpage.aspx

Here's a screenshot:

textpath

For those of you familiar with text in Silverlight, there are a couple of things it's missing that people have asked for. One is that you can't specify a Stroke, and the other is that you can't draw along a curve or distort your text.

How this sample works is that the font data is scraped from the font file and the path data is stored in an XML file that gets included in your Silverlight project. It is then converted at run time based on the text string specified into a Path object. So right away, you now have the ability to specify both a Fill and a Stroke for the text.

Then I run the path data through a transform layer (this is optional), which takes each point in the Path and transforms it to some other point. In the sample, it's a polar transform where Y is converted to distance from the center, and X is converted to an angle.

By running the text through multiple transforms, you could do even more interesting effects. The goal is to easily allow you to extend the functionality by creating your own transforms and hopefully making them available for others to use.

So what I'm trying to do now is encapsulate the code in this sample into a reusable control with full XAML support for specifying properties and transforms so that you could use this without any code behind.

Once I get this a bit closer to where it needs to be, I'll  making the source code available either on this site or through CodePlex, probably CodePlex because I'd like others to be able to contribute.

I think it's pretty cool, hopefully it's interesting to you as well.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Sep 19 2008, 09:21 by Bill Reiss | Comments (10) RSS comment feed |
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Related posts

Comments

geekswithblogs.net said:

pingbackPingback from geekswithblogs.net

Silverlight Cream for September 19, 2008 -- #373

# September 19 2008, 11:52

unruledboy cn said:

unruledboysilverlight has a few more problems with text, it is blurry with ClearType. and it displays doubled characters when accepting Chinese characters through IME. for example, if you input one Chinese character, it will display two of it.

# September 19 2008, 15:31

unruledboy cn said:

unruledboywhat I mean input, is for all editable controls like textbox, field of datagrid etc.

# September 19 2008, 15:33

Bill Reiss us said:

Bill ReissI've heard that the Silverlight team has heard the complaints about text being blurry, hopefully they'll fix it for the release.

# September 19 2008, 16:05

unruledboy cn said:

unruledboyYes, it's the number issue on silverlight's connect.microsoft.com Smile

the team said(hopefully it's official) will won't be fixed until the sp1 of sl 2.0 final.

and for the doubled-text issue, it disabled all silverlight products that mean to support non-ASCII characters like Chinese, Japanese, Koren in real production level.

# September 19 2008, 16:11

unruledboy cn said:

unruledboysorry, typing issure, "number issue" should be "number one issue"

# September 19 2008, 16:12

unruledboy cn said:

unruledboysorry again...

"will won't be" -> "it won't be"

"issure" - > "issue" Frown

# September 19 2008, 16:13

Jonas Follesø said:

Jonas FollesøGreat demo and concept. Can be really helpfull when the built in text support won't cut it. Been in a couple of situations where this approach would be helpfull. So far I've solved this by creating my design in Adobe Illustrator, converting text to paths, and then export to XAML Smile

cheers,
Joans

# September 20 2008, 03:05

Bill Reiss us said:

Bill ReissThanks Jonas, I've done that too. Obviously this has some advantages when it comes to dynamic text. There will probably still be some things you'll have to do the expression design or illustrator export for, like 3D style text and other effects.

# September 20 2008, 03:15

mgalinks.wordpress.com said:

pingbackPingback from mgalinks.wordpress.com

2008 September 23 - Links for today « My (almost) Daily Links

# September 23 2008, 01:37