com.aspose.words

Class ThemeFonts

  • java.lang.Object
    • com.aspose.words.ThemeFonts
  • All Implemented Interfaces:
    java.lang.Cloneable
    public class ThemeFonts 
    extends java.lang.Object

Represents a collection of fonts in the font scheme, allowing to specify different fonts for different languages Latin, EastAsian and ComplexScript.

Example:

Shows how to set custom theme colors and fonts.
Document doc = new Document(getMyDir() + "ThemeColors.docx");

// This object gives us access to the document theme, which is a source of default fonts and colors
Theme theme = doc.getTheme();

// These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
theme.getMajorFonts().setLatin("Courier New");
theme.getMinorFonts().setLatin("Agency FB");

Assert.assertEquals(theme.getMajorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMajorFonts().getEastAsian(), "");
Assert.assertEquals(theme.getMinorFonts().getComplexScript(), "");
Assert.assertEquals(theme.getMinorFonts().getEastAsian(), "");

// This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color 
ThemeColors colors = theme.getColors();

// We will set the color of each color palette column going from left to right like this
colors.setDark1(Color.BLUE);
colors.setLight1(Color.GREEN);
colors.setDark2(Color.MAGENTA);
colors.setLight2(Color.BLACK);

colors.setAccent1(Color.RED);
colors.setAccent2(Color.PINK);
colors.setAccent3(Color.YELLOW);
colors.setAccent4(Color.orange);
colors.setAccent5(Color.cyan);
colors.setAccent6(Color.darkGray);

// We can also set colors for hyperlinks like this
colors.setHyperlink(Color.WHITE);
colors.setFollowedHyperlink(Color.lightGray);

doc.save(getArtifactsDir() + "Themes.CustomColorsAndFonts.docx");

Property Getters/Setters Summary
java.lang.StringgetComplexScript()
void
setComplexScript(java.lang.Stringvalue)
           Specifies font name for ComplexScript characters.
java.lang.StringgetEastAsian()
void
setEastAsian(java.lang.Stringvalue)
           Specifies font name for EastAsian characters.
java.lang.StringgetLatin()
void
setLatin(java.lang.Stringvalue)
           Specifies font name for Latin characters.
 

    • Property Getters/Setters Detail

      • getComplexScript/setComplexScript

        public java.lang.String getComplexScript() / public void setComplexScript(java.lang.String value)
        
        Specifies font name for ComplexScript characters.

        Example:

        Shows how to set custom theme colors and fonts.
        Document doc = new Document(getMyDir() + "ThemeColors.docx");
        
        // This object gives us access to the document theme, which is a source of default fonts and colors
        Theme theme = doc.getTheme();
        
        // These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
        theme.getMajorFonts().setLatin("Courier New");
        theme.getMinorFonts().setLatin("Agency FB");
        
        Assert.assertEquals(theme.getMajorFonts().getComplexScript(), "");
        Assert.assertEquals(theme.getMajorFonts().getEastAsian(), "");
        Assert.assertEquals(theme.getMinorFonts().getComplexScript(), "");
        Assert.assertEquals(theme.getMinorFonts().getEastAsian(), "");
        
        // This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color 
        ThemeColors colors = theme.getColors();
        
        // We will set the color of each color palette column going from left to right like this
        colors.setDark1(Color.BLUE);
        colors.setLight1(Color.GREEN);
        colors.setDark2(Color.MAGENTA);
        colors.setLight2(Color.BLACK);
        
        colors.setAccent1(Color.RED);
        colors.setAccent2(Color.PINK);
        colors.setAccent3(Color.YELLOW);
        colors.setAccent4(Color.orange);
        colors.setAccent5(Color.cyan);
        colors.setAccent6(Color.darkGray);
        
        // We can also set colors for hyperlinks like this
        colors.setHyperlink(Color.WHITE);
        colors.setFollowedHyperlink(Color.lightGray);
        
        doc.save(getArtifactsDir() + "Themes.CustomColorsAndFonts.docx");
      • getEastAsian/setEastAsian

        public java.lang.String getEastAsian() / public void setEastAsian(java.lang.String value)
        
        Specifies font name for EastAsian characters.

        Example:

        Shows how to set custom theme colors and fonts.
        Document doc = new Document(getMyDir() + "ThemeColors.docx");
        
        // This object gives us access to the document theme, which is a source of default fonts and colors
        Theme theme = doc.getTheme();
        
        // These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
        theme.getMajorFonts().setLatin("Courier New");
        theme.getMinorFonts().setLatin("Agency FB");
        
        Assert.assertEquals(theme.getMajorFonts().getComplexScript(), "");
        Assert.assertEquals(theme.getMajorFonts().getEastAsian(), "");
        Assert.assertEquals(theme.getMinorFonts().getComplexScript(), "");
        Assert.assertEquals(theme.getMinorFonts().getEastAsian(), "");
        
        // This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color 
        ThemeColors colors = theme.getColors();
        
        // We will set the color of each color palette column going from left to right like this
        colors.setDark1(Color.BLUE);
        colors.setLight1(Color.GREEN);
        colors.setDark2(Color.MAGENTA);
        colors.setLight2(Color.BLACK);
        
        colors.setAccent1(Color.RED);
        colors.setAccent2(Color.PINK);
        colors.setAccent3(Color.YELLOW);
        colors.setAccent4(Color.orange);
        colors.setAccent5(Color.cyan);
        colors.setAccent6(Color.darkGray);
        
        // We can also set colors for hyperlinks like this
        colors.setHyperlink(Color.WHITE);
        colors.setFollowedHyperlink(Color.lightGray);
        
        doc.save(getArtifactsDir() + "Themes.CustomColorsAndFonts.docx");
      • getLatin/setLatin

        public java.lang.String getLatin() / public void setLatin(java.lang.String value)
        
        Specifies font name for Latin characters.

        Example:

        Shows how to set custom theme colors and fonts.
        Document doc = new Document(getMyDir() + "ThemeColors.docx");
        
        // This object gives us access to the document theme, which is a source of default fonts and colors
        Theme theme = doc.getTheme();
        
        // These fonts will be inherited by some styles like "Heading 1" and "Subtitle"
        theme.getMajorFonts().setLatin("Courier New");
        theme.getMinorFonts().setLatin("Agency FB");
        
        Assert.assertEquals(theme.getMajorFonts().getComplexScript(), "");
        Assert.assertEquals(theme.getMajorFonts().getEastAsian(), "");
        Assert.assertEquals(theme.getMinorFonts().getComplexScript(), "");
        Assert.assertEquals(theme.getMinorFonts().getEastAsian(), "");
        
        // This collection of colors corresponds to the color palette from Microsoft Word which appears when changing shading or font color 
        ThemeColors colors = theme.getColors();
        
        // We will set the color of each color palette column going from left to right like this
        colors.setDark1(Color.BLUE);
        colors.setLight1(Color.GREEN);
        colors.setDark2(Color.MAGENTA);
        colors.setLight2(Color.BLACK);
        
        colors.setAccent1(Color.RED);
        colors.setAccent2(Color.PINK);
        colors.setAccent3(Color.YELLOW);
        colors.setAccent4(Color.orange);
        colors.setAccent5(Color.cyan);
        colors.setAccent6(Color.darkGray);
        
        // We can also set colors for hyperlinks like this
        colors.setHyperlink(Color.WHITE);
        colors.setFollowedHyperlink(Color.lightGray);
        
        doc.save(getArtifactsDir() + "Themes.CustomColorsAndFonts.docx");