UnicodeRanges.cs
// 完毕:
using System;
using System.IO;
using System.Drawing;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;

namespace DsPdfWeb.Demos.Basics
{
    // 此示例列出了每个系统字体中可用的 Unicode 范围。
    public class UnicodeRanges
    {
        public int CreatePDF(Stream stream)
        {
            // 设置:
            var doc = new GcPdfDocument();
            var tl = new TextLayout(72)
            {
                MaxWidth = doc.PageSize.Width,
                MaxHeight = doc.PageSize.Height,
                MarginAll = 72,
            };
            tl.DefaultFormat.FontSize = 7;
            var tfH = new TextFormat() { Font = StandardFonts.TimesBold, FontSize = 12 };
            var tfP = new TextFormat() { Font = StandardFonts.Times, FontSize = 11 };

            // 循环遍历所有系统字体,
            // 列出每种字体提供的 Unicode 范围:
            foreach (var font in FontCollection.SystemFonts)
            {
                tl.AppendLine($"{font.FontFileName} [{font.FullFontName}] [{font.FontFamilyName}]", tfH);
                var shot = font.CreateFontTables(TableTag.OS2);
                tl.AppendLine(shot.GetUnicodeRanges(), tfP);
                tl.AppendLine();
            }

            // 拆分并渲染 TextLayout,如 PaginatedText 示例所示:
            var to = new TextSplitOptions(tl)
            {
                MinLinesInFirstParagraph = 2,
                MinLinesInLastParagraph = 2
            };
            tl.PerformLayout(true);
            while (true)
            {
                var splitResult = tl.Split(to, out TextLayout rest);
                doc.Pages.Add().Graphics.DrawTextLayout(tl, PointF.Empty);
                if (splitResult != SplitResult.Split)
                    break;
                tl = rest;
            }

            // 完毕:
            doc.Save(stream);
            return doc.Pages.Count;
        }
    }
}