Detailed Description

Contains font attributes (font name, font size, color, and so on) for an object.

You do not create instances of the Font class directly. You just use Font to access the font properties of the various objects such as Run, Paragraph, Style, DocumentBuilder.

Examples

Shows how to insert a string surrounded by a border into a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->get_Border()->set_Color(System::Drawing::Color::get_Green());
builder->get_Font()->get_Border()->set_LineWidth(2.5);
builder->get_Font()->get_Border()->set_LineStyle(LineStyle::DashDotStroker);
builder->Write(u"Text surrounded by green border.");
doc->Save(ArtifactsDir + u"Border.FontBorder.docx");

Shows how to add a formatted run of text to a document using the object model.

auto doc = MakeObject<Document>();
// Create a new run of text
auto run = MakeObject<Run>(doc, u"Hello");
// Specify character formatting for the run of text
SharedPtr<Aspose::Words::Font> f = run->get_Font();
f->set_Name(u"Courier New");
f->set_Size(36);
f->set_HighlightColor(System::Drawing::Color::get_Yellow());
// Append the run of text to the end of the first paragraph
// in the body of the first section of the document
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(run);

Shows how to create and use a paragraph style with list formatting.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create a paragraph style and specify some formatting for it
SharedPtr<Style> style = doc->get_Styles()->Add(StyleType::Paragraph, u"MyStyle1");
style->get_Font()->set_Size(24);
style->get_Font()->set_Name(u"Verdana");
style->get_ParagraphFormat()->set_SpaceAfter(12);
// Create a list and make sure the paragraphs that use this style will use this list
style->get_ListFormat()->set_List(doc->get_Lists()->Add(ListTemplate::BulletDefault));
style->get_ListFormat()->set_ListLevelNumber(0);
// Apply the paragraph style to the current paragraph in the document and add some text
builder->get_ParagraphFormat()->set_Style(style);
builder->Writeln(u"Hello World: MyStyle1, bulleted list.");
// Change to a paragraph style that has no list formatting
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"Normal"));
builder->Writeln(u"Hello World: Normal.");
builder->get_Document()->Save(ArtifactsDir + u"Styles.ParagraphStyleBulletedList.docx");

#include <Aspose.Words.Cpp/Model/Text/Font.h>

+ Inheritance diagram for Aspose::Words::Font:

Public Member Functions

void ClearFormatting ()
 Resets to default font formatting. More...
 
bool get_AllCaps ()
 True if the font is formatted as all capital letters. More...
 
Color get_AutoColor ()
 Returns the present calculated color of the text (black or white) to be used for 'auto color'. If the color is not 'auto' then returns Color. More...
 
bool get_Bidi ()
 Specifies whether the contents of this run shall have right-to-left characteristics. More...
 
bool get_Bold ()
 True if the font is formatted as bold. More...
 
bool get_BoldBi ()
 True if the right-to-left text is formatted as bold. More...
 
SharedPtr< Borderget_Border ()
 Returns a Border object that specifies border for the font. More...
 
Color get_Color ()
 Gets or sets the color of the font. More...
 
bool get_ComplexScript ()
 Specifies whether the contents of this run shall be treated as complex script text regardless of their Unicode character values when determining the formatting for this run. More...
 
bool get_DoubleStrikeThrough ()
 True if the font is formatted as double strikethrough text. More...
 
bool get_Emboss ()
 True if the font is formatted as embossed. More...
 
EmphasisMark get_EmphasisMark ()
 Gets the emphasis mark applied to this formatting. More...
 
bool get_Engrave ()
 True if the font is formatted as engraved. More...
 
bool get_Hidden ()
 True if the font is formatted as hidden text. More...
 
Color get_HighlightColor ()
 Gets or sets the highlight (marker) color. More...
 
bool get_Italic ()
 True if the font is formatted as italic. More...
 
bool get_ItalicBi ()
 True if the right-to-left text is formatted as italic. More...
 
double get_Kerning ()
 Gets or sets the font size at which kerning starts. More...
 
double get_LineSpacing ()
 Returns line spacing of this font (in points). More...
 
int32_t get_LocaleId ()
 Gets or sets the locale identifier (language) of the formatted characters. More...
 
int32_t get_LocaleIdBi ()
 Gets or sets the locale identifier (language) of the formatted right-to-left characters. More...
 
int32_t get_LocaleIdFarEast ()
 Gets or sets the locale identifier (language) of the formatted Asian characters. More...
 
String get_Name ()
 Gets or sets the name of the font. More...
 
String get_NameAscii ()
 Returns or sets the font used for Latin text (characters with character codes from 0 (zero) through 127). More...
 
String get_NameBi ()
 Returns or sets the name of the font in a right-to-left language document. More...
 
String get_NameFarEast ()
 Returns or sets an East Asian font name. More...
 
String get_NameOther ()
 Returns or sets the font used for characters with character codes from 128 through 255. More...
 
bool get_NoProofing ()
 True when the formatted characters are not to be spell checked. More...
 
bool get_Outline ()
 True if the font is formatted as outline. More...
 
double get_Position ()
 Gets or sets the position of text (in points) relative to the base line. A positive number raises the text, and a negative number lowers it. More...
 
int32_t get_Scaling ()
 Gets or sets character width scaling in percent. More...
 
SharedPtr< Shadingget_Shading ()
 Returns a Shading object that refers to the shading formatting for the font. More...
 
bool get_Shadow ()
 True if the font is formatted as shadowed. More...
 
double get_Size ()
 Gets or sets the font size in points. More...
 
double get_SizeBi ()
 Gets or sets the font size in points used in a right-to-left document. More...
 
bool get_SmallCaps ()
 True if the font is formatted as small capital letters. More...
 
bool get_SnapToGrid ()
 Specifies whether the current font should use the document grid characters per line settings when laying out. More...
 
double get_Spacing ()
 Returns or sets the spacing (in points) between characters . More...
 
bool get_StrikeThrough ()
 True if the font is formatted as strikethrough text. More...
 
SharedPtr< Styleget_Style ()
 Gets or sets the character style applied to this formatting. More...
 
StyleIdentifier get_StyleIdentifier ()
 Gets or sets the locale independent style identifier of the character style applied to this formatting. More...
 
String get_StyleName ()
 Gets or sets the name of the character style applied to this formatting. More...
 
bool get_Subscript ()
 True if the font is formatted as subscript. More...
 
bool get_Superscript ()
 True if the font is formatted as superscript. More...
 
TextEffect get_TextEffect ()
 Gets or sets the font animation effect. More...
 
Underline get_Underline ()
 Gets or sets the type of underline applied to the font. More...
 
