Exemple #1
0
        /// <summary>
        /// Loads all of the fonts used by this individual theme.
        /// </summary>
        /// <param name="fontDirectory">Path to the directory where the fonts for the current theme are stored.</param>
        public static void LoadFonts(string fontDirectory)
        {
            // Instantiate font styles.
            FontStyle textFontStyle     = FontStyle.Regular;
            FontStyle titleFontStyle    = FontStyle.Regular;
            FontStyle categoryFontStyle = FontStyle.Regular;

            // Create the font loaders.
            _textFontLoader     = new FontLoader();
            _categoryFontLoader = new FontLoader();
            _titleFontLoader    = new FontLoader();

            // Initialize font locations.
            string titleFontLocation    = "";
            string categoryFontLocation = "";
            string textFontLocation     = "";

            // Calculate font styles.
            textFontStyle     = GetFontStyle(textFontStyle, Theme.ThemeProperties.TextFontStyle);
            categoryFontStyle = GetFontStyle(categoryFontStyle, Theme.ThemeProperties.CategoryFontStyle);
            titleFontStyle    = GetFontStyle(titleFontStyle, Theme.ThemeProperties.TitleFontStyle);

            // Check if any file paths exist.
            if (File.Exists(fontDirectory + "\\TitleFont.ttf"))
            {
                titleFontLocation = fontDirectory + "\\TitleFont.ttf";
            }
            else if (File.Exists(fontDirectory + "\\TitleFont.otf"))
            {
                titleFontLocation = fontDirectory + "\\TitleFont.otf";
            }

            if (File.Exists(fontDirectory + "\\CategoryFont.ttf"))
            {
                categoryFontLocation = fontDirectory + "\\CategoryFont.ttf";
            }
            else if (File.Exists(fontDirectory + "\\CategoryFont.otf"))
            {
                categoryFontLocation = fontDirectory + "\\CategoryFont.otf";
            }

            if (File.Exists(fontDirectory + "\\TextFont.ttf"))
            {
                textFontLocation = fontDirectory + "\\TextFont.ttf";
            }
            else if (File.Exists(fontDirectory + "\\TextFont.otf"))
            {
                textFontLocation = fontDirectory + "\\TextFont.ttf";
            }

            // Load appropriate fonts.
            TitleFont    = titleFontLocation != "" ? _titleFontLoader.LoadExternalFont(titleFontLocation, 20.25F) : new Font("Times New Roman", 20.25F, FontStyle.Regular);
            CategoryFont = categoryFontLocation != "" ? _categoryFontLoader.LoadExternalFont(categoryFontLocation, 20.25F) : new Font("Times New Roman", 20.25F, FontStyle.Regular);
            TextFont     = textFontLocation != "" ? _textFontLoader.LoadExternalFont(textFontLocation, 18F) : new Font("Times New Roman", 18F, FontStyle.Regular);

            // Set font style.
            TitleFont    = new Font(TitleFont, titleFontStyle);
            TextFont     = new Font(TextFont, textFontStyle);
            CategoryFont = new Font(CategoryFont, categoryFontStyle);
        }