Surrogates.vb
'' 完毕:
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text
'' 此示例呈现各种有趣的 Unicode 字符
'' 包括代理对。它还隐式地使用自动
'' GcDocs.Pdf 中内置字体后备(字体替换)功能。
'' 请注意,此示例可能会在不同的情况下产生不同的结果
'' 系统,因为它依赖于系统提供的后备字体。
'' 有关此示例的平台和系统独立版本,请参阅SurrogatesPort。
'' 另请参阅FontFallbacks。
Public Class Surrogates
Function CreatePDF(ByVal stream As Stream) As Integer
Dim doc = New GcPdfDocument()
Dim g = doc.NewPage().Graphics
'' 对于本示例中演示的大多数“有趣”字符,
'' 将自动使用@fallback字体(请参阅@{FontFallbacks}),
'' 所以我们可以使用标准字体作为标题:
Dim font = StandardFonts.Helvetica
Dim tf = New TextFormat() With {.Font = font, .FontSize = 12}
Dim tf1 = New TextFormat(tf) With {.FontSize = 14}
g.DrawString("Some Interesting Unicode Characters (relies on system fallbacks)",
New TextFormat(tf) With {.Underline = True, .FontSize = tf.FontSize + 2},
New RectangleF(0, 36, doc.PageSize.Width, Single.MaxValue),
TextAlignment.Center)
'' 设置文本插入点及其高级功能:
Dim ip = New PointF(72, 54)
Dim nextIp As Func(Of Boolean, PointF) =
Function(caption_ As Boolean)
ip.Y += If(caption_, 30, 20)
Return ip
End Function
'' 绘制字符串:
g.DrawString("Surrogate Pairs:", tf, nextIp(True))
g.DrawString($"{ChrW(&HD867)}{ChrW(&HDEDB)} {ChrW(&HD840)}{ChrW(&HDC0B)} {ChrW(&HD834)}{ChrW(&HDD1E)} {ChrW(&HD834)}{ChrW(&HDD61)} {ChrW(&HD83D)}{ChrW(&HDC04)}", tf1, nextIp(False))
g.DrawString("Currency Symbols:", tf, nextIp(True))
g.DrawString($"{ChrW(&H24)} {ChrW(&H20A0)} {ChrW(&H20A1)} {ChrW(&H20A2)} {ChrW(&H20A3)} {ChrW(&H20A4)} {ChrW(&H20AC)} {ChrW(&H20B9)} {ChrW(&H20BD)}", tf1, nextIp(False))
g.DrawString("Mathematical Operators:", tf, nextIp(True))
g.DrawString($"{ChrW(&H221A)} {ChrW(&H222B)} {ChrW(&H2211)} {ChrW(&H2210)} {ChrW(&H2264)} {ChrW(&H2265)} {ChrW(&H2202)} {ChrW(&H2208)}", tf1, nextIp(False))
g.DrawString("CJK Ideographs Extension A:", tf, nextIp(True))
g.DrawString($"{ChrW(&H3400)} {ChrW(&H3401)} {ChrW(&H3402)} {ChrW(&H3403)} {ChrW(&H3404)} {ChrW(&H3405)} {ChrW(&H3406)} {ChrW(&H3407)}", tf1, nextIp(False))
g.DrawString("Letterlike Symbols:", tf, nextIp(True))
g.DrawString($"{ChrW(&H2110)} {ChrW(&H2111)} {ChrW(&H2112)} {ChrW(&H2113)} {ChrW(&H2114)} {ChrW(&H2115)} {ChrW(&H211B)} {ChrW(&H211C)}", tf1, nextIp(False))
g.DrawString("Private Use Area:", tf, nextIp(True))
g.DrawString($"{ChrW(&HE000)} {ChrW(&HE001)} {ChrW(&HE010)} {ChrW(&HE011)} {ChrW(&HE012)} {ChrW(&HE013)} {ChrW(&HE014)} {ChrW(&HE015)}", tf1, nextIp(False))
g.DrawString("Arrows:", tf, nextIp(True))
g.DrawString($"{ChrW(&H2190)} {ChrW(&H2191)} {ChrW(&H2192)} {ChrW(&H2193)} {ChrW(&H21B0)} {ChrW(&H21E6)} {ChrW(&H21CB)} {ChrW(&H21A9)}", tf1, nextIp(False))
g.DrawString("Dingbats:", tf, nextIp(True))
g.DrawString($"{ChrW(&H2714)} {ChrW(&H2717)} {ChrW(&H275B)} {ChrW(&H275C)} {ChrW(&H2706)} {ChrW(&H2707)} {ChrW(&H2708)} {ChrW(&H2709)}", tf1, nextIp(False))
g.DrawString("Braille Patterns:", tf, nextIp(True))
g.DrawString($"{ChrW(&H2830)} {ChrW(&H2831)} {ChrW(&H2832)} {ChrW(&H2833)} {ChrW(&H2834)} {ChrW(&H2835)} {ChrW(&H2836)} {ChrW(&H2837)}", tf1, nextIp(False))
g.DrawString($"Geometric Shapes:", tf, nextIp(True))
g.DrawString($"{ChrW(&H25D0)} {ChrW(&H25D1)} {ChrW(&H25D2)} {ChrW(&H25D3)} {ChrW(&H25A4)} {ChrW(&H25F0)} {ChrW(&H25BC)} {ChrW(&H25CE)}", tf1, nextIp(False))
g.DrawString("Latin Extended A:", tf, nextIp(True))
g.DrawString($"{ChrW(&H100)} {ChrW(&H101)} {ChrW(&H102)} {ChrW(&H103)} {ChrW(&H104)} {ChrW(&H105)} {ChrW(&H106)} {ChrW(&H107)}", tf1, nextIp(False))
g.DrawString("Miscellaneous Symbols:", tf, nextIp(True))
g.DrawString($"{ChrW(&H2600)} {ChrW(&H2601)} {ChrW(&H2602)} {ChrW(&H2603)} {ChrW(&H2604)} {ChrW(&H2605)} {ChrW(&H2606)} " +
$"{ChrW(&H2607)} {ChrW(&H2608)} {ChrW(&H2609)} {ChrW(&H2614)} {ChrW(&H2615)} {ChrW(&H26F0)}", tf1, nextIp(False))
''
'' 完毕:
doc.Save(stream)
Return doc.Pages.Count
End Function
End Class