diff --git a/GraphicsManager/GraphicsManager.csproj b/GraphicsManager/GraphicsManager.csproj index 8d0a92d..120b0c6 100644 --- a/GraphicsManager/GraphicsManager.csproj +++ b/GraphicsManager/GraphicsManager.csproj @@ -10,7 +10,7 @@ False https://git.jacobtech.com/JacobTech.com/GraphicsManager git - 1.0.0-alpha2 + 1.0.0-alpha4 diff --git a/GraphicsManager/Objects/Core/Font.cs b/GraphicsManager/Objects/Core/Font.cs index 216ca23..4c4fad5 100755 --- a/GraphicsManager/Objects/Core/Font.cs +++ b/GraphicsManager/Objects/Core/Font.cs @@ -6,6 +6,7 @@ namespace GraphicsManager.Objects.Core; public class Font { + private static List? System = null; private List _Faces = new(); private Library lib; public IReadOnlyList Faces => _Faces.AsReadOnly(); @@ -33,26 +34,37 @@ public class Font ? Tools.GetResourceBytes(Base + Font) : Tools.GetResourceBytes(Assembly!, $"{Base}{Font}")); fontclass._Faces.Add(new Face(lib, f, 0)); - //load the fucking system fonts - if (OperatingSystem.IsLinux()) + if (System is null) { - try + System = new(); + if (OperatingSystem.IsLinux()) { - Process proc = new() + try { - }; - proc.Start(); - proc.WaitForExit(); - string[] files = proc.StandardOutput.ReadToEnd().Split($":{Environment.NewLine}"); - for (int i = 0; i < files.Length; i++) + Process proc = new() + { + StartInfo = new() + { + FileName = "/bin/bash", + Arguments = "-c \"fc-list ':' file\"", + RedirectStandardOutput = true, + } + }; + proc.Start(); + proc.WaitForExit(); + string[] files = proc.StandardOutput.ReadToEnd().Split($": {Environment.NewLine}"); + for (int i = 0; i < files.Length; i++) + { + System!.Add(new Face(fontclass.lib, files[i], 0)); + } + } + catch { - fontclass._Faces.Add(new Face(lib, files[i], 0)); } } - catch - { - } } + + for (int i = 0; i < System!.Count; i++) fontclass._Faces.Add(System![i]); return fontclass; } @@ -66,31 +78,37 @@ public class Font Name = default!, lib = new() }; - if (OperatingSystem.IsLinux()) + if (Font.System is null) { - try + Font.System = new(); + if (OperatingSystem.IsLinux()) { - Process proc = new() + try { - StartInfo = new() + Process proc = new() { - FileName = "/bin/bash", - Arguments = "-c \"fc-list ':' file\"", - RedirectStandardOutput = true, + StartInfo = new() + { + FileName = "/bin/bash", + Arguments = "-c \"fc-list ':' file\"", + RedirectStandardOutput = true, + } + }; + proc.Start(); + proc.WaitForExit(); + string[] files = proc.StandardOutput.ReadToEnd().Split($": {Environment.NewLine}"); + for (int i = 0; i < files.Length; i++) + { + Font.System!.Add(new Face(fontclass.lib, files[i], 0)); } - }; - proc.Start(); - proc.WaitForExit(); - string[] files = proc.StandardOutput.ReadToEnd().Split($": {Environment.NewLine}"); - for (int i = 0; i < files.Length; i++) + } + catch { - fontclass._Faces.Add(new Face(fontclass.lib, files[i], 0)); } } - catch - { - } } + + for (int i = 0; i < Font.System!.Count; i++) fontclass._Faces.Add(Font.System![i]); return fontclass; } @@ -105,26 +123,37 @@ public class Font }; fontclass.lib = new(); fontclass._Faces.Add(new Face(fontclass.lib, File.ReadAllBytes(Font), 0)); - //load the fucking system fonts - if (OperatingSystem.IsLinux()) + if (System is null) { - try + System = new(); + if (OperatingSystem.IsLinux()) { - Process proc = new() + try { - }; - proc.Start(); - proc.WaitForExit(); - string[] files = proc.StandardOutput.ReadToEnd().Split($":{Environment.NewLine}"); - for (int i = 0; i < files.Length; i++) + Process proc = new() + { + StartInfo = new() + { + FileName = "/bin/bash", + Arguments = "-c \"fc-list ':' file\"", + RedirectStandardOutput = true, + } + }; + proc.Start(); + proc.WaitForExit(); + string[] files = proc.StandardOutput.ReadToEnd().Split($": {Environment.NewLine}"); + for (int i = 0; i < files.Length; i++) + { + System!.Add(new Face(fontclass.lib, files[i], 0)); + } + } + catch { - fontclass._Faces.Add(new Face(fontclass.lib, files[i], 0)); } } - catch - { - } } + + for (int i = 0; i < System!.Count; i++) fontclass._Faces.Add(System![i]); return fontclass; }