Esempio n. 1
0
        public override SpriteFontContent Process(FontDescription input, ContentProcessorContext context)
        {
            SpriteFontContent sfc = base.Process(input, context);

            if (context.TargetPlatform == TargetPlatform.Windows)
            {
                CreateExEnOutput(sfc, input, context);
            }

            return(sfc);
        }
Esempio n. 2
0
        private void CreateExEnOutput(SpriteFontContent spriteFontContent, FontDescription input, ContentProcessorContext context)
        {
            ExEnFontWriter.CreateOutputDirectory(input.Identity);

            ExEnFontWriter.WriteTexture(spriteFontContent, true, context,
                    ExEnFontWriter.AssetOutputFilename(input.Identity, context, "-exenfont.png"));
            ExEnFontWriter.WriteMetrics(spriteFontContent, context,
                    ExEnFontWriter.AssetOutputFilename(input.Identity, context, "-exenfont.exenfont"));

            // Retina Display
            input.BecomeAt2x();
            SpriteFontContent spriteFontContentAt2x = base.Process(input, context);
            ExEnFontWriter.WriteTexture(spriteFontContentAt2x, true, context,
                    ExEnFontWriter.AssetOutputFilename(input.Identity, context, "*****@*****.**"));
            ExEnFontWriter.WriteMetrics(spriteFontContentAt2x, context,
                    ExEnFontWriter.AssetOutputFilename(input.Identity, context, "*****@*****.**"));
        }
Esempio n. 3
0
        private void CreateExEnOutput(SpriteFontContent spriteFontContent, FontDescription input, ContentProcessorContext context)
        {
            ExEnFontWriter.CreateOutputDirectory(input.Identity);

            ExEnFontWriter.WriteTexture(spriteFontContent, true, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "-exenfont.png"));
            ExEnFontWriter.WriteMetrics(spriteFontContent, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "-exenfont.exenfont"));

            // Retina Display
            input.BecomeAt2x();
            SpriteFontContent spriteFontContentAt2x = base.Process(input, context);

            ExEnFontWriter.WriteTexture(spriteFontContentAt2x, true, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "*****@*****.**"));
            ExEnFontWriter.WriteMetrics(spriteFontContentAt2x, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "*****@*****.**"));
        }
Esempio n. 4
0
        private void CreateExEnOutput(Texture2DContent input, ContentProcessorContext context)
        {
            ExEnFontWriter.CreateOutputDirectory(input.Identity);

            // Put the processor in a format suitable for outputting to PNG
            var originalPremultiply = PremultiplyAlpha;
            var originalFormat      = TextureFormat;

            PremultiplyAlpha = false;
            TextureFormat    = TextureProcessorOutputFormat.Color;

            // Build normal size:
            SpriteFontContent spriteFontContent = base.Process(input, context);

            ExEnFontWriter.WriteTexture(spriteFontContent, false, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "-exenfont.png"));
            ExEnFontWriter.WriteMetrics(spriteFontContent, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "-exenfont.exenfont"));

            // Check for retina size:
            string pathAt2x = Path.Combine(Path.GetDirectoryName(input.Identity.SourceFilename),
                                           Path.GetFileNameWithoutExtension(input.Identity.SourceFilename) + "@2x"
                                           + Path.GetExtension(input.Identity.SourceFilename));

            if (File.Exists(pathAt2x))
            {
                var textureImporter = new TextureImporter();
                var textureAt2x     = (Texture2DContent)textureImporter.Import(pathAt2x, null);
                context.AddDependency(pathAt2x);

                var spriteFontContentAt2x = base.Process(textureAt2x, context);
                ExEnFontWriter.WriteTexture(spriteFontContentAt2x, false, context,
                                            ExEnFontWriter.AssetOutputFilename(input.Identity, context, "*****@*****.**"));
                ExEnFontWriter.WriteMetrics(spriteFontContentAt2x, context,
                                            ExEnFontWriter.AssetOutputFilename(input.Identity, context, "*****@*****.**"));
            }

            PremultiplyAlpha = originalPremultiply;
            TextureFormat    = originalFormat;
        }