I'm looking to see if it is possible to use app-wide font in Silverlight controls that can be set in a application.resources and then used throughout the app. They don't need to specifify the other things about a font like bold or italic, just the name.
Mostly, this is for custom fonts that would require to be embedded into the app. For example, I'm looking for something simple like (not of any particular control or control type)...
<Setter x:Key="My First Font"
Property="FontFamily"
Value="VINERTIC.TTF#Viner Hand ITC" />
Then in any given control I would type...
<TextBlock FontFamily="{StaticResource "My First Font"}"
x:Name="ApplicationTitle"
Text="NEXT PAGE" Foreground="Red"/>
...or...
FontFamily="{Binding "My First Font"}"
or some such thing.
I know what I did doesn't work, but that is the desired effect.
I can't seem to find any documention on how to set app-wide font families. Any advice?
Here is some information I think will get you started.
First off, the easiest way I know to embed a font in a shared library (ex: a Silverlight Class library), is to do the following:
After following these steps, you can refer to the font wherever you please, including styles, with syntax similar to the text block below:
<TextBlock
FontFamily="/Common.Windows;component/Assets/Fonts/Action Man Bold.ttf#Action Man" />
Note that the FontFamily
expression above worked within the container project and within a referencing project. I didn't test this process with a zip archive of fonts, but I'd bet a fancy rock out of the garden that it would still work.
That should get you started. If you are interested in going the extra (and useful) step of declaring the font in a style, and using the style on your controls, consider taking a look at this resource:
http://www.silverlight.net/learn/quickstarts/control-styles/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With