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.).
Modifier and Type | Method and Description |
---|---|
static void |
addFontsFolder(String fontFolder)
Adds the
fontFolder into font directory list and marks it as first folder for font searching |
static void |
addFontSubstitutes(String originalFontName,
String[] substituteFontNames)
Adds substitute (alternative) font names for given original font name.
|
static Font |
findFont(Map<TextAttribute,Object> attributes)
Returns the required font (or default font if required font was not be found)
|
static Font |
findFont(String fontName,
int fontStyle,
int fontSize)
Returns the required font (or default font if required font was not be found)
|
static String[] |
getAllFonts()
Returns the list of fonts that are accessible to Aspose.Imaging for Java API.
|
static String |
getDefaultFontName()
Gets the default font name.
|
static String[] |
getDefaultFontsFolders()
Gets the default fonts folders.
|
static String[] |
getFontsFolders()
Gets a copy of the array that contains the list of folders where Aspose.Imaging looks for TrueType fonts.
|
static String[] |
getFontsSources()
Returns all font folders which has been added by
FontSettings methods |
static String[] |
getFontSubstitutes(String originalFontName)
Returns array containing alternative font names to be used if original font is not presented in system.
|
static boolean |
isJavaFontEngineUsed()
Returns current flag to use the standard Java font management engine.
|
static void |
removeFontsFolder(String folder)
Removes
folder from folder list |
static void |
reset()
Resets the fonts folder and default font name to the system default.
|
static void |
resetFontSources()
Resets configuration
|
static void |
setDefaultFontName(String fontName)
Sets the default font name.
|
static void |
setFontsFolder(String folder)
Override font folder list for
folder |
static void |
setFontsFolders(String[] folders)
Override font folder list for
folders |
static void |
setFontsFolders(String[] folders,
boolean recursive)
Sets the folders where TrueType fonts are loaded from and clears all loaded fonts.
|
static void |
setFontSubstitutes(String originalFontName,
String[] substituteFontNames)
Override substitute (alternative) font names for given original font name.
|
static void |
updateFonts()
Updates fonts cache for PSD files that contain text layers.
|
static void |
useJavaFontEngine(boolean use)
Informs the search engine to use or not use the standard Java font management engine.
|
public static void addFontsFolder(String fontFolder)
fontFolder
into font directory list and marks it as first folder for font searchingfontFolder
- The folder contains the TrueType fonts or single font file path.public static String[] getFontsSources()
FontSettings
methodspublic 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.
public static String[] getDefaultFontsFolders()
public static void setFontsFolders(String[] folders)
folders
folders
- Array of folderpublic static void setFontsFolders(String[] folders, boolean recursive)
folders
- The fonts folders.recursive
- if set to true
[recursive].public static void setFontsFolder(String folder)
folder
folder
- Folder with TrueType fonts.public static void removeFontsFolder(String folder)
folder
from folder listfolder
- The folder to removepublic 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.public static boolean isJavaFontEngineUsed()
true
the standard Java font management engine is used.
false
the standard Java font management engine is not used.public static void resetFontSources()
public static void reset()
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.
public static Font findFont(String fontName, int fontStyle, int fontSize)
fontName
- Font familyfontStyle
- Font stylefontSize
- Font sizeFont
objectpublic static String[] getAllFonts()
public static void addFontSubstitutes(String originalFontName, String[] substituteFontNames)
Adds substitute (alternative) font names for given original font name.
originalFontName
- The Font's real namesubstituteFontNames
- The font's substitutionspublic static String[] getFontSubstitutes(String originalFontName)
originalFontName
- public static void setFontSubstitutes(String originalFontName, String[] substituteFontNames)
originalFontName
- substituteFontNames
- public static String getDefaultFontName()
public static void setDefaultFontName(String fontName)
fontName
- The default name of the font.public static Font findFont(Map<TextAttribute,Object> attributes)
attributes
- Font attributesFont
object