Merge pull request #10704 from pchote/filesystem-fonts

Loads fonts via the virtual filesystem.
This commit is contained in:
Oliver Brakmann
2016-02-07 16:41:34 +01:00
4 changed files with 7 additions and 7 deletions

View File

@@ -363,7 +363,7 @@ namespace OpenRA
}
ModData.InitializeLoaders();
Renderer.InitializeFonts(ModData.Manifest);
Renderer.InitializeFonts(ModData);
if (Cursor != null)
Cursor.Dispose();

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Graphics
readonly Face face;
readonly Cache<Pair<char, Color>, 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<Pair<char, Color>, GlyphInfo>(CreateGlyph, Pair<char, Color>.EqualityComparer);

View File

@@ -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();
}
}

View File

@@ -172,7 +172,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