public FreeTypeFontGlyph(FreeTypeFont freeTypeFont, uint glyphIndex, float advance = 0.0f, Image image = null, bool valid = false) : base(advance, image, valid) { d_freeTypeFont = freeTypeFont; d_glyphIndex = glyphIndex; }
protected override void LoadContent() { base.LoadContent(); Rt = new RenderTarget2D(Graphics.GraphicsDevice, 512, 512); var provider = new EmbeddedFreeTypeFontProvider(RenderCoordinator); Font = provider.Load("FiraSans-Medium"); Font.SizePoints = 20; Font.GlyphMargin = 4; Texture = Texture2D.FromStream(Graphics.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("bunny")); try { Materials = new DefaultMaterialSet(RenderCoordinator) { ViewTransform = ViewTransform.CreateOrthographic(Graphics.PreferredBackBufferWidth, Graphics.PreferredBackBufferHeight) }; } catch (Exception exc) { Console.WriteLine("Shader load failed."); Console.WriteLine(exc); Thread.Sleep(5000); Environment.Exit(1); return; } EffectProvider = new EmbeddedEffectProvider(RenderCoordinator); Vpos = new Material(EffectProvider.Load("vpos"), "vposShader"); Materials.Add(Vpos); }
protected override void LoadContent() { Font = new FreeTypeFont( RenderCoordinator, Environment.GetFolderPath(Environment.SpecialFolder.Windows) + "\\Fonts\\arial.ttf" ) { DPIPercent = 100, SizePoints = 10f, Hinting = false }; WhitePixel = new Texture2D(GraphicsDevice, 1, 1); WhitePixel.SetData(new [] { Color.White }); GrayPixel = new Texture2D(GraphicsDevice, 1, 1); GrayPixel.SetData(new [] { Color.Silver }); }
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 }; }
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); } }