public void InitFont(GUIFontConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(config.Tag))
            {
                throw new ArgumentException("config.Tag must not be null or empty.");
            }

            if (Fonts.ContainsKey(config.Tag))
            {
                this.LogWarning("Font was already loaded: {0}", config.Tag);
                return;
            }

            config.ScaleFactor = Owner.ScaleFactor;

            IGUIFont font = null;

            if (!String.IsNullOrEmpty(config.Path))
            {
                font = FontManager.CreateFont(config);
                if (font == null)
                {
                    this.LogWarning("Failed to load font: {0}", config.Tag);
                }
            }

            // Add even when font is null, which means: loading failed
            Fonts.Add(config.Tag, font);
        }
 public static IGUIFont CreateFont <T>(GUIFontConfiguration config) where T : IGUIFont
 {
     try {
         return(Activator.CreateInstance(typeof(T), config) as IGUIFont);
     } catch (Exception ex) {
         ex.LogError();
         return(null);
     }
 }
 public static IGUIFont CreateFont(Type type, GUIFontConfiguration config)
 {
     try {
         return(Activator.CreateInstance(type, config) as IGUIFont);
     } catch (Exception ex) {
         ex.LogError();
         return(null);
     }
 }
 public void AddFontConfig(GUIFontConfiguration config)
 {
     if (config == null || String.IsNullOrEmpty(config.Tag))
     {
         this.LogWarning("Font config or config.Tag must not be null.");
     }
     else if (FontConfigs.ContainsKey(config.Tag))
     {
         this.LogWarning("Duplicate font config.Tag: {0}", config.Tag);
     }
     else
     {
         FontConfigs.Add(config.Tag, config);
     }
 }
 public static IGUIFont CreateFont(GUIFontConfiguration config)
 {
     return(CreateFont <GuiFont>(config));
 }
Beispiel #6
0
 public GuiFont(GUIFontConfiguration conf)
     : this(conf.Path, conf.Size, conf.ScaleFactor, conf.Filter, conf.YOffset, conf.LineSpacing)
 {
 }