Ligatures.vb
C# VB
'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.IOImports System.DrawingImports GrapeCity.Documents.PdfImports GrapeCity.Documents.TextImports GCTEXT = GrapeCity.Documents.Text
'' Ligatures (joining two or more letters into a single glyph) are supported by DsPdf,'' provided the selected font supports them, and the corresponding font feature is on.'' For the complete list of font features see featurelist.htm.'' See also FontFeatures.Public Class Ligatures Function CreatePDF(ByVal stream As Stream) As Integer '' The list of common Latin ligatures: Const latinLigatures = "fi, fj, fl, ff, ffi, ffl." '' Set up ligature-related font features: '' All ON: Dim allOn As FontFeature() = { New FontFeature(FeatureTag.clig, True), '' Contextual Ligatures New FontFeature(FeatureTag.dlig, True), '' Discretionary Ligatures New FontFeature(FeatureTag.hlig, True), '' Historical Ligatures New FontFeature(FeatureTag.liga, True), '' Standard Ligatures New FontFeature(FeatureTag.rlig, True) '' Required Ligatures } '' All OFF: Dim allOff As FontFeature() = { New FontFeature(FeatureTag.clig, False), New FontFeature(FeatureTag.dlig, False), New FontFeature(FeatureTag.hlig, False), New FontFeature(FeatureTag.liga, False), New FontFeature(FeatureTag.rlig, False) } Dim doc = New GcPdfDocument() Dim g = doc.NewPage().Graphics '' Text insertion point: Dim ip = New PointF(72, 72) Dim tf = New TextFormat() tf.Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "NotoSerif-Regular.ttf")) tf.FontSize = 20 g.DrawString($"Common Latin ligatures, font {tf.Font.FontFamilyName}", tf, ip) ip.Y += 36 '' Turn all ligature features OFF: tf.FontFeatures = allOff g.DrawString($"All ligature features OFF: {latinLigatures}", tf, ip) ip.Y += 36 '' Turn all ligature features ON: tf.FontFeatures = allOn g.DrawString($"All ligature features ON: {latinLigatures}", tf, ip) ip.Y += 72 '' Repeat with a different font: tf.Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "FoglihtenNo07.otf")) g.DrawString($"Common Latin ligatures, font {tf.Font.FontFamilyName}", tf, ip) ip.Y += 36 '' Turn all ligature features OFF: tf.FontFeatures = allOff g.DrawString($"All ligature features OFF: {latinLigatures}", tf, ip) ip.Y += 36 '' Turn all ligature features ON: tf.FontFeatures = allOn g.DrawString($"All ligature features ON: {latinLigatures}", tf, ip) '' '' Done: doc.Save(stream) Return doc.Pages.Count End FunctionEnd Class