Reduce the size of the sheets created for fonts.

- A 512x512 sheet is about half full after precaching and some usage, but uses 16x less memory than the default 2048x2048 sheet. This saving occurs twice as we maintain a managed buffer for this sheet.
- Only precache smaller fonts, as the larger fonts are less used and take up more space than is worthwhile.
- Only precache in white, as red is largely unused.
This commit is contained in:
RoosterDragon
2017-11-11 18:38:53 +00:00
committed by Paul Chote
parent 713cdaef5d
commit a71a5cc71d
2 changed files with 3 additions and 3 deletions

View File

@@ -49,8 +49,8 @@ namespace OpenRA.Graphics
Func<char, float> characterWidth = character => glyphs[Pair.New(character, Color.White)].Advance; Func<char, float> characterWidth = character => glyphs[Pair.New(character, Color.White)].Advance;
lineWidth = line => line.Sum(characterWidth) / deviceScale; lineWidth = line => line.Sum(characterWidth) / deviceScale;
PrecacheColor(Color.White, name); if (size <= 24)
PrecacheColor(Color.Red, name); PrecacheColor(Color.White, name);
} }
public void SetScale(float scale) public void SetScale(float scale)

View File

@@ -84,7 +84,7 @@ namespace OpenRA
{ {
if (fontSheetBuilder != null) if (fontSheetBuilder != null)
fontSheetBuilder.Dispose(); fontSheetBuilder.Dispose();
fontSheetBuilder = new SheetBuilder(SheetType.BGRA); fontSheetBuilder = new SheetBuilder(SheetType.BGRA, 512);
Fonts = modData.Manifest.Fonts.ToDictionary(x => x.Key, Fonts = modData.Manifest.Fonts.ToDictionary(x => x.Key,
x => new SpriteFont(x.Value.First, modData.DefaultFileSystem.Open(x.Value.First).ReadAllBytes(), x => new SpriteFont(x.Value.First, modData.DefaultFileSystem.Open(x.Value.First).ReadAllBytes(),
x.Value.Second, Device.WindowScale, fontSheetBuilder)).AsReadOnly(); x.Value.Second, Device.WindowScale, fontSheetBuilder)).AsReadOnly();