com.aspose.words

  • java.lang.Object
    • com.aspose.words.Font
public class Font 
extends java.lang.Object

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.

Example:

Shows how to format a run of text using its font property.
Document doc = new Document();
Run run = new Run(doc, "Hello world!");

Font font = run.getFont();
font.setName("Courier New");
font.setSize(36.0);
font.setHighlightColor(Color.YELLOW);

doc.getFirstSection().getBody().getFirstParagraph().appendChild(run);
doc.save(getArtifactsDir() + "Font.CreateFormattedRun.docx");

Example:

Shows how to insert a string surrounded by a border into a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.getFont().getBorder().setColor(Color.GREEN);
builder.getFont().getBorder().setLineWidth(2.5);
builder.getFont().getBorder().setLineStyle(LineStyle.DASH_DOT_STROKER);

builder.write("Text surrounded by green border.");

doc.save(getArtifactsDir() + "Border.FontBorder.docx");

Example:

Shows how to create and use a paragraph style with list formatting.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a custom paragraph style.
Style style = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle1");
style.getFont().setSize(24.0);
style.getFont().setName("Verdana");
style.getParagraphFormat().setSpaceAfter(12.0);

// Create a list and make sure the paragraphs that use this style will use this list.
style.getListFormat().setList(doc.getLists().add(ListTemplate.BULLET_DEFAULT));
style.getListFormat().setListLevelNumber(0);

// Apply the paragraph style to the document builder's current paragraph, and then add some text.
builder.getParagraphFormat().setStyle(style);
builder.writeln("Hello World: MyStyle1, bulleted list.");

// Change the document builder's style to one that has no list formatting and write another paragraph.
builder.getParagraphFormat().setStyle(doc.getStyles().get("Normal"));
builder.writeln("Hello World: Normal.");

builder.getDocument().save(getArtifactsDir() + "Styles.ParagraphStyleBulletedList.docx");

Property Getters/Setters Summary
booleangetAllCaps()
void
setAllCaps(booleanvalue)
           True if the font is formatted as all capital letters.
java.awt.ColorgetAutoColor()
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.
booleangetBidi()
void
setBidi(booleanvalue)
           Specifies whether the contents of this run shall have right-to-left characteristics.
booleangetBold()
void
setBold(booleanvalue)
           True if the font is formatted as bold.
booleangetBoldBi()
void
setBoldBi(booleanvalue)
           True if the right-to-left text is formatted as bold.
BordergetBorder()
Returns a Border object that specifies border for the font.
java.awt.ColorgetColor()
void
setColor(java.awt.Colorvalue)
           Gets or sets the color of the font.
booleangetComplexScript()
void
setComplexScript(booleanvalue)
           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.
booleangetDoubleStrikeThrough()
void
           True if the font is formatted as double strikethrough text.
booleangetEmboss()
void
setEmboss(booleanvalue)
           True if the font is formatted as embossed.
intgetEmphasisMark()
void
setEmphasisMark(intvalue)
           Gets or sets the emphasis mark applied to this formatting. The value of the property is EmphasisMark integer constant.
booleangetEngrave()
void
setEngrave(booleanvalue)
           True if the font is formatted as engraved.
FillgetFill()
Gets fill formatting for the Font.
booleangetHidden()
void
setHidden(booleanvalue)
           True if the font is formatted as hidden text.
java.awt.ColorgetHighlightColor()
void
setHighlightColor(java.awt.Colorvalue)
           Gets or sets the highlight (marker) color.
booleangetItalic()
void
setItalic(booleanvalue)
           True if the font is formatted as italic.
booleangetItalicBi()
void
setItalicBi(booleanvalue)
           True if the right-to-left text is formatted as italic.
doublegetKerning()
void
setKerning(doublevalue)
           Gets or sets the font size at which kerning starts.
doublegetLineSpacing()
Returns line spacing of this font (in points).
intgetLocaleId()
void
setLocaleId(intvalue)
           Gets or sets the locale identifier (language) of the formatted characters.
intgetLocaleIdBi()
void
setLocaleIdBi(intvalue)
           Gets or sets the locale identifier (language) of the formatted right-to-left characters.
intgetLocaleIdFarEast()
void
           Gets or sets the locale identifier (language) of the formatted Asian characters.
java.lang.StringgetName()
void
setName(java.lang.Stringvalue)
           Gets or sets the name of the font.
java.lang.StringgetNameAscii()
void
setNameAscii(java.lang.Stringvalue)
           Returns or sets the font used for Latin text (characters with character codes from 0 (zero) through 127).
java.lang.StringgetNameBi()
void
setNameBi(java.lang.Stringvalue)
           Returns or sets the name of the font in a right-to-left language document.
java.lang.StringgetNameFarEast()
void
setNameFarEast(java.lang.Stringvalue)
           Returns or sets an East Asian font name.
java.lang.StringgetNameOther()
void
setNameOther(java.lang.Stringvalue)
           Returns or sets the font used for characters with character codes from 128 through 255.
booleangetNoProofing()
void
setNoProofing(booleanvalue)
           True when the formatted characters are not to be spell checked.
booleangetOutline()
void
setOutline(booleanvalue)
           True if the font is formatted as outline.
doublegetPosition()
void
setPosition(doublevalue)
           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.
intgetScaling()
void
setScaling(intvalue)
           Gets or sets character width scaling in percent.
ShadinggetShading()
Returns a Shading object that refers to the shading formatting for the font.
booleangetShadow()
void
setShadow(booleanvalue)
           True if the font is formatted as shadowed.
doublegetSize()
void
setSize(doublevalue)
           Gets or sets the font size in points.
doublegetSizeBi()
void
setSizeBi(doublevalue)
           Gets or sets the font size in points used in a right-to-left document.
booleangetSmallCaps()
void
setSmallCaps(booleanvalue)
           True if the font is formatted as small capital letters.
booleangetSnapToGrid()
void
setSnapToGrid(booleanvalue)
           Specifies whether the current font should use the document grid characters per line settings when laying out.
doublegetSpacing()
void
setSpacing(doublevalue)
           Returns or sets the spacing (in points) between characters .
booleangetStrikeThrough()
void
setStrikeThrough(booleanvalue)
           True if the font is formatted as strikethrough text.
StylegetStyle()
void
setStyle(Style value)
           Gets or sets the character style applied to this formatting.
intgetStyleIdentifier()
void
           Gets or sets the locale independent style identifier of the character style applied to this formatting. The value of the property is StyleIdentifier integer constant.
java.lang.StringgetStyleName()
void
setStyleName(java.lang.Stringvalue)
           Gets or sets the name of the character style applied to this formatting.
booleangetSubscript()
void
setSubscript(booleanvalue)
           True if the font is formatted as subscript.
booleangetSuperscript()
void
setSuperscript(booleanvalue)
           True if the font is formatted as superscript.
intgetTextEffect()
void
setTextEffect(intvalue)
           Gets or sets the font animation effect. The value of the property is TextEffect integer constant.
intgetThemeColor()
void
setThemeColor(intvalue)
           Gets or sets the theme color in the applied color scheme that is associated with this Font object. The value of the property is ThemeColor integer constant.
intgetThemeFont()
void
setThemeFont(intvalue)
           Gets or sets the theme font in the applied font scheme that is associated with this Font object. The value of the property is ThemeFont integer constant.
intgetThemeFontAscii()
void
           Gets or sets the theme font used for Latin text (characters with character codes from 0 (zero) through 127) in the applied font scheme that is associated with this Font object. The value of the property is ThemeFont integer constant.
intgetThemeFontBi()
void
setThemeFontBi(intvalue)
           Gets or sets the theme font in the applied font scheme that is associated with this Font object in a right-to-left language document. The value of the property is ThemeFont integer constant.
intgetThemeFontFarEast()
void
           Gets or sets the East Asian theme font in the applied font scheme that is associated with this Font object. The value of the property is ThemeFont integer constant.
intgetThemeFontOther()
void
           Gets or sets the theme font used for characters with character codes from 128 through 255 in the applied font scheme that is associated with this Font object. The value of the property is ThemeFont integer constant.
doublegetTintAndShade()
void
setTintAndShade(doublevalue)
           Gets or sets a double value that lightens or darkens a color.
intgetUnderline()
void
setUnderline(intvalue)
           Gets or sets the type of underline applied to the font. The value of the property is Underline integer constant.
java.awt.ColorgetUnderlineColor()
void
setUnderlineColor(java.awt.Colorvalue)
           Gets or sets the color of the underline applied to the font.
 
