TextPath Class |
Namespace: Aspose.Words.Drawing
The TextPath type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | Bold |
True if the font is formatted as bold.
|
![]() ![]() | FitPath |
Defines whether the text fits the path of a shape.
|
![]() ![]() | FitShape |
Defines whether the text fits bounding box of a shape.
|
![]() ![]() | FontFamily |
Defines the family of the textpath font.
|
![]() ![]() | Italic |
True if the font is formatted as italic.
|
![]() ![]() | Kerning |
Determines whether kerning is turned on.
|
![]() ![]() | On |
Defines whether the text is displayed.
|
![]() ![]() | ReverseRows |
Determines whether the layout order of rows is reversed.
|
![]() ![]() | RotateLetters |
Determines whether the letters of the text are rotated.
|
![]() ![]() | SameLetterHeights |
Determines whether all letters will be the same height regardless of initial case.
|
![]() ![]() | Shadow |
Defines whether a shadow is applied to the text on a text path.
|
![]() | Size |
Defines the size of the font in points.
|
![]() ![]() | SmallCaps |
True if the font is formatted as small capital letters.
|
![]() ![]() | Spacing |
Defines the amount of spacing for text. 1 means 100%.
|
![]() ![]() | StrikeThrough |
True if the font is formatted as strikethrough text.
|
![]() ![]() | Text |
Defines the text of the text path.
|
![]() ![]() | TextPathAlignment |
Defines the alignment of text.
|
![]() ![]() | Trim |
Determines whether extra space is removed above and below the text.
|
![]() ![]() | Underline |
True if the font is underlined.
|
![]() ![]() | XScale |
Determines whether a straight textpath will be used instead of the shape path.
|
Name | Description | |
---|---|---|
![]() | Equals | (Inherited from Object.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | ToString | (Inherited from Object.) |
Use the TextPath property to access WordArt properties of a shape. You do not create instances of the TextPath class directly.
public void InsertTextPaths() { Document doc = new Document(); // Insert a WordArt object and capture the shape that contains it in a variable Shape shape = AppendWordArt(doc, "Bold & Italic", "Arial", 240, 24, Color.White, Color.Black, ShapeType.TextPlainText); // View and verify various text formatting settings shape.TextPath.Bold = true; shape.TextPath.Italic = true; Assert.False(shape.TextPath.Underline); Assert.False(shape.TextPath.Shadow); Assert.False(shape.TextPath.StrikeThrough); Assert.False(shape.TextPath.ReverseRows); Assert.False(shape.TextPath.XScale); Assert.False(shape.TextPath.Trim); Assert.False(shape.TextPath.SmallCaps); Assert.AreEqual(36.0, shape.TextPath.Size); Assert.AreEqual("Bold & Italic", shape.TextPath.Text); Assert.AreEqual(ShapeType.TextPlainText, shape.ShapeType); // Toggle whether or not to display text shape = AppendWordArt(doc, "On set to true", "Calibri", 150, 24, Color.Yellow, Color.Red, ShapeType.TextPlainText); shape.TextPath.On = true; shape = AppendWordArt(doc, "On set to false", "Calibri", 150, 24, Color.Yellow, Color.Red, ShapeType.TextPlainText); shape.TextPath.On = false; // Apply kerning shape = AppendWordArt(doc, "Kerning: VAV", "Times New Roman", 90, 24, Color.Orange, Color.Red, ShapeType.TextPlainText); shape.TextPath.Kerning = true; shape = AppendWordArt(doc, "No kerning: VAV", "Times New Roman", 100, 24, Color.Orange, Color.Red, ShapeType.TextPlainText); shape.TextPath.Kerning = false; // Apply custom spacing, on a scale from 0.0 (none) to 1.0 (default) shape = AppendWordArt(doc, "Spacing set to 0.1", "Calibri", 120, 24, Color.BlueViolet, Color.Blue, ShapeType.TextCascadeDown); shape.TextPath.Spacing = 0.1; // Rotate letters 90 degrees to the left, text is still laid out horizontally shape = AppendWordArt(doc, "RotateLetters", "Calibri", 200, 36, Color.GreenYellow, Color.Green, ShapeType.TextWave); shape.TextPath.RotateLetters = true; // Set the x-height to equal the cap height shape = AppendWordArt(doc, "Same character height for lower and UPPER case", "Calibri", 300, 24, Color.DeepSkyBlue, Color.DodgerBlue, ShapeType.TextSlantUp); shape.TextPath.SameLetterHeights = true; // By default, the size of the text will scale to always fit the size of the containing shape, overriding the text size setting shape = AppendWordArt(doc, "FitShape on", "Calibri", 160, 24, Color.LightBlue, Color.Blue, ShapeType.TextPlainText); Assert.True(shape.TextPath.FitShape); shape.TextPath.Size = 24.0; // If we set FitShape to false, the size of the text will defy the shape bounds and always keep the size value we set below // We can also set TextPathAlignment to align the text shape = AppendWordArt(doc, "FitShape off", "Calibri", 160, 24, Color.LightBlue, Color.Blue, ShapeType.TextPlainText); shape.TextPath.FitShape = false; shape.TextPath.Size = 24.0; shape.TextPath.TextPathAlignment = TextPathAlignment.Right; doc.Save(ArtifactsDir + "Shape.InsertTextPaths.docx"); } /// <summary> /// Insert a new paragraph with a WordArt shape inside it. /// </summary> private static Shape AppendWordArt(Document doc, string text, string textFontFamily, double shapeWidth, double shapeHeight, Color wordArtFill, Color line, ShapeType wordArtShapeType) { // Insert a new paragraph Paragraph para = (Paragraph)doc.FirstSection.Body.AppendChild(new Paragraph(doc)); // Create an inline Shape, which will serve as a container for our WordArt, and append it to the paragraph // The shape can only be a valid WordArt shape if the ShapeType assigned here is a WordArt-designated ShapeType // These types will have "WordArt object" in the description and their enumerator names will start with "Text..." Shape shape = new Shape(doc, wordArtShapeType); shape.WrapType = WrapType.Inline; para.AppendChild(shape); // Set the shape's width and height shape.Width = shapeWidth; shape.Height = shapeHeight; // These color settings will apply to the letters of the displayed WordArt text shape.FillColor = wordArtFill; shape.StrokeColor = line; // The WordArt object is accessed here, and we will set the text and font like this shape.TextPath.Text = text; shape.TextPath.FontFamily = textFontFamily; return shape; }