コード例 #1
0
        public void InitializeFonts(ModData modData)
        {
            if (Fonts != null)
            {
                foreach (var font in Fonts.Values)
                {
                    font.Dispose();
                }
            }
            using (new PerfTimer("SpriteFonts"))
            {
                fontSheetBuilder?.Dispose();
                fontSheetBuilder = new SheetBuilder(SheetType.BGRA, 512);
                Fonts            = modData.Manifest.Get <Fonts>().FontList.ToDictionary(x => x.Key,
                                                                                        x => new SpriteFont(x.Value.Font, modData.DefaultFileSystem.Open(x.Value.Font).ReadAllBytes(),
                                                                                                            x.Value.Size, x.Value.Ascender, Window.EffectiveWindowScale, fontSheetBuilder)).AsReadOnly();
            }

            Window.OnWindowScaleChanged += (oldNative, oldEffective, newNative, newEffective) =>
            {
                Game.RunAfterTick(() =>
                {
                    ChromeProvider.SetDPIScale(newEffective);

                    foreach (var f in Fonts)
                    {
                        f.Value.SetScale(newEffective);
                    }
                });
            };
        }