public FontInfo(FontFamilyInfo fontFamily, float size, FontStyle style) { #if DEBUG Debug.Assert(fontFamilyInfo != null); #endif this.fontFamilyInfo = fontFamily; this.size = size; this.style = style; }
public static void DrawFontItem(Graphics g, FontFamilyInfo fontFamily, Rectangle rect, bool isSelected) { using (StringFormat sf = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }) { sf.FormatFlags |= StringFormatFlags.NoWrap; using (FontFamily ff = new FontFamily(fontFamily.CultureName)) { Font font = null; // some fonts are not support Regular style, we need find // a style which is supported by current font if (ff.IsStyleAvailable(FontStyle.Regular)) font = new Font(fontFamily.CultureName, FixedDrawFontSize, FontStyle.Regular); else if (ff.IsStyleAvailable(FontStyle.Bold)) font = new Font(fontFamily.CultureName, FixedDrawFontSize, FontStyle.Bold); else if (ff.IsStyleAvailable(FontStyle.Italic)) font = new Font(fontFamily.CultureName, FixedDrawFontSize, FontStyle.Italic); else if (ff.IsStyleAvailable(FontStyle.Strikeout)) font = new Font(fontFamily.CultureName, FixedDrawFontSize, FontStyle.Strikeout); else if (ff.IsStyleAvailable(FontStyle.Underline)) font = new Font(fontFamily.CultureName, FixedDrawFontSize, FontStyle.Underline); if (font != null) { g.DrawString(font.Name, font, isSelected ? SystemBrushes.HighlightText : Brushes.Black, rect, sf); font.Dispose(); } } } }
public FontInfo(FontInfo proto) { this.fontFamilyInfo = proto.fontFamilyInfo; this.size = proto.size; this.style = proto.style; }