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

namespace DsPdfWeb.Demos.Basics
{
    // 此示例呈现各种有趣的 Unicode 字符
    // 包括代理对。它还隐式地使用自动
    // GcDocs.Pdf 中内置字体后备(字体替换)功能。
    // 请注意,此示例可能会在不同的情况下产生不同的结果
    // 系统,因为它依赖于系统提供的后备字体。
    // 有关此示例的平台和系统独立版本,请参阅SurrogatesPort。
    // 另请参阅FontFallbacks。
    public class Surrogates
    {
        public int CreatePDF(Stream stream)
        {
            var doc = new GcPdfDocument();
            var g = doc.NewPage().Graphics;
            // 对于本示例中演示的大多数“有趣”字符,
            // 将自动使用@fallback字体(请参阅@{FontFallbacks}),
            // 所以我们可以使用标准字体作为标题:
            var font = StandardFonts.Helvetica;

            var tf = new TextFormat() { Font = font, FontSize = 12 };
            var tf1 = new TextFormat(tf) { FontSize = 14 };

            g.DrawString("Some Interesting Unicode Characters (relies on system fallbacks)",
                new TextFormat(tf) { Underline = true, FontSize = tf.FontSize + 2 },
                new RectangleF(0, 36, doc.PageSize.Width, float.MaxValue),
                TextAlignment.Center);

            // 设置文本插入点及其高级功能:
            var ip = new PointF(72, 54);
            Func<bool, PointF> nextIp = (caption_) => { ip.Y += caption_ ? 30 : 20; return ip; };

            // 绘制字符串:
            g.DrawString("Surrogate Pairs:", tf, nextIp(true));
            g.DrawString("\uD867\uDEDB \uD840\uDC0B \uD834\uDD1E \uD834\uDD61 \uD83D\uDC04", tf1, nextIp(false));

            g.DrawString("Currency Symbols:", tf, nextIp(true));
            g.DrawString("\u0024 \u20A0 \u20A1 \u20A2 \u20A3 \u20A4 \u20AC \u20B9 \x20BD", tf1, nextIp(false));

            g.DrawString("Mathematical Operators:", tf, nextIp(true));
            g.DrawString("\u221A \u222B \u2211 \u2210 \u2264 \u2265 \u2202 \u2208", tf1, nextIp(false));

            g.DrawString("CJK Ideographs Extension A:", tf, nextIp(true));
            g.DrawString("\u3400 \u3401 \u3402 \u3403 \u3404 \u3405 \u3406 \u3407", tf1, nextIp(false));

            g.DrawString("Letterlike Symbols:", tf, nextIp(true));
            g.DrawString("\u2110 \u2111 \u2112 \u2113 \u2114 \u2115 \u211B \u211C", tf1, nextIp(false));

            g.DrawString("Private Use Area:", tf, nextIp(true));
            g.DrawString("\uE000 \uE001 \uE010 \uE011 \uE012 \uE013 \uE014 \uE015", tf1, nextIp(false));

            g.DrawString("Arrows:", tf, nextIp(true));
            g.DrawString("\u2190 \u2191 \u2192 \u2193 \u21B0 \u21E6 \u21CB \u21A9", tf1, nextIp(false));

            g.DrawString("Dingbats:", tf, nextIp(true));
            g.DrawString("\u2714 \u2717 \u275B \u275C \u2706 \u2707 \u2708 \u2709", tf1, nextIp(false));

            g.DrawString("Braille Patterns:", tf, nextIp(true));
            g.DrawString("\u2830 \u2831 \u2832 \u2833 \u2834 \u2835 \u2836 \u2837", tf1, nextIp(false));

            g.DrawString("Geometric Shapes:", tf, nextIp(true));
            g.DrawString("\u25D0 \u25D1 \u25D2 \u25D3 \u25A4 \u25F0 \u25BC \u25CE", tf1, nextIp(false));

            g.DrawString("Latin Extended A:", tf, nextIp(true));
            g.DrawString("\u0100 \u0101 \u0102 \u0103 \u0104 \u0105 \u0106 \u0107", tf1, nextIp(false));

            g.DrawString("Miscellaneous Symbols:", tf, nextIp(true));
            g.DrawString("\u2600 \u2601 \u2602 \u2603 \u2604 \u2605 \u2606 \u2607 \u2608 \u2609 \u2614 \u2615 \u26F0", tf1, nextIp(false));

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