public OS2Info(TypographicFontWeight weight, FontStyle style, byte[] panose, ushort version, string vendor) { Weight = weight; Style = style; Panose = panose; Version = version; Vendor = vendor; }
private TypographicFont(string family, string subFamily, string name, TypographicFontWeight weight, bool bold, bool italic, bool oblique, bool underlined, bool negative, bool outlined, bool strikeout, bool regular, string fileName) { this.Family = family; this.SubFamily = subFamily; this.Name = name; this.Weight = weight; this.Bold = bold; this.Italic = italic; this.Underlined = underlined; this.Negative = negative; this.Outlined = outlined; this.Strikeout = strikeout; this.Regular = regular; this.FileName = fileName; this.Oblique = oblique; }
public static Font With(this Font font, float size, TypographicFontWeight weight, bool italic, bool underline, bool strikeout) { var selectedSubfamily = font.GetTypographicFamily().Fonts .Where(_ => italic || !_.Italic && underline || !_.Underlined) // Can simulate styles, but can't reverse them .SelectMany(_ => _.Bold ? new[] { // Bold style is already set, so it cannot be set twice to simulate bolder new { font = _, simulateBold = false, weight = (int)_.Weight } } : new[] { // Bold style could be set. Consider both normal and simulated-bold versions new { font = _, simulateBold = false, weight = (int)_.Weight }, new { font = _, simulateBold = true, weight = (int)_.Weight * (int)TypographicFontWeight.Bold / (int)TypographicFontWeight.Normal } }) .OrderBy(_ => Math.Abs(_.weight - (int)weight)) // Get the closest available by weight .ThenByDescending(_ => _.font.Italic == italic) // Avoid simulating italic if possible .ThenByDescending(_ => _.font.Underlined == underline) // Avoid simulating underline if possible .ThenByDescending(_ => _.font.Strikeout == underline) // Avoid simulating strikethrough if possible .First(); var fontStyle = FontStyle.Regular; if (selectedSubfamily.font.Bold || selectedSubfamily.simulateBold) { fontStyle |= FontStyle.Bold; } if (selectedSubfamily.font.Italic || italic) { fontStyle |= FontStyle.Italic; } if (selectedSubfamily.font.Underlined || underline) { fontStyle |= FontStyle.Underline; } if (selectedSubfamily.font.Strikeout || strikeout) { fontStyle |= FontStyle.Strikeout; } return(selectedSubfamily.font.Name == font.Name && fontStyle == font.Style ? font : new Font(selectedSubfamily.font.Name, size, fontStyle)); }
public OS2Info(TypographicFontWeight weight, FontStyle style) { Weight = weight; Style = style; }
public static Font With(this Font font, TypographicFontWeight weight) { return(font.With(font.SizeInPoints, weight, font.Italic, font.Underline, font.Strikeout)); }
public static Font With(this Font font, float size, TypographicFontWeight weight, bool italic, bool underline) { return(font.With(size, weight, italic, underline, font.Strikeout)); }
public static Font With(this Font font, float size, TypographicFontWeight weight) { return(font.With(size, weight, font.Italic, font.Underline, font.Strikeout)); }