/// <summary>
        /// An XGlyphTypeface for a font souce that comes from a custom font resolver
        /// creates a solitary font family exclusively for it.
        /// </summary>
        internal static XFontFamily CreateSolitary(string name)
        {
            // Custom font resolver face names must not clash with platform family names.
            FontFamilyInternal fontFamilyInternal = FontFamilyCache.GetFamilyByName(name);

            if (fontFamilyInternal == null)
            {
                fontFamilyInternal = FontFamilyInternal.GetOrCreateFromName(name, false);
                fontFamilyInternal = FontFamilyCache.CacheOrGetFontFamily(fontFamilyInternal);
            }

            // Create font family and save it in cache. Do not try to create platform objects.
            return(new XFontFamily(fontFamilyInternal));

            //// Custom font resolver face names must not clash with platform family names.
            //if (FontFamilyCache.GetFamilyByName(name) != null)
            //{
            //    // User must rename its font face to resolve naming confilict.
            //    throw new InvalidOperationException(String.Format("Font face name {0} clashs with existing family name.", name));
            //}

            //// Create font family and save it in cache. Do not try to create platform objects.
            //FontFamilyInternal fontFamilyInternal = FontFamilyInternal.GetOrCreateFromName(name, false);
            //fontFamilyInternal = FontFamilyCache.CacheFontFamily(fontFamilyInternal);
            //return new XFontFamily(fontFamilyInternal);
        }
        internal static FontFamilyInternal GetOrCreateFromWpf(WpfFontFamily wpfFontFamily)
        {
            FontFamilyInternal fontFamily = new FontFamilyInternal(wpfFontFamily);

            fontFamily = FontFamilyCache.CacheOrGetFontFamily(fontFamily);
            return(fontFamily);
        }
 internal static FontFamilyInternal GetOrCreateFromGdi(GdiFontFamily gdiFontFamily)
 {
     try
     {
         Lock.EnterFontFactory();
         FontFamilyInternal fontFamily = new FontFamilyInternal(gdiFontFamily);
         fontFamily = FontFamilyCache.CacheOrGetFontFamily(fontFamily);
         return(fontFamily);
     }
     finally { Lock.ExitFontFactory(); }
 }
Example #4
0
        /// <summary>
        /// An XGlyphTypeface for a font source that comes from a custom font resolver
        /// creates a solitary font family exclusively for it.
        /// </summary>
        internal static XFontFamily GetOrCreateFontFamily(string name)
        {
            // Custom font resolver face names must not clash with platform family names.
            FontFamilyInternal fontFamilyInternal = FontFamilyCache.GetFamilyByName(name);

            if (fontFamilyInternal == null)
            {
                fontFamilyInternal = FontFamilyInternal.GetOrCreateFromName(name, false);
                fontFamilyInternal = FontFamilyCache.CacheOrGetFontFamily(fontFamilyInternal);
            }

            // Create font family and save it in cache. Do not try to create platform objects.
            return(new XFontFamily(fontFamilyInternal));
        }
 internal static FontFamilyInternal GetOrCreateFromName(string familyName, bool createPlatformObject)
 {
     try
     {
         Lock.EnterFontFactory();
         FontFamilyInternal family = FontFamilyCache.GetFamilyByName(familyName);
         if (family == null)
         {
             family = new FontFamilyInternal(familyName, createPlatformObject);
             family = FontFamilyCache.CacheOrGetFontFamily(family);
         }
         return(family);
     }
     finally { Lock.ExitFontFactory(); }
 }