Inheritance: IDisposable
Exemplo n.º 1
0
        void UpdateToFontValues()
        {

            BitmapFont font = null;


            var loaderManager = global::RenderingLibrary.Content.LoaderManager.Self;
            var contentLoader = loaderManager.ContentLoader;

            if (UseCustomFont)
            {

                if (!string.IsNullOrEmpty(CustomFontFile))
                {
                    font = contentLoader.TryGetCachedDisposable<BitmapFont>(CustomFontFile);
                    if (font == null)
                    {
                        font = new BitmapFont(CustomFontFile, SystemManagers.Default);
                        contentLoader.AddDisposable(CustomFontFile, font);
                    }
                }


            }
            else
            {
                if (FontSize > 0 && !string.IsNullOrEmpty(Font))
                {
                    string fontName = global::RenderingLibrary.Graphics.Fonts.BmfcSave.GetFontCacheFileNameFor(FontSize, Font, OutlineThickness);

                    string fullFileName = ToolsUtilities.FileManager.RelativeDirectory + fontName;

#if ANDROID || IOS
                    fullFileName = fullFileName.ToLowerInvariant();
#endif

                    if (ToolsUtilities.FileManager.FileExists(fullFileName))
                    {

                        font = contentLoader.TryGetCachedDisposable<BitmapFont>(fullFileName);
                        if (font == null)
                        {
                            font = new BitmapFont(fullFileName, SystemManagers.Default);

                            contentLoader.AddDisposable(fullFileName, font);
                        }
                        if (font.Textures.Any(item => item.IsDisposed))
                        {
                            throw new InvalidOperationException("The returned font has a disposed texture");
                        }
                    }
                }
            }

            var text = this.mContainedObjectAsIpso as Text;

            text.BitmapFont = font;

        }