protected void OnChangeSelected(UIChangeEventArgs e) { Selected = (string)e.Value; ITypographyOptions theme = Typography.ThemeForName(Selected); Fontsize = Typography.Unitless(theme.BaseFontSize) + ".00"; Lineheight = theme.BaseLineHeight; Ratio = theme.ScaleRatio.ToString(); Spacing = theme.BlockMarginBottom; HeaderFont = theme.HeaderFontFamily[0]; BodyFont = theme.BodyFontFamily[0]; HeaderWeights = GetWeightForDropdown(HeaderFont); HeaderWeight = theme.HeaderWeight; BodyWeights = GetWeightForDropdown(BodyFont); BodyWeight = theme.BodyWeight; BoldWeights = GetWeightForDropdown(BodyFont); BoldWeight = theme.BoldWeight; }
protected void OnClick() { ITypographyOptions theme = Typography.ThemeForName(Selected); theme.BaseFontSize = Fontsize + "px"; theme.BaseLineHeight = Lineheight; theme.ScaleRatio = double.Parse(Ratio); theme.BlockMarginBottom = Spacing; if (UseCodePlugin) { theme.Plugins = new List <IPlugin> { new CodePlugn() }; } if (theme.HeaderFontFamily[0] != HeaderFont) { Font headerFont = GetFont(HeaderFont); if (headerFont != null) { theme.HeaderFontFamily = new List <string> { HeaderFont, headerFont.Category }; theme.HeaderWeight = HeaderWeight != "regular" ? HeaderWeight : "400"; if (theme.GoogleFonts == null) { theme.GoogleFonts = new List <GoogleFont>(); } theme.GoogleFonts.Add(new GoogleFont { Name = HeaderFont, Styles = new List <string> { theme.HeaderWeight } }); //TODO: Remove old font here } } if (theme.BodyFontFamily[0] != BodyFont) { Font bodyFont = GetFont(BodyFont); if (bodyFont != null) { theme.BodyFontFamily = new List <string> { BodyFont, bodyFont.Category }; theme.BodyWeight = BodyWeight != "regular" ? BodyWeight : "400"; theme.BoldWeight = BoldWeight != "regular" ? BoldWeight : "400"; if (theme.GoogleFonts == null) { theme.GoogleFonts = new List <GoogleFont>(); } theme.GoogleFonts.Add(new GoogleFont { Name = BodyFont, Styles = new List <string> { "400", "400i", theme.BoldWeight, theme.BoldWeight + "i" } }); //TODO: Remove old font here } } Typography.ApplyTypography(theme); }