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

        A copy of the current font locations.
      • getDefaultFontsFolders

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

        public static void setFontsFolders(String[] folders)
        Override font folder list for folders
        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.
        folders - The fonts folders.
        recursive - if set to true [recursive].
      • setFontsFolder

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

        public static void removeFontsFolder(String folder)
        Removes folder from folder list
        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

        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.
        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)
        fontName - Font family
        fontStyle - Font style
        fontSize - Font size
        Font object
      • getAllFonts

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

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

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

        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.
        originalFontName -
        array of font substitutes
      • setFontSubstitutes

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

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

        public static void setDefaultFontName(String fontName)
        Sets the default font name.
        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)
        attributes - Font attributes
        Font object