FontsManager

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.IFontsManager

public class FontsManager implements IFontsManager

Manages fonts across the presentation.


The following example shows how to add embedded fonts to PowerPoint Presentation.
 
 // Load presentation
 Presentation pres = new Presentation("Fonts.pptx");
 try {
     // Load source font to be replaced
     IFontData sourceFont = new FontData("Arial");
     IFontData[] allFonts = pres.getFontsManager().getFonts();
     for (IFontData font : allFonts)
     {
         boolean fontAlreadyEmbedded = false;
         IFontData[] embeddedFonts = pres.getFontsManager().getEmbeddedFonts();
         for (int i = 0; i < embeddedFonts.length; i++)
         {
             if (embeddedFonts[i].equals(font))
             {
                 fontAlreadyEmbedded = true;
                 break;
             }
         }
         if (!fontAlreadyEmbedded) {
             pres.getFontsManager().addEmbeddedFont(font, EmbedFontCharacters.All);
         }
     }
     // Save the presentation
     pres.save("AddEmbeddedFont_out.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Methods

MethodDescription
getFontSubstRuleList()Font substitutions to use when rendering.
setFontSubstRuleList(IFontSubstRuleCollection value)Font substitutions to use when rendering.
getFontFallBackRulesCollection()Represents a user’s collection of FontFallBack rules for managing of collections of fonts for proper substitutions by fallback functionality Read/write IFontFallBackRulesCollection.
setFontFallBackRulesCollection(IFontFallBackRulesCollection value)Represents a user’s collection of FontFallBack rules for managing of collections of fonts for proper substitutions by fallback functionality Read/write IFontFallBackRulesCollection.
getFonts()Returns the fonts used in the presentation
getSubstitutions()Gets the information about fonts that will be replaced on the presentation’s rendering.
getEmbeddedFonts()Returns the fonts embedded in the presentation
removeEmbeddedFont(IFontData fontData)Removes the embedded font
addEmbeddedFont(IFontData fontData, int embedFontRule)Adds the embedded font
addEmbeddedFont(byte[] fontData, int embedFontRule)Adds the embedded font
replaceFont(IFontData sourceFont, IFontData destFont)Replace font in presentation
replaceFont(IFontSubstRule substRule)Replace font in presentation using information provided in FontSubstRule
replaceFont(IFontSubstRuleCollection substRules)Replace font in presentation using information provided in collection of FontSubstRule

getFontSubstRuleList()

public final IFontSubstRuleCollection getFontSubstRuleList()

Font substitutions to use when rendering. Read/write IFontSubstRuleCollection.

Returns: IFontSubstRuleCollection

setFontSubstRuleList(IFontSubstRuleCollection value)

public final void setFontSubstRuleList(IFontSubstRuleCollection value)

Font substitutions to use when rendering. Read/write IFontSubstRuleCollection.

Parameters:

ParameterTypeDescription
valueIFontSubstRuleCollection

getFontFallBackRulesCollection()

public final IFontFallBackRulesCollection getFontFallBackRulesCollection()

Represents a user’s collection of FontFallBack rules for managing of collections of fonts for proper substitutions by fallback functionality Read/write IFontFallBackRulesCollection.


Presentation pres = new Presentation();
 try
 {
     // Getting of empty or preinitialized rules collection from FontsManager
     IFontFallBackRulesCollection rulesList = pres.getFontsManager().getFontFallBackRulesCollection();
     // adding of rules to collection
     rulesList.add(new FontFallBackRule(0x400,0x4FF, "Times New Roman"));
     // or 
     // initialization of new instance of rules collection
     IFontFallBackRulesCollection rulesList = new FontFallBackRulesCollection();
     // adding of rules to collection
     rulesList.add(new FontFallBackRule(0x400,0x4FF, "Times New Roman"));
     // and replacing of existing collection by the new one in FontsManager 
     pres.getFontsManager().setFontFallBackRulesCollection(rulesList);
 }
 finally {
     if (pres != null) pres.dispose();
 }

Returns: IFontFallBackRulesCollection

setFontFallBackRulesCollection(IFontFallBackRulesCollection value)

public final void setFontFallBackRulesCollection(IFontFallBackRulesCollection value)

Represents a user’s collection of FontFallBack rules for managing of collections of fonts for proper substitutions by fallback functionality Read/write IFontFallBackRulesCollection.


Presentation pres = new Presentation();
 try
 {
     // Getting of empty or preinitialized rules collection from FontsManager
     IFontFallBackRulesCollection rulesList = pres.getFontsManager().getFontFallBackRulesCollection();
     // adding of rules to collection
     rulesList.add(new FontFallBackRule(0x400,0x4FF, "Times New Roman"));
     // or 
     // initialization of new instance of rules collection
     IFontFallBackRulesCollection rulesList = new FontFallBackRulesCollection();
     // adding of rules to collection
     rulesList.add(new FontFallBackRule(0x400,0x4FF, "Times New Roman"));
     // and replacing of existing collection by the new one in FontsManager 
     pres.getFontsManager().setFontFallBackRulesCollection(rulesList);
 }
 finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
valueIFontFallBackRulesCollection

getFonts()

public final IFontData[] getFonts()

Returns the fonts used in the presentation

Returns: com.aspose.slides.IFontData[] - An array of fonts

getSubstitutions()

public final System.Collections.Generic.IGenericEnumerable<FontSubstitutionInfo> getSubstitutions()

Gets the information about fonts that will be replaced on the presentation’s rendering.


Presentation pres = new Presentation("pres.pptx");
 try {
     for (FontSubstitutionInfo fontSubstitution : pres.getFontsManager().getSubstitutions())
     {
         System.out.println(fontSubstitution.getOriginalFontName() + " -> " + fontSubstitution.getSubstitutedFontName());
     }
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.slides.FontSubstitutionInfo> - Collection of all fonts substitution FontSubstitutionInfo.

getEmbeddedFonts()

public final IFontData[] getEmbeddedFonts()

Returns the fonts embedded in the presentation

Returns: com.aspose.slides.IFontData[]

removeEmbeddedFont(IFontData fontData)

public final void removeEmbeddedFont(IFontData fontData)

Removes the embedded font

Parameters:

ParameterTypeDescription
fontDataIFontData

addEmbeddedFont(IFontData fontData, int embedFontRule)

public final void addEmbeddedFont(IFontData fontData, int embedFontRule)

Adds the embedded font

Parameters:

ParameterTypeDescription
fontDataIFontData
embedFontRuleint

addEmbeddedFont(byte[] fontData, int embedFontRule)

public final void addEmbeddedFont(byte[] fontData, int embedFontRule)

Adds the embedded font

Parameters:

ParameterTypeDescription
fontDatabyte[]
embedFontRuleint

replaceFont(IFontData sourceFont, IFontData destFont)

public final void replaceFont(IFontData sourceFont, IFontData destFont)

Replace font in presentation

Parameters:

ParameterTypeDescription
sourceFontIFontDataSource font
destFontIFontDataDestination font

replaceFont(IFontSubstRule substRule)

public final void replaceFont(IFontSubstRule substRule)

Replace font in presentation using information provided in FontSubstRule

Parameters:

ParameterTypeDescription
substRuleIFontSubstRuleFont substitution info

replaceFont(IFontSubstRuleCollection substRules)

public final void replaceFont(IFontSubstRuleCollection substRules)

Replace font in presentation using information provided in collection of FontSubstRule

Parameters:

ParameterTypeDescription
substRulesIFontSubstRuleCollectionFont substitution rules collection