Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010 Grant Archibald
The second of the two options was the quickest (code snippet below). In the future another enhancement could look at creating web service or using a xap file with different fonts.
The next piece to the process was to load the path data into a Geometry instance. Using Alex Golesh's PathFigureCollectionConverter the shapes are now loaded and the updated version now supports generation of letters. One problem I have now if that the closed in shapes are not rendering properly i.e. the O is a solid oval.
var code = new StringBuilder();
code.Append("var arial = new Dictionary<string, string>();\r\n");
var lettersToCreate = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for (var i = 0;i < lettersToCreate.Length; i++)
{
var letter = lettersToCreate.Substring(i, 1);
var fText = new FormattedText(
letter,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(
new FontFamily("Arial"),
FontStyles.Normal,
FontWeights.Heavy,
FontStretches.Normal),
300,
Brushes.Black
);
var g = fText.BuildGeometry(new Point(0, 0)).GetAsFrozen() as Geometry;
// Get the Path info from the geometry
var p = g.GetFlattenedPathGeometry();
code.Append("arial.Add(\"" + letter + "\", \"" + p.ToString().Replace("F1M", "M ") + "\");\r\n");
}
Comments [0] Monday, August 04, 2008 12:35:13 PM (GMT Standard Time, UTC+00:00) Related posts:Three Little Pigs – Silverlight E-BookMy Mix09 10k Contest Entry Is Live – Spin And WinSilverlight BabySmash Audio FilesSilverlight BabySmash Performance – The Asynchronous StoryBabySmash At PDCTracking Silverlight And Moonlight Enabled Browsers via Google Analytics babysmash | silverlight