//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Text;usingGCTEXT = GrapeCity.Documents.Text;usingGCDRAW = GrapeCity.Documents.Drawing; namespaceDsPdfWeb.Demos.Basics{// 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.publicclassLigatures {publicintCreatePDF(Stream stream) {// The list of common Latin ligatures:conststringlatinLigatures = "fi, fj, fl, ff, ffi, ffl.";// Set up ligature-related font features:// All ON:FontFeature[] allOn = newFontFeature[] {newFontFeature(FeatureTag.clig, true), // Contextual LigaturesnewFontFeature(FeatureTag.dlig, true), // Discretionary LigaturesnewFontFeature(FeatureTag.hlig, true), // Historical LigaturesnewFontFeature(FeatureTag.liga, true), // Standard LigaturesnewFontFeature(FeatureTag.rlig, true), // Required Ligatures };// All OFF:FontFeature[] allOff = newFontFeature[] {newFontFeature(FeatureTag.clig, false),newFontFeature(FeatureTag.dlig, false),newFontFeature(FeatureTag.hlig, false),newFontFeature(FeatureTag.liga, false),newFontFeature(FeatureTag.rlig, false), };var doc = newGcPdfDocument();var g = doc.NewPage().Graphics;// Text insertion point:var ip = newPointF(72, 72);var tf = newTextFormat(); 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; } }}