コード例 #1
0
 private void CreateGlyph(char @char) =>
 Task.Run(() =>
 {
     var safeFileName = $"{(byte)@char}.png";
     var outputPath   = Path.Combine(_outputDirectory, safeFileName);
     FontRasterizer.RenderText(_font, @char.ToString(), outputPath, Rgba32.White);
     var bitmap = new Bitmap(outputPath);
     var glyph  = Tuple.Create(@char, bitmap);
     Dispatcher.UIThread.InvokeAsync(() => Glyphs.Add(glyph));
 });
コード例 #2
0
        private void UpdateRenderImage(object sender, EventArgs e)
        {
            var textBox = sender as TextBox;
            var text    = textBox.Text;

            Task.Run(() =>
            {
                FontRasterizer.RenderText(_font, text, _renderOutputPath);

                Dispatcher.UIThread.InvokeAsync(() => _outputImage.Source = new Bitmap(_renderOutputPath));
            });
        }