1

We have a text editor with a dropdown font list. The list is, like Word, styled with the fonts themselves.

We have found that at least one font makes the editor crash. The font is Niconne Regular, and can be downloaded from Google Web Fonts: http://www.google.com/fonts/ : search Niconne, click "add to collection", and click the top right arrow button "download". Then, copy the font to your Windows\Fonts folder.

I have been able to create a simple project that reproduces the bug here : https://github.com/tbroust-trepia/wpf-font-crash

Here is the simplified code:

<ComboBox Name="DropFontName">
  <ComboBox.ItemTemplate>
      <DataTemplate>
          <Viewbox>
              <TextBlock Name="TextFontName" 
                Text="{Binding Path=Source, Converter={local:FontNameFormatConvertor}}" 
                FontFamily="{Binding}" />
          </Viewbox>
      </DataTemplate>
  </ComboBox.ItemTemplate>
</ComboBox>

The ItemsSource of DropFontName is bound in the view code, and the source is an ObservableCollection<FontFamily>.

Each time I open the DropFontName to select a font, it crashes (so, basically, whenever .Net tries to apply the font to an element).
If I remove the font that causes problems from my fonts, it works. If I remove the FontFamily binding, it works when I open the dropdown, but it crashes when I apply the font.

The font works fine in any other non-WPF app (like Word for instance).

The problem is, the crash is not catched, except by the main "catcher". The stacktrace only mentions internal errors. I thought I could catch this error and remove the problematic font on binding, but since I don't know how to catch it, I can't.

Thanks !

thomasb
  • 5,816
  • 10
  • 57
  • 92
  • For info we already have a method http://stackoverflow.com/questions/7006436/systemfontfamilies-error-when-binding-to-combobox that validates the fonts, but it does not fix our problem. – thomasb Apr 10 '14 at 09:43

0 Answers0