Most of the time, the customer's computer has not installed this font. For example, XP computers do not have this font. How can we embed this font into the resource file so that the program can call it, can be displayed normally on XP? WPF implementation method: Find the Quartz MS. TTF font file in the C: \ Windows \ Fonts \ folder, add it to the Resources of the WPF project, and set it to the Resource type. Add a Style in XAML to reference this Font Resource <Window. resources> <Style x: Key = "QuartzMSFont"> <Setter Property = "TextElement. fontFamily "Value =" Resources/# Quartz MS "/> </Style> </Window. resources> call method: <TextBlock Style = "{DynamicResource QuartzMSFont}" Text = "1234567"/> note that the name of "# Quartz MS" of Value must be consistent with the actual name of the font file! If you double-click the font file Quartz MS. TTF, you can find the font name in the font file (as shown in) font name C # Winform implementation method is relatively simple, you can use the following code:
System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection(); privateFonts.AddFontFile("C:\\Documents and Settings\\QuartzMS.ttf"); System.Drawing.Font font = new Font(privateFonts.Families[0], 12); this.label1.Font = font;