Merge pull request #10704 from pchote/filesystem-fonts
Loads fonts via the virtual filesystem.
This commit is contained in:
@@ -363,7 +363,7 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
ModData.InitializeLoaders();
|
||||
Renderer.InitializeFonts(ModData.Manifest);
|
||||
Renderer.InitializeFonts(ModData);
|
||||
|
||||
if (Cursor != null)
|
||||
Cursor.Dispose();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user