Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar problem, and found a solution, please have a look <a href="https://stackoverflow.com/questions/12296887/silverlight-writeablebitmap-not-converting-custom-font-correctly">here</a> or <a href="http://social.msdn.microsoft.com/forums/en-us/wpdevelop/thread/abbbf3c1-7970-46f9-9560-661965ae33ed/" rel="nofollow noreferrer">here</a></p> <p>I boils down to either 1. creating a hidden textblock that use the font before doing the conversion, or 2. creating a FontSource.</p> <p>I used the first because it was simpler for now.</p> <p>The textblock is hidden, but it ensures that the embedded font is loaded.</p> <p>Inside my control, I added the following:</p> <pre><code>void Grid_Loaded(object sender, RoutedEventArgs e) { #if SILVERLIGHT Grid Grid = (Grid)sender; AddFontLoaderTextBox(Grid, "Signs Road Features"); AddFontLoaderTextBox(Grid, "Signs G Old"); AddFontLoaderTextBox(Grid, "Signs G"); AddFontLoaderTextBox(Grid, "Signs G1"); AddFontLoaderTextBox(Grid, "Signs G2"); AddFontLoaderTextBox(Grid, "Signs G3"); AddFontLoaderTextBox(Grid, "Signs Info"); AddFontLoaderTextBox(Grid, "Signs Regulatory"); AddFontLoaderTextBox(Grid, "Signs Regulatory1"); AddFontLoaderTextBox(Grid, "Road Manager"); AddFontLoaderTextBox(Grid, "Signs Temporary"); AddFontLoaderTextBox(Grid, "Road Manager"); AddFontLoaderTextBox(Grid, "Signs Warning"); AddFontLoaderTextBox(Grid, "Signs Warning1"); #endif } #if SILVERLIGHT void AddFontLoaderTextBox(Grid Grid, string fontName) { TextBlock TextBlock = new TextBlock(); TextBlock.FontFamily = new FontFamily(string.Format( "pack://application:,,,/ITIS.Controls.LinearViewer.Silverlight;component/Fonts/{0}.ttf#{0}", fontName)); TextBlock.Opacity = 0; /* hide the text block, we only load it for the font to be cached */ Grid.SetRowSpan(TextBlock, 3); /* just to ensure the text block doesn't affect the size of the first row */ Grid.Children.Insert(0, TextBlock); /* keep underneath other children */ } #endif </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload