Skip to main content

Character Shaping

Version: 10.0

Character Shaping

Character Shaping or Complex Text Layout (CTL) is the selection of the required shape of a character based on that character’s position within a word and its surrounding characters. Fonts that use characters shaping are supported however certain programming and deployment impacts must be considered. A simple example and other considerations are highlights below.

This example demonstrates how to enable character shaping when adding text using TextArea page element.

// Create a PDF Document
Document document = new Document();
// Create an OpenTypeFont object with useCharacterShaping parameter set to true.
OpenTypeFont charShapingFont = new OpenTypeFont("Path to .ttf or .otf font file", true);
// Create a page and add it to the document
Page page = new Page();
document.Pages.Add(page);
// Create and add a TextArea that uses the OpenTypeFont object.
TextArea area = new TextArea("Text requiring character shaping", 0, 0, 300, 30, charShapingFont, 18);
page.Elements.Add(area);
// Save the PDF
document.Draw(pdfFilePath);
'Create a PDF Document
Dim document As Document = New Document()
' Create an OpenTypeFont object with useCharacterShaping parameter set to true.
Dim charShapingFont As OpenTypeFont = New OpenTypeFont("Path to .ttf or .otf font file"", True)
' Create a Page and add it to the document
Dim page As Page = New Page()
document.Pages.Add(page)
' Create and add a TextArea that uses the OpenTypeFont object.
Dim area As TextArea = New TextArea("Text requiring character shaping", 0, 0, 300, 30, charShapingFont, 18)
page.Elements.Add(area)
' Save the PDF
document.Draw(pdfFilePath)

Considerations​

  • Enabling character shaping for an OpenTypeFont object will automatically determine the text’s direction (in other words the RightToLeft property will be ignored and automatically determined).
  • Using a character shaping enabled OpenTypeFont object in TextArea, will raise an exception if the TextArea.GetOverflowText() method is called.
  • Using the character shaping enabled OpenTypeFont object in Cell2, Cell2.Splittable property should be set to false.
  • Text extraction from the output PDF can yield incorrect output in some cases when the text was written with character shaping.
  • For character shaping native dll should be deployed in the project. For deployment information refer Referencing the Assembly and Deployment topic.