Beispiel #1
0
 internal static Typeface GetTypeface(MediaCenterTheme theme, FontFace info)
 {
     FontFamily fontFamily = theme.GetFontFamily(info.FontFamily);
     if (fontFamily == null)
         return (Typeface)null;
     else
         return new Typeface(fontFamily, FontStyles.Normal, info.FontWeight, FontStretches.Normal);
 }
Beispiel #2
0
        public static FontFace GetFontFaceInfo(string font, MediaCenterTheme theme)
        {
            FontFace fontFace = new FontFace();
            List<FontFamily> list = new List<FontFamily>();

            if (theme != null)
                list.AddRange(theme.Fonts);

            InstallMediaCenterFonts();

            list.AddRange(Fonts.SystemFontFamilies);

            foreach (FontFamily fontFamily in list)
            {
                string name = FontUtil.GetName(fontFamily);
                if (font.StartsWith(name))
                {
                    fontFace.FontFamily = name;
                    FontWeightConverter fontWeightConverter = new FontWeightConverter();
                    string str = font.Substring(name.Length).Trim();
                    char[] chArray = new char[1] { ' ' };
                    foreach (string text in str.Split(chArray))
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            try
                            {
                                fontFace.FontWeight = (FontWeight)fontWeightConverter.ConvertFromString(text);
                            }
                            catch (FormatException)
                            {
                            }
                        }
                    }
                    break;
                }
            }
            if (fontFace.FontFamily == null)
                return (FontFace)null;
            else
                return fontFace;
        }
Beispiel #3
0
 internal static string GetTypefaceName(MediaCenterTheme theme, FontFace typeface)
 {
     return FontUtilities.GetTypefaceName(FontUtilities.GetTypeface(theme, typeface));
 }
Beispiel #4
0
 public FontFace(FontFace source)
 {
     this.fontFamily = source.FontFamily;
     this.fontWeight = source.FontWeight;
 }