internal static void Initialize() { NVG.InitOpenGL(); Engine.NVGCtx = NVG.CreateGL3(NVG.NVG_DEBUG | NVG.NVG_ANTIALIAS); string[] Fonts = ContentManager.GetAllFonts(); List <string> LoadedFonts = new List <string>(); foreach (var Font in Fonts) { string FontName = Files.GetFileName(Font); NVG.CreateFont(Engine.NVGCtx, FontName, Font); LoadedFonts.Add(FontName); } // Every font is the fallback for every other font. TODO: Is this even a good idea? for (int i = 0; i < LoadedFonts.Count; i++) { for (int j = 0; j < LoadedFonts.Count; j++) { if (i == j) { continue; } NVG.AddFallbackFont(Engine.NVGCtx, LoadedFonts[i], LoadedFonts[j]); } } NVG.ImagePattern(Engine.NVGCtx, 0, 0, 100, 100, 0, 0, 0); }
static int LoadDemoData(NanoVGContext vg, ref DemoData data) { int i; data.images = new int[13]; for (i = 0; i < 12; i++) { string file; file = $"data/images/image{i + 1}.jpg"; data.images[i] = vg.CreateImage(file, 0); if (data.images[i] == 0) { Console.WriteLine("Could not load %s.\n", file); return(-1); } } data.fontIcons = NVG.CreateFont(vg, "icons", "data/fonts/entypo.ttf"); if (data.fontIcons == -1) { Console.WriteLine("Could not add font icons.\n"); return(-1); } data.fontNormal = NVG.CreateFont(vg, "sans", "data/fonts/Roboto-Regular.ttf"); if (data.fontNormal == -1) { Console.WriteLine("Could not add font italic.\n"); return(-1); } data.fontBold = NVG.CreateFont(vg, "sans-bold", "data/fonts/Roboto-Bold.ttf"); if (data.fontBold == -1) { Console.WriteLine("Could not add font bold.\n"); return(-1); } data.fontEmoji = NVG.CreateFont(vg, "emoji", "data/fonts/NotoEmoji-Regular.ttf"); if (data.fontEmoji == -1) { Console.WriteLine("Could not add font emoji.\n"); return(-1); } NVG.AddFallbackFontId(vg, data.fontNormal, data.fontEmoji); NVG.AddFallbackFontId(vg, data.fontBold, data.fontEmoji); return(0); }