(fc0a5b62d) Option to generate font atlases dynamically (rendering new symbols to the atlas as needed). WIP

This commit is contained in:
Joonas Rikkonen
2019-05-07 18:05:50 +03:00
parent b83302408f
commit e0a3e8f8fb
2 changed files with 157 additions and 22 deletions
@@ -137,9 +137,10 @@ namespace Barotrauma
private ScalableFont LoadFont(XElement element, GraphicsDevice graphicsDevice)
{
string file = GetFontFilePath(element);
uint size = GetFontSize(element);
return new ScalableFont(file, size, graphicsDevice);
string file = GetFontFilePath(element);
uint size = GetFontSize(element);
bool dynamicLoading = GetFontDynamicLoading(element);
return new ScalableFont(file, size, graphicsDevice, dynamicLoading);
}
private uint GetFontSize(XElement element)
@@ -170,6 +171,20 @@ namespace Barotrauma
return element.GetAttributeString("file", "");
}
private bool GetFontDynamicLoading(XElement element)
{
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLowerInvariant() != "override") { continue; }
string language = subElement.GetAttributeString("language", "").ToLowerInvariant();
if (GameMain.Config.Language.ToLowerInvariant() == language)
{
return subElement.GetAttributeBool("dynamicloading", false);
}
}
return element.GetAttributeBool("dynamicloading", false);
}
public GUIComponentStyle GetComponentStyle(string name)
{
componentStyles.TryGetValue(name.ToLowerInvariant(), out GUIComponentStyle style);