No OTF Fonts visible after Windows Update KB2783534

Topics: Prism v4 - Silverlight 4
Dec 13, 2012 at 5:38 PM

We have a strange behavior since Microsoft published the patch KB2783534 via the windows update on the December 11, 2012.

Our included font *.otf is not showing anymore. I have a controls library project with FontFamily Style definition as follows:

<FontFamily x:Key="FontFamilyTheSerifBW6SemiBold">/ControlsLib;component/Fonts/TheSerifB-W6SemiBold.otf#TheSerifB W6 SemiBold</FontFamily>

I use this style in different projects as a StaticResource. My solution is built with PRISM and MefBootstrapping. So the styles are merged in the main solution's App.xaml. The modules (with the reference to the Style) will only get on runtime the Style definition of the FontFamily).

Up to now it was working properly. But with the new patch installed, the font is not visibible anymore.

I isolated the program down to Region usage. When I use the Font Lib within a module, the font is not shown anymore, when I load the module in my shell.

Does anyone has an idea how to solve that?

thanks a lot.

kind regards

dave

Developer
Dec 13, 2012 at 9:04 PM

Hi Dave,

As explained in the following article, this update seems to change how the OpenType Font (OTF) driver works, which could explain why your font is not working after the update:

As a starting point, I believe it could be useful to check the following points, to know how this is affecting your applications:

  • Does this happens only in the modules?
  • Is this issue also present when using this font in a Silverlight-only application, without Prism?
  • If you change the OTF font with a different one, does this behavior persists?

Regards,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Dec 14, 2012 at 10:28 AM

Thanks for your comments. I isolated the Problem down to the module usage. Without PRISM and Moddules the OTF Font is working without any Problem.

Kind regards dave

Developer
Dec 14, 2012 at 5:45 PM

Hi Dave,

We tried to reproduce the behavior you are mentioning by creating a small Prism, Silverlight application based on the descriptions you made. In our case we used a Windows 7 environment with the aforementioned updates. In it we defined a static resource FontFamily containing an OTF file resource from a referenced project like you mentioned, and merged this resource in the main App.xaml file so it could be consumed by other modules. So far we could use this resource in different modules at run time without finding any problems.

Based on this, I believe that perhaps the problem could be related to the custom OTF font you are using. Have you tried if this behavior persists when using a different font or different font types?

Regards,

Agustin Adami
http://blogs.southworks.net/aadami

Dec 17, 2012 at 7:50 AM
Edited Dec 17, 2012 at 7:54 AM

Ok, that sound promising :) I hope it is still possible to use the OTF font as expected before the update. But can you please try one more thing?

The kind of usage in my project (where the OTF resource is not working):

Projects:

  • FontLib -> Silverlight Class Library
    •  <FontFamily x:Key="FontFamilyTheSansBW9Black">/FontLib;component/Fonts/TheSansB-W9Black.otf#TheSansB W9 Black</FontFamily>
  • NotificationControls -> Silverlight Class Library
    • MyNotification UserControl
      • <TextBlock Text="My Text..." FontSize="30" FontFamily="{StaticResource FontFamilyTheSansBW9Black}"></TextBlock>
  • MyModule -> Silverlight Class Library
    • MyModule UserControl with following content:
      •  <Grid x:Name="LayoutRoot" Background="White"> <notificationControls:MyNotification/>  </Grid>
  • TestFontApplication -> Silverlight Application Library
    • App.xaml:
 <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/FontLib;component/FontStyles.xaml"></ResourceDictionary>               
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

I use the NotificationControls as a Content Provider for my Notifications. There I use the specific StaticResource of the FontLib.

This NotificationControls Lib I use in the MyModule Library. And the MyModule Library is used via ModuleExport in the TestFontApplication.

 

Is the OTF Font still visible when you set up your project as described above? Thank you mery much for your help.

Kind regards

Dave

Developer
Dec 17, 2012 at 2:28 PM

Hi Dave,

This scenario was very similar to the one I used to run the tests before. I made some minor changes based on your new descriptions and the font is still visible. This time I also run the sample in a Windows 8 installation.

I uploaded the sample to my Skydrive account under the name "Silverlight&OTFStaticResource". Note that I didn't upload any OTF files within it, hence in order to run the sample it will require adding them to the ClassLibrary1 project in the solution and redefine the file names in the ResourceDictionary (Styles2.xaml file).

On the other hand, If this behavior persists with your specific font, perhaps as a possible approach you could try converting the font to other format.

Best Regards,

Agustin Adami
http://blogs.southworks.net/aadami

Dec 19, 2012 at 9:16 AM

hey

Thank you for your effort. I tried it out and it is working. But one thing to my solution is different.

Can you try one more thing please?

Can you add the MyUserControl as a UserControl in your HelloWorldModule? Thats how I am using the Notification Lib. Within other modules... Is it still working? (On my side, it doesn't compile, I get a runtime error... but I think my Visual Studio behaves a little strange lately :)

<StackPanel>
        <TextBlock Text="Module Text" FontFamily="{StaticResource FontFamilyCustom}" Foreground="Green" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24"></TextBlock>
        <Button Click="Button_Click">Load remote module</Button>        
        <controls2:MyUserControl></controls2:MyUserControl>
</StackPanel>

Kind Regards

Dave

Developer
Dec 19, 2012 at 9:23 PM

Hi Dave,

I took Agustin's sample and modified it to include the MyUserControl control in the HelloWorldView as you mentioned. I could make it work correctly after performing the following additions to the sample:

  • First, in the HelloWorldModule add a reference the MyControls project.
  • Second, you need to work around a known limitation that appears when in a Prism/Silverlight application, inside a Module (e.g. HelloWorldModule,) you include a control for another assembly (e.g. MyControls) only in XAML, without using this assembly in the Module's code. For some reason, it seems that in such cases, the assembly containing the control is not loaded, causing run-time exceptions. In order order to workaround this, you can do one of the following approaches:
    • Use the assembly containing the control in the HelloWorldModule's code. For example, you could create an instance of MyControls' Class1 in the HelloWorldView's Constructor and discard it. Like this, Silverlight will know that it should load the MyControls' assembly when loading the HelloWorldModule.
    • Add a reference to the MyControls project in the Shell project (e.g. HelloWorld.Silverlight.) Like this, the MyControls' assembly will be loaded at start-up, avoiding run-time exceptions when loading the HelloWorldModule.

After performing the aforementioned changes, the HelloWorldModule loaded an the fonts showed correctly. Please let us know if this works in your environment too.

Note that the aforementioned known limitation is not related to font files but to XAML controls defined in referenced assemblies and its been known long before the Windows update. So in my opinion, it's highly unprovable that this limitation is related to you original issue.

As a side note, users have reported problems about OTF fonts being rendered incorrectly in several applications (for example PowerPoint) after applying the update, as mentioned in Known Issues section of the following article (which forms part of the Microsoft Security Bulletin MS12 - 078.) According to this, Microsoft seems to be investing this issue:

I hope you find this useful,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Dec 20, 2012 at 8:34 AM

Hey Damian

Thank you very much for this profound answer. I will check and give Feedback ASAP.

Kind regards Dave