示例#1
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);
        }