Method Summary
voidclearFormatting()
Resets to default font formatting.
booleanhasDmlEffect(int dmlEffectType)
Checks if particular DrawingML text effect is applied.
 

    • Property Getters/Setters Detail

      • getAllCaps/setAllCaps

        public boolean getAllCaps() / public void setAllCaps(boolean value)
        
        True if the font is formatted as all capital letters.

        Example:

        Shows how to format a run to display its contents in capitals.
        Document doc = new Document();
        Paragraph para = (Paragraph) doc.getChild(NodeType.PARAGRAPH, 0, true);
        
        // There are two ways of getting a run to display its lowercase text in uppercase without changing the contents.
        // 1 -  Set the AllCaps flag to display all characters in regular capitals:
        Run run = new Run(doc, "all capitals");
        run.getFont().setAllCaps(true);
        para.appendChild(run);
        
        para = (Paragraph) para.getParentNode().appendChild(new Paragraph(doc));
        
        // 2 -  Set the SmallCaps flag to display all characters in small capitals:
        // If a character is lower case, it will appear in its upper case form
        // but will have the same height as the lower case (the font's x-height).
        // Characters that were in upper case originally will look the same.
        run = new Run(doc, "Small Capitals");
        run.getFont().setSmallCaps(true);
        para.appendChild(run);
        
        doc.save(getArtifactsDir() + "Font.Caps.docx");
      • getAutoColor

        public java.awt.Color getAutoColor()
        
        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.

        Example:

        Shows how to improve readability by automatically selecting text color based on the brightness of its background.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // If a run's Font object does not specify text color, it will automatically
        // select either black or white depending on the background color's color.
        Assert.assertEquals(0, builder.getFont().getColor().getRGB());
        
        // The default color for text is black. If the color of the background is dark, black text will be difficult to see.
        // To solve this problem, the AutoColor property will display this text in white.
        builder.getFont().getShading().setBackgroundPatternColor(Color.BLUE);
        
        builder.writeln("The text color automatically chosen for this run is white.");
        
        Assert.assertEquals(Color.WHITE.getRGB(), doc.getFirstSection().getBody().getParagraphs().get(0).getRuns().get(0).getFont().getAutoColor().getRGB());
        
        // If we change the background to a light color, black will be a more
        // suitable text color than white so that the auto color will display it in black.
        builder.getFont().getShading().setBackgroundPatternColor(Color.RED);
        
        builder.writeln("The text color automatically chosen for this run is black.");
        
        Assert.assertEquals(Color.BLACK.getRGB(), doc.getFirstSection().getBody().getParagraphs().get(1).getRuns().get(0).getFont().getAutoColor().getRGB());
        
        doc.save(getArtifactsDir() + "Font.SetFontAutoColor.docx");
      • getBidi/setBidi

        public boolean getBidi() / public void setBidi(boolean value)
        
        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".

        Example:

        Shows how to define separate sets of font settings for right-to-left, and right-to-left text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Define a set of font settings for left-to-right text.
        builder.getFont().setName("Courier New");
        builder.getFont().setSize(16.0);
        builder.getFont().setItalic(false);
        builder.getFont().setBold(false);
        builder.getFont().setLocaleId(1033);
        
        // Define another set of font settings for right-to-left text.
        builder.getFont().setNameBi("Andalus");
        builder.getFont().setSizeBi(24.0);
        builder.getFont().setItalicBi(true);
        builder.getFont().setBoldBi(true);
        builder.getFont().setLocaleIdBi(1025);
        
        // We can use the Bidi flag to indicate whether the text we are about to add
        // with the document builder is right-to-left. When we add text with this flag set to true,
        // it will be formatted using the right-to-left set of font settings.
        builder.getFont().setBidi(true);
        builder.write("مرحبًا");
        
        // Set the flag to false, and then add left-to-right text.
        // The document builder will format these using the left-to-right set of font settings.
        builder.getFont().setBidi(false);
        builder.write(" Hello world!");
        
        doc.save(getArtifactsDir() + "Font.Bidi.docx");
      • getBold/setBold

        public boolean getBold() / public void setBold(boolean value)
        
        True if the font is formatted as bold.

        Example:

        Shows how to insert formatted text using DocumentBuilder.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Specify font formatting, then add text.
        Font font = builder.getFont();
        font.setSize(16.0);
        font.setBold(true);
        font.setColor(Color.BLUE);
        font.setName("Courier New");
        font.setUnderline(Underline.DASH);
        
        builder.write("Hello world!");
      • getBoldBi/setBoldBi

        public boolean getBoldBi() / public void setBoldBi(boolean value)
        
        True if the right-to-left text is formatted as bold.

        Example:

        Shows how to define separate sets of font settings for right-to-left, and right-to-left text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Define a set of font settings for left-to-right text.
        builder.getFont().setName("Courier New");
        builder.getFont().setSize(16.0);
        builder.getFont().setItalic(false);
        builder.getFont().setBold(false);
        builder.getFont().setLocaleId(1033);
        
        // Define another set of font settings for right-to-left text.
        builder.getFont().setNameBi("Andalus");
        builder.getFont().setSizeBi(24.0);
        builder.getFont().setItalicBi(true);
        builder.getFont().setBoldBi(true);
        builder.getFont().setLocaleIdBi(1025);
        
        // We can use the Bidi flag to indicate whether the text we are about to add
        // with the document builder is right-to-left. When we add text with this flag set to true,
        // it will be formatted using the right-to-left set of font settings.
        builder.getFont().setBidi(true);
        builder.write("مرحبًا");
        
        // Set the flag to false, and then add left-to-right text.
        // The document builder will format these using the left-to-right set of font settings.
        builder.getFont().setBidi(false);
        builder.write(" Hello world!");
        
        doc.save(getArtifactsDir() + "Font.Bidi.docx");
      • getBorder

        public Border getBorder()
        
        Returns a Border object that specifies border for the font.

        Example:

        Shows how to insert a string surrounded by a border into a document.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().getBorder().setColor(Color.GREEN);
        builder.getFont().getBorder().setLineWidth(2.5);
        builder.getFont().getBorder().setLineStyle(LineStyle.DASH_DOT_STROKER);
        
        builder.write("Text surrounded by green border.");
        
        doc.save(getArtifactsDir() + "Border.FontBorder.docx");
      • getColor/setColor

        public java.awt.Color getColor() / public void setColor(java.awt.Color value)
        
        Gets or sets the color of the font.

        Example:

        Shows how to insert formatted text using DocumentBuilder.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Specify font formatting, then add text.
        Font font = builder.getFont();
        font.setSize(16.0);
        font.setBold(true);
        font.setColor(Color.BLUE);
        font.setName("Courier New");
        font.setUnderline(Underline.DASH);
        
        builder.write("Hello world!");

        Example:

        Shows how to insert a hyperlink field.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("For more information, please visit the ");
        
        // Insert a hyperlink and emphasize it with custom formatting.
        // The hyperlink will be a clickable piece of text which will take us to the location specified in the URL.
        builder.getFont().setColor(Color.BLUE);
        builder.getFont().setUnderline(Underline.SINGLE);
        builder.insertHyperlink("Google website", "https://www.google.com", false);
        builder.getFont().clearFormatting();
        builder.writeln(".");
        
        // Ctrl + left clicking the link in the text in Microsoft Word will take us to the URL via a new web browser window.
        doc.save(getArtifactsDir() + "DocumentBuilder.InsertHyperlink.docx");
      • getComplexScript/setComplexScript

        public boolean getComplexScript() / public void setComplexScript(boolean value)
        
        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.

        Example:

        Shows how to add text that is always treated as complex script.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().setComplexScript(true);
        
        builder.writeln("Text treated as complex script.");
        
        doc.save(getArtifactsDir() + "Font.ComplexScript.docx");
      • getDoubleStrikeThrough/setDoubleStrikeThrough

        public boolean getDoubleStrikeThrough() / public void setDoubleStrikeThrough(boolean value)
        
        True if the font is formatted as double strikethrough text.

        Example:

        Shows how to add a line strikethrough to text.
        Document doc = new Document();
        Paragraph para = (Paragraph) doc.getChild(NodeType.PARAGRAPH, 0, true);
        
        Run run = new Run(doc, "Text with a single-line strikethrough.");
        run.getFont().setStrikeThrough(true);
        para.appendChild(run);
        
        para = (Paragraph) para.getParentNode().appendChild(new Paragraph(doc));
        
        run = new Run(doc, "Text with a double-line strikethrough.");
        run.getFont().setDoubleStrikeThrough(true);
        para.appendChild(run);
        
        doc.save(getArtifactsDir() + "Font.StrikeThrough.docx");
      • getEmboss/setEmboss

        public boolean getEmboss() / public void setEmboss(boolean value)
        
        True if the font is formatted as embossed.

        Example:

        Shows how to apply engraving/embossing effects to text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().setSize(36.0);
        builder.getFont().setColor(Color.WHITE);
        
        // Below are two ways of using shadows to apply a 3D-like effect to the text.
        // 1 -  Engrave text to make it look like the letters are sunken into the page:
        builder.getFont().setEngrave(true);
        
        builder.writeln("This text is engraved.");
        
        // 2 -  Emboss text to make it look like the letters pop out of the page:
        builder.getFont().setEngrave(false);
        builder.getFont().setEmboss(true);
        
        builder.writeln("This text is embossed.");
        
        doc.save(getArtifactsDir() + "Font.EngraveEmboss.docx");
      • getEmphasisMark/setEmphasisMark

        public int getEmphasisMark() / public void setEmphasisMark(int value)
        
        Gets or sets the emphasis mark applied to this formatting. The value of the property is EmphasisMark integer constant.

        Example:

        Shows how to add additional character rendered above/below the glyph-character.
        DocumentBuilder builder = new DocumentBuilder();
        
        // Possible types of emphasis mark:
        // https://apireference.aspose.com/words/net/aspose.words/emphasismark
        builder.getFont().setEmphasisMark(emphasisMark);
        
        builder.write("Emphasis text");
        builder.writeln();
        builder.getFont().clearFormatting();
        builder.write("Simple text");
        
        builder.getDocument().save(getArtifactsDir() + "Fonts.SetEmphasisMark.docx");
      • getEngrave/setEngrave

        public boolean getEngrave() / public void setEngrave(boolean value)
        
        True if the font is formatted as engraved.

        Example:

        Shows how to apply engraving/embossing effects to text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().setSize(36.0);
        builder.getFont().setColor(Color.WHITE);
        
        // Below are two ways of using shadows to apply a 3D-like effect to the text.
        // 1 -  Engrave text to make it look like the letters are sunken into the page:
        builder.getFont().setEngrave(true);
        
        builder.writeln("This text is engraved.");
        
        // 2 -  Emboss text to make it look like the letters pop out of the page:
        builder.getFont().setEngrave(false);
        builder.getFont().setEmboss(true);
        
        builder.writeln("This text is embossed.");
        
        doc.save(getArtifactsDir() + "Font.EngraveEmboss.docx");
      • getFill

        public Fill getFill()
        
        Gets fill formatting for the Font.
      • getHidden/setHidden

        public boolean getHidden() / public void setHidden(boolean value)
        
        True if the font is formatted as hidden text.

        Example:

        Shows how to create a run of hidden text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // With the Hidden flag set to true, any text that we create using this Font object will be invisible in the document.
        // We will not see or highlight hidden text unless we enable the "Hidden text" option
        // found in Microsoft Word via "File" -> "Options" -> "Display". The text will still be there,
        // and we will be able to access this text programmatically.
        // It is not advised to use this method to hide sensitive information.
        builder.getFont().setHidden(true);
        builder.getFont().setSize(36.0);
        
        builder.writeln("This text will not be visible in the document.");
        
        doc.save(getArtifactsDir() + "Font.Hidden.docx");

        Example:

        Shows how to use a DocumentVisitor implementation to remove all hidden content from a document.
        public void removeHiddenContentFromDocument() throws Exception {
            Document doc = new Document(getMyDir() + "Hidden content.docx");
        
            RemoveHiddenContentVisitor hiddenContentRemover = new RemoveHiddenContentVisitor();
        
            // Below are three types of fields which can accept a document visitor,
            // which will allow it to visit the accepting node, and then traverse its child nodes in a depth-first manner.
            // 1 -  Paragraph node:
            Paragraph para = (Paragraph) doc.getChild(NodeType.PARAGRAPH, 4, true);
            para.accept(hiddenContentRemover);
        
            // 2 -  Table node:
            Table table = doc.getFirstSection().getBody().getTables().get(0);
            table.accept(hiddenContentRemover);
        
            // 3 -  Document node:
            doc.accept(hiddenContentRemover);
        
            doc.save(getArtifactsDir() + "Font.RemoveHiddenContentFromDocument.docx");
        }
        
        /// <summary>
        /// Removes all visited nodes marked as "hidden content".
        /// </summary>
        public static class RemoveHiddenContentVisitor extends DocumentVisitor {
            /// <summary>
            /// Called when a FieldStart node is encountered in the document.
            /// </summary>
            public int visitFieldStart(FieldStart fieldStart) {
                if (fieldStart.getFont().getHidden())
                    fieldStart.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a FieldEnd node is encountered in the document.
            /// </summary>
            public int visitFieldEnd(FieldEnd fieldEnd) {
                if (fieldEnd.getFont().getHidden())
                    fieldEnd.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a FieldSeparator node is encountered in the document.
            /// </summary>
            public int visitFieldSeparator(FieldSeparator fieldSeparator) {
                if (fieldSeparator.getFont().getHidden())
                    fieldSeparator.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a Run node is encountered in the document.
            /// </summary>
            public int visitRun(Run run) {
                if (run.getFont().getHidden())
                    run.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a Paragraph node is encountered in the document.
            /// </summary>
            public int visitParagraphStart(Paragraph paragraph) {
                if (paragraph.getParagraphBreakFont().getHidden())
                    paragraph.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a FormField is encountered in the document.
            /// </summary>
            public int visitFormField(FormField formField) {
                if (formField.getFont().getHidden())
                    formField.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a GroupShape is encountered in the document.
            /// </summary>
            public int visitGroupShapeStart(GroupShape groupShape) {
                if (groupShape.getFont().getHidden())
                    groupShape.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a Shape is encountered in the document.
            /// </summary>
            public int visitShapeStart(Shape shape) {
                if (shape.getFont().getHidden())
                    shape.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a Comment is encountered in the document.
            /// </summary>
            public int visitCommentStart(Comment comment) {
                if (comment.getFont().getHidden())
                    comment.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a Footnote is encountered in the document.
            /// </summary>
            public int visitFootnoteStart(Footnote footnote) {
                if (footnote.getFont().getHidden())
                    footnote.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when a SpecialCharacter is encountered in the document.
            /// </summary>
            public int visitSpecialChar(SpecialChar specialChar) {
                if (specialChar.getFont().getHidden())
                    specialChar.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when visiting of a Table node is ended in the document.
            /// </summary>
            public int visitTableEnd(Table table) {
                // The content inside table cells may have the hidden content flag, but the tables themselves cannot.
                // If this table had nothing but hidden content, this visitor would have removed all of it,
                // and there would be no child nodes left.
                // Thus, we can also treat the table itself as hidden content and remove it.
                // Tables which are empty but do not have hidden content will have cells with empty paragraphs inside,
                // which this visitor will not remove.
                if (!table.hasChildNodes())
                    table.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when visiting of a Cell node is ended in the document.
            /// </summary>
            public int visitCellEnd(Cell cell) {
                if (!cell.hasChildNodes() && cell.getParentNode() != null)
                    cell.remove();
        
                return VisitorAction.CONTINUE;
            }
        
            /// <summary>
            /// Called when visiting of a Row node is ended in the document.
            /// </summary>
            public int visitRowEnd(Row row) {
                if (!row.hasChildNodes() && row.getParentNode() != null)
                    row.remove();
        
                return VisitorAction.CONTINUE;
            }
        }
      • getHighlightColor/setHighlightColor

        public java.awt.Color getHighlightColor() / public void setHighlightColor(java.awt.Color value)
        
        Gets or sets the highlight (marker) color.

        Example:

        Shows how to format a run of text using its font property.
        Document doc = new Document();
        Run run = new Run(doc, "Hello world!");
        
        Font font = run.getFont();
        font.setName("Courier New");
        font.setSize(36.0);
        font.setHighlightColor(Color.YELLOW);
        
        doc.getFirstSection().getBody().getFirstParagraph().appendChild(run);
        doc.save(getArtifactsDir() + "Font.CreateFormattedRun.docx");
      • getItalic/setItalic

        public boolean getItalic() / public void setItalic(boolean value)
        
        True if the font is formatted as italic.

        Example:

        Shows how to write italicized text using a document builder.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().setSize(36.0);
        builder.getFont().setItalic(true);
        builder.writeln("Hello world!");
        
        doc.save(getArtifactsDir() + "Font.Italic.docx");
      • getItalicBi/setItalicBi

        public boolean getItalicBi() / public void setItalicBi(boolean value)
        
        True if the right-to-left text is formatted as italic.

        Example:

        Shows how to define separate sets of font settings for right-to-left, and right-to-left text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Define a set of font settings for left-to-right text.
        builder.getFont().setName("Courier New");
        builder.getFont().setSize(16.0);
        builder.getFont().setItalic(false);
        builder.getFont().setBold(false);
        builder.getFont().setLocaleId(1033);
        
        // Define another set of font settings for right-to-left text.
        builder.getFont().setNameBi("Andalus");
        builder.getFont().setSizeBi(24.0);
        builder.getFont().setItalicBi(true);
        builder.getFont().setBoldBi(true);
        builder.getFont().setLocaleIdBi(1025);
        
        // We can use the Bidi flag to indicate whether the text we are about to add
        // with the document builder is right-to-left. When we add text with this flag set to true,
        // it will be formatted using the right-to-left set of font settings.
        builder.getFont().setBidi(true);
        builder.write("مرحبًا");
        
        // Set the flag to false, and then add left-to-right text.
        // The document builder will format these using the left-to-right set of font settings.
        builder.getFont().setBidi(false);
        builder.write(" Hello world!");
        
        doc.save(getArtifactsDir() + "Font.Bidi.docx");
      • getKerning/setKerning

        public double getKerning() / public void setKerning(double value)
        
        Gets or sets the font size at which kerning starts.

        Example:

        Shows how to specify the font size at which kerning begins to take effect.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        builder.getFont().setName("Arial Black");
        
        // Set the builder's font size, and minimum size at which kerning will take effect.
        // The font size falls below the kerning threshold, so the run bellow will not have kerning.
        builder.getFont().setSize(18.0);
        builder.getFont().setKerning(24.0);
        
        builder.writeln("TALLY. (Kerning not applied)");
        
        // Set the kerning threshold so that the builder's current font size is above it.
        // Any text we add from this point will have kerning applied. The spaces between characters
        // will be adjusted, normally resulting in a slightly more aesthetically pleasing text run.
        builder.getFont().setKerning(12.0);
        
        builder.writeln("TALLY. (Kerning applied)");
        
        doc.save(getArtifactsDir() + "Font.Kerning.docx");
      • getLineSpacing

        public double getLineSpacing()
        
        Returns line spacing of this font (in points).

        Example:

        Shows how to get a font's line spacing, in points.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Set different fonts for the DocumentBuilder, and verify their line spacing.
        builder.getFont().setName("Calibri");
        Assert.assertEquals(13.7d, builder.getFont().getLineSpacing(), 1);
        
        builder.getFont().setName("Times New Roman");
        Assert.assertEquals(13.7d, builder.getFont().getLineSpacing(), 1);
      • getLocaleId/setLocaleId

        public int getLocaleId() / public void setLocaleId(int value)
        
        Gets or sets the locale identifier (language) of the formatted characters. For the list of locale identifiers see https://msdn.microsoft.com/en-us/library/cc233965.aspx

        Example:

        Shows how to set the locale of the text that we are adding with a document builder.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // If we set the font's locale to English and insert some Russian text,
        // the English locale spell checker will not recognize the text and detect it as a spelling error.
        builder.getFont().setLocaleId(1033);
        builder.writeln("Привет!");
        
        // Set a matching locale for the text that we are about to add to apply the appropriate spell checker.
        builder.getFont().setLocaleId(1049);
        builder.writeln("Привет!");
        
        doc.save(getArtifactsDir() + "Font.LocaleId.docx");
      • getLocaleIdBi/setLocaleIdBi

        public int getLocaleIdBi() / public void setLocaleIdBi(int value)
        
        Gets or sets the locale identifier (language) of the formatted right-to-left characters. For the list of locale identifiers see https://msdn.microsoft.com/en-us/library/cc233965.aspx

        Example:

        Shows how to define separate sets of font settings for right-to-left, and right-to-left text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Define a set of font settings for left-to-right text.
        builder.getFont().setName("Courier New");
        builder.getFont().setSize(16.0);
        builder.getFont().setItalic(false);
        builder.getFont().setBold(false);
        builder.getFont().setLocaleId(1033);
        
        // Define another set of font settings for right-to-left text.
        builder.getFont().setNameBi("Andalus");
        builder.getFont().setSizeBi(24.0);
        builder.getFont().setItalicBi(true);
        builder.getFont().setBoldBi(true);
        builder.getFont().setLocaleIdBi(1025);
        
        // We can use the Bidi flag to indicate whether the text we are about to add
        // with the document builder is right-to-left. When we add text with this flag set to true,
        // it will be formatted using the right-to-left set of font settings.
        builder.getFont().setBidi(true);
        builder.write("مرحبًا");
        
        // Set the flag to false, and then add left-to-right text.
        // The document builder will format these using the left-to-right set of font settings.
        builder.getFont().setBidi(false);
        builder.write(" Hello world!");
        
        doc.save(getArtifactsDir() + "Font.Bidi.docx");
      • getLocaleIdFarEast/setLocaleIdFarEast

        public int getLocaleIdFarEast() / public void setLocaleIdFarEast(int value)
        
        Gets or sets the locale identifier (language) of the formatted Asian characters. For the list of locale identifiers see https://msdn.microsoft.com/en-us/library/cc233965.aspx

        Example:

        Shows how to insert and format text in a Far East language.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Specify font settings that the document builder will apply to any text that it inserts.
        builder.getFont().setName("Courier New");
        builder.getFont().setLocaleId(1033);
        
        // Name "FarEast" equivalents for our font and locale.
        // If the builder inserts Asian characters with this Font configuration, then each run that contains
        // these characters will display them using the "FarEast" font/locale instead of the default.
        // This could be useful when a western font does not have ideal representations for Asian characters.
        builder.getFont().setNameFarEast("SimSun");
        builder.getFont().setLocaleIdFarEast(2052);
        
        // This text will be displayed in the default font/locale.
        builder.writeln("Hello world!");
        
        // Since these are Asian characters, this run will apply our "FarEast" font/locale equivalents.
        builder.writeln("你好世界");
        
        doc.save(getArtifactsDir() + "Font.FarEast.docx");
      • getName/setName

        public java.lang.String getName() / public void setName(java.lang.String value)
        
        Gets or sets the name of the font.

        When getting, returns NameAscii.

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

        Example:

        Shows how to format a run of text using its font property.
        Document doc = new Document();
        Run run = new Run(doc, "Hello world!");
        
        Font font = run.getFont();
        font.setName("Courier New");
        font.setSize(36.0);
        font.setHighlightColor(Color.YELLOW);
        
        doc.getFirstSection().getBody().getFirstParagraph().appendChild(run);
        doc.save(getArtifactsDir() + "Font.CreateFormattedRun.docx");

        Example:

        Shows how to insert formatted text using DocumentBuilder.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Specify font formatting, then add text.
        Font font = builder.getFont();
        font.setSize(16.0);
        font.setBold(true);
        font.setColor(Color.BLUE);
        font.setName("Courier New");
        font.setUnderline(Underline.DASH);
        
        builder.write("Hello world!");
      • getNameAscii/setNameAscii

        public java.lang.String getNameAscii() / public void setNameAscii(java.lang.String value)
        
        Returns or sets the font used for Latin text (characters with character codes from 0 (zero) through 127).

        Example:

        Shows how Microsoft Word can combine two different fonts in one run.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Suppose a run that we use the builder to insert while using this font configuration
        // contains characters within the ASCII characters' range. In that case,
        // it will display those characters using this font.
        builder.getFont().setNameAscii("Calibri");
        
        // With no other font specified, the builder will also apply this font to all characters that it inserts.
        Assert.assertEquals("Calibri", builder.getFont().getName());
        
        // Specify a font to use for all characters outside of the ASCII range.
        // Ideally, this font should have a glyph for each required non-ASCII character code.
        builder.getFont().setNameOther("Courier New");
        
        // Insert a run with one word consisting of ASCII characters, and one word with all characters outside that range.
        // Each character will be displayed using either of the fonts, depending on.
        builder.writeln("Hello, Привет");
        
        doc.save(getArtifactsDir() + "Font.NameAscii.docx");
        See Also:
        Name
      • getNameBi/setNameBi

        public java.lang.String getNameBi() / public void setNameBi(java.lang.String value)
        
        Returns or sets the name of the font in a right-to-left language document.

        Example:

        Shows how to define separate sets of font settings for right-to-left, and right-to-left text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Define a set of font settings for left-to-right text.
        builder.getFont().setName("Courier New");
        builder.getFont().setSize(16.0);
        builder.getFont().setItalic(false);
        builder.getFont().setBold(false);
        builder.getFont().setLocaleId(1033);
        
        // Define another set of font settings for right-to-left text.
        builder.getFont().setNameBi("Andalus");
        builder.getFont().setSizeBi(24.0);
        builder.getFont().setItalicBi(true);
        builder.getFont().setBoldBi(true);
        builder.getFont().setLocaleIdBi(1025);
        
        // We can use the Bidi flag to indicate whether the text we are about to add
        // with the document builder is right-to-left. When we add text with this flag set to true,
        // it will be formatted using the right-to-left set of font settings.
        builder.getFont().setBidi(true);
        builder.write("مرحبًا");
        
        // Set the flag to false, and then add left-to-right text.
        // The document builder will format these using the left-to-right set of font settings.
        builder.getFont().setBidi(false);
        builder.write(" Hello world!");
        
        doc.save(getArtifactsDir() + "Font.Bidi.docx");
        See Also:
        Name
      • getNameFarEast/setNameFarEast

        public java.lang.String getNameFarEast() / public void setNameFarEast(java.lang.String value)
        
        Returns or sets an East Asian font name.

        Example:

        Shows how to insert and format text in a Far East language.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Specify font settings that the document builder will apply to any text that it inserts.
        builder.getFont().setName("Courier New");
        builder.getFont().setLocaleId(1033);
        
        // Name "FarEast" equivalents for our font and locale.
        // If the builder inserts Asian characters with this Font configuration, then each run that contains
        // these characters will display them using the "FarEast" font/locale instead of the default.
        // This could be useful when a western font does not have ideal representations for Asian characters.
        builder.getFont().setNameFarEast("SimSun");
        builder.getFont().setLocaleIdFarEast(2052);
        
        // This text will be displayed in the default font/locale.
        builder.writeln("Hello world!");
        
        // Since these are Asian characters, this run will apply our "FarEast" font/locale equivalents.
        builder.writeln("你好世界");
        
        doc.save(getArtifactsDir() + "Font.FarEast.docx");
        See Also:
        Name
      • getNameOther/setNameOther

        public java.lang.String getNameOther() / public void setNameOther(java.lang.String value)
        
        Returns or sets the font used for characters with character codes from 128 through 255.

        Example:

        Shows how Microsoft Word can combine two different fonts in one run.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Suppose a run that we use the builder to insert while using this font configuration
        // contains characters within the ASCII characters' range. In that case,
        // it will display those characters using this font.
        builder.getFont().setNameAscii("Calibri");
        
        // With no other font specified, the builder will also apply this font to all characters that it inserts.
        Assert.assertEquals("Calibri", builder.getFont().getName());
        
        // Specify a font to use for all characters outside of the ASCII range.
        // Ideally, this font should have a glyph for each required non-ASCII character code.
        builder.getFont().setNameOther("Courier New");
        
        // Insert a run with one word consisting of ASCII characters, and one word with all characters outside that range.
        // Each character will be displayed using either of the fonts, depending on.
        builder.writeln("Hello, Привет");
        
        doc.save(getArtifactsDir() + "Font.NameAscii.docx");
        See Also:
        Name
      • getNoProofing/setNoProofing

        public boolean getNoProofing() / public void setNoProofing(boolean value)
        
        True when the formatted characters are not to be spell checked.

        Example:

        Shows how to prevent text from being spell checked by Microsoft Word.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Normally, Microsoft Word emphasizes spelling errors with a jagged red underline.
        // We can un-set the "NoProofing" flag to create a portion of text that
        // bypasses the spell checker while completely disabling it.
        builder.getFont().setNoProofing(true);
        
        builder.writeln("Proofing has been disabled, so these spelking errrs will not display red lines underneath.");
        
        doc.save(getArtifactsDir() + "Font.NoProofing.docx");
      • getOutline/setOutline

        public boolean getOutline() / public void setOutline(boolean value)
        
        True if the font is formatted as outline.

        Example:

        Shows how to create a run of text formatted as outline.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Set the Outline flag to change the text's fill color to white and
        // leave a thin outline around each character in the original color of the text. 
        builder.getFont().setOutline(true);
        builder.getFont().setColor(Color.BLUE);
        builder.getFont().setSize(36.0);
        
        builder.writeln("This text has an outline.");
        
        doc.save(getArtifactsDir() + "Font.Outline.docx");
      • getPosition/setPosition

        public double getPosition() / public void setPosition(double value)
        
        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.

        Example:

        Shows how to format text to offset its position.
        Document doc = new Document();
        Paragraph para = (Paragraph) doc.getChild(NodeType.PARAGRAPH, 0, true);
        
        // Raise this run of text 5 points above the baseline.
        Run run = new Run(doc, "Raised text. ");
        run.getFont().setPosition(5.0);
        para.appendChild(run);
        
        // Lower this run of text 10 points below the baseline.
        run = new Run(doc, "Lowered text. ");
        run.getFont().setPosition(-10);
        para.appendChild(run);
        
        // Add a run of normal text.
        run = new Run(doc, "Text in its default position. ");
        para.appendChild(run);
        
        // Add a run of text that appears as subscript.
        run = new Run(doc, "Subscript. ");
        run.getFont().setSubscript(true);
        para.appendChild(run);
        
        // Add a run of text that appears as superscript.
        run = new Run(doc, "Superscript.");
        run.getFont().setSuperscript(true);
        para.appendChild(run);
        
        doc.save(getArtifactsDir() + "Font.PositionSubscript.docx");
      • getScaling/setScaling

        public int getScaling() / public void setScaling(int value)
        
        Gets or sets character width scaling in percent.

        Example:

        Shows how to set horizontal scaling and spacing for characters.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Add run of text and increase character width to 150%.
        builder.getFont().setScaling(150);
        builder.writeln("Wide characters");
        
        // Add run of text and add 1pt of extra horizontal spacing between each character.
        builder.getFont().setSpacing(1.0);
        builder.writeln("Expanded by 1pt");
        
        // Add run of text and bring characters closer together by 1pt.
        builder.getFont().setSpacing(-1);
        builder.writeln("Condensed by 1pt");
        
        doc.save(getArtifactsDir() + "Font.ScalingSpacing.docx");
      • getShading

        public Shading getShading()
        
        Returns a Shading object that refers to the shading formatting for the font.

        Example:

        Shows how to apply shading to text created by a document builder.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().setColor(Color.WHITE);
        
        // One way to make the text created using our white font color visible
        // is to apply a background shading effect.
        Shading shading = builder.getFont().getShading();
        shading.setTexture(TextureIndex.TEXTURE_DIAGONAL_UP);
        shading.setBackgroundPatternColor(Color.RED);
        shading.setForegroundPatternColor(Color.BLUE);
        
        builder.writeln("White text on an orange background with a two-tone texture.");
        
        doc.save(getArtifactsDir() + "Font.Shading.docx");
      • getShadow/setShadow

        public boolean getShadow() / public void setShadow(boolean value)
        
        True if the font is formatted as shadowed.

        Example:

        Shows how to create a run of text formatted with a shadow.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Set the Shadow flag to apply an offset shadow effect,
        // making it look like the letters are floating above the page.
        builder.getFont().setShadow(true);
        builder.getFont().setSize(36.0);
        
        builder.writeln("This text has a shadow.");
        
        doc.save(getArtifactsDir() + "Font.Shadow.docx");
      • getSize/setSize

        public double getSize() / public void setSize(double value)
        
        Gets or sets the font size in points.

        Example:

        Shows how to format a run of text using its font property.
        Document doc = new Document();
        Run run = new Run(doc, "Hello world!");
        
        Font font = run.getFont();
        font.setName("Courier New");
        font.setSize(36.0);
        font.setHighlightColor(Color.YELLOW);
        
        doc.getFirstSection().getBody().getFirstParagraph().appendChild(run);
        doc.save(getArtifactsDir() + "Font.CreateFormattedRun.docx");

        Example:

        Shows how to insert formatted text using DocumentBuilder.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Specify font formatting, then add text.
        Font font = builder.getFont();
        font.setSize(16.0);
        font.setBold(true);
        font.setColor(Color.BLUE);
        font.setName("Courier New");
        font.setUnderline(Underline.DASH);
        
        builder.write("Hello world!");
      • getSizeBi/setSizeBi

        public double getSizeBi() / public void setSizeBi(double value)
        
        Gets or sets the font size in points used in a right-to-left document.

        Example:

        Shows how to define separate sets of font settings for right-to-left, and right-to-left text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Define a set of font settings for left-to-right text.
        builder.getFont().setName("Courier New");
        builder.getFont().setSize(16.0);
        builder.getFont().setItalic(false);
        builder.getFont().setBold(false);
        builder.getFont().setLocaleId(1033);
        
        // Define another set of font settings for right-to-left text.
        builder.getFont().setNameBi("Andalus");
        builder.getFont().setSizeBi(24.0);
        builder.getFont().setItalicBi(true);
        builder.getFont().setBoldBi(true);
        builder.getFont().setLocaleIdBi(1025);
        
        // We can use the Bidi flag to indicate whether the text we are about to add
        // with the document builder is right-to-left. When we add text with this flag set to true,
        // it will be formatted using the right-to-left set of font settings.
        builder.getFont().setBidi(true);
        builder.write("مرحبًا");
        
        // Set the flag to false, and then add left-to-right text.
        // The document builder will format these using the left-to-right set of font settings.
        builder.getFont().setBidi(false);
        builder.write(" Hello world!");
        
        doc.save(getArtifactsDir() + "Font.Bidi.docx");
      • getSmallCaps/setSmallCaps

        public boolean getSmallCaps() / public void setSmallCaps(boolean value)
        
        True if the font is formatted as small capital letters.

        Example:

        Shows how to format a run to display its contents in capitals.
        Document doc = new Document();
        Paragraph para = (Paragraph) doc.getChild(NodeType.PARAGRAPH, 0, true);
        
        // There are two ways of getting a run to display its lowercase text in uppercase without changing the contents.
        // 1 -  Set the AllCaps flag to display all characters in regular capitals:
        Run run = new Run(doc, "all capitals");
        run.getFont().setAllCaps(true);
        para.appendChild(run);
        
        para = (Paragraph) para.getParentNode().appendChild(new Paragraph(doc));
        
        // 2 -  Set the SmallCaps flag to display all characters in small capitals:
        // If a character is lower case, it will appear in its upper case form
        // but will have the same height as the lower case (the font's x-height).
        // Characters that were in upper case originally will look the same.
        run = new Run(doc, "Small Capitals");
        run.getFont().setSmallCaps(true);
        para.appendChild(run);
        
        doc.save(getArtifactsDir() + "Font.Caps.docx");
      • getSnapToGrid/setSnapToGrid

        public boolean getSnapToGrid() / public void setSnapToGrid(boolean value)
        
        Specifies whether the current font should use the document grid characters per line settings when laying out.
      • getSpacing/setSpacing

        public double getSpacing() / public void setSpacing(double value)
        
        Returns or sets the spacing (in points) between characters .

        Example:

        Shows how to set horizontal scaling and spacing for characters.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Add run of text and increase character width to 150%.
        builder.getFont().setScaling(150);
        builder.writeln("Wide characters");
        
        // Add run of text and add 1pt of extra horizontal spacing between each character.
        builder.getFont().setSpacing(1.0);
        builder.writeln("Expanded by 1pt");
        
        // Add run of text and bring characters closer together by 1pt.
        builder.getFont().setSpacing(-1);
        builder.writeln("Condensed by 1pt");
        
        doc.save(getArtifactsDir() + "Font.ScalingSpacing.docx");
      • getStrikeThrough/setStrikeThrough

        public boolean getStrikeThrough() / public void setStrikeThrough(boolean value)
        
        True if the font is formatted as strikethrough text.

        Example:

        Shows how to add a line strikethrough to text.
        Document doc = new Document();
        Paragraph para = (Paragraph) doc.getChild(NodeType.PARAGRAPH, 0, true);
        
        Run run = new Run(doc, "Text with a single-line strikethrough.");
        run.getFont().setStrikeThrough(true);
        para.appendChild(run);
        
        para = (Paragraph) para.getParentNode().appendChild(new Paragraph(doc));
        
        run = new Run(doc, "Text with a double-line strikethrough.");
        run.getFont().setDoubleStrikeThrough(true);
        para.appendChild(run);
        
        doc.save(getArtifactsDir() + "Font.StrikeThrough.docx");
      • getStyle/setStyle

        public Style getStyle() / public void setStyle(Style value)
        
        Gets or sets the character style applied to this formatting.

        Example:

        Applies a double underline to all runs in a document that are formatted with custom character styles.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Insert a custom style and apply it to text created using a document builder.
        Style style = doc.getStyles().add(StyleType.CHARACTER, "MyStyle");
        style.getFont().setColor(Color.RED);
        style.getFont().setName("Courier New");
        
        builder.getFont().setStyleName("MyStyle");
        builder.write("This text is in a custom style.");
        
        // Iterate over every run and add a double underline to every custom style.
        for (Run run : (Iterable<Run>) doc.getChildNodes(NodeType.RUN, true)) {
            Style charStyle = run.getFont().getStyle();
        
            if (!charStyle.getBuiltIn())
                run.getFont().setUnderline(Underline.DOUBLE);
        }
        
        doc.save(getArtifactsDir() + "Font.Style.docx");
      • getStyleIdentifier/setStyleIdentifier

        public int getStyleIdentifier() / public void setStyleIdentifier(int value)
        
        Gets or sets the locale independent style identifier of the character style applied to this formatting. The value of the property is StyleIdentifier integer constant.

        Example:

        Shows how to change the style of existing text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Below are two ways of referencing styles.
        // 1 -  Using the style name:
        builder.getFont().setStyleName("Emphasis");
        builder.writeln("Text originally in \"Emphasis\" style");
        
        // 2 -  Using a built-in style identifier:
        builder.getFont().setStyleIdentifier(StyleIdentifier.INTENSE_EMPHASIS);
        builder.writeln("Text originally in \"Intense Emphasis\" style");
        
        // Convert all uses of one style to another,
        // using the above methods to reference old and new styles.
        for (Run run : (Iterable<Run>) doc.getChildNodes(NodeType.RUN, true)) {
            if (run.getFont().getStyleName().equals("Emphasis"))
                run.getFont().setStyleName("Strong");
        
            if (((run.getFont().getStyleIdentifier()) == (StyleIdentifier.INTENSE_EMPHASIS)))
                run.getFont().setStyleIdentifier(StyleIdentifier.STRONG);
        }
        
        doc.save(getArtifactsDir() + "Font.ChangeStyle.docx");
      • getStyleName/setStyleName

        public java.lang.String getStyleName() / public void setStyleName(java.lang.String value)
        
        Gets or sets the name of the character style applied to this formatting.

        Example:

        Shows how to change the style of existing text.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Below are two ways of referencing styles.
        // 1 -  Using the style name:
        builder.getFont().setStyleName("Emphasis");
        builder.writeln("Text originally in \"Emphasis\" style");
        
        // 2 -  Using a built-in style identifier:
        builder.getFont().setStyleIdentifier(StyleIdentifier.INTENSE_EMPHASIS);
        builder.writeln("Text originally in \"Intense Emphasis\" style");
        
        // Convert all uses of one style to another,
        // using the above methods to reference old and new styles.
        for (Run run : (Iterable<Run>) doc.getChildNodes(NodeType.RUN, true)) {
            if (run.getFont().getStyleName().equals("Emphasis"))
                run.getFont().setStyleName("Strong");
        
            if (((run.getFont().getStyleIdentifier()) == (StyleIdentifier.INTENSE_EMPHASIS)))
                run.getFont().setStyleIdentifier(StyleIdentifier.STRONG);
        }
        
        doc.save(getArtifactsDir() + "Font.ChangeStyle.docx");
      • getSubscript/setSubscript

        public boolean getSubscript() / public void setSubscript(boolean value)
        
        True if the font is formatted as subscript.

        Example:

        Shows how to format text to offset its position.
        Document doc = new Document();
        Paragraph para = (Paragraph) doc.getChild(NodeType.PARAGRAPH, 0, true);
        
        // Raise this run of text 5 points above the baseline.
        Run run = new Run(doc, "Raised text. ");
        run.getFont().setPosition(5.0);
        para.appendChild(run);
        
        // Lower this run of text 10 points below the baseline.
        run = new Run(doc, "Lowered text. ");
        run.getFont().setPosition(-10);
        para.appendChild(run);
        
        // Add a run of normal text.
        run = new Run(doc, "Text in its default position. ");
        para.appendChild(run);
        
        // Add a run of text that appears as subscript.
        run = new Run(doc, "Subscript. ");
        run.getFont().setSubscript(true);
        para.appendChild(run);
        
        // Add a run of text that appears as superscript.
        run = new Run(doc, "Superscript.");
        run.getFont().setSuperscript(true);
        para.appendChild(run);
        
        doc.save(getArtifactsDir() + "Font.PositionSubscript.docx");
      • getSuperscript/setSuperscript

        public boolean getSuperscript() / public void setSuperscript(boolean value)
        
        True if the font is formatted as superscript.

        Example:

        Shows how to format text to offset its position.
        Document doc = new Document();
        Paragraph para = (Paragraph) doc.getChild(NodeType.PARAGRAPH, 0, true);
        
        // Raise this run of text 5 points above the baseline.
        Run run = new Run(doc, "Raised text. ");
        run.getFont().setPosition(5.0);
        para.appendChild(run);
        
        // Lower this run of text 10 points below the baseline.
        run = new Run(doc, "Lowered text. ");
        run.getFont().setPosition(-10);
        para.appendChild(run);
        
        // Add a run of normal text.
        run = new Run(doc, "Text in its default position. ");
        para.appendChild(run);
        
        // Add a run of text that appears as subscript.
        run = new Run(doc, "Subscript. ");
        run.getFont().setSubscript(true);
        para.appendChild(run);
        
        // Add a run of text that appears as superscript.
        run = new Run(doc, "Superscript.");
        run.getFont().setSuperscript(true);
        para.appendChild(run);
        
        doc.save(getArtifactsDir() + "Font.PositionSubscript.docx");
      • getTextEffect/setTextEffect

        public int getTextEffect() / public void setTextEffect(int value)
        
        Gets or sets the font animation effect. The value of the property is TextEffect integer constant.

        Example:

        Shows how to apply a visual effect to a run.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().setSize(36.0);
        builder.getFont().setTextEffect(TextEffect.SPARKLE_TEXT);
        
        builder.writeln("Text with a sparkle effect.");
        
        // Older versions of Microsoft Word only support font animation effects.
        doc.save(getArtifactsDir() + "Font.SparklingText.doc");
      • getThemeColor/setThemeColor

        public int getThemeColor() / public void setThemeColor(int value)
        
        Gets or sets the theme color in the applied color scheme that is associated with this Font object. The value of the property is ThemeColor integer constant.

        Example:

        Shows how to create and use themed style.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.writeln();
        
        // Create some style with theme font properties.
        Style style = doc.getStyles().add(StyleType.PARAGRAPH, "ThemedStyle");
        style.getFont().setThemeFont(ThemeFont.MAJOR);
        style.getFont().setThemeColor(ThemeColor.ACCENT_5);
        style.getFont().setTintAndShade(0.3);
        
        builder.getParagraphFormat().setStyleName("ThemedStyle");
        builder.writeln("Text with themed style");

        Example:

        Shows how to work with theme fonts and colors.
        Document doc = new Document();
        
        // Define fonts for languages uses by default.
        doc.getTheme().getMinorFonts().setLatin("Algerian");
        doc.getTheme().getMinorFonts().setEastAsian("Aharoni");
        doc.getTheme().getMinorFonts().setComplexScript("Andalus");
        
        Font font = doc.getStyles().get("Normal").getFont();
        System.out.println(MessageFormat.format("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.getThemeColor(), font.getColor()));
        
        // We can use theme font and color instead of default values.
        font.setThemeFont(ThemeFont.MINOR);
        font.setThemeColor(ThemeColor.ACCENT_2);
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.ACCENT_2, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // There are several ways of reset them font and color.
        // 1 -  By setting ThemeFont.None/ThemeColor.None:
        font.setThemeFont(ThemeFont.NONE);
        font.setThemeColor(ThemeColor.NONE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // 2 -  By setting non-theme font/color names:
        font.setName("Arial");
        font.setColor(Color.BLUE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Arial", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Arial", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Arial", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Arial", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Arial", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(Color.BLUE.getRGB(), font.getColor().getRGB());
      • getThemeFont/setThemeFont

        public int getThemeFont() / public void setThemeFont(int value)
        
        Gets or sets the theme font in the applied font scheme that is associated with this Font object. The value of the property is ThemeFont integer constant.

        Example:

        Shows how to create and use themed style.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.writeln();
        
        // Create some style with theme font properties.
        Style style = doc.getStyles().add(StyleType.PARAGRAPH, "ThemedStyle");
        style.getFont().setThemeFont(ThemeFont.MAJOR);
        style.getFont().setThemeColor(ThemeColor.ACCENT_5);
        style.getFont().setTintAndShade(0.3);
        
        builder.getParagraphFormat().setStyleName("ThemedStyle");
        builder.writeln("Text with themed style");

        Example:

        Shows how to work with theme fonts and colors.
        Document doc = new Document();
        
        // Define fonts for languages uses by default.
        doc.getTheme().getMinorFonts().setLatin("Algerian");
        doc.getTheme().getMinorFonts().setEastAsian("Aharoni");
        doc.getTheme().getMinorFonts().setComplexScript("Andalus");
        
        Font font = doc.getStyles().get("Normal").getFont();
        System.out.println(MessageFormat.format("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.getThemeColor(), font.getColor()));
        
        // We can use theme font and color instead of default values.
        font.setThemeFont(ThemeFont.MINOR);
        font.setThemeColor(ThemeColor.ACCENT_2);
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.ACCENT_2, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // There are several ways of reset them font and color.
        // 1 -  By setting ThemeFont.None/ThemeColor.None:
        font.setThemeFont(ThemeFont.NONE);
        font.setThemeColor(ThemeColor.NONE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // 2 -  By setting non-theme font/color names:
        font.setName("Arial");
        font.setColor(Color.BLUE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Arial", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Arial", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Arial", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Arial", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Arial", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(Color.BLUE.getRGB(), font.getColor().getRGB());
      • getThemeFontAscii/setThemeFontAscii

        public int getThemeFontAscii() / public void setThemeFontAscii(int value)
        
        Gets or sets the theme font used for Latin text (characters with character codes from 0 (zero) through 127) in the applied font scheme that is associated with this Font object. The value of the property is ThemeFont integer constant.

        Example:

        Shows how to work with theme fonts and colors.
        Document doc = new Document();
        
        // Define fonts for languages uses by default.
        doc.getTheme().getMinorFonts().setLatin("Algerian");
        doc.getTheme().getMinorFonts().setEastAsian("Aharoni");
        doc.getTheme().getMinorFonts().setComplexScript("Andalus");
        
        Font font = doc.getStyles().get("Normal").getFont();
        System.out.println(MessageFormat.format("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.getThemeColor(), font.getColor()));
        
        // We can use theme font and color instead of default values.
        font.setThemeFont(ThemeFont.MINOR);
        font.setThemeColor(ThemeColor.ACCENT_2);
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.ACCENT_2, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // There are several ways of reset them font and color.
        // 1 -  By setting ThemeFont.None/ThemeColor.None:
        font.setThemeFont(ThemeFont.NONE);
        font.setThemeColor(ThemeColor.NONE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // 2 -  By setting non-theme font/color names:
        font.setName("Arial");
        font.setColor(Color.BLUE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Arial", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Arial", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Arial", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Arial", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Arial", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(Color.BLUE.getRGB(), font.getColor().getRGB());
      • getThemeFontBi/setThemeFontBi

        public int getThemeFontBi() / public void setThemeFontBi(int value)
        
        Gets or sets the theme font in the applied font scheme that is associated with this Font object in a right-to-left language document. The value of the property is ThemeFont integer constant.

        Example:

        Shows how to work with theme fonts and colors.
        Document doc = new Document();
        
        // Define fonts for languages uses by default.
        doc.getTheme().getMinorFonts().setLatin("Algerian");
        doc.getTheme().getMinorFonts().setEastAsian("Aharoni");
        doc.getTheme().getMinorFonts().setComplexScript("Andalus");
        
        Font font = doc.getStyles().get("Normal").getFont();
        System.out.println(MessageFormat.format("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.getThemeColor(), font.getColor()));
        
        // We can use theme font and color instead of default values.
        font.setThemeFont(ThemeFont.MINOR);
        font.setThemeColor(ThemeColor.ACCENT_2);
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.ACCENT_2, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // There are several ways of reset them font and color.
        // 1 -  By setting ThemeFont.None/ThemeColor.None:
        font.setThemeFont(ThemeFont.NONE);
        font.setThemeColor(ThemeColor.NONE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // 2 -  By setting non-theme font/color names:
        font.setName("Arial");
        font.setColor(Color.BLUE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Arial", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Arial", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Arial", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Arial", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Arial", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(Color.BLUE.getRGB(), font.getColor().getRGB());
      • getThemeFontFarEast/setThemeFontFarEast

        public int getThemeFontFarEast() / public void setThemeFontFarEast(int value)
        
        Gets or sets the East Asian theme font in the applied font scheme that is associated with this Font object. The value of the property is ThemeFont integer constant.

        Example:

        Shows how to work with theme fonts and colors.
        Document doc = new Document();
        
        // Define fonts for languages uses by default.
        doc.getTheme().getMinorFonts().setLatin("Algerian");
        doc.getTheme().getMinorFonts().setEastAsian("Aharoni");
        doc.getTheme().getMinorFonts().setComplexScript("Andalus");
        
        Font font = doc.getStyles().get("Normal").getFont();
        System.out.println(MessageFormat.format("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.getThemeColor(), font.getColor()));
        
        // We can use theme font and color instead of default values.
        font.setThemeFont(ThemeFont.MINOR);
        font.setThemeColor(ThemeColor.ACCENT_2);
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.ACCENT_2, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // There are several ways of reset them font and color.
        // 1 -  By setting ThemeFont.None/ThemeColor.None:
        font.setThemeFont(ThemeFont.NONE);
        font.setThemeColor(ThemeColor.NONE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // 2 -  By setting non-theme font/color names:
        font.setName("Arial");
        font.setColor(Color.BLUE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Arial", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Arial", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Arial", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Arial", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Arial", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(Color.BLUE.getRGB(), font.getColor().getRGB());
      • getThemeFontOther/setThemeFontOther

        public int getThemeFontOther() / public void setThemeFontOther(int value)
        
        Gets or sets the theme font used for characters with character codes from 128 through 255 in the applied font scheme that is associated with this Font object. The value of the property is ThemeFont integer constant.

        Example:

        Shows how to work with theme fonts and colors.
        Document doc = new Document();
        
        // Define fonts for languages uses by default.
        doc.getTheme().getMinorFonts().setLatin("Algerian");
        doc.getTheme().getMinorFonts().setEastAsian("Aharoni");
        doc.getTheme().getMinorFonts().setComplexScript("Andalus");
        
        Font font = doc.getStyles().get("Normal").getFont();
        System.out.println(MessageFormat.format("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.getThemeColor(), font.getColor()));
        
        // We can use theme font and color instead of default values.
        font.setThemeFont(ThemeFont.MINOR);
        font.setThemeColor(ThemeColor.ACCENT_2);
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.ACCENT_2, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // There are several ways of reset them font and color.
        // 1 -  By setting ThemeFont.None/ThemeColor.None:
        font.setThemeFont(ThemeFont.NONE);
        font.setThemeColor(ThemeColor.NONE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Algerian", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Algerian", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Andalus", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Aharoni", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Algerian", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(0, font.getColor().getRGB());
        
        // 2 -  By setting non-theme font/color names:
        font.setName("Arial");
        font.setColor(Color.BLUE);
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
        Assert.assertEquals("Arial", font.getName());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
        Assert.assertEquals("Arial", font.getNameAscii());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
        Assert.assertEquals("Arial", font.getNameBi());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
        Assert.assertEquals("Arial", font.getNameFarEast());
        
        Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
        Assert.assertEquals("Arial", font.getNameOther());
        
        Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
        Assert.assertEquals(Color.BLUE.getRGB(), font.getColor().getRGB());
      • getTintAndShade/setTintAndShade

        public double getTintAndShade() / public void setTintAndShade(double value)
        
        Gets or sets a double value that lightens or darkens a color.

        The allowed values are in range from -1 (darkest) to 1 (lightest) for this property. Zero (0) is neutral. Attempting to set this property to a value less than -1 or more than 1 results in a java.lang.IllegalArgumentException.

        Setting this property for Font object with non-theme colors results in a java.lang.IllegalStateException.

        Example:

        Shows how to create and use themed style.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.writeln();
        
        // Create some style with theme font properties.
        Style style = doc.getStyles().add(StyleType.PARAGRAPH, "ThemedStyle");
        style.getFont().setThemeFont(ThemeFont.MAJOR);
        style.getFont().setThemeColor(ThemeColor.ACCENT_5);
        style.getFont().setTintAndShade(0.3);
        
        builder.getParagraphFormat().setStyleName("ThemedStyle");
        builder.writeln("Text with themed style");
      • getUnderline/setUnderline

        public int getUnderline() / public void setUnderline(int value)
        
        Gets or sets the type of underline applied to the font. The value of the property is Underline integer constant.

        Example:

        Shows how to configure the style and color of a text underline.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().setUnderline(Underline.DOTTED);
        builder.getFont().setUnderlineColor(Color.RED);
        
        builder.writeln("Underlined text.");
        
        doc.save(getArtifactsDir() + "Font.Underlines.docx");

        Example:

        Shows how to insert formatted text using DocumentBuilder.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Specify font formatting, then add text.
        Font font = builder.getFont();
        font.setSize(16.0);
        font.setBold(true);
        font.setColor(Color.BLUE);
        font.setName("Courier New");
        font.setUnderline(Underline.DASH);
        
        builder.write("Hello world!");

        Example:

        Shows how to insert a hyperlink field.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("For more information, please visit the ");
        
        // Insert a hyperlink and emphasize it with custom formatting.
        // The hyperlink will be a clickable piece of text which will take us to the location specified in the URL.
        builder.getFont().setColor(Color.BLUE);
        builder.getFont().setUnderline(Underline.SINGLE);
        builder.insertHyperlink("Google website", "https://www.google.com", false);
        builder.getFont().clearFormatting();
        builder.writeln(".");
        
        // Ctrl + left clicking the link in the text in Microsoft Word will take us to the URL via a new web browser window.
        doc.save(getArtifactsDir() + "DocumentBuilder.InsertHyperlink.docx");
      • getUnderlineColor/setUnderlineColor

        public java.awt.Color getUnderlineColor() / public void setUnderlineColor(java.awt.Color value)
        
        Gets or sets the color of the underline applied to the font.

        Example:

        Shows how to configure the style and color of a text underline.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.getFont().setUnderline(Underline.DOTTED);
        builder.getFont().setUnderlineColor(Color.RED);
        
        builder.writeln("Underlined text.");
        
        doc.save(getArtifactsDir() + "Font.Underlines.docx");
    • Method Detail

      • clearFormatting

        public void 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.

        Example:

        Shows how to insert a hyperlink field.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("For more information, please visit the ");
        
        // Insert a hyperlink and emphasize it with custom formatting.
        // The hyperlink will be a clickable piece of text which will take us to the location specified in the URL.
        builder.getFont().setColor(Color.BLUE);
        builder.getFont().setUnderline(Underline.SINGLE);
        builder.insertHyperlink("Google website", "https://www.google.com", false);
        builder.getFont().clearFormatting();
        builder.writeln(".");
        
        // Ctrl + left clicking the link in the text in Microsoft Word will take us to the URL via a new web browser window.
        doc.save(getArtifactsDir() + "DocumentBuilder.InsertHyperlink.docx");
      • hasDmlEffect

        public boolean hasDmlEffect(int dmlEffectType)
        Checks if particular DrawingML text effect is applied.
        Parameters:
        dmlEffectType - A TextDmlEffect value. DrawingML text effect type.
        Returns:
        True if particular DrawingML text effect is applied.

        Example:

        Shows how to check if a run displays a DrawingML text effect.
        Document doc = new Document(getMyDir() + "DrawingML text effects.docx");
        
        RunCollection runs = doc.getFirstSection().getBody().getFirstParagraph().getRuns();
        
        Assert.assertTrue(runs.get(0).getFont().hasDmlEffect(TextDmlEffect.SHADOW));
        Assert.assertTrue(runs.get(1).getFont().hasDmlEffect(TextDmlEffect.SHADOW));
        Assert.assertTrue(runs.get(2).getFont().hasDmlEffect(TextDmlEffect.REFLECTION));
        Assert.assertTrue(runs.get(3).getFont().hasDmlEffect(TextDmlEffect.EFFECT_3_D));
        Assert.assertTrue(runs.get(4).getFont().hasDmlEffect(TextDmlEffect.FILL));