Example #1
0
        public new PixelFontSize AddFontSize(string path, Atlas atlas = null, bool outline = false)
        {
            Logger.Log("PixelFont", $"Loading font: {path}");

            PixelFontSize loadedSize = null;

            // load the vanilla font if it exists.
            if (patch_Calc.orig_XMLExists(path))
            {
                Logger.Log("PixelFont", "=> vanilla font file");
                XmlElement data = patch_Calc.orig_LoadXML(path)["font"];
                loadedSize = AddFontSize(path, data, atlas, outline);
                Sizes.Remove(loadedSize);
            }

            // load custom fonts
            string modPath = FileProxy._Modize(path);

            foreach (ModAsset modAsset in Everest.Content.Mods
                     .Select(mod => mod.Map)
                     .Where(map => map.ContainsKey(modPath))
                     .Select(map => map[modPath]))
            {
                Logger.Log("PixelFont", $"=> mod font file from {modAsset.Source.Name}");
                XmlElement    data        = loadXMLFromModAsset(modAsset)["font"];
                PixelFontSize newFontSize = AddFontSize(path, data, atlas, outline);
                Sizes.Remove(newFontSize);
                loadedSize = mergeFonts(loadedSize, newFontSize);
            }

            // add the merged font into the list of existing fonts.
            Sizes.Add(loadedSize);
            Sizes.Sort((PixelFontSize a, PixelFontSize b) => Math.Sign(a.Size - b.Size));

            return(loadedSize);
        }