void UpdateFontFormattingProperties() { if (CurrentFont != font) { int index = UsedFonts.IndexOf(CurrentFont); if (index < 0) { index = UsedFonts.Count; UsedFonts.Add(font); FontTable.AppendFormat(@"{{\f{0}", index); // Try to guess the font family if (font.FontFamily == FontFamily.GenericMonospace) { FontTable.Append(@"\fmodern"); } else if (font.FontFamily == FontFamily.GenericSansSerif || font.Name == "Microsoft Sans Serif") { FontTable.Append(@"\fswiss"); // Proportionally spaced sans serif fonts } else if (font.FontFamily == FontFamily.GenericSerif) { FontTable.Append(@"\froman"); // Proportionally spaced serif fonts } else { FontTable.Append(@"\fnil"); } if (font.IsSystemFont) { FontTable.AppendFormat(@"{{\*\falt {0}}}", font.SystemFontName); } // Default charset; hopefully that means Unicode. FontTable.Append(@"\fcharset1"); FontTable.AppendFormat(@" {0};}}", font.Name); } EmitCodeIndex("f", index); CurrentFont = font; } if (CurrentFontSize != FontSize) { CurrentFontSize = FontSize; EmitCodeIndex("fs", (int)(FontSize * 2)); } RichTextUnderlineStyle underlineStyle = IsUnderlined ? UnderlineStyle : RichTextUnderlineStyle.None; if (underlineStyle != CurrentUnderlineStyle) { CurrentUnderlineStyle = underlineStyle; Content.Append(UnderlineStyleCodes[underlineStyle]); } EmitColorProperty("cf", ref CurrentForegroundColor, ForegroundColor); }
void UpdateFontFormattingProperties() { if (CurrentFont != font) { int index = UsedFonts.IndexOf(CurrentFont); if (index < 0) { index = UsedFonts.Count; UsedFonts.Add(font); FontTable.AppendFormat(@"{{\f{0}", index); // Try to guess the font family if (font.FontFamily == FontFamily.GenericMonospace) FontTable.Append(@"\fmodern"); else if (font.FontFamily == FontFamily.GenericSansSerif || font.Name == "Microsoft Sans Serif") FontTable.Append(@"\fswiss"); // Proportionally spaced sans serif fonts else if (font.FontFamily == FontFamily.GenericSerif) FontTable.Append(@"\froman"); // Proportionally spaced serif fonts else FontTable.Append(@"\fnil"); if (font.IsSystemFont) FontTable.AppendFormat(@"{{\*\falt {0}}}", font.SystemFontName); // Default charset; hopefully that means Unicode. FontTable.Append(@"\fcharset1"); FontTable.AppendFormat(@" {0};}}", font.Name); } EmitCodeIndex("f", index); CurrentFont = font; } if (CurrentFontSize != FontSize) { CurrentFontSize = FontSize; EmitCodeIndex("fs", (int)(FontSize * 2)); } RichTextUnderlineStyle underlineStyle = IsUnderlined ? UnderlineStyle : RichTextUnderlineStyle.None; if (underlineStyle != CurrentUnderlineStyle) { CurrentUnderlineStyle = underlineStyle; Content.Append(UnderlineStyleCodes[underlineStyle]); } EmitColorProperty("cf", ref CurrentForegroundColor, ForegroundColor); }