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:
committed by
Paul Chote
parent
713cdaef5d
commit
a71a5cc71d
@@ -49,8 +49,8 @@ namespace OpenRA.Graphics
|
||||
Func<char, float> characterWidth = character => glyphs[Pair.New(character, Color.White)].Advance;
|
||||
lineWidth = line => line.Sum(characterWidth) / deviceScale;
|
||||
|
||||
PrecacheColor(Color.White, name);
|
||||
PrecacheColor(Color.Red, name);
|
||||
if (size <= 24)
|
||||
PrecacheColor(Color.White, name);
|
||||
}
|
||||
|
||||
public void SetScale(float scale)
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA
|
||||
{
|
||||
if (fontSheetBuilder != null)
|
||||
fontSheetBuilder.Dispose();
|
||||
fontSheetBuilder = new SheetBuilder(SheetType.BGRA);
|
||||
fontSheetBuilder = new SheetBuilder(SheetType.BGRA, 512);
|
||||
Fonts = modData.Manifest.Fonts.ToDictionary(x => x.Key,
|
||||
x => new SpriteFont(x.Value.First, modData.DefaultFileSystem.Open(x.Value.First).ReadAllBytes(),
|
||||
x.Value.Second, Device.WindowScale, fontSheetBuilder)).AsReadOnly();
|
||||
|
||||
Reference in New Issue
Block a user