Example #1
0
        public override void Load(IResourceCache cache, string path)
        {
            if (!System.IO.File.Exists(path))
            {
                throw new FileNotFoundException(path);
            }

            var res = ResourceLoader.Load(path);

            if (!(res is DynamicFontData fontData))
            {
                throw new InvalidDataException("Path does not point to a font.");
            }

            FontData = fontData;
            Font     = new DynamicFont();
            Font.AddFallback(FontData);
        }
Example #2
0
        public override void Load(IResourceCache cache, ResourcePath path)
        {
            if (!cache.ContentFileExists(path))
            {
                throw new FileNotFoundException("Content file does not exist for texture");
            }
            if (!cache.TryGetDiskFilePath(path, out string diskPath))
            {
                throw new InvalidOperationException("Textures can only be loaded from disk.");
            }

            var res = ResourceLoader.Load(diskPath);

            if (!(res is DynamicFontData fontData))
            {
                throw new InvalidDataException("Path does not point to a font.");
            }

            FontData = fontData;
            Font     = new DynamicFont();
            Font.AddFallback(FontData);
        }