Color get_UnderlineColor ()
 Gets or sets the color of the underline applied to the font. More...
 
virtual const TypeInfoGetType () const override
 
bool HasDmlEffect (TextDmlEffect dmlEffectType)
 Checks if particular DrawingML text effect is applied. More...
 
virtual bool Is (const TypeInfo &target) const override
 
void set_AllCaps (bool value)
 Setter for get_AllCaps. More...
 
void set_Bidi (bool value)
 Setter for get_Bidi. More...
 
void set_Bold (bool value)
 Setter for get_Bold. More...
 
void set_BoldBi (bool value)
 Setter for get_BoldBi. More...
 
void set_Color (Color value)
 Setter for get_Color. More...
 
void set_ComplexScript (bool value)
 Setter for get_ComplexScript. More...
 
void set_DoubleStrikeThrough (bool value)
 Setter for get_DoubleStrikeThrough. More...
 
void set_Emboss (bool value)
 Setter for get_Emboss. More...
 
void set_EmphasisMark (EmphasisMark value)
 Sets the emphasis mark applied to this formatting. More...
 
void set_Engrave (bool value)
 Setter for get_Engrave. More...
 
void set_Hidden (bool value)
 Setter for get_Hidden. More...
 
void set_HighlightColor (Color value)
 Setter for get_HighlightColor. More...
 
void set_Italic (bool value)
 Setter for get_Italic. More...
 
void set_ItalicBi (bool value)
 Setter for get_ItalicBi. More...
 
void set_Kerning (double value)
 Setter for get_Kerning. More...
 
void set_LocaleId (int32_t value)
 Setter for get_LocaleId. More...
 
void set_LocaleIdBi (int32_t value)
 Setter for get_LocaleIdBi. More...
 
void set_LocaleIdFarEast (int32_t value)
 Setter for get_LocaleIdFarEast. More...
 
void set_Name (String value)
 Setter for get_Name. More...
 
void set_NameAscii (String value)
 Setter for get_NameAscii. More...
 
void set_NameBi (String value)
 Setter for get_NameBi. More...
 
void set_NameFarEast (String value)
 Setter for get_NameFarEast. More...
 
void set_NameOther (String value)
 Setter for get_NameOther. More...
 
void set_NoProofing (bool value)
 Setter for get_NoProofing. More...
 
void set_Outline (bool value)
 Setter for get_Outline. More...
 
void set_Position (double value)
 Setter for get_Position. More...
 
void set_Scaling (int32_t value)
 Setter for get_Scaling. More...
 
void set_Shadow (bool value)
 Setter for get_Shadow. More...
 
void set_Size (double value)
 Setter for get_Size. More...
 
void set_SizeBi (double value)
 Setter for get_SizeBi. More...
 
void set_SmallCaps (bool value)
 Setter for get_SmallCaps. More...
 
void set_SnapToGrid (bool value)
 Specifies whether the current font should use the document grid characters per line settings when laying out. More...
 
void set_Spacing (double value)
 Setter for get_Spacing. More...
 
void set_StrikeThrough (bool value)
 Setter for get_StrikeThrough. More...
 
void set_Style (SharedPtr< Style > value)
 Setter for get_Style. More...
 
void set_StyleIdentifier (StyleIdentifier value)
 Setter for get_StyleIdentifier. More...
 
void set_StyleName (String value)
 Setter for get_StyleName. More...
 
void set_Subscript (bool value)
 Setter for get_Subscript. More...
 
void set_Superscript (bool value)
 Setter for get_Superscript. More...
 
void set_TextEffect (TextEffect value)
 Setter for get_TextEffect. More...
 
void set_Underline (Underline value)
 Setter for get_Underline. More...
 
void set_UnderlineColor (Color value)
 Setter for get_UnderlineColor. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ ClearFormatting()

void Aspose::Words::Font::ClearFormatting ( )

Resets to default font formatting.

Removes all font formatting specified explicitly on the object from which Font was obtained so the font formatting will be inherited from the appropriate parent.

Examples

Shows how to insert a hyperlink into a document using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Please make sure to visit ");
// Specify font formatting for the hyperlink
builder->get_Font()->set_Color(System::Drawing::Color::get_Blue());
builder->get_Font()->set_Underline(Underline::Single);
// Insert the link
builder->InsertHyperlink(u"Aspose Website", u"https://www.aspose.com", false);
// Revert to default formatting
builder->get_Font()->ClearFormatting();
builder->Write(u" for more information.");
// Holding Ctrl and left clicking on the field in Microsoft Word will take you to the link's address in a web browser
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertHyperlink.docx");

◆ get_AllCaps()

bool Aspose::Words::Font::get_AllCaps ( )

True if the font is formatted as all capital letters.

Examples

Shows how to use all capitals and small capitals character formatting properties.

auto doc = MakeObject<Document>();
auto para = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
auto run = MakeObject<Run>(doc, u"All capitals");
run->get_Font()->set_AllCaps(true);
para->AppendChild(run);
run = MakeObject<Run>(doc, u"SMALL CAPITALS");
run->get_Font()->set_SmallCaps(true);
para->AppendChild(run);
doc->Save(ArtifactsDir + u"Font.Caps.docx");

◆ get_AutoColor()

System::Drawing::Color Aspose::Words::Font::get_AutoColor ( )

Returns the present calculated color of the text (black or white) to be used for 'auto color'. If the color is not 'auto' then returns Color.

When text has 'automatic color', the actual color of text is calculated automatically so that it is readable against the background color. As you change the background color, the text color will automatically switch to black or white in MS Word to maximize legibility.

Examples

Shows how calculated color of the text (black or white) to be used for 'auto color'

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Remove direct color, so it can be calculated automatically with Font.AutoColor
builder->get_Font()->set_Color(System::Drawing::Color::Empty);
// When we set black color for background, autocolor for font must be white
builder->get_Font()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_Black());
builder->Writeln(u"The text color automatically chosen for this run is white.");
// When we set white color for background, autocolor for font must be black
builder->get_Font()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_White());
builder->Writeln(u"The text color automatically chosen for this run is black.");
doc->Save(ArtifactsDir + u"Font.SetFontAutoColor.docx");

◆ get_Bidi()

bool Aspose::Words::Font::get_Bidi ( )

Specifies whether the contents of this run shall have right-to-left characteristics.

This property, when on, shall not be used with strongly left-to-right text. Any behavior under that condition is unspecified. This property, when off, shall not be used with strong right-to-left text. Any behavior under that condition is unspecified.

When the contents of this run are displayed, all characters shall be treated as complex script characters for formatting purposes. This means that BoldBi, ItalicBi, SizeBi and a corresponding font name will be used when rendering this run.

Also, when the contents of this run are displayed, this property acts as a right-to-left override for characters which are classified as "weak types" and "neutral types".

Examples

Shows how to insert and format right-to-left text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Signal to Microsoft Word that this run of text contains right-to-left text
builder->get_Font()->set_Bidi(true);
// Specify the font and font size to be used for the right-to-left text
builder->get_Font()->set_NameBi(u"Andalus");
builder->get_Font()->set_SizeBi(48);
// Specify that the right-to-left text in this run is bold and italic
builder->get_Font()->set_ItalicBi(true);
builder->get_Font()->set_BoldBi(true);
// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia
builder->get_Font()->set_LocaleIdBi(MakeObject<System::Globalization::CultureInfo>(u"ar-AR", false)->get_LCID());
// Insert some Arabic text
builder->Writeln(u"مرحبًا");
doc->Save(ArtifactsDir + u"Font.Bidi.docx");

◆ get_Bold()

bool Aspose::Words::Font::get_Bold ( )

True if the font is formatted as bold.

Examples

Inserts formatted text using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify font formatting before adding text
SharedPtr<Aspose::Words::Font> font = builder->get_Font();
font->set_Size(16);
font->set_Bold(true);
font->set_Name(u"Courier New");
font->set_Underline(Underline::Dash);
builder->Write(u"Hello world!");

◆ get_BoldBi()

bool Aspose::Words::Font::get_BoldBi ( )

True if the right-to-left text is formatted as bold.

Examples

Shows how to insert and format right-to-left text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Signal to Microsoft Word that this run of text contains right-to-left text
builder->get_Font()->set_Bidi(true);
// Specify the font and font size to be used for the right-to-left text
builder->get_Font()->set_NameBi(u"Andalus");
builder->get_Font()->set_SizeBi(48);
// Specify that the right-to-left text in this run is bold and italic
builder->get_Font()->set_ItalicBi(true);
builder->get_Font()->set_BoldBi(true);
// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia
builder->get_Font()->set_LocaleIdBi(MakeObject<System::Globalization::CultureInfo>(u"ar-AR", false)->get_LCID());
// Insert some Arabic text
builder->Writeln(u"مرحبًا");
doc->Save(ArtifactsDir + u"Font.Bidi.docx");

◆ get_Border()

System::SharedPtr<Aspose::Words::Border> Aspose::Words::Font::get_Border ( )

Returns a Border object that specifies border for the font.

Examples

Shows how to insert a string surrounded by a border into a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->get_Border()->set_Color(System::Drawing::Color::get_Green());
builder->get_Font()->get_Border()->set_LineWidth(2.5);
builder->get_Font()->get_Border()->set_LineStyle(LineStyle::DashDotStroker);
builder->Write(u"Text surrounded by green border.");
doc->Save(ArtifactsDir + u"Border.FontBorder.docx");

◆ get_Color()

System::Drawing::Color Aspose::Words::Font::get_Color ( )

Gets or sets the color of the font.

Examples

Inserts formatted text using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify font formatting before adding text
SharedPtr<Aspose::Words::Font> font = builder->get_Font();
font->set_Size(16);
font->set_Bold(true);
font->set_Name(u"Courier New");
font->set_Underline(Underline::Dash);
builder->Write(u"Hello world!");

Shows how to insert a hyperlink into a document using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Please make sure to visit ");
// Specify font formatting for the hyperlink
builder->get_Font()->set_Color(System::Drawing::Color::get_Blue());
builder->get_Font()->set_Underline(Underline::Single);
// Insert the link
builder->InsertHyperlink(u"Aspose Website", u"https://www.aspose.com", false);
// Revert to default formatting
builder->get_Font()->ClearFormatting();
builder->Write(u" for more information.");
// Holding Ctrl and left clicking on the field in Microsoft Word will take you to the link's address in a web browser
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertHyperlink.docx");

◆ get_ComplexScript()

bool Aspose::Words::Font::get_ComplexScript ( )

Specifies whether the contents of this run shall be treated as complex script text regardless of their Unicode character values when determining the formatting for this run.

Examples

Shows how to make a run that's always treated as complex script.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_ComplexScript(true);
builder->Writeln(u"Text treated as complex script.");
doc->Save(ArtifactsDir + u"Font.ComplexScript.docx");

◆ get_DoubleStrikeThrough()

bool Aspose::Words::Font::get_DoubleStrikeThrough ( )

True if the font is formatted as double strikethrough text.

Examples

Shows how to use strike-through character formatting properties.

auto doc = MakeObject<Document>();
auto para = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
auto run = MakeObject<Run>(doc, u"Double strike through text");
run->get_Font()->set_DoubleStrikeThrough(true);
para->AppendChild(run);
run = MakeObject<Run>(doc, u"Single strike through text");
run->get_Font()->set_StrikeThrough(true);
para->AppendChild(run);
doc->Save(ArtifactsDir + u"Font.StrikeThrough.docx");

◆ get_Emboss()

bool Aspose::Words::Font::get_Emboss ( )

True if the font is formatted as embossed.

Examples

Shows the difference between embossing and engraving text via font formatting.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(36);
builder->get_Font()->set_Color(System::Drawing::Color::get_White());
builder->get_Font()->set_Engrave(true);
builder->Writeln(u"This text is engraved.");
builder->get_Font()->set_Engrave(false);
builder->get_Font()->set_Emboss(true);
builder->Writeln(u"This text is embossed.");
doc->Save(ArtifactsDir + u"Font.EngraveEmboss.docx");

◆ get_EmphasisMark()

Aspose::Words::EmphasisMark Aspose::Words::Font::get_EmphasisMark ( )

Gets the emphasis mark applied to this formatting.

◆ get_Engrave()

bool Aspose::Words::Font::get_Engrave ( )

True if the font is formatted as engraved.

Examples

Shows the difference between embossing and engraving text via font formatting.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(36);
builder->get_Font()->set_Color(System::Drawing::Color::get_White());
builder->get_Font()->set_Engrave(true);
builder->Writeln(u"This text is engraved.");
builder->get_Font()->set_Engrave(false);
builder->get_Font()->set_Emboss(true);
builder->Writeln(u"This text is embossed.");
doc->Save(ArtifactsDir + u"Font.EngraveEmboss.docx");

◆ get_Hidden()

bool Aspose::Words::Font::get_Hidden ( )

True if the font is formatted as hidden text.

Examples

Shows how to create a hidden run of text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(36);
builder->get_Font()->set_Hidden(true);
// With the Hidden flag set to true, we can add text that will be present but invisible in the document
// It is not recommended to use this as a way of hiding sensitive information as the text is still easily reachable
builder->Writeln(u"This text won't be visible in the document.");
doc->Save(ArtifactsDir + u"Font.Hidden.docx");

