Exemple #1
0
        public static ITexture Load(ICoreFactory factory, MetaFontId id, ITexture regular, ITexture bold)
        {
            var texture = (EightBitTexture)(id.IsBold ? bold : regular);
            var bytes   = (byte[])texture.TextureData.Clone();

            if (!Mappings.TryGetValue(id.Color, out var mapping))
            {
                mapping = Mappings[FontColor.White];
            }

            for (int i = 0; i < bytes.Length; i++)
            {
                if (bytes[i] == 0)
                {
                    continue;
                }

                bytes[i] = mapping[bytes[i]];
            }

            return(factory.CreateEightBitTexture(
                       $"Font{id.Color}{(id.IsBold ? "Bold" : "")}",
                       texture.Width, texture.Height,
                       texture.MipLevels, texture.ArrayLayers,
                       bytes, texture.SubImages));
        }
Exemple #2
0
        public ITexture Build(MetaFontId id)
        {
            var assets    = Resolve <IAssetManager>();
            var textureId = (SpriteId)(id.IsBold ? Base.Font.BoldFont : Base.Font.RegularFont);
            var texture   = (IReadOnlyTexture <byte>)assets.LoadTexture(textureId);

            if (texture == null)
            {
                throw new InvalidOperationException($"MetafontBuilder: Could not load font {textureId}");
            }

            var bytes = texture.PixelData.ToArray();

            if (!Mappings.TryGetValue(id.Color, out var mapping))
            {
                mapping = Mappings[FontColor.White];
            }

            for (int i = 0; i < bytes.Length; i++)
            {
                if (bytes[i] == 0)
                {
                    continue;
                }

                bytes[i] = mapping[bytes[i]];
            }

            return(new ArrayTexture <byte>(
                       textureId,
                       $"Font{id.Color}{(id.IsBold ? "Bold" : "")}",
                       texture.Width, texture.Height, texture.ArrayLayers,
                       bytes, texture.Regions));
        }
Exemple #3
0
        public static ITexture Load(MetaFontId id, ITexture regular, ITexture bold)
        {
            var texture = (EightBitTexture)(id.IsBold ? bold : regular);
            var bytes   = (byte[])texture.TextureData.Clone();
            var mapping = Mappings[id.Color];

            for (int i = 0; i < bytes.Length; i++)
            {
                if (bytes[i] == 0)
                {
                    continue;
                }

                bytes[i] = mapping[bytes[i]];
            }

            return(new EightBitTexture(
                       $"Font{id.Color}{(id.IsBold ? "Bold" : "")}",
                       texture.Width, texture.Height,
                       texture.MipLevels, texture.ArrayLayers,
                       bytes, texture.SubImages));
        }