[]
Represents one or more paragraphs of multi-formatted text. Provides text analysis and layout functionality.
public class TextLayout
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Initializes a new instance of the TextLayout class with Resolution set to 72 graphic units per inch.
[Obsolete("Instead, use the constructor with explicit 'resolution' parameter, or the GcGraphics.CreateTextLayout() method.", false)]
public TextLayout()
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Initializes a new instance of the TextLayout class.
If a TextLayout is created to be used with a GrapeCity.Documents.Drawing.GcGraphics, it is recommended to use the GrapeCity.Documents.Drawing.GcGraphics.CreateTextLayout method instead, as it ensures that properties such as Resolution and FontCollection are set up properly to be used with the graphics.
public TextLayout(float resolution)
resolution
floatSpecifies the resolution (graphic units per inch).
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether the line spacing should be added after the last line of text. The default is false.
public bool AddSpacingAfterLastLine { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether to delay full text alignment till when any of the Split* methods is called.
Do not use this property unless you are calling any of the Split* methods to render the text.
[Obsolete("This property is not used anymore. It is always equal to true.")]
public bool AlignmentDelayToSplit { get; set; }
By default this property is false, and the text is completely aligned by the PerformLayout(bool) method. Setting this property to true delays complete alignment (e.g. justification) till one of the Split* methods is called. This improves performance when dealing with large amounts of text that is split between pages or columns, as it avoids aligning portions of text that will need to be re-aligned later anyway.
Gets or sets a value indicating whether long words can overhang beyond the layout box bounds. The default is false.
public bool AllowOverhangingWords { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the list of anchored objects.
public IReadOnlyList<AnchoredObject> AnchoredObjects { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array with bidi levels of the code points.
public byte[] BidiLevels { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets whether the whole first line of a paragraph with indentation can be skipped. The default is true.
public bool CanSkipFirstLineWithIndentation { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array mapping code points to glyphs.
public GlyphInfo[] ClusterMap { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the number of code points.
public int CodePointCount { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array of CodePointFlags, one for each code point.
public CodePointFlags[] CodePointFlags { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array of UTF-32 characters (code points). Only the first CodePointCount elements should be taken into account.
public int[] CodePoints { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the width of the layout box measured from the left margin (for positive values) or from the right margin (for negative values), in graphic units.
public float? ColumnWidth { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the height of the formatted text, in graphic units.
public float ContentHeight { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets a value indicating whether the height of the formatted text fits in the specified MaxHeight.
public bool ContentHeightFitsInBounds { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the height of the formatted text, taking into account the trailing whitespace at the end of each line, in graphic units.
public float ContentHeightIncludingTrailingWhitespace { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the rectangle containing the formatted text, in graphic units.
public RectangleF ContentRectangle { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the width of the formatted text, in graphic units.
public float ContentWidth { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets a value indicating whether the width of the formatted text fits in the specified MaxWidth.
public bool ContentWidthFitsInBounds { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the width of the formatted text, taking into account the trailing whitespace at the end of each line, in graphic units.
public float ContentWidthIncludingTrailingWhitespace { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Get the rectangle of the formatted text, taking into account the trailing whitespace at the end of each line.
public RectangleF ContentWithWhitespaceBounds { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the X coordinate of the rectangle containing the formatted text, in graphic units.
public float ContentX { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the Y coordinate of the rectangle containing the formatted text, in graphic units.
public float ContentY { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the default text format for the current text layout.
public TextFormat DefaultFormat { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the spacing between the default tab stops, in graphic units.
public float DefaultTabStops { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a UTF-32 character code used as a delimiter that signals the beginning of the portion of text to be preserved (for text trimming).
public int DelimiterCharCode { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the delimiter count, counting from the end of the text, to preserve text from (for text trimming).
public int DelimiterCharCount { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a UTF-32 code of the omission sign (ellipsis character) for text trimming.
Setting this property to 0 prevents the ellipsis character from showing.
public int EllipsisCharCode { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the indent of the first line after paragraph separator, in graphic units.
public float FirstLineIndent { get; set; }
Positive value applies indentation to the first line, negative value applies indentation to all lines except the first one.
Gets or sets a value indicating whether the first line of text is the start of paragraph. The default is true.
public bool FirstLineIsStartOfParagraph { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the flow direction (how lines of text are placed relative to one another).
public FlowDirection FlowDirection { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the custom font collection used for searching fonts and font fallbacks.
public FontCollection FontCollection { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value specifying the scope for searching fallback fonts for the glyphs missing in the font defined in TextFormat.
public FontFallbackScope FontFallbackScope { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the uniform scale factor for all fonts used in the current text layout.
Valid values are from 0.001 to 1000. The default is 1.
public float FontScaleFactor { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array of TextFormat objects, one for each code point.
public TextFormat[] Formats { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array with general classification of the code points.
public GeneralCategory[] GeneralCategories { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the number of resulting glyphs.
public int GlyphCount { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the linked list with each glyph info.
public GlyphInfo GlyphLinkedList { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array mapping code points to glyph runs.
public GlyphRun[] GlyphRunMap { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether the ideographic baseline should be used instead of the Roman baseline for hieroglyph characters. The default is false.
public bool HonorIdeographicBaseline { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether line spacing for the last line is considered a part of the layout content. The default is false.
public bool HonorLastLineSpacing { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether the trailing line break causes a blank line to be added to the output text layout. The default is false.
public bool HonorTrailingLineBreak { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the list of inline objects.
public IReadOnlyList<InlineObject> InlineObjects { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
public List<Inline> Inlines { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the maximum white space extension factor before applying extension to other characters when text is justified.
Valid values are from 0 to 10000. The default is 2.5.
public float JustifiedSpaceExtension { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the white space shrinking factor when text is justified.
Valid values are from 0.0 to 1.0. The default is 0.2.
public float JustifiedSpaceShrinking { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the maximum text extension factor when text is justified.
Valid values are from 0 to 10000. The default is 0.3.
public float JustifiedTextExtension { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether for paragraphs that have TextAlignment set to Distributed, the last line will be justified (typical in East Asian typography).
This property has effect only for horizontal text, and only if TextExtensionStrategy is set to EastAsianExcel or Excel.
The default is false.
public bool JustifyLastLine { get; set; }
Setting this property to true allows implementing text alignment that is similar to "Justify distributed" mode available in East Asian versions of MS Excel.
Gets or sets a value indicating whether the last line of text is the end of paragraph. The default is true.
public bool LastLineIsEndOfParagraph { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets a value indicating if PerformLayout(bool) method was executed at least once.
public bool LayoutPerformed { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value specifying the line breaking algorithm.
The default is Unicode.
public LineBreakingRules LineBreakingRules { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether the typographic line gap should be added before the first line of text. The default is false.
public bool LineGapBeforeFirstLine { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the list of text lines after executing the PerformLayout(bool) method.
public IReadOnlyList<TextLine> Lines { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the minimum number of lines not using hyphens after breaking a word across lines and displaying a visible hyphen at the position of soft hyphen.
The default is zero.
public int LinesBetweenConsecutiveHyphens { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the scaling factor to be applied to the computed line height.
Valid values are from 0 to 1000. The default is 1.
public float LineSpacingScaleFactor { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets all margins of the layout box, in graphic units.
Returns null if the margins have different values.
public float? MarginAll { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the bottom margin of the layout box, in graphic units.
public float MarginBottom { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the left margin of the layout box, in graphic units.
public float MarginLeft { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the right margin of the layout box, in graphic units.
public float MarginRight { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the top margin of the layout box, in graphic units.
public float MarginTop { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the height of the layout box, in graphic units.
public float? MaxHeight { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the maximum fraction of the last line's height overflowing beyond the layout bounds for that line not to be truncated. The default is 0 (last line must completely fit within the layout bounds). Valid values are from 0 to 1. This property does not affect values returned by ContentHeightFitsInBounds or ContentWidthFitsInBounds. This property is ignored if ObjectRects is not null.
public float MaxLastLineOverflowFactor { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the width of the layout box, in graphic units.
public float? MaxWidth { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the explicit minimal distance between lines, in graphic units.
public float? MinimalLineSpacing { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether justified or distributed text alignment should be applied as if the SimplifiedWordBreak is always false. In other words, when this property is set to true the value of SimplifiedWordBreak does not affect the text alignment rules, it affects only the line breaking behavior.
The default is false.
[Obsolete("Use the TextExtensionStrategy property instead.")]
public bool NoExcelAlignment { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the list of areas occupied by embedded objects.
public List<ObjectRect> ObjectRects { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the alignment of paragraphs along the flow direction axis.
public ParagraphAlignment ParagraphAlignment { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the additional spacing between paragraphs, in graphic units.
public float ParagraphSpacing { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the resolution (graphic units per inch) used by the current text layout.
public float Resolution { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether the fonts should be searched in the custom collection only, if any specified. The default is false.
public bool RestrictedFontLookup { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the base direction for horizontal and sideways text. The default is false.
public bool RightToLeft { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether sideways text should be rotated counterclockwise. The default is false.
public bool RotateSidewaysCounterclockwise { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the height of the layout box measured from the top margin (for positive values) or from the bottom margin (for negative values), in graphic units.
public float? RowHeight { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array of ScriptCode's, one for each code point.
public ScriptCode[] ScriptCodes { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the array of ScriptTag's, one for each code point.
public ScriptTag[] ScriptTags { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether to use simplified text alignment rules. In particular, the same rules will be applied to narrow and wide (East Asian) characters.
This property has effect only for horizontal text, and only if SimplifiedWordBreak is true and NoExcelAlignment is false.
The default is false.
[Obsolete("Use the TextExtensionStrategy property instead.")]
public bool SimplifiedAlignment { get; set; }
Setting this property to true allows implementing text alignments that are similar to "Justify" and "Distributed" modes available in English version of MS Excel.
Gets or sets a value indicating whether to use simplified rules when determining word boundaries and line breaks.
Setting this property to true prevents word breaking on certain non-whitespace characters to make word breaking behavior similar to that of MS Excel.
The default is false.
[Obsolete("Use the LineBreakingRules and WordBoundaryRules properties instead.")]
public bool SimplifiedWordBreak { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a UTF-32 character code used as replacement for soft hyphen characters (0x00AD) at ends of lines when breaking words across lines.
The default is 0x002D (the Unicode hyphen-minus character).
Setting this to 0 breaks words without showing any visible hyphen character.
Setting this to -1 prevents breaking words at soft hyphens.
Note that if this property is changed, either RecalculateGlyphs() or PerformLayout(bool) with true as the parameter must be called for the changes to be processed correctly.public int SoftHyphenReplacementCharCode { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the first code point index of the current split rest, if this TextLayout contains the rest lines after calling the Split(TextSplitOptions, out TextLayout) or SplitAndBalance(PageSplitArea[], TextSplitOptions, out TextLayout) methods.
public int SplitCodePointIndex { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating if shaping and positioning of graphemes should be skipped for the sake of speed. The default is false.
public bool SuppressShaping { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the list of tab stops.
public List<TabStop> TabStops { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the alignment of text along the reading direction axis.
public TextAlignment TextAlignment { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value specifying the rules used for justified text extension. If LineBreakingRules is Simplified, this property also affects the rules used for line breaking.
The default is Default.
public TextExtensionStrategy TextExtensionStrategy { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the text granularity used to trim text overflowing the layout box.
public TrimmingGranularity TrimmingGranularity { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets the explicit distance between lines, in graphic units.
public float? UniformLineSpacing { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating if the linked and fallback fonts have to be embeddable. The default is false.
public bool UseEmbeddableFonts { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value indicating whether the following scripts should use their old tags: Bengali, Devanagari, Gujarati, Gurmukhi, Kannada, Malayalam, Myanmar, Odia, Tamil, Telugu. The default is false.
public bool UseOldScriptTags { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets a value indicating whether the FlowDirection was vertical when RecalculateGlyphs() was last called.
public bool VerticalDirection { get; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value specifying the word breaking algorithm.
The default is Unicode.
public WordBoundaryRules WordBoundaryRules { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets or sets a value specifying how text lines are broken to avoid text overflowing the layout box.
public WrapMode WrapMode { get; set; }
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds an anchored object, or a copy of it, to the end of the Inlines collection.
If adding the same anchored object multiple times, make sure to pass true as the addCopy
parameter.
public AnchoredObject Append(AnchoredObject anchoredObject, bool addCopy = true)
anchoredObject
AnchoredObjectThe anchored object to add or copy.
addCopy
boolIf true, a copy of the anchoredObject
will be created and added.
Otherwise, the passed object itself will be added.
The appended anchored object.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds an inline object, or a copy of it, to the end of the Inlines collection.
If adding the same inline object multiple times, make sure to pass true as the addCopy
parameter.
public InlineObject Append(InlineObject inlineObject, bool addCopy = true)
inlineObject
InlineObjectThe inline object to add or copy.
addCopy
boolIf true, a copy of the inlineObject
will be created and added.
Otherwise, the passed object itself will be added.
The appended inline object.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with the specified format to the end of the Inlines collection.
public TextRun Append(int[] codePoints, TextFormat format, IGcTag gcTag)
codePoints
int[]An array of UTF-32 characters (code points).
format
TextFormatThe text format to use.
gcTag
IGcTagThe tag associated with the text.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with the specified format to the end of the Inlines collection.
public TextRun Append(int[] codePoints, TextFormat format)
codePoints
int[]An array of UTF-32 characters (code points).
format
TextFormatThe text format to use.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with the specified format to the end of the Inlines collection.
public TextRun Append(int[] codePoints, int startIndex, int count, TextFormat format, IGcTag gcTag)
codePoints
int[]An array of UTF-32 characters (code points).
startIndex
intIndex of the first code point in the subrange.
count
intNumber of code points in the subrange.
format
TextFormatThe text format to use.
gcTag
IGcTagThe tag associated with the text.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with the specified format to the end of the Inlines collection.
public TextRun Append(int[] codePoints, int startIndex, int count, TextFormat format)
codePoints
int[]An array of UTF-32 characters (code points).
startIndex
intIndex of the first code point in the subrange.
count
intNumber of code points in the subrange.
format
TextFormatThe text format to use.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with default formatting to the end of the Inlines collection.
public TextRun Append(int[] codePoints, int startIndex, int count)
codePoints
int[]An array of UTF-32 characters (code points).
startIndex
intIndex of the first code point in the subrange.
count
intNumber of code points in the subrange.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with default formatting to the end of the Inlines collection.
public TextRun Append(int[] codePoints)
codePoints
int[]An array of UTF-32 characters (code points).
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with the specified format to the end of the Inlines collection.
public TextRun Append(string text, TextFormat format)
text
stringThe text to append.
format
TextFormatThe text format to use.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with default formatting to the end of the Inlines collection.
public TextRun Append(string text)
text
stringThe text to append.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds an anchored object with specified dimensions to the end of the Inlines collection.
public AnchoredObject AppendAnchoredObject(float width, float height, bool wrapWithText)
width
floatThe object's width.
height
floatThe object's height.
wrapWithText
boolIndicates whether to wrap the object with text.
The created AnchoredObject.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds an inline object with specified dimensions and formatting to the end of the Inlines collection.
public InlineObject AppendInlineObject(object obj, float width, float height, TextFormat format)
obj
objectThe object to add.
width
floatThe object's width.
height
floatThe object's height.
format
TextFormatFormatting associated with the object.
The created InlineObject.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds an inline object with specified dimensions to the end of the Inlines collection.
public InlineObject AppendInlineObject(object obj, float width, float height)
obj
objectThe object to add.
width
floatThe object's width.
height
floatThe object's height.
The created InlineObject.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a line break element to the end of the Inlines collection.
public LineBreak AppendLine()
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a line break element to the end of the Inlines collection.
public LineBreak AppendLine(TextFormat format)
format
TextFormatThe text format.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with the specified format, followed by a line break, to the end of the Inlines collection.
public LineBreak AppendLine(string text, TextFormat format)
text
stringThe text to append.
format
TextFormatThe text format.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a text run with default formatting, followed by a line break, to the end of the Inlines collection.
public LineBreak AppendLine(string text)
text
stringThe text to append.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a special character (0x2029) that causes a paragraph break but prevents a page break between paragraphs (GrapeCity specifics).
public TextRun AppendParagraphBreak()
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a special character (0x2029) that causes a paragraph break but prevents a page break between paragraphs (GrapeCity specifics).
public TextRun AppendParagraphBreak(TextFormat format)
format
TextFormatThe text format.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Appends a form feed character ('\f', character code 0x000C) to the text. This causes any text added after it to "not fit" - if the text layout is drawn, that text will not be rendered. If the Split() method is called, the text will be split at this point.
public TextRun AppendSectionBreak()
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Appends a form feed character ('\f', character code 0x000C) to the text. This causes any text added after it to "not fit" - if the text layout is drawn, that text will not be rendered. If the Split() method is called, the text will be split at this point.
public TextRun AppendSectionBreak(TextFormat format)
format
TextFormatThe text format.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a line separator character (0x2028) that causes a line break without ending the paragraph.
public TextRun AppendSoftBreak()
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adds a line separator character (0x2028) that causes a line break without ending the paragraph.
public TextRun AppendSoftBreak(TextFormat format)
format
TextFormatThe text format.
The created text run.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Adjusts the positions of content rectangle, inline and anchored objects by a specified amount.
public void ApplyOffset(float dx, float dy)
dx
floatThe offset along the horizontal direction.
dy
floatThe offset along the vertical direction.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Clears the current text layout, removing all text and formatting associated with individual text runs.
public void Clear()
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Creates a copy of the current TextLayout instance.
public TextLayout Clone(bool copyInlines = false, bool copyObjectRects = false)
copyInlines
boolIndicates whether to copy Inline objects with text data to the new instance of TextLayout.
copyObjectRects
boolIndicates whether to copy ObjectRect embedded objects to the new instance of TextLayout.
The newly created instance of TextLayout.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Gets the InlineObject at the specified code point index.
public InlineObject GetInlineObjectAt(int codePointIndex)
codePointIndex
intIn the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Returns the list of TextRect objects for the specified range of code points.
public IReadOnlyList<TextRect> GetTextRects(int codePointIndex, int codePointCount, bool withLineGap = false, bool withLineSpacing = false)
codePointIndex
intThe code point index of the range start.
codePointCount
intThe number of code points in the range.
withLineGap
boolIndicates if the additional spacing before text lines should be included.
withLineSpacing
boolIndicates if the additional spacing after text lines should be included.
A read-only list of text rectangles.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Maps a character range to the corresponding code point range.
public bool MapCharRangeToCodePoints(ref int index, ref int count)
index
intInputs the character index of the range start, outputs the code point index of the range start.
count
intInputs the number of characters in the range, outputs the number of code points in the range.
True if the resulting range contains at least one code point, false otherwise.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Maps a code point range to the corresponding character range.
public bool MapCodePointsToCharRange(ref int index, ref int count)
index
intInputs the code point index of the range start, outputs the character index of the range start.
count
intInputs the number of code points in the range, outputs the number of characters in the range.
True if the resulting range contains at least one character, false otherwise.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Determines the coordinates for all lines and glyph runs. Optionally calls RecalculateGlyphs() prior to performing the layout.
public bool PerformLayout(bool recalculateGlyphsBeforeLayout = false)
recalculateGlyphsBeforeLayout
boolIf true, RecalculateGlyphs() will be called before performing the layout.
true if the whole text fits in the bounds of TextLayout, false if some text doesn't fit in bounds and one of the Split* methods must be executed to move the rest of the text into another TextLayout instance.
When all text and formatting have been specified on an instance of TextLayout, RecalculateGlyphs() must be called on it to convert characters to glyphs. After that, PerformLayout(false) can be called multiple times for different layout parameters (such as MaxWidth and MaxHeight to create different layouts of the same text.When only a single layout for each text is needed, the two calls can be shortened to just one PerformLayout(true) call for convenience.
Converts characters in the current TextLayout to glyphs, and performs text shaping.
In order to layout the text (e.g. when rendering it on a graphics), a call to this method must precede the call(s) to PerformLayout(bool), or alternatively the PerformLayout method should be called with true as the parameter.
public void RecalculateGlyphs()
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Resolves characters with ambiguous East Asian width to either narrow or wide.
protected virtual void ResolveAmbiguousEastAsianWidths(CodePointFlags[] cpFlags, int length)
cpFlags
CodePointFlags[]The source and destination array of CodePointFlags elements.
length
intNumber of code points.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Resolves the ambiguous AI, CJ, SA, SG, XX line-breaking classes.
protected virtual void ResolveAmbiguousLineBreakingClasses(LineBreakingClass[] lbClasses, int length)
lbClasses
LineBreakingClass[]The source and destination array of LineBreakingClass elements.
length
intNumber of code points.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Resolves the Inherited, Common, and Unknown script codes, if possible.
protected virtual void ResolveAmbiguousScriptCodes(ScriptCode[] scCodes, int length)
scCodes
ScriptCode[]The source and destination array of ScriptCode elements.
length
intNumber of UTF-32 code points in the analyzed range.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Fits all or the first portion of the current text layout into the current layout bounds.
If the whole text did not fit into the bounds, the rest is moved into a new
TextLayout instance specified by the output parameter rest
.
public SplitResult Split(TextSplitOptions splitOptions, out TextLayout rest)
splitOptions
TextSplitOptionsOptions controlling how text is split.
rest
TextLayoutOutput: a new TextLayout instance containing the text that did not fit into the bounds specified by the current TextLayout.
A value indicating the result of splitting the current text layout.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Fits all or the first portion of the current text layout into one or more layout areas (such as page columns).
If the whole text did not fit into the provided areas, the rest is moved into a new
TextLayout instance specified by the output parameter rest
.
If the whole text fits in the specified areas (i.e. rest
is empty), the content is equally distributed between all areas,
which in the case of page columns results in columns of equal height (balanced).
public SplitResult SplitAndBalance(PageSplitArea[] pageAreas, TextSplitOptions splitOptions, out TextLayout rest)
pageAreas
PageSplitArea[]The array of additional page areas that can be used to layout the text.
splitOptions
TextSplitOptionsOptions controlling how text is split.
rest
TextLayoutOutput: a new TextLayout instance containing the text that did not fit into the bounds specified by the current TextLayout.
A value indicating the result of splitting the current text layout.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Fits all or the first portion of the current text layout into one or more layout areas (such as page columns).
If the whole text did not fit into the provided areas, the rest is moved into a new
TextLayout instance specified by the output parameter rest
.
If the whole text fits in the specified areas (i.e. rest
is empty), the content is equally distributed between all areas,
which in the case of page columns results in columns of equal height (balanced).
public SplitResult SplitAndBalanceRef(PageSplitArea[] pageAreas, TextSplitOptions splitOptions, ref TextLayout rest)
pageAreas
PageSplitArea[]The array of additional page areas that can be used to layout the text.
splitOptions
TextSplitOptionsOptions controlling how text is split.
rest
TextLayoutRecipient for the text that did not fit in the current bounds and additional areas. If null, a new instance will be created and assigned to this parameter. If non-null, that TextLayout instance will be filled with the text that did not fit. When rendering large blocks of text, this improves performance by avoiding the need to initialize a new instance of a TextLayout for each split.
A value indicating the result of splitting the current text layout.
In the simplest scenario, these steps can be followed to render a text on a graphics object using TextLayout:
Fits all or the first portion of the current text layout into the current layout bounds.
If the whole text did not fit into the bounds, the rest is moved into the TextLayout
instance specified by the reference parameter rest
.
If it is null, a new TextLayout instance is created.
public SplitResult SplitRef(TextSplitOptions splitOptions, ref TextLayout rest)
splitOptions
TextSplitOptionsOptions controlling how text is split.
rest
TextLayoutRecipient for the text that did not fit in the current bounds. If null, a new instance will be created and assigned to this parameter. If non-null, that TextLayout instance will be filled with the text that did not fit. When rendering large blocks of text, this improves performance by avoiding the need to initialize a new instance of a TextLayout for each split.
A value indicating the result of splitting the current text layout.
Because initializing a new instance of the TextLayout class takes a relatively long time, reusing an existing instance can improve performance when rendering large amounts of text. This is why this method exists, and may be preferred over the Split(TextSplitOptions, out TextLayout) method. The typical use of this method would be:
GcPdfDocument doc = new GcPdfDocument();
// ...
TextLayout tl = new TextLayout();
// set up the text layout, add text to it...
TextSplitOptions to = new TextSplitOptions();
// set up text split options...
TextLayout rest = null;
// a loop rendering a long text layout:
while (true)
{
var splitResult = tl.SplitRef(to, ref rest);
doc.Pages.Add().Graphics.DrawTextLayout(tl, PointF.Empty);
if (splitResult != SplitResult.Split)
break;
var temp = tl;
tl = rest; // move on to the next portion of the text
rest = temp; // avoid re-initializing a new text layout, by re-using the old one
}
Note that in this code, the ONLY point of swapping 'rest' and 'tl' is to provide an existing instance of a TextLayout class to the next SplitRef call so that a new instance does not need to be initialized. No actual data from the old text layout is (re)used, so functionally the last three lines can be replaced with 'tl = rest; rest = null;' assignments.
If a portion of the text content does not fit into the current layout bounds, removes that portion so that the remaining text fits.
If the text is truncated and lastLineTrimming
is not None,
ellipsis (specified by EllipsisCharCode) is appended to the last line
to indicate that it was trimmed.
public bool Truncate(TrimmingGranularity lastLineTrimming = TrimmingGranularity.None)
lastLineTrimming
TrimmingGranularityThe text granularity used when trimming the last line of text.
true if at least some text remains that fits into the current layout bounds, false if the current layout did not contain any text or all text had to be removed.
Note that if there is only one line, and it does not fit into the available height, it is not removed, and this method returns true.