I'm having problems in rendering custom textblock with custom font resource on liveTile ?
My project updates a live tile in background. but it should be personalized.
Im using this code. but its does not woks, the text shows blank when i try to use an embedded font the bitmap background works just fine. But the fonts does not works.
When i use this same code in "foreground agent" the fonts shows perfectly.
Grid grid = new Grid();
// load your image
StreamResourceInfo info = Application.GetResourceStream(new Uri("tile.jpg", UriKind.Relative));
// create source bitmap for Image control (image is assumed to be alread 173x173)
WriteableBitmap wbmp2 = new WriteableBitmap(1, 1);
wbmp2.SetSource(info.Stream);
Image img = new Image();
img.Source = wbmp2;
// add Image to Grid
grid.Children.Add(img);
TextBlock text = new TextBlock()
{
FontFamily = new FontFamily("/MyTaskAgent;component/Fonts/Fonts.zip#Buxton Sketch"),
Foreground = new SolidColorBrush(Colors.Black) ,
TextWrapping = TextWrapping.Wrap,
};
text.Text = "Test";
// this is our final image containing custom text and image
WriteableBitmap wbmp = new WriteableBitmap(173, 173);
// now render everything - this image can be used as background for tile
wbmp.Render(grid, null);
wbmp.Invalidate();
I had a similar problem, and found a solution, please have a look here or here
I boils down to either 1. creating a hidden textblock that use the font before doing the conversion, or 2. creating a FontSource.
I used the first because it was simpler for now.
The textblock is hidden, but it ensures that the embedded font is loaded.
Inside my control, I added the following: