Packages

 

com.aspose.imaging

Interfaces

Classes

Exceptions

com.aspose.imaging

Class FontSettings



  • public final class FontSettings
    extends Object

    General imaging vector formats renderer font settings. This static class allows add/change/override directories containing the TrueType fonts. The search of the font starts from last added folder to first added folder, if font has not been found the search continues using standard Java font management engine (in case if isJavaFontEngineUsed() return true otherwise default font will be returned.).

    • Method Detail

      • addFontsFolder

        public static void addFontsFolder(String fontFolder)
        Adds the fontFolder into font directory list and marks it as first folder for font searching
        Parameters:
        fontFolder - The folder contains the TrueType fonts or single font file path.
      • getFontsSources

        public static String[] getFontsSources()
        Returns all font folders which has been added by FontSettings methods
        Returns:
        The font folders list
      • getFontsFolders

        public static String[] getFontsFolders()

        Gets a copy of the array that contains the list of folders where Aspose.Imaging looks for TrueType fonts.

        The returned value is a copy of the data that Aspose.Imaging uses. If you change the entries in the returned array, it will have no effect on document rendering. To specify new font locations use the setFontsFolders method.

        Returns:
        A copy of the current font locations.
      • getDefaultFontsFolders

        public static String[] getDefaultFontsFolders()
        Gets the default fonts folders.
        Returns:
        Returns system folder
      • setFontsFolders

        public static void setFontsFolders(String[] folders)
        Override font folder list for folders
        Parameters:
        folders - Array of folder
      • setFontsFolders

        public static void setFontsFolders(String[] folders,
                                           boolean recursive)
        Sets the folders where TrueType fonts are loaded from and clears all loaded fonts. There are no checks performed on the fonts folders.
        Parameters:
        folders - The fonts folders.
        recursive - if set to true [recursive].
      • setFontsFolder

        public static void setFontsFolder(String folder)
        Override font folder list for folder
        Parameters:
        folder - Folder with TrueType fonts.
      • removeFontsFolder

        public static void removeFontsFolder(String folder)
        Removes folder from folder list
        Parameters:
        folder - The folder to remove
      • useJavaFontEngine

        public static void useJavaFontEngine(boolean use)

        Informs the search engine to use or not use the standard Java font management engine.

        Attention: if you set it to false be ready that some fonts could be not found if you do not correct set the folder list

        Parameters:
        use - flag true use the standard Java font management engine. false not use the standard Java font management engine.
      • isJavaFontEngineUsed

        public static boolean isJavaFontEngineUsed()
        Returns current flag to use the standard Java font management engine.
        Returns:
        true the standard Java font management engine is used. false the standard Java font management engine is not used.
      • resetFontSources

        public static void resetFontSources()
        Resets configuration
      • reset

        public static void reset()
        Resets the fonts folder and default font name to the system default.
      • updateFonts

        public static void updateFonts()

        Updates fonts cache for PSD files that contain text layers. This method guarantees that fonts from folder fontsFolder using method FontSettings.setFontsFolder(fontsFolder) or after reset fonts using FontSettings.reset() will be taken into consideration when processing PSD files. Please use this method each time when FontSettings.setFontsFolder(fontsFolder) or FontSettings.reset() called for PSD images. Without calling this Method there is no guarantee that fonts will be updated.

      • findFont

        public static Font findFont(String fontName,
                                    int fontStyle,
                                    int fontSize)
        Returns the required font (or default font if required font was not be found)
        Parameters:
        fontName - Font family
        fontStyle - Font style
        fontSize - Font size
        Returns:
        Font object
      • getAllFonts

        public static String[] getAllFonts()
        Returns the list of fonts that are accessible to Aspose.Imaging for Java API.
        Returns:
        Font list
      • addFontSubstitutes

        public static void addFontSubstitutes(String originalFontName,
                                              String[] substituteFontNames)

        Adds substitute (alternative) font names for given original font name.

        Parameters:
        originalFontName - The Font's real name
        substituteFontNames - The font's substitutions
      • getFontSubstitutes

        public static String[] getFontSubstitutes(String originalFontName)
        Returns array containing alternative font names to be used if original font is not presented in system.
        Parameters:
        originalFontName -
        Returns:
        array of font substitutes
      • setFontSubstitutes

        public static void setFontSubstitutes(String originalFontName,
                                              String[] substituteFontNames)
        Override substitute (alternative) font names for given original font name.
        Parameters:
        originalFontName -
        substituteFontNames -
      • getDefaultFontName

        public static String getDefaultFontName()
        Gets the default font name.
        Returns:
        default font's name
      • setDefaultFontName

        public static void setDefaultFontName(String fontName)
        Sets the default font name.
        Parameters:
        fontName - The default name of the font.
      • findFont

        public static Font findFont(Map<TextAttribute,Object> attributes)
        Returns the required font (or default font if required font was not be found)
        Parameters:
        attributes - Font attributes
        Returns:
        Font object