◆ get_HighlightColor()

System::Drawing::Color Aspose::Words::Font::get_HighlightColor ( )

Gets or sets the highlight (marker) color.

Examples

Shows how to add a formatted run of text to a document using the object model.

auto doc = MakeObject<Document>();
// Create a new run of text
auto run = MakeObject<Run>(doc, u"Hello");
// Specify character formatting for the run of text
SharedPtr<Aspose::Words::Font> f = run->get_Font();
f->set_Name(u"Courier New");
f->set_Size(36);
f->set_HighlightColor(System::Drawing::Color::get_Yellow());
// Append the run of text to the end of the first paragraph
// in the body of the first section of the document
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(run);

◆ get_Italic()

bool Aspose::Words::Font::get_Italic ( )

True if the font is formatted as italic.

Examples

Shows how to italicize a run of text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(36);
builder->get_Font()->set_Italic(true);
builder->Writeln(u"Hello world!");
doc->Save(ArtifactsDir + u"Font.Italic.docx");

◆ get_ItalicBi()

bool Aspose::Words::Font::get_ItalicBi ( )

True if the right-to-left text is formatted as italic.

Examples

Shows how to insert and format right-to-left text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Signal to Microsoft Word that this run of text contains right-to-left text
builder->get_Font()->set_Bidi(true);
// Specify the font and font size to be used for the right-to-left text
builder->get_Font()->set_NameBi(u"Andalus");
builder->get_Font()->set_SizeBi(48);
// Specify that the right-to-left text in this run is bold and italic
builder->get_Font()->set_ItalicBi(true);
builder->get_Font()->set_BoldBi(true);
// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia
builder->get_Font()->set_LocaleIdBi(MakeObject<System::Globalization::CultureInfo>(u"ar-AR", false)->get_LCID());
// Insert some Arabic text
builder->Writeln(u"مرحبًا");
doc->Save(ArtifactsDir + u"Font.Bidi.docx");

◆ get_Kerning()

double Aspose::Words::Font::get_Kerning ( )

Gets or sets the font size at which kerning starts.

Examples

Shows how to specify the font size at which kerning starts.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Name(u"Arial Black");
// Set the font's kerning size threshold and font size
builder->get_Font()->set_Kerning(24);
builder->get_Font()->set_Size(18);
// The font size falls below the kerning threshold so kerning will not be applied
builder->Writeln(u"TALLY. (Kerning not applied)");
// If we add runs of text with a document builder's writing methods,
// the Font attributes of any new runs will inherit the values from the Font attributes of the previous runs
// The font size is still 18, and we will change the kerning threshold to a value below that
builder->get_Font()->set_Kerning(12);
// Kerning has now been applied to this run
builder->Writeln(u"TALLY. (Kerning applied)");
doc->Save(ArtifactsDir + u"Font.Kerning.docx");

◆ get_LineSpacing()

double Aspose::Words::Font::get_LineSpacing ( )

Returns line spacing of this font (in points).

Examples

Shows how to get line spacing of current font (in points).

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set different fonts for the DocumentBuilder and verify their line spacing
builder->get_Font()->set_Name(u"Calibri");
ASPOSE_ASSERT_EQ(14.6484375, builder->get_Font()->get_LineSpacing());
builder->get_Font()->set_Name(u"Times New Roman");
ASPOSE_ASSERT_EQ(13.798828125, builder->get_Font()->get_LineSpacing());

◆ get_LocaleId()

int32_t Aspose::Words::Font::get_LocaleId ( )

Gets or sets the locale identifier (language) of the formatted characters.

Examples

Shows how to specify the language of a text run so Microsoft Word can use a proper spell checker.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify the locale so Microsoft Word recognizes this text as Russian
builder->get_Font()->set_LocaleId(MakeObject<System::Globalization::CultureInfo>(u"ru-RU", false)->get_LCID());
builder->Writeln(u"Привет!");
doc->Save(ArtifactsDir + u"Font.LocaleId.docx");

◆ get_LocaleIdBi()

int32_t Aspose::Words::Font::get_LocaleIdBi ( )

Gets or sets the locale identifier (language) of the formatted right-to-left characters.

Examples

Shows how to insert and format right-to-left text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Signal to Microsoft Word that this run of text contains right-to-left text
builder->get_Font()->set_Bidi(true);
// Specify the font and font size to be used for the right-to-left text
builder->get_Font()->set_NameBi(u"Andalus");
builder->get_Font()->set_SizeBi(48);
// Specify that the right-to-left text in this run is bold and italic
builder->get_Font()->set_ItalicBi(true);
builder->get_Font()->set_BoldBi(true);
// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia
builder->get_Font()->set_LocaleIdBi(MakeObject<System::Globalization::CultureInfo>(u"ar-AR", false)->get_LCID());
// Insert some Arabic text
builder->Writeln(u"مرحبًا");
doc->Save(ArtifactsDir + u"Font.Bidi.docx");

◆ get_LocaleIdFarEast()

int32_t Aspose::Words::Font::get_LocaleIdFarEast ( )

Gets or sets the locale identifier (language) of the formatted Asian characters.

Examples

Shows how to insert and format text in a Far East language.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify the font name
builder->get_Font()->set_NameFarEast(u"SimSun");
// Specify the locale so Microsoft Word recognizes this text as Chinese
builder->get_Font()->set_LocaleIdFarEast(MakeObject<System::Globalization::CultureInfo>(u"zh-CN", false)->get_LCID());
// Insert some Chinese text
builder->Writeln(u"你好世界");
doc->Save(ArtifactsDir + u"Font.FarEast.docx");

◆ get_Name()

System::String Aspose::Words::Font::get_Name ( )

Gets or sets the name of the font.

When getting, returns NameAscii.

When setting, sets NameAscii, NameBi, NameFarEast and NameOther to the specified value.

Examples

Inserts formatted text using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify font formatting before adding text
SharedPtr<Aspose::Words::Font> font = builder->get_Font();
font->set_Size(16);
font->set_Bold(true);
font->set_Name(u"Courier New");
font->set_Underline(Underline::Dash);
builder->Write(u"Hello world!");

Shows how to add a formatted run of text to a document using the object model.

auto doc = MakeObject<Document>();
// Create a new run of text
auto run = MakeObject<Run>(doc, u"Hello");
// Specify character formatting for the run of text
SharedPtr<Aspose::Words::Font> f = run->get_Font();
f->set_Name(u"Courier New");
f->set_Size(36);
f->set_HighlightColor(System::Drawing::Color::get_Yellow());
// Append the run of text to the end of the first paragraph
// in the body of the first section of the document
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(run);

◆ get_NameAscii()

System::String Aspose::Words::Font::get_NameAscii ( )

Returns or sets the font used for Latin text (characters with character codes from 0 (zero) through 127).

See also
Aspose::Words::Font::get_Name
Examples

Shows how Microsoft Word can combine two different fonts in one run.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify a font to use for all characters that fall within the ASCII character set
builder->get_Font()->set_NameAscii(u"Calibri");
// Specify a font to use for all other characters
// This font should have a glyph for every other required character code
builder->get_Font()->set_NameOther(u"Courier New");
// The builder's font is the ASCII font
ASSERT_EQ(u"Calibri", builder->get_Font()->get_Name());
// Insert a run with one word consisting of ASCII characters, and one word with all characters outside that range
// This will create a run with two fonts
builder->Writeln(u"Hello, Привет");
doc->Save(ArtifactsDir + u"Font.Names.docx");

◆ get_NameBi()

System::String Aspose::Words::Font::get_NameBi ( )

Returns or sets the name of the font in a right-to-left language document.

See also
Aspose::Words::Font::get_Name
Examples

Shows how to insert and format right-to-left text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Signal to Microsoft Word that this run of text contains right-to-left text
builder->get_Font()->set_Bidi(true);
// Specify the font and font size to be used for the right-to-left text
builder->get_Font()->set_NameBi(u"Andalus");
builder->get_Font()->set_SizeBi(48);
// Specify that the right-to-left text in this run is bold and italic
builder->get_Font()->set_ItalicBi(true);
builder->get_Font()->set_BoldBi(true);
// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia
builder->get_Font()->set_LocaleIdBi(MakeObject<System::Globalization::CultureInfo>(u"ar-AR", false)->get_LCID());
// Insert some Arabic text
builder->Writeln(u"مرحبًا");
doc->Save(ArtifactsDir + u"Font.Bidi.docx");

◆ get_NameFarEast()

System::String Aspose::Words::Font::get_NameFarEast ( )

Returns or sets an East Asian font name.

See also
Aspose::Words::Font::get_Name
Examples

Shows how to insert and format text in a Far East language.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify the font name
builder->get_Font()->set_NameFarEast(u"SimSun");
// Specify the locale so Microsoft Word recognizes this text as Chinese
builder->get_Font()->set_LocaleIdFarEast(MakeObject<System::Globalization::CultureInfo>(u"zh-CN", false)->get_LCID());
// Insert some Chinese text
builder->Writeln(u"你好世界");
doc->Save(ArtifactsDir + u"Font.FarEast.docx");

◆ get_NameOther()

System::String Aspose::Words::Font::get_NameOther ( )

Returns or sets the font used for characters with character codes from 128 through 255.

See also
Aspose::Words::Font::get_Name
Examples

Shows how Microsoft Word can combine two different fonts in one run.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify a font to use for all characters that fall within the ASCII character set
builder->get_Font()->set_NameAscii(u"Calibri");
// Specify a font to use for all other characters
// This font should have a glyph for every other required character code
builder->get_Font()->set_NameOther(u"Courier New");
// The builder's font is the ASCII font
ASSERT_EQ(u"Calibri", builder->get_Font()->get_Name());
// Insert a run with one word consisting of ASCII characters, and one word with all characters outside that range
// This will create a run with two fonts
builder->Writeln(u"Hello, Привет");
doc->Save(ArtifactsDir + u"Font.Names.docx");

◆ get_NoProofing()

bool Aspose::Words::Font::get_NoProofing ( )

True when the formatted characters are not to be spell checked.

Examples

Shows how to specify that the run of text is not to be spell checked by Microsoft Word.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_NoProofing(true);
builder->Writeln(u"Proofing has been disabled for this run, so these spelking errrs will not display red lines underneath.");
doc->Save(ArtifactsDir + u"Font.NoProofing.docx");

◆ get_Outline()

bool Aspose::Words::Font::get_Outline ( )

True if the font is formatted as outline.

Examples

Shows how to create a run of text formatted as outline.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(36);
builder->get_Font()->set_Outline(true);
builder->Writeln(u"This text has an outline.");
doc->Save(ArtifactsDir + u"Font.Outline.docx");

◆ get_Position()

double Aspose::Words::Font::get_Position ( )

Gets or sets the position of text (in points) relative to the base line. A positive number raises the text, and a negative number lowers it.

Examples

Shows how to use subscript, superscript, complex script, text effects, and baseline text position properties.

auto doc = MakeObject<Document>();
auto para = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
// Add a run of text that is raised 5 points above the baseline
auto run = MakeObject<Run>(doc, u"Raised text");
run->get_Font()->set_Position(5);
para->AppendChild(run);
// Add a run of normal text
run = MakeObject<Run>(doc, u"Normal text");
para->AppendChild(run);
// Add a run of text that appears as subscript
run = MakeObject<Run>(doc, u"Subscript");
run->get_Font()->set_Subscript(true);
para->AppendChild(run);
// Add a run of text that appears as superscript
run = MakeObject<Run>(doc, u"Superscript");
run->get_Font()->set_Superscript(true);
para->AppendChild(run);
doc->Save(ArtifactsDir + u"Font.PositionSubscript.docx");

◆ get_Scaling()

int32_t Aspose::Words::Font::get_Scaling ( )

Gets or sets character width scaling in percent.

Examples

Shows how to use character scaling and spacing properties.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a run of text with characters 150% width of normal characters
builder->get_Font()->set_Scaling(150);
builder->Writeln(u"Wide characters");
// Add a run of text with extra 1pt space between characters
builder->get_Font()->set_Spacing(1);
builder->Writeln(u"Expanded by 1pt");
// Add a run of text with space between characters reduced by 1pt
builder->get_Font()->set_Spacing(-1);
builder->Writeln(u"Condensed by 1pt");
doc->Save(ArtifactsDir + u"Font.ScalingSpacing.docx");

◆ get_Shading()

System::SharedPtr<Aspose::Words::Shading> Aspose::Words::Font::get_Shading ( )

Returns a Shading object that refers to the shading formatting for the font.

Examples

Shows how to apply shading for a run of text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shading> shd = builder->get_Font()->get_Shading();
shd->set_BackgroundPatternColor(System::Drawing::Color::get_OrangeRed());
shd->set_ForegroundPatternColor(System::Drawing::Color::get_DarkBlue());
builder->get_Font()->set_Color(System::Drawing::Color::get_White());
builder->Writeln(u"White text on an orange background with texture.");
doc->Save(ArtifactsDir + u"Font.Shading.docx");

