Example #1
0
        protected override void OnInitialized()
        {
            DefaultTypographyOptions defaultTheme = new DefaultTypographyOptions
            {
                Plugins = new List <IPlugin> {
                    new CodePlugn()
                }
            };

            Typography.ApplyTypography(defaultTheme);
        }
Example #2
0
        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);
        }