/// <summary> /// Initializes a new instance for the given list of font families. /// <para> /// If more than one family is specified, the first family is used for metrics. /// </para> /// </summary> /// <param name="fontFamilyList">The font families, separated by comma (syntax as in CSS).</param> public FontMetrics(string fontFamilyList) { FontFamilyList = fontFamilyList; FirstFontFamily = GetFirstFontFamily(fontFamilyList); var family = FirstFontFamily.ToLowerInvariant(); short[] boldCharWidthx20x7F; short[] boldCharWidthxA0xFF; short boldCharDefaultWidth; short boldCharNDashWidth; if (family.Contains("arial")) { _charWidthx20x7F = CharWidthData.ArialNormal_20_7F; _charWidthxA0xFF = CharWidthData.ArialNormal_A0_FF; _charDefaultWidth = CharWidthData.ArialNormalDefaultWidth; _charNDashWidth = CharWidthData.ArialNormalNDashWidth; boldCharWidthx20x7F = CharWidthData.ArialBold_20_7F; boldCharWidthxA0xFF = CharWidthData.ArialBold_A0_FF; boldCharDefaultWidth = CharWidthData.ArialBoldDefaultWidth; boldCharNDashWidth = CharWidthData.ArialBoldNDashWidth; } else if (family.Contains("liberation") && family.Contains("sans")) { _charWidthx20x7F = CharWidthData.LiberationSansNormal_20_7F; _charWidthxA0xFF = CharWidthData.LiberationSansNormal_A0_FF; _charDefaultWidth = CharWidthData.LiberationSansNormalDefaultWidth; _charNDashWidth = CharWidthData.LiberationSansNormalNDashWidth; boldCharWidthx20x7F = CharWidthData.LiberationSansBold_20_7F; boldCharWidthxA0xFF = CharWidthData.LiberationSansBold_A0_FF; boldCharDefaultWidth = CharWidthData.LiberationSansBoldDefaultWidth; boldCharNDashWidth = CharWidthData.LiberationSansBoldNDashWidth; } else if (family.Contains("frutiger")) { _charWidthx20x7F = CharWidthData.FrutigerNormal_20_7F; _charWidthxA0xFF = CharWidthData.FrutigerNormal_A0_FF; _charDefaultWidth = CharWidthData.FrutigerNormalDefaultWidth; _charNDashWidth = CharWidthData.FrutigerNormalNDashWidth; boldCharWidthx20x7F = CharWidthData.FrutigerBold_20_7F; boldCharWidthxA0xFF = CharWidthData.FrutigerBold_A0_FF; boldCharDefaultWidth = CharWidthData.FrutigerBoldDefaultWidth; boldCharNDashWidth = CharWidthData.FrutigerBoldNDashWidth; } else { _charWidthx20x7F = CharWidthData.HelveticaNormal_20_7F; _charWidthxA0xFF = CharWidthData.HelveticaNormal_A0_FF; _charDefaultWidth = CharWidthData.HelveticaNormalDefaultWidth; _charNDashWidth = CharWidthData.HelveticaNormalNDashWidth; boldCharWidthx20x7F = CharWidthData.HelveticaBold_20_7F; boldCharWidthxA0xFF = CharWidthData.HelveticaBold_A0_FF; boldCharDefaultWidth = CharWidthData.HelveticaBoldDefaultWidth; boldCharNDashWidth = CharWidthData.HelveticaBoldNDashWidth; } _boldMetrics = new FontMetrics(boldCharWidthx20x7F, boldCharWidthxA0xFF, boldCharDefaultWidth, boldCharNDashWidth); }
public ICollection <Typeface> GetTypefaces() { return(FirstFontFamily.GetTypefaces(_familyIdentifier)); }
internal double GetLineSpacingForDisplayMode(double emSize, double pixelsPerDip) { return(FirstFontFamily.LineSpacing(emSize, 1, pixelsPerDip, TextFormattingMode.Display)); }