public void GetFont_NoFont_ThrowsFontNotFound() { Mock <Font> mockedFont = new Mock <Font>(null); FontStore.DefaultFont = mockedFont.Object; Assert.That(() => FontStore.GetFont("test"), Throws.TypeOf <FontNotFoundException>()); }
private void load(FontStore store) { this.store = store; InternalChildren = new Drawable[] { shadowVisibility = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Child = spriteShadow = new Sprite { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fit, Y = 2, Colour = new Color4(0f, 0f, 0f, 0.2f), }, Alpha = shadow ? 1 : 0, }, spriteMain = new Sprite { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fit }, }; updateTexture(); }
/// <summary> /// Gets the font from the FontStore, with the name passed to FontFamily constructor and assigns it to the TextWidget. /// Then the new space required by the widget is calculated and updated. /// </summary> /// <param name="widget"></param> /// <exception cref="IncompatibleWidgetException"></exception> public void ApplyOn(IWidget widget) { ApplicationDone = false; var tail = widget.Skip(1).OfType <Widgets.BuiltIn.Text>().ToList(); if (widget is Widgets.BuiltIn.Text text) { text.Font = FontStore.GetFont(_name); } if (tail.Count > 0) { foreach (var t in tail) { var alreadyHasFontFamilyProp = t.Props.SafeGetByProp <FontFamily>().TryGetValue(out var l); if (!alreadyHasFontFamilyProp || l.Count == 0) { t.Font = FontStore.GetFont(_name); } } } else { Log.Warning( "FontFamily was applied to a widget that is not a Text nor has any Text in its sub-tree"); } ApplicationDone = true; OnApplied(); }
private void load(FrameworkConfigManager config) { Resources = new ResourceStore <byte[]>(); Resources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore(@"osu.Framework.dll"), @"Resources")); Resources.AddStore(new DllResourceStore(MainResourceFile)); Textures = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); Textures.AddStore(new RawTextureLoaderStore(new OnlineStore())); Dependencies.Cache(Textures); Audio = Dependencies.Cache(new AudioManager( new NamespacedResourceStore <byte[]>(Resources, @"Tracks"), new NamespacedResourceStore <byte[]>(Resources, @"Samples")) { EventScheduler = Scheduler }); Host.RegisterThread(Audio.Thread); //attach our bindables to the audio subsystem. config.BindWith(FrameworkSetting.AudioDevice, Audio.AudioDevice); config.BindWith(FrameworkSetting.VolumeUniversal, Audio.Volume); config.BindWith(FrameworkSetting.VolumeEffect, Audio.VolumeSample); config.BindWith(FrameworkSetting.VolumeMusic, Audio.VolumeTrack); Shaders = new ShaderManager(new NamespacedResourceStore <byte[]>(Resources, @"Shaders")); Dependencies.Cache(Shaders); Fonts = new FontStore(new GlyphStore(Resources, @"Fonts/OpenSans")) { ScaleAdjust = 100 }; Dependencies.Cache(Fonts); }
public bool SetSpriteTextRichFont(SpriteTextRich ST) { bool result = false; if (FontList.Count == 0) { LoadxFont(); } // if (ST.font.name[0] == 'c' && ST.font.name[1] == 'n') return result; //Debug.Log("[xFont2-1]" + ST.font.name + " :: " + ST.text); for (int i = 0; i < ST.font.fonts.Length; i++) { if (ST.font.fonts[i].fontText.name[0] == 'c' && ST.font.fonts[i].fontText.name[1] == 'n') { continue; } Font2Font f2f = GetFont2Font(ST.font.fonts[i].fontText.name); Debug.Log("[xFont2]" + ST.font.name + "-->>" + f2f.Name + " :: " + ST.text); ST.font.fonts[i].fontText = f2f.fontDef; ST.font.fonts[i].material = f2f.fontMat; ST.font.fonts[i].SpriteFont = FontStore.GetFont(f2f.fontDef); //Debug.Log("[xFont2-2]" + ST.font.name + "-->>" + f2f.Name + " :: " + ST.text); result = true; } ST.font.name = "cn" + ST.font.name; return(result); }
private void load(FrameworkConfigManager config) { Resources = new ResourceStore <byte[]>(); Resources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore(@"osu.Framework.dll"), @"Resources")); Textures = new TextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); Textures.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); dependencies.Cache(Textures); var tracks = new ResourceStore <byte[]>(); tracks.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Tracks")); tracks.AddStore(new OnlineStore()); var samples = new ResourceStore <byte[]>(); samples.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Samples")); samples.AddStore(new OnlineStore()); Audio = new AudioManager(Host.AudioThread, tracks, samples) { EventScheduler = Scheduler }; dependencies.Cache(Audio); dependencies.CacheAs(Audio.Tracks); dependencies.CacheAs(Audio.Samples); // attach our bindables to the audio subsystem. config.BindWith(FrameworkSetting.AudioDevice, Audio.AudioDevice); config.BindWith(FrameworkSetting.VolumeUniversal, Audio.Volume); config.BindWith(FrameworkSetting.VolumeEffect, Audio.VolumeSample); config.BindWith(FrameworkSetting.VolumeMusic, Audio.VolumeTrack); Shaders = new ShaderManager(new NamespacedResourceStore <byte[]>(Resources, @"Shaders")); dependencies.Cache(Shaders); var cacheStorage = Host.Storage.GetStorageForDirectory(Path.Combine("cache", "fonts")); // base store is for user fonts Fonts = new FontStore(useAtlas: true, cacheStorage: cacheStorage); // nested store for framework provided fonts. // note that currently this means there could be two async font load operations. Fonts.AddStore(localFonts = new FontStore(useAtlas: false)); localFonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans/OpenSans")); localFonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans/OpenSans-Bold")); localFonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans/OpenSans-Italic")); localFonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans/OpenSans-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome5/FontAwesome-Solid")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome5/FontAwesome-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome5/FontAwesome-Brands")); dependencies.Cache(Fonts); Localisation = new LocalisationManager(config); dependencies.Cache(Localisation); }
private void load() { Resources.AddStore(new DllResourceStore(@"TypeProyect.dll")); dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 }); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); Metadata = new Bindable <AudioMetadata>(); }
void load() { Resources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore("osu.Framework.Design.Desktop.dll"), "Resources")); // Load fonts var fonts = new FontStore(new GlyphStore(Resources, "Fonts/Nunito")); _dependencies.Cache(fonts); fonts.AddStore(new GlyphStore(Resources, "Fonts/Nunito-Bold")); fonts.AddStore(new GlyphStore(Resources, "Fonts/Nunito-Italic")); fonts.AddStore(new GlyphStore(Resources, "Fonts/Nunito-BoldItalic")); fonts.AddStore(new GlyphStore(Resources, "Fonts/Inconsolata")); fonts.AddStore(new GlyphStore(Resources, "Fonts/Inconsolata-Bold")); fonts.AddStore(new GlyphStore(Resources, "Fonts/Inconsolata-Italic")); fonts.AddStore(new GlyphStore(Resources, "Fonts/Inconsolata-BoldItalic")); fonts.AddStore(new GlyphStore(Resources, "Fonts/Consolas")); // Global workspace _dependencies.CacheAs <IFileSystem>(_fileSystem = new FileSystem()); var rootDir = string.IsNullOrEmpty(_projectPath) ? _fileSystem.GetCurrentDirectory() : _fileSystem.DirectoryInfo.FromDirectoryName(_projectPath); _dependencies.Cache(_workspace = new Workspace(rootDir)); }
private static void AddInfo(ref UIPanel page, string name, string value) { var label = page.AddUIComponent <UILabel>(); label.font = FontStore.Get(12); label.text = $"{name}: {value}"; }
private void load() { Dependencies.Cache(Config); Resources = new ResourceStore <byte[]>(); Resources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore(@"osu.Framework.dll"), @"Resources")); Resources.AddStore(new DllResourceStore(MainResourceFile)); Textures = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); Textures.AddStore(new RawTextureLoaderStore(new OnlineStore())); Dependencies.Cache(Textures); Audio = Dependencies.Cache(new AudioManager( new NamespacedResourceStore <byte[]>(Resources, @"Tracks"), new NamespacedResourceStore <byte[]>(Resources, @"Samples")) { EventScheduler = Scheduler }); //attach our bindables to the audio subsystem. Audio.AudioDevice.Weld(Config.GetBindable <string>(FrameworkConfig.AudioDevice)); Audio.Volume.Weld(Config.GetBindable <double>(FrameworkConfig.VolumeUniversal)); Audio.VolumeSample.Weld(Config.GetBindable <double>(FrameworkConfig.VolumeEffect)); Audio.VolumeTrack.Weld(Config.GetBindable <double>(FrameworkConfig.VolumeMusic)); Shaders = new ShaderManager(new NamespacedResourceStore <byte[]>(Resources, @"Shaders")); Dependencies.Cache(Shaders); Fonts = new FontStore(new GlyphStore(Resources, @"Fonts/OpenSans")) { ScaleAdjust = 100 }; Dependencies.Cache(Fonts); }
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(FontStore store) { this.store = store; spaceWidth = CreateCharacterDrawable('.')?.DrawWidth * 2 ?? default_text_size; validateLayout(); }
private void load() { Dependencies.Cache(this); Dependencies.Cache(LocalConfig); SQLiteConnection connection = Host.Storage.GetDatabase(@"client"); Dependencies.Cache(RulesetDatabase = new RulesetDatabase(Host.Storage, connection)); Dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, connection, RulesetDatabase, Host)); Dependencies.Cache(ScoreDatabase = new ScoreDatabase(Host.Storage, connection, Host, BeatmapDatabase)); Dependencies.Cache(new OsuColour()); //this completely overrides the framework default. will need to change once we make a proper FontStore. Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 }, true); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); var defaultBeatmap = new DummyWorkingBeatmap(this); Beatmap = new NonNullableBindable <WorkingBeatmap>(defaultBeatmap); BeatmapDatabase.DefaultBeatmap = defaultBeatmap; OszArchiveReader.Register(); Dependencies.Cache(API = new APIAccess { Username = LocalConfig.Get <string>(OsuSetting.Username), Token = LocalConfig.Get <string>(OsuSetting.Token) }); API.Register(this); }
public SpectrumVideoCanvas(SpectrumVideoSource source, SpectrumVideoCanvasConfig config, IOutputProvider outputProvider) { //Set width = config.video_output.width; label = config.label; decimation = config.baseband.decimation; frameRate = config.video_output.frameRate; this.outputProvider = outputProvider; this.source = source; //Create IQ decimator and oscilator oscillator = new Oscillator(SampleRate, config.baseband.freqOffset); decimator = new ComplexDecimator(SampleRate, DecimatedSampleRate, config.baseband.decimation, config.baseband.decimationAttenuation, DecimatedSampleRate * config.baseband.decimationTransitionRatio); //Create all audio resources foreach (var o in config.audio_outputs) { AddResource(new AudioResource(o, this)); } //Create all components components = new SpectrumVideoComponent[config.components.Count]; componentOffsets = new int[config.components.Count]; for (int i = 0; i < components.Length; i++) { components[i] = ComponentFactory.MakeComponent(this, config.components[i]); } //Get the image dimensions by calculating the total height height = 0; for (int i = 0; i < components.Length; i++) { componentOffsets[i] = height * ImageWidth; height += components[i].Height; } //Create misc videoOutput = outputProvider.GetVideoOutput(config.video_output.filename, ImageWidth, ImageHeight, config.video_output.frameRate, BufferSize); frameBuffer = UnsafeBuffer.Create(ImageWidth * ImageHeight, out frameBufferPtr); buffer = UnsafeBuffer.Create(BufferSize, out bufferPtr); textGenerator = FontStore.CreateRenderer(ImageWidth, ImageHeight); //Fill the entire canvas with black for (int i = 0; i < ImageWidth * ImageHeight; i++) { frameBufferPtr[i] = new UnsafeColor(0, 0, 0); } //Init all components for (int i = 0; i < components.Length; i++) { components[i].Init(); components[i].InitFrame(frameBufferPtr + componentOffsets[i]); } }
protected override void Dispose(bool isDisposing) { Audio?.Dispose(); Audio = null; Fonts?.Dispose(); Fonts = null; localFonts?.Dispose(); localFonts = null; base.Dispose(isDisposing); }
public void ApplyOn_TextWidget_ChangesSizeOfFont() { var anotherFont = new Mock <Font>(null).Object; FontStore.RegisterFont("ff1", anotherFont); var font = new FontFamily("ff1"); var testWidget = (Text)WidgetFactory.Text("Test string"); font.ApplyOn(testWidget); Assert.That(testWidget.Font, Is.EqualTo(anotherFont)); }
public static void Setup(ref UIPanel page) { page.padding = Helper.Padding(8, 12); var pane = ToolHelper.AddConfig( ref page, "Tree movement", "Sets the amount of tree branch movement.\nVanilla: maximum; Recommended: minimum", opts: new SliderOption <float>( minValue: 0.0f, maxValue: 1.0f, stepSize: 0.1f, defaultValue: App.Config.Graphics.treeMoveFactor, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.treeMoveFactor, value); } ) { hasField = false, }, labelPadding: 4, bullet: "InfoIconMaintenance" ); Helper.AddCheckBox( ref page, "Force stop distant trees (*)", "* restart required", initialValue: App.Config.Graphics.stopDistantTrees, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.stopDistantTrees = isChecked; } }, font: FontStore.Get(11) ); Helper.AddCheckBox( ref page, "Random tree rotation", "Close range only (technical limitation for LOD)", initialValue: App.Config.Graphics.randomTrees, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.randomTrees = isChecked; } }, font: FontStore.Get(11) ); }
// fontStore passed in via ctor to be able to test scenarios where an animation // already has frames before load public TestAnimation(bool startFromCurrent, FontStore fontStore) : base(startFromCurrent) { Anchor = Anchor.Centre; Origin = Anchor.Centre; for (int i = 0; i < LOADABLE_FRAMES; i++) { AddFrame(new Texture(fontStore.Get(null, (char)('0' + i))?.Texture.TextureGL) { ScaleAdjust = 1 + i / 40f, }, 250); } }
public void TestNoCrashOnMissingResources() { using (var glyphStore = new RawCachingGlyphStore(fontResourceStore, "DoesntExist") { CacheStorage = storage }) using (var fontStore = new FontStore(glyphStore, 100)) { Assert.That(glyphStore.Get('a'), Is.Null); Assert.That(fontStore.Get("DoesntExist", 'a'), Is.Null); Assert.That(fontStore.Get("OtherAttempt", 'a'), Is.Null); } }
public void ApplyOn_TextWidget_RecalculatesSizeOfText() { var mockedFont = new Mock <Font>(null); mockedFont.Setup(f => f.MeasureText(It.IsAny <string>(), It.IsAny <int>())).Returns((1, 1)); FontStore.RegisterFont("mockF", mockedFont.Object); var font = new FontFamily("mockF"); var testWidget = (Text)WidgetFactory.Text("Test string"); Assert.That(testWidget.Space.Size, Is.EqualTo(new Vector2(0, 0))); font.ApplyOn(testWidget); Assert.That(testWidget.Space.Size, Is.EqualTo(new Vector2(1, 1))); }
private void load() { sim = new RigidBodySimulation { RelativeSizeAxes = Axes.Both }; Resources.AddStore(new DllResourceStore(@"Gale.dll")); dependencies.Cache(Fonts = new FontStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"))); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); sim.Add(new Player()); base.Content.Add(new GaleKeyBindingContainer { sim }); }
private void load(FrameworkConfigManager config) { Resources = new ResourceStore <byte[]>(); Resources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore(@"osu.Framework.dll"), @"Resources")); Textures = new TextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); Textures.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); dependencies.Cache(Textures); var tracks = new ResourceStore <byte[]>(); tracks.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Tracks")); tracks.AddStore(new OnlineStore()); var samples = new ResourceStore <byte[]>(); samples.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Samples")); samples.AddStore(new OnlineStore()); Shaders = new ShaderManager(new NamespacedResourceStore <byte[]>(Resources, @"Shaders")); dependencies.Cache(Shaders); var cacheStorage = Host.Storage.GetStorageForDirectory(Path.Combine("cache", "fonts")); // base store is for user fonts Fonts = new FontStore(useAtlas: true, cacheStorage: cacheStorage); // nested store for framework provided fonts. // note that currently this means there could be two async font load operations. Fonts.AddStore(localFonts = new FontStore(useAtlas: false)); localFonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans/OpenSans")); localFonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans/OpenSans-Bold")); localFonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans/OpenSans-Italic")); localFonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans/OpenSans-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome5/FontAwesome-Solid")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome5/FontAwesome-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome5/FontAwesome-Brands")); dependencies.Cache(Fonts); Localisation = new LocalisationManager(config); dependencies.Cache(Localisation); }
private void load(FrameworkConfigManager config) { Resources = new ResourceStore <byte[]>(); Resources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore(@"osu.Framework.dll"), @"Resources")); Textures = new TextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); Textures.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); dependencies.Cache(Textures); var tracks = new ResourceStore <byte[]>(Resources); tracks.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Tracks")); tracks.AddStore(new OnlineStore()); var samples = new ResourceStore <byte[]>(Resources); samples.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Samples")); samples.AddStore(new OnlineStore()); Audio = new AudioManager(tracks, samples) { EventScheduler = Scheduler }; dependencies.Cache(Audio); Host.RegisterThread(Audio.Thread); //attach our bindables to the audio subsystem. config.BindWith(FrameworkSetting.AudioDevice, Audio.AudioDevice); config.BindWith(FrameworkSetting.VolumeUniversal, Audio.Volume); config.BindWith(FrameworkSetting.VolumeEffect, Audio.VolumeSample); config.BindWith(FrameworkSetting.VolumeMusic, Audio.VolumeTrack); Shaders = new ShaderManager(new NamespacedResourceStore <byte[]>(Resources, @"Shaders")); dependencies.Cache(Shaders); Fonts = new FontStore(new GlyphStore(Resources, @"Fonts/OpenSans")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans-Italic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/OpenSans-BoldItalic")); dependencies.Cache(Fonts); Localisation = new LocalisationManager(config); dependencies.Cache(Localisation); }
private void load(FontStore store) { this.store = store; spaceWidth = CreateCharacterDrawable('.')?.DrawWidth * 2 ?? default_text_size; if (!string.IsNullOrEmpty(text)) { //this is used to prepare the initial string (useful for intial preloading). foreach (char c in text) { if (!char.IsWhiteSpace(c)) { CreateCharacterDrawable(c); } } } }
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); } }
public void TestNestedScaleAdjust() { var fontStore = new FontStore(new GlyphStore(fontResourceStore, "OpenSans") { CacheStorage = storage }, scaleAdjust: 100); var nestedFontStore = new FontStore(new GlyphStore(fontResourceStore, "OpenSans-Bold") { CacheStorage = storage }, 10); fontStore.AddStore(nestedFontStore); var normalGlyph = (TexturedCharacterGlyph)fontStore.Get("OpenSans", 'a'); var boldGlyph = (TexturedCharacterGlyph)fontStore.Get("OpenSans-Bold", 'a'); Assert.That(normalGlyph.Scale, Is.EqualTo(1f / 100)); Assert.That(boldGlyph.Scale, Is.EqualTo(1f / 10)); }
public void ApplyOn_NotTextWidget_CascadesToChildren() { // arrange var root = WidgetFactory.Container(); var testWidget = (Text)WidgetFactory.Text("Test string"); root.AddChild(testWidget); var mockedFont = new Mock <Font>(null); FontStore.RegisterFont("mockF2", mockedFont.Object); var font = new FontFamily("mockF2"); // act root.WithProp(font); TreeVisitor.ApplyPropsOnTree(root); // assert Assert.That(testWidget.Font, Is.EqualTo(mockedFont.Object)); }
private void load() { Dependencies.Cache(this); Dependencies.Cache(LocalConfig); Dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, Host)); Dependencies.Cache(ScoreDatabase = new ScoreDatabase(Host.Storage, Host, BeatmapDatabase)); Dependencies.Cache(new OsuColour()); //this completely overrides the framework default. will need to change once we make a proper FontStore. Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 }, true); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera")); OszArchiveReader.Register(); Dependencies.Cache(API = new APIAccess { Username = LocalConfig.Get <string>(OsuConfig.Username), Token = LocalConfig.Get <string>(OsuConfig.Token) }); API.Register(this); }
private void load(FontStore fontStore, Storage storage, TextureStore textureStore) { Child = new BasicScrollContainer { RelativeSizeAxes = Axes.Both, Child = flow = new FillFlowContainer <ResourceDisplay> { Margin = new MarginPadding(10), Spacing = new Vector2(3), RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, }, }; this.fontStore = fontStore; this.textureStore = textureStore; this.storage = storage; }
protected override void Dispose(bool isDisposing) { // ensure any async disposals are completed before we begin to rip components out. // if we were to not wait, async disposals may throw unexpected exceptions. AsyncDisposalQueue.WaitForEmpty(); base.Dispose(isDisposing); // call a second time to protect against anything being potentially async disposed in the base.Dispose call. AsyncDisposalQueue.WaitForEmpty(); Audio?.Dispose(); Audio = null; Fonts?.Dispose(); Fonts = null; localFonts?.Dispose(); localFonts = null; }
private void load() { Dependencies.Cache(this); Dependencies.Cache(Config); Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); Dependencies.Cache(new OsuColour()); //this completely overrides the framework default. will need to change once we make a proper FontStore. Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }, true); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera")); OszArchiveReader.Register(); Dependencies.Cache(API = new APIAccess { Username = Config.Get<string>(OsuConfig.Username), Password = Config.Get<string>(OsuConfig.Password), Token = Config.Get<string>(OsuConfig.Token) }); API.Register(this); }