UnicodeRanges.vb
  1. ''
  2. '' This code is part of Document Solutions for PDF demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports GrapeCity.Documents.Pdf
  8. Imports GrapeCity.Documents.Text
  9.  
  10. '' This sample lists Unicode ranges available in each system font.
  11. public class UnicodeRanges
  12. Function CreatePDF(ByVal stream As Stream) As Integer
  13. '' Setup:
  14. Dim doc = New GcPdfDocument()
  15. Dim tl = New TextLayout(72) With {
  16. .MaxWidth = doc.PageSize.Width,
  17. .MaxHeight = doc.PageSize.Height,
  18. .MarginAll = 72
  19. }
  20. tl.DefaultFormat.FontSize = 7
  21. Dim tfH = New TextFormat() With {.Font = StandardFonts.TimesBold, .FontSize = 12}
  22. Dim tfP = New TextFormat() With {.Font = StandardFonts.Times, .FontSize = 11}
  23.  
  24. '' Loop through all system fonts,
  25. '' list Unicode ranges provided by each font:
  26. For Each font In FontCollection.SystemFonts
  27. tl.AppendLine($"{font.FontFileName} [{font.FullFontName}] [{font.FontFamilyName}]", tfH)
  28. Dim shot = font.CreateFontTables(TableTag.OS2)
  29. tl.AppendLine(shot.GetUnicodeRanges(), tfP)
  30. tl.AppendLine()
  31. Next
  32.  
  33. '' Split and render TextLayout as shown in the PaginatedText sample:
  34. Dim tso = New TextSplitOptions(tl) With {
  35. .MinLinesInFirstParagraph = 2,
  36. .MinLinesInLastParagraph = 2
  37. }
  38. tl.PerformLayout(True)
  39. While True
  40. Dim rest As TextLayout = Nothing
  41. Dim SplitResult = tl.Split(tso, rest)
  42. doc.Pages.Add().Graphics.DrawTextLayout(tl, PointF.Empty)
  43. If SplitResult <> SplitResult.Split Then
  44. Exit While
  45. End If
  46. tl = rest
  47. End While
  48. ''
  49. '' Done:
  50. doc.Save(stream)
  51. Return doc.Pages.Count
  52. End Function
  53. End Class
  54.