Package com.itextpdf.io.font
Class FontRegisterProvider
java.lang.Object
com.itextpdf.io.font.FontRegisterProvider
If you are using True Type fonts, you can declare the paths of the different ttf- and ttc-files
to this class first and then create fonts in your code using one of the getFont method
without having to enter a path as parameter.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
(package private) FontProgram
Constructs aFont
-object.(package private) FontProgram
Constructs aFont
-object.protected FontProgram
getFontProgram
(String fontName, boolean cached) Gets a set of registered font names.Gets a set of registered font names.(package private) boolean
isRegisteredFont
(String fontname) Checks if a certain font is registered.(package private) void
registerFont
(String path) Register a font file, either .ttf or .otf, .afm or a font from TrueType Collection.(package private) void
registerFont
(String path, String alias) Register a font file and use an alias for the font contained in it.(package private) int
Register all the fonts in a directory.(package private) int
registerFontDirectory
(String dir, boolean scanSubdirectories) Register all the fonts in a directory and possibly its subdirectories.(package private) void
registerFontFamily
(String familyName, String fullName, String path) Register a font by giving explicitly the font family and name.protected void
protected void
(package private) int
Register fonts in some probable directories.(package private) boolean
saveCopyOfRegularFont
(String regularFontName, String path)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
fontNames
This is a map of postscriptfontnames of fonts and the path of their font file. -
fontFamilies
This is a map of fontfamilies.
-
-
Constructor Details
-
FontRegisterProvider
FontRegisterProvider()Creates new FontRegisterProvider
-
-
Method Details
-
getFont
Constructs aFont
-object.- Parameters:
fontName
- the name of the fontstyle
- the style of this font- Returns:
- the Font constructed based on the parameters
- Throws:
IOException
-
getFont
Constructs aFont
-object.- Parameters:
fontName
- the name of the fontstyle
- the style of this fontcached
- true if the font comes from the cache or is added to the cache if new, false if the font is always created new- Returns:
- the Font constructed based on the parameters
- Throws:
IOException
-
registerStandardFonts
protected void registerStandardFonts() -
registerStandardFontFamilies
protected void registerStandardFontFamilies() -
getFontProgram
- Throws:
IOException
-
registerFontFamily
Register a font by giving explicitly the font family and name.- Parameters:
familyName
- the font familyfullName
- the font namepath
- the font path
-
registerFont
Register a font file, either .ttf or .otf, .afm or a font from TrueType Collection. If a TrueType Collection is registered, an additional index of the font program can be specified- Parameters:
path
- the path to a ttf- or ttc-file
-
registerFont
Register a font file and use an alias for the font contained in it.- Parameters:
path
- the path to a font filealias
- the alias you want to use for the font
-
saveCopyOfRegularFont
-
registerFontDirectory
Register all the fonts in a directory.- Parameters:
dir
- the directory- Returns:
- the number of fonts registered
-
registerFontDirectory
Register all the fonts in a directory and possibly its subdirectories.- Parameters:
dir
- the directoryscanSubdirectories
- recursively scan subdirectories iftrue
- Returns:
- the number of fonts registered
-
registerSystemFontDirectories
int registerSystemFontDirectories()Register fonts in some probable directories. It usually works in Windows, Linux and Solaris.- Returns:
- the number of fonts registered
-
getRegisteredFonts
Gets a set of registered font names.- Returns:
- a set of registered fonts
-
getRegisteredFontFamilies
Gets a set of registered font names.- Returns:
- a set of registered font families
-
isRegisteredFont
Checks if a certain font is registered.- Parameters:
fontname
- the name of the font that has to be checked.- Returns:
- true if the font is found
-
clearRegisteredFonts
public void clearRegisteredFonts() -
clearRegisteredFontFamilies
public void clearRegisteredFontFamilies()
-