Exemplo n.º 1
0
        /// <summary>
        /// Loads required font. Actually does reference counting and if fount was already
        /// loaded with required parameters the existing object is returned and reference count
        /// is incremented
        /// </summary>
        /// <param name="fontName">font name</param>
        /// <param name="size">font size</param>
        /// <param name="bold">is font bold</param>
        /// <param name="italic">is font italic</param>
        /// <returns></returns>
        internal IFont CreateFont(String fontName, int size, bool bold, bool italic, UIEngine engine, Theme theme)
        {
            foreach (IFont font in this.loadedFonts)
            {
                if ((font.Name == fontName) && (font.Size == size) && (font.Bold == bold) && (font.Italic == italic))
                {
                    font.AddRef();

                    return(font);
                }
            }

            for (int i = this.fontCreators.Count - 1; i >= 0; i--)
            {
                IFont font = this.fontCreators[i].GetFont(fontName, size, bold, italic, engine, theme);

                if (null != font)
                {
                    font.AddRef();

                    this.loadedFonts.Add(font);

                    return(font);
                }
            }

            CensoredFont censoredFont = new CensoredFont(fontName, size, bold, italic);

            censoredFont.AddRef();

            this.loadedFonts.Add(censoredFont);

            return(censoredFont);
        }