System.Text.StringBuilder.AppendFont(Font)

Here are the examples of the csharp api System.Text.StringBuilder.AppendFont(Font) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 Source : StylesXml.cs
with MIT License
from sveinungf

private static async ValueTask<Dictionary<Font, int>> WriteFontsAsync(
            Stream stream,
            SpreadsheetBuffer buffer,
            List<Style> styles,
            CancellationToken token)
        {
            var defaultFont = new Font();
            const int defaultCount = 1;

            var uniqueFonts = new Dictionary<Font, int> { { defaultFont, 0 } };
            for (var i = 0; i < styles.Count; ++i)
            {
                var font = styles[i].Font;
                uniqueFonts[font] = 0;
            }

            var sb = new StringBuilder();
            var totalCount = uniqueFonts.Count + defaultCount - 1;
            sb.Append("<fonts count=\"").Append(totalCount).Append("\">");

            // The default font must be the first one (index 0)
            sb.Append("<font><sz val=\"11\"/><name val=\"Calibri\"/></font>");
            await buffer.WriteAsciiStringAsync(sb.ToString(), stream, token).ConfigureAwait(false);

            var fontIndex = defaultCount;
            foreach (var font in uniqueFonts.Keys.ToArray())
            {
                if (font.Equals(defaultFont)) continue;

                sb.Clear();
                sb.AppendFont(font);
                await buffer.WriteAsciiStringAsync(sb.ToString(), stream, token).ConfigureAwait(false);

                uniqueFonts[font] = fontIndex;
                ++fontIndex;
            }

            await buffer.WriteAsciiStringAsync("</fonts>", stream, token).ConfigureAwait(false);
            return uniqueFonts;
        }