liveTileでカスタムフォントリソースを使用してカスタムテキストブロックをレンダリングする際に問題が発生しましたか?
私のプロジェクトは、バックグラウンドでライブタイルを更新します。しかし、それはパーソナライズする必要があります。
このコードを使用しています。しかし、それはうまくいきません。埋め込みフォントを使おうとすると、テキストは空白で表示されます。ビットマップの背景は問題なく機能します。しかし、フォントは機能しません。
「フォアグラウンドエージェント」でこれと同じコードを使用すると、フォントが完全に表示されます。
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();