/// <summary>
        /// Gets the FontDescriptor identified by the specified FontSelector. If no such object
        /// exists, a new FontDescriptor is created and added to the stock.
        /// </summary>
        public static FontDescriptor GetOrCreateDescriptor(string fontFamilyName, XFontStyle style)
        {
            if (string.IsNullOrEmpty(fontFamilyName))
            {
                throw new ArgumentNullException("fontFamilyName");
            }

            //FontSelector1 selector = new FontSelector1(fontFamilyName, style);
            string fontDescriptorKey = FontDescriptor.ComputeKey(fontFamilyName, style);

            try
            {
                Lock.EnterFontFactory();
                FontDescriptor descriptor;
                if (!Singleton._cache.TryGetValue(fontDescriptorKey, out descriptor))
                {
                    XFont font = new XFont(fontFamilyName, 10, style);
                    descriptor = GetOrCreateDescriptorFor(font);
                    if (Singleton._cache.ContainsKey(fontDescriptorKey))
                    {
                        Singleton.GetType();
                    }
                    else
                    {
                        Singleton._cache.Add(fontDescriptorKey, descriptor);
                    }
                }
                return(descriptor);
            }
            finally { Lock.ExitFontFactory(); }
        }
Example #2
0
        /// <summary>
        /// Gets the FontDescriptor identified by the specified FontSelector. Returns null if no
        /// such objects exists.
        /// </summary>
        public FontDescriptor FindDescriptor(FontSelector selector)
        {
            if (selector == null)
            {
                return(null);
            }

            FontDescriptor descriptor = table[selector] as FontDescriptor;

            return(descriptor);
        }
Example #3
0
        public static FontDescriptor GetOrCreateDescriptor(string idName, byte[] fontData)
        {
            //FontSelector1 selector = new FontSelector1(idName);
            string fontDescriptorKey = FontDescriptor.ComputeKey(idName);

            try
            {
                Lock.EnterFontFactory();
                FontDescriptor descriptor;
                if (!Singleton._cache.TryGetValue(fontDescriptorKey, out descriptor))
                {
                    descriptor = GetOrCreateOpenTypeDescriptor(fontDescriptorKey, idName, fontData);
                    Singleton._cache.Add(fontDescriptorKey, descriptor);
                }
                return(descriptor);
            }
            finally { Lock.ExitFontFactory(); }
        }
Example #4
0
        ///// <summary>
        ///// Gets the FontDescriptor identified by the specified FontSelector. If no such object
        ///// exists, a new FontDescriptor is created and added to the stock.
        ///// </summary>
        //public static FontDescriptor GetOrCreateDescriptor_DEL-ETE(string familyName, XFontStyle stlye, OpenTypeFontface fontface)
        //{
        //    //FontSelector1 selector = new FontSelector1(familyName, stlye);
        //    string fontDescriptorKey = null; // FontDescriptor.ComputeKey(familyName, stlye);
        //    try
        //    {
        //        Lock.EnterFontFactory();
        //        FontDescriptor descriptor;
        //        if (!Singleton._cache.TryGetValue(fontDescriptorKey, out descriptor))
        //        {
        //            descriptor = new OpenTypeDescriptor(fontDescriptorKey, familyName, stlye, fontface, null);
        //            Singleton._cache.Add(fontDescriptorKey, descriptor);
        //        }
        //        return descriptor;
        //    }
        //    finally { Lock.ExitFontFactory(); }
        //}

        /// <summary>
        /// Gets the FontDescriptor identified by the specified XFont. If no such object
        /// exists, a new FontDescriptor is created and added to the cache.
        /// </summary>
        public static FontDescriptor GetOrCreateDescriptorFor(XFont font)
        {
            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            //FontSelector1 selector = new FontSelector1(font);
            string fontDescriptorKey = FontDescriptor.ComputeKey(font);

            try
            {
                Lock.EnterFontFactory();
                FontDescriptor descriptor;
                if (!Singleton._cache.TryGetValue(fontDescriptorKey, out descriptor))
                {
                    descriptor = new OpenTypeDescriptor(fontDescriptorKey, font);
                    Singleton._cache.Add(fontDescriptorKey, descriptor);
                }
                return(descriptor);
            }
            finally { Lock.ExitFontFactory(); }
        }