/// <summary>Creates a new font by loading the font from resources.</summary>
		/// <param name="name">The name of the font to load.</param>
		/// <returns>A new dynamic font.</returns>
		public static DynamicFont Get(string name){
			
			// Start fonts if it needs it:
			Fonts.Start();
			
			// Create it:
			DynamicFont font=new DynamicFont(name);
			
			// Is a font family available already?
			font.Family=Fonts.Get(name);
			
			if(font.Family==null){
				
				// Try loading the faces from Resources:
				if(font.LoadFaces()){
					
					if(DefaultFamily==null){
						DefaultFamily=font;
					}
					
				}
				
			}
			
			return font;
		}
Пример #2
0
        /// <summary>Creates a new font by loading the font from resources.</summary>
        /// <param name="name">The name of the font to load.</param>
        /// <returns>A new dynamic font.</returns>
        public static DynamicFont Get(string name)
        {
            // Start fonts if it needs it:
            Fonts.Start();

            // Create it:
            DynamicFont font = new DynamicFont(name);

            // Is a font family available already?
            font.Family = Fonts.Get(name);

            if (font.Family == null)
            {
                // Try loading the faces from Resources:
                font.LoadFaces();
            }

            return(font);
        }
        /// <summary>Called when a @font-face font is done loading.</summary>
        public void FontLoaded(DynamicFont font)
        {
            if (Style.Computed.Text != null)
            {
                Style.Computed.Text.FontLoaded(font);
            }

            if (ChildNodes == null)
            {
                return;
            }

            int count = ChildNodes.Count;

            for (int i = 0; i < count; i++)
            {
                ChildNodes[i].FontLoaded(font);
            }
        }
Пример #4
0
        /// <summary>Called when a @font-face font is done loading.</summary>
        public void FontLoaded(DynamicFont font)
        {
            if (childNodes_ == null)
            {
                return;
            }

            int count = childNodes_.length;

            for (int i = 0; i < count; i++)
            {
                IRenderableNode node = (childNodes_[i] as IRenderableNode);

                if (node == null)
                {
                    continue;
                }

                node.FontLoaded(font);
            }
        }
Пример #5
0
        /// <summary>Gets the font with the given name. May load it from the cache or generate a new one.</summary>
        /// <param name="fontName">The name of the font to find.</param>
        /// <returns>A dynamic font if found; null otherwise.</returns>
        public DynamicFont GetOrCreateFont(string fontName)
        {
            if (fontName == null || AotDocument)
            {
                return(null);
            }

            DynamicFont result;

            // Cache contains all available fonts for this document/ renderer.
            ActiveFonts.TryGetValue(fontName, out result);

            if (result == null)
            {
                // Go get the font now:
                result = DynamicFont.Get(fontName);

                // And add it:
                ActiveFonts[fontName] = result;
            }

            return(result);
        }
//--------------------------------------