Example #1
0
        protected override void LoadContent()
        {
            Batch   = new(GraphicsDevice);
            Watcher = new()
            {
                Path = "Content",
                IncludeSubdirectories = true,
                EnableRaisingEvents   = true
            };
            Fonts = FontSystemFactory.CreateStroked(GraphicsDevice, 1);
            Fonts.AddFont(File.ReadAllBytes("Content/fonts/Montserrat-Medium.ttf"));

            base.LoadContent();
        }
Example #2
0
        public FontSystem Load(AssetLoaderContext context, string assetName)
        {
            var parts = assetName.Split(':');

            var fontType = FontType.Regular;
            var amount   = 1;

            if (parts.Length > 1)
            {
                fontType = (FontType)Enum.Parse(typeof(FontType), parts[1]);

                if (fontType != FontType.Regular)
                {
                    if (parts.Length < 3)
                    {
                        throw new Exception("Missing amount");
                    }

                    amount = int.Parse(parts[2]);
                }
            }

            FontSystem fontSystem = null;

            switch (fontType)
            {
            case FontType.Regular:
                fontSystem = FontSystemFactory.Create(context.GraphicsDevice, 1024, 1024);
                break;

            case FontType.Blurry:
                fontSystem = FontSystemFactory.CreateBlurry(context.GraphicsDevice, 1024, 1024, amount);
                break;

            case FontType.Stroked:
                fontSystem = FontSystemFactory.CreateStroked(context.GraphicsDevice, 1024, 1024, amount);
                break;
            }

            var data = context.Load <byte[]>(parts[0]);

            fontSystem.AddFont(data);

            return(fontSystem);
        }
Example #3
0
        protected override Task LoadContent()
#endif
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            var fontSystems = new List <FontSystem>();

            // Simple
            var fontSystem = FontSystemFactory.Create(GraphicsDevice);

            LoadFontSystem(fontSystem);
            fontSystems.Add(fontSystem);

            // Blurry
            var blurryFontSystem = FontSystemFactory.CreateBlurry(GraphicsDevice, EffectAmount);

            LoadFontSystem(blurryFontSystem);
            fontSystems.Add(blurryFontSystem);

            // Stroked
            var strokedFontSystem = FontSystemFactory.CreateStroked(GraphicsDevice, EffectAmount);

            LoadFontSystem(strokedFontSystem);
            fontSystems.Add(strokedFontSystem);

            _fontSystems       = fontSystems.ToArray();
            _currentFontSystem = _fontSystems[0];

#if MONOGAME || FNA
            _white = new Texture2D(GraphicsDevice, 1, 1);
            _white.SetData(new[] { Color.White });
#elif STRIDE
            _white = Texture2D.New2D(GraphicsDevice, 1, 1, false, PixelFormat.R8G8B8A8_UNorm_SRgb, TextureFlags.ShaderResource);
            _white.SetData(GraphicsContext.CommandList, new[] { Color.White });
#endif

            GC.Collect();

#if STRIDE
            return(base.LoadContent());
#endif
        }
        //-------------------------------------------------
        #region Initialize Method's Region
        /// <summary>
        /// Initializ the components.
        /// </summary>
        private void InitializeComponents()
        {
            //---------------------------------------------
            //news:
            this.MyRes                  = new WotoRes(typeof(FontManager));
            this._ranges                = _getRanges();
            this._old_story_bold        = _generate();
            this._old_story_bold_italic = _generate();
            this._LTW_bold              = _generate();
            this._LTW_regular           = _generate();
            this._noto_sans_regular     = _generate();
            byte[] _old_story_bold_        = _fromRes(OSBFileInRes);
            byte[] _old_story_bold_italic_ = _fromRes(OSBIFileInRes);
            byte[] _LTW_bold_          = _fromRes(LTWTTBoldFileInRes);
            byte[] _LTW_regular_       = _fromRes(LTWTTRFileInRes);
            byte[] _noto_sans_regular_ = _fromRes(NSRFileInRes);
            //---------------------------------------------
            //add colection fonts:
            this._old_story_bold?.AddFont(_old_story_bold_);
            this._old_story_bold?.AddFont(_noto_sans_regular_);
            this._old_story_bold_italic?.AddFont(_old_story_bold_italic_);
            this._old_story_bold_italic?.AddFont(_noto_sans_regular_);
            this._LTW_bold?.AddFont(_LTW_bold_);
            this._LTW_bold?.AddFont(_noto_sans_regular_);
            this._LTW_regular?.AddFont(_LTW_regular_);
            this._LTW_regular?.AddFont(_noto_sans_regular_);
            this._noto_sans_regular?.AddFont(_noto_sans_regular_);
            this._noto_sans_regular?.AddFont(_LTW_bold_);
            //---------------------------------------------
            //localFunctions:
            FontSystem _generate()
            {
                return(FontSystemFactory.CreateStroked(this.Client.GraphicsDevice,
                                                       STROKE_AMOUNT,
                                                       this.GraphicsLevel * FontBitmapWidth,
                                                       this.GraphicsLevel * FontBitmapHeight));;
            }

            //---------------------------------------------
        }
Example #5
0
        public FontSystem Load(AssetLoaderContext context, string assetName)
        {
            var parts = assetName.Split(':');

            var fontType = FontType.Regular;
            var amount   = 1;

            if (parts.Length > 1)
            {
                fontType = (FontType)Enum.Parse(typeof(FontType), parts[1]);

                if (fontType != FontType.Regular)
                {
                    if (parts.Length < 3)
                    {
                        throw new Exception("Missing amount");
                    }

                    amount = int.Parse(parts[2]);
                }
            }

            FontSystem fontSystem = null;

#if MONOGAME || FNA || STRIDE
            switch (fontType)
            {
            case FontType.Regular:
                fontSystem = FontSystemFactory.Create(MyraEnvironment.GraphicsDevice, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;

            case FontType.Blurry:
                fontSystem = FontSystemFactory.CreateBlurry(MyraEnvironment.GraphicsDevice, amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;

            case FontType.Stroked:
                fontSystem = FontSystemFactory.CreateStroked(MyraEnvironment.GraphicsDevice, amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;
            }
#else
            switch (fontType)
            {
            case FontType.Regular:
                fontSystem = FontSystemFactory.Create(MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;

            case FontType.Blurry:
                fontSystem = FontSystemFactory.CreateBlurry(amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;

            case FontType.Stroked:
                fontSystem = FontSystemFactory.CreateStroked(amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize);
                break;
            }
#endif

            var data = context.Load <byte[]>(parts[0]);
            fontSystem.AddFont(data);

            return(fontSystem);
        }