Multiple font family values in WPF
To ensure which font will be used as a fallback if the primary f开发者_如何转开发ont is not available on the user's OS.
Is it possible to specify multiple font family values in WPF, similar to CSS?
For instance:
font-family: "Times New Roman", Georgia, Serif;
Yes, you can: FontFamily = "Times New Roman, Georgia, Serif"
:
Extract from the XAML values of TextBlock.FontFamily
property documentation:
fontFamilyNamesList
A string specifying multiple font family names, each separated by a comma (any white space following a comma is ignored). The first font family specified serves as the primary font family; subsequent font families serve as fallback families to be used in cases where the primary font family is unavailable or not applicable. For example,"Arial, Century Gothic"
specifies Arial as the primary font family, with Century Gothic as the fallback font family.
Example, Georgia doesn't contains chinese font.
<StackPanel>
<TextBlock FontSize = "20" FontFamily = "Georgia">English 中文</TextBlock>
<TextBlock FontSize = "20" FontFamily = "Georgia, FangSong">English 中文</TextBlock>
<TextBlock FontSize = "20" FontFamily = "FangSong">English 中文</TextBlock>
</StackPanel>
精彩评论