◆ get_Shadow()

bool Aspose::Words::Font::get_Shadow ( )

True if the font is formatted as shadowed.

Examples

Shows how to create a run of text formatted with a shadow.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(36);
builder->get_Font()->set_Shadow(true);
builder->Writeln(u"This text has a shadow.");
doc->Save(ArtifactsDir + u"Font.Shadow.docx");

◆ get_Size()

double Aspose::Words::Font::get_Size ( )

Gets or sets the font size in points.

Examples

Inserts formatted text using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify font formatting before adding text
SharedPtr<Aspose::Words::Font> font = builder->get_Font();
font->set_Size(16);
font->set_Bold(true);
font->set_Name(u"Courier New");
font->set_Underline(Underline::Dash);
builder->Write(u"Hello world!");

Shows how to add a formatted run of text to a document using the object model.

auto doc = MakeObject<Document>();
// Create a new run of text
auto run = MakeObject<Run>(doc, u"Hello");
// Specify character formatting for the run of text
SharedPtr<Aspose::Words::Font> f = run->get_Font();
f->set_Name(u"Courier New");
f->set_Size(36);
f->set_HighlightColor(System::Drawing::Color::get_Yellow());
// Append the run of text to the end of the first paragraph
// in the body of the first section of the document
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(run);

◆ get_SizeBi()

double Aspose::Words::Font::get_SizeBi ( )

Gets or sets the font size in points used in a right-to-left document.

Examples

Shows how to insert and format right-to-left text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Signal to Microsoft Word that this run of text contains right-to-left text
builder->get_Font()->set_Bidi(true);
// Specify the font and font size to be used for the right-to-left text
builder->get_Font()->set_NameBi(u"Andalus");
builder->get_Font()->set_SizeBi(48);
// Specify that the right-to-left text in this run is bold and italic
builder->get_Font()->set_ItalicBi(true);
builder->get_Font()->set_BoldBi(true);
// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia
builder->get_Font()->set_LocaleIdBi(MakeObject<System::Globalization::CultureInfo>(u"ar-AR", false)->get_LCID());
// Insert some Arabic text
builder->Writeln(u"مرحبًا");
doc->Save(ArtifactsDir + u"Font.Bidi.docx");

◆ get_SmallCaps()

bool Aspose::Words::Font::get_SmallCaps ( )

True if the font is formatted as small capital letters.

Examples

Shows how to use all capitals and small capitals character formatting properties.

auto doc = MakeObject<Document>();
auto para = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
auto run = MakeObject<Run>(doc, u"All capitals");
run->get_Font()->set_AllCaps(true);
para->AppendChild(run);
run = MakeObject<Run>(doc, u"SMALL CAPITALS");
run->get_Font()->set_SmallCaps(true);
para->AppendChild(run);
doc->Save(ArtifactsDir + u"Font.Caps.docx");

◆ get_SnapToGrid()

bool Aspose::Words::Font::get_SnapToGrid ( )

Specifies whether the current font should use the document grid characters per line settings when laying out.

◆ get_Spacing()

double Aspose::Words::Font::get_Spacing ( )

Returns or sets the spacing (in points) between characters .

Examples

Shows how to use character scaling and spacing properties.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Add a run of text with characters 150% width of normal characters
builder->get_Font()->set_Scaling(150);
builder->Writeln(u"Wide characters");
// Add a run of text with extra 1pt space between characters
builder->get_Font()->set_Spacing(1);
builder->Writeln(u"Expanded by 1pt");
// Add a run of text with space between characters reduced by 1pt
builder->get_Font()->set_Spacing(-1);
builder->Writeln(u"Condensed by 1pt");
doc->Save(ArtifactsDir + u"Font.ScalingSpacing.docx");

◆ get_StrikeThrough()

bool Aspose::Words::Font::get_StrikeThrough ( )

True if the font is formatted as strikethrough text.

Examples

Shows how to use strike-through character formatting properties.

auto doc = MakeObject<Document>();
auto para = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
auto run = MakeObject<Run>(doc, u"Double strike through text");
run->get_Font()->set_DoubleStrikeThrough(true);
para->AppendChild(run);
run = MakeObject<Run>(doc, u"Single strike through text");
run->get_Font()->set_StrikeThrough(true);
para->AppendChild(run);
doc->Save(ArtifactsDir + u"Font.StrikeThrough.docx");

◆ get_Style()

System::SharedPtr<Aspose::Words::Style> Aspose::Words::Font::get_Style ( )

Gets or sets the character style applied to this formatting.

Examples

Applies double underline to all runs in a document that are formatted with custom character styles.

//Document doc = new Document(MyDir + "Custom style.docx");
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a custom style
SharedPtr<Style> style = doc->get_Styles()->Add(StyleType::Character, u"MyStyle");
style->get_Font()->set_Color(System::Drawing::Color::get_Red());
style->get_Font()->set_Name(u"Courier New");
// Set the style of the current paragraph to our custom style
// This will apply to only the text after the style separator
builder->get_Font()->set_StyleName(u"MyStyle");
builder->Write(u"This text is in a custom style.");
// Iterate through every run node and apply underlines to the run if its style is not a built in style,
// like the one we added
for (auto node : System::IterateOver(doc->GetChildNodes(NodeType::Run, true)))
{
auto run = System::DynamicCast<Run>(node);
SharedPtr<Style> charStyle = run->get_Font()->get_Style();
if (!charStyle->get_BuiltIn())
{
run->get_Font()->set_Underline(Underline::Double);
}
}
doc->Save(ArtifactsDir + u"Font.Style.docx");

◆ get_StyleIdentifier()

Aspose::Words::StyleIdentifier Aspose::Words::Font::get_StyleIdentifier ( )

Gets or sets the locale independent style identifier of the character style applied to this formatting.

Examples

Shows how to use style name or identifier to find text formatted with a specific character style and apply different character style.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert text with two styles that will be replaced by another style
builder->get_Font()->set_StyleIdentifier(StyleIdentifier::Emphasis);
builder->Writeln(u"Text originally in \"Emphasis\" style");
builder->get_Font()->set_StyleIdentifier(StyleIdentifier::IntenseEmphasis);
builder->Writeln(u"Text originally in \"Intense Emphasis\" style");
// Loop through every run node
for (auto run : System::IterateOver(doc->GetChildNodes(NodeType::Run, true)->LINQ_OfType<SharedPtr<Run> >()))
{
// If the run's text is of the "Emphasis" style, referenced by name, change the style to "Strong"
if (run->get_Font()->get_StyleName() == u"Emphasis")
{
run->get_Font()->set_StyleName(u"Strong");
}
// If the run's text style is "Intense Emphasis", change it to "Strong" also, but this time reference using a StyleIdentifier
if (run->get_Font()->get_StyleIdentifier() == StyleIdentifier::IntenseEmphasis)
{
run->get_Font()->set_StyleIdentifier(StyleIdentifier::Strong);
}
}
doc->Save(ArtifactsDir + u"Font.ChangeStyle.docx");

◆ get_StyleName()

System::String Aspose::Words::Font::get_StyleName ( )

Gets or sets the name of the character style applied to this formatting.

Examples

Shows how to use style name or identifier to find text formatted with a specific character style and apply different character style.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert text with two styles that will be replaced by another style
builder->get_Font()->set_StyleIdentifier(StyleIdentifier::Emphasis);
builder->Writeln(u"Text originally in \"Emphasis\" style");
builder->get_Font()->set_StyleIdentifier(StyleIdentifier::IntenseEmphasis);
builder->Writeln(u"Text originally in \"Intense Emphasis\" style");
// Loop through every run node
for (auto run : System::IterateOver(doc->GetChildNodes(NodeType::Run, true)->LINQ_OfType<SharedPtr<Run> >()))
{
// If the run's text is of the "Emphasis" style, referenced by name, change the style to "Strong"
if (run->get_Font()->get_StyleName() == u"Emphasis")
{
run->get_Font()->set_StyleName(u"Strong");
}
// If the run's text style is "Intense Emphasis", change it to "Strong" also, but this time reference using a StyleIdentifier
if (run->get_Font()->get_StyleIdentifier() == StyleIdentifier::IntenseEmphasis)
{
run->get_Font()->set_StyleIdentifier(StyleIdentifier::Strong);
}
}
doc->Save(ArtifactsDir + u"Font.ChangeStyle.docx");

◆ get_Subscript()

bool Aspose::Words::Font::get_Subscript ( )

True if the font is formatted as subscript.

Examples

Shows how to use subscript, superscript, complex script, text effects, and baseline text position properties.

auto doc = MakeObject<Document>();
auto para = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
// Add a run of text that is raised 5 points above the baseline
auto run = MakeObject<Run>(doc, u"Raised text");
run->get_Font()->set_Position(5);
para->AppendChild(run);
// Add a run of normal text
run = MakeObject<Run>(doc, u"Normal text");
para->AppendChild(run);
// Add a run of text that appears as subscript
run = MakeObject<Run>(doc, u"Subscript");
run->get_Font()->set_Subscript(true);
para->AppendChild(run);
// Add a run of text that appears as superscript
run = MakeObject<Run>(doc, u"Superscript");
run->get_Font()->set_Superscript(true);
para->AppendChild(run);
doc->Save(ArtifactsDir + u"Font.PositionSubscript.docx");

◆ get_Superscript()

bool Aspose::Words::Font::get_Superscript ( )

True if the font is formatted as superscript.

Examples

Shows how to use subscript, superscript, complex script, text effects, and baseline text position properties.

auto doc = MakeObject<Document>();
auto para = System::DynamicCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));
// Add a run of text that is raised 5 points above the baseline
auto run = MakeObject<Run>(doc, u"Raised text");
run->get_Font()->set_Position(5);
para->AppendChild(run);
// Add a run of normal text
run = MakeObject<Run>(doc, u"Normal text");
para->AppendChild(run);
// Add a run of text that appears as subscript
run = MakeObject<Run>(doc, u"Subscript");
run->get_Font()->set_Subscript(true);
para->AppendChild(run);
// Add a run of text that appears as superscript
run = MakeObject<Run>(doc, u"Superscript");
run->get_Font()->set_Superscript(true);
para->AppendChild(run);
doc->Save(ArtifactsDir + u"Font.PositionSubscript.docx");

◆ get_TextEffect()

Aspose::Words::TextEffect Aspose::Words::Font::get_TextEffect ( )

Gets or sets the font animation effect.

Examples

Shows how to apply a visual effect to a run.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(36);
builder->get_Font()->set_TextEffect(TextEffect::SparkleText);
builder->Writeln(u"Text with a sparkle effect.");
// Font animation effects are only visible in older versions of Microsoft Word
doc->Save(ArtifactsDir + u"Font.SparklingText.doc");

◆ get_Underline()

Aspose::Words::Underline Aspose::Words::Font::get_Underline ( )

Gets or sets the type of underline applied to the font.

Examples

Inserts formatted text using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Specify font formatting before adding text
SharedPtr<Aspose::Words::Font> font = builder->get_Font();
font->set_Size(16);
font->set_Bold(true);
font->set_Name(u"Courier New");
font->set_Underline(Underline::Dash);
builder->Write(u"Hello world!");

Shows how to insert a hyperlink into a document using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Please make sure to visit ");
// Specify font formatting for the hyperlink
builder->get_Font()->set_Color(System::Drawing::Color::get_Blue());
builder->get_Font()->set_Underline(Underline::Single);
// Insert the link
builder->InsertHyperlink(u"Aspose Website", u"https://www.aspose.com", false);
// Revert to default formatting
builder->get_Font()->ClearFormatting();
builder->Write(u" for more information.");
// Holding Ctrl and left clicking on the field in Microsoft Word will take you to the link's address in a web browser
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertHyperlink.docx");

Shows how use the underline character formatting properties.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set an underline color and style
builder->get_Font()->set_Underline(Underline::Dotted);
builder->get_Font()->set_UnderlineColor(System::Drawing::Color::get_Red());
builder->Writeln(u"Underlined text.");
doc->Save(ArtifactsDir + u"Font.Underlines.docx");

◆ get_UnderlineColor()

System::Drawing::Color Aspose::Words::Font::get_UnderlineColor ( )

Gets or sets the color of the underline applied to the font.

Examples

Shows how use the underline character formatting properties.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set an underline color and style
builder->get_Font()->set_Underline(Underline::Dotted);
builder->get_Font()->set_UnderlineColor(System::Drawing::Color::get_Red());
builder->Writeln(u"Underlined text.");
doc->Save(ArtifactsDir + u"Font.Underlines.docx");

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Font::GetType ( ) const
overridevirtual

◆ HasDmlEffect()

bool Aspose::Words::Font::HasDmlEffect ( Aspose::Words::TextDmlEffect  dmlEffectType)

Checks if particular DrawingML text effect is applied.

Parameters
dmlEffectTypeDrawingML text effect type.
Returns
True if particular DrawingML text effect is applied.
Examples

Shows how to checks if particular Dml text effect is applied.

