static void setFontFromStrings(_Style style, string fontStrings) { ChartStyle sty = new ChartStyle(style); // fontStrings appears like "FontFamily,FontSize,FontStretch,FontWeight,FontStyle"; string[] fs = fontStrings.Split(','); System.Windows.Media.FontFamily fontFamily = null; double fontSize = -1.0; var fontStretch = System.Windows.FontStretches.Normal; var fontWeight = System.Windows.FontWeights.Normal; var fontStyle = System.Windows.FontStyles.Normal; // FontFamily if (fs.Length > 0 && !string.IsNullOrWhiteSpace(fs[0])) { try { fontFamily = new System.Windows.Media.FontFamily(fs[0].Trim()); } catch { } } // FontSize if (fs.Length > 1 && !string.IsNullOrWhiteSpace(fs[1])) { double fsize = 0.0; if (double.TryParse(fs[1].Trim(), out fsize)) { fontSize = fsize; } } // FontStretch if (fs.Length > 2 && !string.IsNullOrWhiteSpace(fs[2])) { fontStretch = (System.Windows.FontStretch) getStaticPropertyValue(fs[2].Trim(), typeof(System.Windows.FontStretches), fontStretch); } // FontWeight if (fs.Length > 3 && !string.IsNullOrWhiteSpace(fs[3])) { fontWeight = (System.Windows.FontWeight) getStaticPropertyValue(fs[3].Trim(), typeof(System.Windows.FontWeights), fontWeight); } // FontStyle if (fs.Length > 4 && !string.IsNullOrWhiteSpace(fs[4])) { fontStyle = (System.Windows.FontStyle) getStaticPropertyValue(fs[4].Trim(), typeof(System.Windows.FontStyles), fontStyle); } if (fontFamily != null) { sty.FontFamily = fontFamily; } if (fontSize > 0.0) { sty.FontSize = fontSize; } sty.FontStretch = fontStretch; sty.FontWeight = fontWeight; sty.FontStyle = fontStyle; style.Font = sty.ToStyle().Font; }