From 844e1a17705d3cdac8870483591493ff2548e60d Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 21 Jan 2016 17:33:43 +0000 Subject: [PATCH] Loads fonts via the virtual filesystem. --- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/Graphics/SpriteFont.cs | 4 ++-- OpenRA.Game/Renderer.cs | 6 +++--- mods/d2k/mod.yaml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index f2bdf80ec7..4cb0e11111 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -363,7 +363,7 @@ namespace OpenRA } ModData.InitializeLoaders(); - Renderer.InitializeFonts(ModData.Manifest); + Renderer.InitializeFonts(ModData); if (Cursor != null) Cursor.Dispose(); diff --git a/OpenRA.Game/Graphics/SpriteFont.cs b/OpenRA.Game/Graphics/SpriteFont.cs index d23bc0a728..be167a0b2f 100644 --- a/OpenRA.Game/Graphics/SpriteFont.cs +++ b/OpenRA.Game/Graphics/SpriteFont.cs @@ -27,7 +27,7 @@ namespace OpenRA.Graphics readonly Face face; readonly Cache, GlyphInfo> glyphs; - public SpriteFont(string name, int size, SheetBuilder builder) + public SpriteFont(string name, byte[] data, int size, SheetBuilder builder) { if (builder.Type != SheetType.BGRA) throw new ArgumentException("The sheet builder must create BGRA sheets.", "builder"); @@ -35,7 +35,7 @@ namespace OpenRA.Graphics this.size = size; this.builder = builder; - face = new Face(Library, name); + face = new Face(Library, data, 0); face.SetPixelSizes((uint)size, (uint)size); glyphs = new Cache, GlyphInfo>(CreateGlyph, Pair.EqualityComparer); diff --git a/OpenRA.Game/Renderer.cs b/OpenRA.Game/Renderer.cs index 6e669c68ef..37c487c0c0 100644 --- a/OpenRA.Game/Renderer.cs +++ b/OpenRA.Game/Renderer.cs @@ -90,7 +90,7 @@ namespace OpenRA throw new InvalidOperationException("Renderer DLL is missing RendererAttribute to tell us what type to use!"); } - public void InitializeFonts(Manifest m) + public void InitializeFonts(ModData modData) { if (Fonts != null) foreach (var font in Fonts.Values) @@ -100,8 +100,8 @@ namespace OpenRA if (fontSheetBuilder != null) fontSheetBuilder.Dispose(); fontSheetBuilder = new SheetBuilder(SheetType.BGRA); - Fonts = m.Fonts.ToDictionary(x => x.Key, - x => new SpriteFont(Platform.ResolvePath(x.Value.First), x.Value.Second, fontSheetBuilder)).AsReadOnly(); + Fonts = modData.Manifest.Fonts.ToDictionary(x => x.Key, + x => new SpriteFont(x.Value.First, modData.ModFiles.Open(x.Value.First).ReadAllBytes(), x.Value.Second, fontSheetBuilder)).AsReadOnly(); } } diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index 71e61e6fb7..b3487393e5 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -173,7 +173,7 @@ Fonts: Font:./mods/common/FreeSansBold.ttf Size:14 Title: - Font:d2k:Dune2k.ttf + Font:./mods/d2k/Dune2k.ttf Size:32 MediumBold: Font:./mods/common/FreeSansBold.ttf