Esempio n. 1
0
        protected override void LoadContent()
        {
            SpriteFont = new SpriteFontGlyphSource(Content.Load <SpriteFont>("font"));
            LatinFont  = new FreeTypeFont(RenderCoordinator, "FiraSans-Regular.otf")
            {
                SizePoints = 40, DPIPercent = 200, GlyphMargin = 4, Gamma = 1.6
            };
            if (false)
            {
                LatinFont = new FreeTypeFont(RenderCoordinator, "cambria.ttc")
                {
                    SizePoints = 40, DPIPercent = 200, GlyphMargin = 4, Gamma = 1.6
                }
            }
            ;
            UniFont = new FreeTypeFont(RenderCoordinator, @"C:\Windows\Fonts\ArialUni.ttf")
            {
                SizePoints = 30, DPIPercent = 200, GlyphMargin = 4, Gamma = 1.6
            };
            FallbackFont = new FallbackGlyphSource(LatinFont, UniFont);

            ActiveFont = FallbackFont;

            Text = new DynamicStringLayout(ActiveFont, TestText)
            {
                // Alignment = HorizontalAlignment.Right,
                AlignToPixels = GlyphPixelAlignment.FloorY,
                CharacterWrap = true,
                WordWrap      = true,
                Scale         = 2f,
                ReverseOrder  = true
            };
            Text2 = new DynamicStringLayout(ActiveFont, TestText2)
            {
                AlignToPixels = GlyphPixelAlignment.FloorY,
                CharacterWrap = true,
                WordWrap      = true,
                Scale         = 2f,
                ReverseOrder  = true
            };
        }
Esempio n. 2
0
        protected override void OnLoadContent(bool isReloading)
        {
            var margin = 6;

            LatinFont = new FreeTypeFont(RenderCoordinator, "FiraSans-Regular.otf")
            {
                SizePoints         = 40, DPIPercent = 200, GlyphMargin = margin, Gamma = 1.6,
                DefaultGlyphColors =
                {
                    { (uint)'h', Color.Red }
                }
            };
            if (false)
            {
                LatinFont = new FreeTypeFont(RenderCoordinator, "cambria.ttc")
                {
                    SizePoints = 40, DPIPercent = 200, GlyphMargin = margin, Gamma = 1.6
                }
            }
            ;
            UniFont = new FreeTypeFont(RenderCoordinator, @"C:\Windows\Fonts\msgothic.ttc")
            {
                SizePoints = 30, DPIPercent = 200, GlyphMargin = margin, Gamma = 1.6
            };
            FallbackFont   = new FallbackGlyphSource(LatinFont, UniFont);
            SmallLatinFont = new FreeTypeFont.FontSize((FreeTypeFont)LatinFont, 40 * 0.75f);

            ActiveFont = FallbackFont;

            Content.RootDirectory = "";
            DutchAndHarley        = Content.Load <SpriteFont>("DutchAndHarley");

            Text = new DynamicStringLayout(ActiveFont, SelectedString)
            {
                AlignToPixels         = GlyphPixelAlignment.RoundXY,
                CharacterWrap         = true,
                WordWrap              = true,
                Scale                 = TextScale,
                ReverseOrder          = true,
                RichText              = true,
                HideOverflow          = true,
                RichTextConfiguration = new RichTextConfiguration {
                    MarkedStringProcessor = ProcessMarkedString,
                    Styles = new Dictionary <string, RichStyle> {
                        { "quick", new RichStyle {
                              Color = Color.Yellow
                          } },
                        { "brown", new RichStyle {
                              Color = Color.Brown, Scale = 2
                          } }
                    },
                    GlyphSources = new Dictionary <string, IGlyphSource> {
                        { "large", LatinFont },
                        { "small", SmallLatinFont }
                    },
                    ImageProvider = Text_ImageProvider
                },
                WordWrapCharacters = new uint[] {
                    '\\', '/', ':', ','
                },
            };

            for (int i = 0; i < Images.Length; i++)
            {
                using (var s = File.OpenRead($"{i + 1}.png"))
                    Images[i] = Texture2D.FromStream(Graphics.GraphicsDevice, s);
            }
        }