auto doc = MakeObject<Document>(MyDir + u"DrawingML text effects.docx");
SharedPtr<RunCollection> runs = doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_Runs();
ASSERT_TRUE(runs->idx_get(0)->get_Font()->HasDmlEffect(TextDmlEffect::Shadow));
ASSERT_TRUE(runs->idx_get(1)->get_Font()->HasDmlEffect(TextDmlEffect::Shadow));
ASSERT_TRUE(runs->idx_get(2)->get_Font()->HasDmlEffect(TextDmlEffect::Reflection));
ASSERT_TRUE(runs->idx_get(3)->get_Font()->HasDmlEffect(TextDmlEffect::Effect3D));
ASSERT_TRUE(runs->idx_get(4)->get_Font()->HasDmlEffect(TextDmlEffect::Fill));

◆ Is()

virtual bool Aspose::Words::Font::Is ( const System::TypeInfo target) const
overridevirtual

◆ set_AllCaps()

void Aspose::Words::Font::set_AllCaps ( bool  value)

◆ set_Bidi()

void Aspose::Words::Font::set_Bidi ( bool  value)

◆ set_Bold()

void Aspose::Words::Font::set_Bold ( bool  value)

◆ set_BoldBi()

void Aspose::Words::Font::set_BoldBi ( bool  value)

◆ set_Color()

void Aspose::Words::Font::set_Color ( System::Drawing::Color  value)

◆ set_ComplexScript()

void Aspose::Words::Font::set_ComplexScript ( bool  value)

◆ set_DoubleStrikeThrough()

void Aspose::Words::Font::set_DoubleStrikeThrough ( bool  value)

◆ set_Emboss()

void Aspose::Words::Font::set_Emboss ( bool  value)

◆ set_EmphasisMark()

void Aspose::Words::Font::set_EmphasisMark ( Aspose::Words::EmphasisMark  value)

Sets the emphasis mark applied to this formatting.

◆ set_Engrave()

void Aspose::Words::Font::set_Engrave ( bool  value)

◆ set_Hidden()

void Aspose::Words::Font::set_Hidden ( bool  value)

◆ set_HighlightColor()

void Aspose::Words::Font::set_HighlightColor ( System::Drawing::Color  value)

◆ set_Italic()

void Aspose::Words::Font::set_Italic ( bool  value)

◆ set_ItalicBi()

void Aspose::Words::Font::set_ItalicBi ( bool  value)

◆ set_Kerning()

void Aspose::Words::Font::set_Kerning ( double  value)

◆ set_LocaleId()

void Aspose::Words::Font::set_LocaleId ( int32_t  value)

◆ set_LocaleIdBi()

void Aspose::Words::Font::set_LocaleIdBi ( int32_t  value)

◆ set_LocaleIdFarEast()

void Aspose::Words::Font::set_LocaleIdFarEast ( int32_t  value)

◆ set_Name()

void Aspose::Words::Font::set_Name ( System::String  value)

◆ set_NameAscii()

void Aspose::Words::Font::set_NameAscii ( System::String  value)

◆ set_NameBi()

void Aspose::Words::Font::set_NameBi ( System::String  value)

◆ set_NameFarEast()

void Aspose::Words::Font::set_NameFarEast ( System::String  value)

◆ set_NameOther()

void Aspose::Words::Font::set_NameOther ( System::String  value)

◆ set_NoProofing()

void Aspose::Words::Font::set_NoProofing ( bool  value)

◆ set_Outline()

void Aspose::Words::Font::set_Outline ( bool  value)

◆ set_Position()

void Aspose::Words::Font::set_Position ( double  value)

◆ set_Scaling()

void Aspose::Words::Font::set_Scaling ( int32_t  value)

◆ set_Shadow()

void Aspose::Words::Font::set_Shadow ( bool  value)

◆ set_Size()

void Aspose::Words::Font::set_Size ( double  value)

◆ set_SizeBi()

void Aspose::Words::Font::set_SizeBi ( double  value)

◆ set_SmallCaps()

void Aspose::Words::Font::set_SmallCaps ( bool  value)

◆ set_SnapToGrid()

void Aspose::Words::Font::set_SnapToGrid ( bool  value)

Specifies whether the current font should use the document grid characters per line settings when laying out.

◆ set_Spacing()

void Aspose::Words::Font::set_Spacing ( double  value)

◆ set_StrikeThrough()

void Aspose::Words::Font::set_StrikeThrough ( bool  value)

◆ set_Style()

void Aspose::Words::Font::set_Style ( System::SharedPtr< Aspose::Words::Style value)

◆ set_StyleIdentifier()

void Aspose::Words::Font::set_StyleIdentifier ( Aspose::Words::StyleIdentifier  value)

◆ set_StyleName()

void Aspose::Words::Font::set_StyleName ( System::String  value)

◆ set_Subscript()

void Aspose::Words::Font::set_Subscript ( bool  value)

◆ set_Superscript()

void Aspose::Words::Font::set_Superscript ( bool  value)

◆ set_TextEffect()

void Aspose::Words::Font::set_TextEffect ( Aspose::Words::TextEffect  value)

◆ set_Underline()

void Aspose::Words::Font::set_Underline ( Aspose::Words::Underline  value)

◆ set_UnderlineColor()

void Aspose::Words::Font::set_UnderlineColor ( System::Drawing::Color  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Font::Type ( )
static
static ASPOSECPP_SHARED_API Color get_White()
@ Fill
Fill overlay effect.
@ SparkleText
static ASPOSECPP_SHARED_API Color get_OrangeRed()
static ASPOSECPP_SHARED_API Color get_Yellow()
@ Character
The style is a character style.
std::enable_if_t<!Details::IsIterable< Enumerable >::value, Details::EnumeratorAdapter< Enumerable, T > > IterateOver(System::SmartPtr< Enumerable > enumerable)
static ASPOSECPP_SHARED_API Color get_Black()
@ DashDotStroker
@ Strong
@ TextureDiagonalUp
static ASPOSECPP_SHARED_API Color get_DarkBlue()
@ Paragraph
The style is a paragraph style.
static ASPOSECPP_SHARED_API Color get_Green()
@ IntenseEmphasis
@ Dash
@ Shadow
Shadow effect.
@ Double
@ Emphasis
static ASPOSECPP_SHARED_API Color get_Blue()
static ASPOSECPP_SHARED_API Color get_Red()
@ Effect3D
3D effect.
static ASPOSECPP_SHARED_API const Color Empty
@ Single
@ Run
A run of text.
@ Paragraph
A paragraph of text. A Paragraph node is a container for inline level elements Run,...
@ Dotted
@ Reflection
Reflection effect.