// Internal helper method to set clipboard static void TrySetClipboard(Character c, FontMapViewModel v) { DataPackage dp = new DataPackage { RequestedOperation = DataPackageOperation.Copy, }; dp.SetText(c.Char); if (!v.SelectedVariant.IsImported) { // We can allow users to also copy the glyph with the font meta-data included, // so when they paste into a supported program like Microsoft Word or // Adobe Photoshop the correct font is automatically applied to the paste. // This can't include any Typographic variations unfortunately. var rtf = $@"{{\rtf1\fbidis\ansi\ansicpg1252\deff0\nouicompat\deflang2057{{\fonttbl{{\f0\fnil {v.FontFamily.Source};}}}} " + $@"{{\colortbl;\red0\green0\blue0; }}\viewkind4\uc1\pard\ltrpar\tx720\cf1\f0\fs24\u{c.UnicodeIndex}?}}"; dp.SetRtf(rtf); var longName = v.FontFamily.Source; if (v.SelectedVariant.FontInformation.FirstOrDefault(i => i.Key == "Full Name") is var p) { if (p.Value != longName) { longName = $"{v.FontFamily.Source}, {p.Value}"; } } dp.SetHtmlFormat($"<p style=\"font-family:'{longName}'; \">{c.Char}</p>"); } Clipboard.SetContent(dp); // Possibly causing crashes. //Clipboard.Flush(); }
public static Task <bool> TryCopyToClipboardAsync(Character character, FontMapViewModel viewModel) { string c = @$ "\u{character.UnicodeIndex}?";
public static async Task <bool> TryCopyToClipboardAsync(Character character, FontMapViewModel viewModel) {