VectSharp 2.5.0
A light library for C# vector graphics
Loading...
Searching...
No Matches
VectSharp.FormattedText Class Reference

Represents a run of text that should be drawn with the same style. More...

Public Member Functions

 FormattedText (string text, Font font, Script script=Script.Normal, Brush brush=null)
 Creates a new FormattedText instance with the specified text , font , script position and brush . More...
 

Static Public Member Functions

static IEnumerable< FormattedTextFormat (string text, Font normalFont, Font boldFont, Font italicFont, Font boldItalicFont, Brush defaultBrush=null)
 Parse the formatting information contained in a text string into a collection of FormattedText objects. More...
 
static IEnumerable< FormattedTextFormat (string text, FontFamily.StandardFontFamilies fontFamily, double fontSize, bool defaultUnderline=false, Brush defaultBrush=null)
 Parse the formatting information contained in a text string into a collection of FormattedText objects, using fonts from a standard font family. More...
 

Properties

string Text [get]
 Represents the text represented by this instance. More...
 
Font Font [get]
 Represents the font that should be used to draw the text. More...
 
Script Script [get]
 Represents the position of the text. More...
 
Brush Brush [get]
 Represents the brush that should be used to draw the text. If this is null, the default brush is used. More...
 

Detailed Description

Represents a run of text that should be drawn with the same style.

Definition at line 50 of file FormattedText.cs.

Constructor & Destructor Documentation

◆ FormattedText()

VectSharp.FormattedText.FormattedText ( string  text,
Font  font,
Script  script = Script.Normal,
Brush  brush = null 
)

Creates a new FormattedText instance with the specified text , font , script position and brush .

Parameters
textThe text that will be contained in the new FormattedText.
fontThe font that will be used by the new FormattedText.
scriptThe script position of the new FormattedText.
brushThe brush that will be used by the new FormattedText.

Definition at line 79 of file FormattedText.cs.

Member Function Documentation

◆ Format() [1/2]

static IEnumerable< FormattedText > VectSharp.FormattedText.Format ( string  text,
Font  normalFont,
Font  boldFont,
Font  italicFont,
Font  boldItalicFont,
Brush  defaultBrush = null 
)
static

Parse the formatting information contained in a text string into a collection of FormattedText objects.

Parameters
textThe string containing formatting information. Format information is specified using HTML-like tags:
  • <b></b> or <strong></strong> are used for bold text;
  • <i></i> or <em></em> are used for text in italics;
  • <u></u> are used for underlined text;
  • <sup></sup> and <sub></sub> are used, respectively, for superscript and subscript text;
  • <#COLOUR></#> is used to specify the colour of the text, where COLOUR is a CSS colour string (e.g. <#red>, <#0080FF>, or <#rgba(128, 80, 52, 0.5)>).
normalFontThe font that will be used for text that is neither bold nor italic.
boldFontThe font that will be used for text that is bold. Note that this does not necessarily have to be a bold font; this is just the font that is applied to text contained within <b></b> tags.
italicFontThe font that will be used for text that is in italics. Note that this does not necessarily have to be an italic font; this is just the font that is applied to text contained within <i></i> tags.
boldItalicFontThe font that will be used for text that is both in bold and in italics.
defaultBrushThe default Brush that will be used for text runs that do not specify a colour. If this is null, the default Brush will be the one specified in the painting call.
Returns
A lazy collection of FormattedText objects. Note that every enumeration of this collection causes the text to be parsed again; if you need to enumerate this collection more than once, you should probably convert it e.g. to a List<T>.

Definition at line 105 of file FormattedText.cs.

◆ Format() [2/2]

static IEnumerable< FormattedText > VectSharp.FormattedText.Format ( string  text,
FontFamily.StandardFontFamilies  fontFamily,
double  fontSize,
bool  defaultUnderline = false,
Brush  defaultBrush = null 
)
static

Parse the formatting information contained in a text string into a collection of FormattedText objects, using fonts from a standard font family.

Parameters
textThe string containing formatting information. Format information is specified using HTML-like tags:
  • <b></b> or <strong></strong> are used for bold text;
  • <i></i> or <em></em> are used for text in italics;
  • <u></u> are used for underlined text;
  • <sup></sup> and <sub></sub> are used, respectively, for superscript and subscript text;
  • <#COLOUR></#> is used to specify the colour of the text, where COLOUR is a CSS colour string (e.g. <#red>, <#0080FF>, or <#rgba(128, 80, 52, 0.5)>).
fontFamilyThe font family from which the fonts will be created. If this is a regular font family, the bold, italic and bold-italic versions of the font will be used for the formatted text. Otherwise, the relevant font styles will be toggled (e.g. if the supplied font family is bold, then regular text in the formatted string will be displayed as bold, while bold text in the formatted string will be displayed as regular text).
fontSizeThe size of the fonts to use.
defaultUnderlineDetermines whether text should be underlined by default. This is toggled by <u></u> tags.
defaultBrushThe default Brush that will be used for text runs that do not specify a colour. If this is null, the default Brush will be the one specified in the painting call.
Returns
A lazy collection of FormattedText objects. Note that every enumeration of this collection causes the text to be parsed again; if you need to enumerate this collection more than once, you should probably convert it e.g. to a List<T>.

Definition at line 287 of file FormattedText.cs.

Property Documentation

◆ Brush

Brush VectSharp.FormattedText.Brush
get

Represents the brush that should be used to draw the text. If this is null, the default brush is used.

Definition at line 70 of file FormattedText.cs.

◆ Font

Font VectSharp.FormattedText.Font
get

Represents the font that should be used to draw the text.

Definition at line 60 of file FormattedText.cs.

◆ Script

Script VectSharp.FormattedText.Script
get

Represents the position of the text.

Definition at line 65 of file FormattedText.cs.

◆ Text

string VectSharp.FormattedText.Text
get

Represents the text represented by this instance.

Definition at line 55 of file FormattedText.cs.


The documentation for this class was generated from the following file: