private void load(GameHost host) { var storage = host.Storage; if (!storage.ExistsDirectory("fonts/cached")) { return; } // create font store if wants to import. localFontStore = new FontStore(scaleAdjust: 200, minFilterMode: All.Linear); fontStore.AddStore(localFontStore); var files = storage.GetFiles("fonts/cached"); foreach (var file in files) { // should only accept .cached extension. if (Path.GetExtension(file) != ".cached") { return; } var fontName = Path.GetFileNameWithoutExtension(file); var resources = new CachedFontArchiveReader(storage.GetStream(file), fontName); var store = new GlyphStore(new ResourceStore <byte[]>(resources), $"{fontName}", host.CreateTextureLoaderStore(resources)); localFontStore.AddStore(store); } }
private void load(GameHost host, KaraokeRulesetConfigManager manager) { var storage = host.Storage; if (!storage.ExistsDirectory(base_path)) { return; } // get all font usage which wants to import. var targetImportFonts = new[] { manager.Get <FontUsage>(KaraokeRulesetSetting.MainFont), manager.Get <FontUsage>(KaraokeRulesetSetting.RubyFont), manager.Get <FontUsage>(KaraokeRulesetSetting.RomajiFont), manager.Get <FontUsage>(KaraokeRulesetSetting.TranslateFont), manager.Get <FontUsage>(KaraokeRulesetSetting.NoteFont), }; // convert to file path then import var targetImportFontPaths = targetImportFonts.Select(x => { var path = Path.Combine(base_path, x.FontName); var pathWithExtension = Path.ChangeExtension(path, "cached"); return(pathWithExtension); }).Where(p => storage.Exists(p)).Distinct().ToArray(); if (!targetImportFontPaths.Any()) { return; } // create font store if wants to import. localFontStore = new FontStore(scaleAdjust: 200, minFilterMode: All.Linear); fontStore.AddStore(localFontStore); foreach (var path in targetImportFontPaths) { var fontName = Path.GetFileNameWithoutExtension(path); var resources = new CachedFontArchiveReader(storage.GetStream(path), fontName); var store = new GlyphStore(new ResourceStore <byte[]>(resources), $"{fontName}", host.CreateTextureLoaderStore(resources)); localFontStore.AddStore(store); } }