मैं फ़ॉन्टफमिलियों की सूची का आकलन करता हूं और combobox से बांधता हूं, समस्या तब होती है जब दूषित सिस्टम में कोई फ़ॉन्ट होता है। पूरा आवेदन दुर्घटनाग्रस्त हो जाएगा। किसी भी तरह से मैं systemfontfamilies से जुड़ने में सक्षम हूं, फिर भी त्रुटि प्रदर्शित करने वाले फ़ॉन्ट को छोड़ने में सक्षम है?SystemFontFamilies को संकुचित करते समय combobox
यह कोड ठीक से चलाता है यदि itemtemplate में फ़ॉन्टफैमिली बाध्यकारी टिप्पणी की जाती है।
<ComboBox x:Name="comboFonts"
Grid.IsSharedSizeScope="True"
Grid.Row="0" Grid.Column="1"
ItemsSource="{Binding Source={x:Static Member=Fonts.SystemFontFamilies}}"
SelectedItem="{Binding FontFamily, Mode=TwoWay}"
HorizontalAlignment="Stretch">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="FontName"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Source}" HorizontalAlignment="Left"/>
<Label FontFamily="{Binding FallbackValue=Verdana}" HorizontalAlignment="Right">Sample</Label>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
त्रुटि संदेश प्राप्त निम्नलिखित
Message=Input file or data stream does not conform to the expected file format specification.
Source=PresentationCore
StackTrace:
at MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr)
at MS.Internal.Text.TextInterface.Font.CreateFontFace()
at MS.Internal.Text.TextInterface.Font.AddFontFaceToCache()
at MS.Internal.Text.TextInterface.Font.GetFontFace()
कृपया मदद के रूप में है। धन्यवाद
नोट, हालांकि, यह वैध फ़ॉन्ट परिवारों, यानी समग्र फ़ॉन्ट्स के लिए 'null' वापस करने के लिए 'TryGetGlyphTypeface()' के लिए _normal_ है। सिर्फ इसलिए कि यह 'शून्य' देता है, इसका मतलब यह नहीं है कि फ़ॉन्ट फ़ाइल भ्रष्ट है (बेशक, यदि आप 'ग्लाइफ टाइपफेस' पर भरोसा कर रहे हैं, तो आपको कंपोजिट को विघटित करके इसे प्राप्त करने के लिए और अधिक काम करना होगा फ़ॉन्ट ... लेकिन यह इस मुद्दे का हिस्सा नहीं है)। –