internal static async Task ExportFontsAsZipAsync(List <FontVariant> fonts, string name)
        {
            if (await PickFileAsync(name, "ZIP", new[] { ".zip" }) is StorageFile file)
            {
                await Task.Run(async() =>
                {
                    ExportNamingScheme scheme = ResourceHelper.AppSettings.ExportNamingScheme;

                    using var i = await file.OpenStreamForWriteAsync();
                    i.SetLength(0);

                    using ZipArchive z = new ZipArchive(i, ZipArchiveMode.Create);
                    foreach (var font in fonts)
                    {
                        if (DirectWrite.IsFontLocal(font.FontFace))
                        {
                            string fileName       = GetFileName(font, scheme);
                            ZipArchiveEntry entry = z.CreateEntry(fileName);
                            using IOutputStream s = entry.Open().AsOutputStream();
                            await DirectWrite.WriteToStreamAsync(font.FontFace, s);
                        }
                    }
                });

                Messenger.Default.Send(new AppNotificationMessage(true, new ExportFontFileResult(true, file)));
            }
        }
        private static async Task <bool> TryWriteToFileAsync(FontVariant font, StorageFile file)
        {
            try
            {
                using IRandomAccessStream s = await file.OpenAsync(FileAccessMode.ReadWrite);

                s.Size = 0;

                using IOutputStream o = s.GetOutputStreamAt(0);
                await DirectWrite.WriteToStreamAsync(font.FontFace, o);

                return(true);
            }
            catch { }

            return(false);
        }
        private static async Task <bool> TryWriteToFileAsync(FontVariant font, StorageFile file)
        {
            try
            {
                using IRandomAccessStream s = await file.OpenAsync(FileAccessMode.ReadWrite).AsTask().ConfigureAwait(false);

                s.Size = 0;

                using IOutputStream o = s.GetOutputStreamAt(0);
                await DirectWrite.WriteToStreamAsync(font.FontFace, o).AsTask().ConfigureAwait(false);

                await s.FlushAsync(); // using statements force synchronous flushes

                return(true);
            }
            catch { }

            return(false);
        }