Example #1
0
        public BitmapFont GetBitmapFontFor(string fontName, int fontSize, int outlineThickness, bool useFontSmoothing)
        {
            string fileName = AbsoluteFontCacheFolder +
                              FileManager.RemovePath(BmfcSave.GetFontCacheFileNameFor(fontSize, fontName, outlineThickness, useFontSmoothing));

            if (FileManager.FileExists(fileName))
            {
                try
                {
                    BitmapFont bitmapFont = (BitmapFont)LoaderManager.Self.GetDisposable(fileName);
                    if (bitmapFont == null)
                    {
                        bitmapFont = new BitmapFont(fileName, (SystemManagers)null);
                        LoaderManager.Self.AddDisposable(fileName, bitmapFont);
                    }

                    return(bitmapFont);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        public void TryCreateFontFileFor(InstanceSave instance, StateSave stateSave)
        {
            string prefix = "";

            if (instance != null)
            {
                prefix = instance.Name + ".";
            }

            int?fontSize     = stateSave.GetValueRecursive(prefix + "FontSize") as int?;
            var fontValue    = (string)stateSave.GetValueRecursive(prefix + "Font");
            int outlineValue = stateSave.GetValueRecursive(prefix + "OutlineThickness") as int? ?? 0;

            // default to true to match how old behavior worked
            bool fontSmoothing = stateSave.GetValueRecursive(prefix + "UseFontSmoothing") as bool? ?? true;
            bool isItalic      = stateSave.GetValueRecursive(prefix + "IsItalic") as bool? ?? false;

            if (fontValue != null && fontSize != null)
            {
                BmfcSave.CreateBitmapFontFilesIfNecessary(
                    fontSize.Value,
                    fontValue,
                    outlineValue,
                    fontSmoothing, isItalic);
            }
        }
Example #3
0
        public void TryCreateFontFileFor(InstanceSave instance, StateSave stateSave)
        {
            string prefix = "";

            if (instance != null)
            {
                prefix = instance.Name + ".";
            }

            int?   fontSize         = null;
            object fontSizeAsObject = stateSave.GetValueRecursive(prefix + "FontSize");

            if (fontSizeAsObject != null)
            {
                fontSize = (int)fontSizeAsObject;
            }

            var fontValue =
                (string)stateSave.GetValueRecursive(prefix + "Font");

            int?outlineValue         = 0;
            var outlineValueAsObject = stateSave.GetValueRecursive(prefix + "OutlineThickness");

            if (outlineValueAsObject != null)
            {
                outlineValue = (int)outlineValueAsObject;
            }

            // default to true to match how old behavior worked
            bool fontSmoothing         = true;
            var  fontSmoothingAsObject = stateSave.GetValueRecursive(prefix + "UseFontSmoothing");

            if (fontSmoothingAsObject != null)
            {
                fontSmoothing = (bool)fontSmoothingAsObject;
            }

            if (fontValue != null && fontSize != null && outlineValue != null)
            {
                BmfcSave.CreateBitmapFontFilesIfNecessary(
                    fontSize.Value,
                    fontValue,
                    outlineValue.Value,
                    fontSmoothing);
            }
        }
Example #4
0
        internal void ReactToFontValueSet()
        {
            StateSave stateSave = SelectedState.Self.SelectedStateSave;

            string prefix = "";

            if (SelectedState.Self.SelectedInstance != null)
            {
                prefix = SelectedState.Self.SelectedInstance.Name + ".";
            }

            object fontSizeAsObject = stateSave.GetValueRecursive(prefix + "FontSize");

            BmfcSave.CreateBitmapFontFilesIfNecessary(
                (int)fontSizeAsObject,
                (string)stateSave.GetValueRecursive(prefix + "Font"),
                0);
        }