public final class PdfFontFactory extends Object
PdfDocument
Note, just created PdfFont
is almost empty until it will be flushed, because it is impossible to fulfill font data until flush.
Constructor and Description |
---|
PdfFontFactory() |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
checkFontDictionary(PdfDictionary fontDic, PdfName fontType, boolean isException)
Deprecated.
this method will become private in 7.1. Do not use this method
|
static PdfFont |
createFont()
Creates a new instance of default font, namely FontConstants.HELVETICA standard font with PdfEncodings.WINANSI encoding.
|
static PdfFont |
createFont(byte[] fontProgram, boolean embedded)
Created a PdfFont instance by the bytes of the underlying font program.
|
static PdfFont |
createFont(byte[] fontProgram, String encoding)
Created a PdfFont instance by the bytes of the underlying font program.
|
static PdfFont |
createFont(byte[] fontProgram, String encoding, boolean embedded)
Created a PdfFont instance by the bytes of the underlying font program.
|
static PdfFont |
createFont(byte[] fontProgram, String encoding, boolean embedded, boolean cached)
Created a PdfFont instance by the bytes of the underlying font program.
|
static PdfFont |
createFont(FontProgram fontProgram)
Created a PdfFont instance given the given underlying FontProgram instance.
|
static PdfFont |
createFont(FontProgram fontProgram, String encoding)
Created a PdfFont instance given the given underlying FontProgram instance.
|
static PdfFont |
createFont(FontProgram fontProgram, String encoding, boolean embedded)
Created a PdfFont instance given the given underlying FontProgram instance.
|
static PdfFont |
createFont(PdfDictionary fontDictionary)
Creates a PdfFont by already existing font dictionary.
|
static PdfFont |
createFont(String fontProgram)
Creates a PdfFont instance by the path of the font program file
|
static PdfFont |
createFont(String fontProgram, boolean embedded)
Created a PdfFont instance given the path to the font file.
|
static PdfFont |
createFont(String fontProgram, String encoding)
Creates a PdfFont instance by the path of the font program file and given encoding.
|
static PdfFont |
createFont(String fontProgram, String encoding, boolean embedded)
Created a PdfFont instance given the path to the font file.
|
static PdfFont |
createFont(String fontProgram, String encoding, boolean embedded, boolean cached)
Created a PdfFont instance given the path to the font file.
|
static PdfFont |
createRegisteredFont(String fontName)
Creates PdfFont based on registered FontProgram 's.
|
static PdfFont |
createRegisteredFont(String fontName, String encoding)
Creates PdfFont based on registered FontProgram 's.
|
static PdfFont |
createRegisteredFont(String fontName, String encoding, boolean embedded)
Creates PdfFont based on registered FontProgram 's.
|
static PdfFont |
createRegisteredFont(String fontName, String encoding, boolean embedded, boolean cached)
Creates PdfFont based on registered FontProgram 's.
|
static PdfFont |
createRegisteredFont(String fontName, String encoding, boolean embedded, int style)
Creates PdfFont based on registered FontProgram 's.
|
static PdfFont |
createRegisteredFont(String fontName, String encoding, boolean embedded, int style, boolean cached)
Creates PdfFont based on registered FontProgram 's.
|
static PdfFont |
createTtcFont(byte[] ttc, int ttcIndex, String encoding, boolean embedded, boolean cached)
Creates a PdfFont instance from the TrueType Collection represented by its byte contents.
|
static PdfFont |
createTtcFont(String ttc, int ttcIndex, String encoding, boolean embedded, boolean cached)
Creates a PdfFont instance from the TrueType Collection given by the path to the .ttc file.
|
static PdfType3Font |
createType3Font(PdfDocument document, boolean colorized)
Creates a new instance of PdfType3Font
|
static Set<String> |
getRegisteredFamilies()
Gets a set of registered font families.
|
static Set<String> |
getRegisteredFonts()
Gets a set of registered font names.
|
static boolean |
isRegistered(String fontName)
Checks if a certain font is registered.
|
static void |
register(String path)
Registers a .ttf, .otf, .afm, .pfm, or a .ttc font file.
|
static void |
register(String path, String alias)
Register a font file and use an alias for the font contained in it.
|
static int |
registerDirectory(String dirPath)
Registers all the fonts in a directory.
|
static void |
registerFamily(String familyName, String fullName, String path)
Register a font by giving explicitly the font family and name.
|
static int |
registerSystemDirectories()
Register fonts in some probable directories.
|
public static PdfFont createFont() throws IOException
FontConstants.HELVETICA
standard font with PdfEncodings.WINANSI
encoding. Note, if you want to reuse the same instance of default font, you may use PdfDocument.getDefaultFont()
.
IOException
- if error occurred while creating the font, e.g. metrics loading failure
public static PdfFont createFont(PdfDictionary fontDictionary)
PdfFont
by already existing font dictionary. Note, the font won't be added to any document, until you add it to PdfCanvas
. While adding to PdfCanvas
, or to PdfResources
the font will be made indirect implicitly. PdfDocument.getFont(com.itextpdf.kernel.pdf.PdfDictionary)
method is strongly recommended if you want to get PdfFont by both existing font dictionary, or just created and hasn't flushed yet.
fontDictionary
- the font dictionary to create the font from
PdfFont
instance
public static PdfFont createFont(String fontProgram) throws IOException
PdfFont
instance by the path of the font program file
fontProgram
- the path of the font program file
PdfFont
instance
IOException
- exception is thrown in case an I/O error occurs when reading the file
public static PdfFont createFont(String fontProgram, String encoding) throws IOException
PdfFont
instance by the path of the font program file and given encoding.
fontProgram
- the path of the font program file
encoding
- the font encoding. See PdfEncodings
PdfFont
instance
IOException
- exception is thrown in case an I/O error occurs when reading the file
public static PdfFont createTtcFont(byte[] ttc, int ttcIndex, String encoding, boolean embedded, boolean cached) throws IOException
PdfFont
instance from the TrueType Collection represented by its byte contents.
ttc
- the byte contents of the TrueType Collection
ttcIndex
- the index of the font in the collection, zero-based
encoding
- the encoding of the font to be created. See PdfEncodings
embedded
- indicates whether the font is to be embedded into the target document
cached
- indicates whether the font will be cached
PdfFont
instance
IOException
- in case the contents of the TrueType Collection is mal-formed or an error occurred during reading the font
public static PdfFont createTtcFont(String ttc, int ttcIndex, String encoding, boolean embedded, boolean cached) throws IOException
PdfFont
instance from the TrueType Collection given by the path to the .ttc file.
ttc
- the path of the .ttc file
ttcIndex
- the index of the font in the collection, zero-based
encoding
- the encoding of the font to be created. See PdfEncodings
embedded
- indicates whether the font is to be embedded into the target document
cached
- indicates whether the font will be cached
PdfFont
instance
IOException
- in case the file is not found, contents of the TrueType Collection is mal-formed or an error occurred during reading the font
public static PdfFont createFont(String fontProgram, boolean embedded) throws IOException
PdfFont
instance given the path to the font file.
fontProgram
- the font program file
embedded
- indicates whether the font is to be embedded into the target document
PdfFont
instance
IOException
- in case the file is not found or the contents of the font file is mal-formed
public static PdfFont createFont(String fontProgram, String encoding, boolean embedded) throws IOException
PdfFont
instance given the path to the font file.
fontProgram
- the font program file
encoding
- the encoding of the font to be created. See PdfEncodings
embedded
- indicates whether the font is to be embedded into the target document
PdfFont
instance
IOException
- in case the file is not found or the contents of the font file is mal-formed
public static PdfFont createFont(String fontProgram, String encoding, boolean embedded, boolean cached) throws IOException
PdfFont
instance given the path to the font file.
fontProgram
- the font program file
encoding
- the encoding of the font to be created. See PdfEncodings
embedded
- indicates whether the font is to be embedded into the target document
cached
- indicates whether the font will be cached
PdfFont
instance
IOException
- in case the file is not found or the contents of the font file is mal-formed
public static PdfFont createFont(FontProgram fontProgram, String encoding, boolean embedded) throws IOException
PdfFont
instance given the given underlying FontProgram
instance.
fontProgram
- the font program of the PdfFont
instance to be created
encoding
- the encoding of the font to be created. See PdfEncodings
embedded
- indicates whether the font is to be embedded into the target document
PdfFont
instance
IOException
- this exception is actually never thrown and will be removed in 7.1.
public static PdfFont createFont(FontProgram fontProgram, String encoding) throws IOException
PdfFont
instance given the given underlying FontProgram
instance.
fontProgram
- the font program of the PdfFont
instance to be created
encoding
- the encoding of the font to be created. See PdfEncodings
PdfFont
instance
IOException
- this exception is actually never thrown and will be removed in 7.1.
public static PdfFont createFont(FontProgram fontProgram) throws IOException
PdfFont
instance given the given underlying FontProgram
instance.
fontProgram
- the font program of the PdfFont
instance to be created
PdfFont
instance
IOException
- this exception is actually never thrown and will be removed in 7.1.
public static PdfFont createFont(byte[] fontProgram, String encoding) throws IOException
PdfFont
instance by the bytes of the underlying font program.
fontProgram
- the bytes of the underlying font program
PdfFont
instance
IOException
- this exception is actually never thrown. Will be removed in 7.1.
public static PdfFont createFont(byte[] fontProgram, boolean embedded) throws IOException
PdfFont
instance by the bytes of the underlying font program.
fontProgram
- the bytes of the underlying font program
embedded
- indicates whether the font is to be embedded into the target document
PdfFont
instance
IOException
- this exception is actually never thrown. Will be removed in 7.1.
public static PdfFont createFont(byte[] fontProgram, String encoding, boolean embedded) throws IOException
PdfFont
instance by the bytes of the underlying font program.
fontProgram
- the bytes of the underlying font program
encoding
- the encoding of the font to be created. See PdfEncodings
embedded
- indicates whether the font is to be embedded into the target document
PdfFont
instance
IOException
- this exception is actually never thrown. Will be removed in 7.1.
public static PdfFont createFont(byte[] fontProgram, String encoding, boolean embedded, boolean cached) throws IOException
PdfFont
instance by the bytes of the underlying font program.
fontProgram
- the bytes of the underlying font program
encoding
- the encoding of the font to be created. See PdfEncodings
embedded
- indicates whether the font is to be embedded into the target document
cached
- indicates whether the font will be cached
PdfFont
instance
IOException
- this exception is actually never thrown. Will be removed in 7.1.
public static PdfType3Font createType3Font(PdfDocument document, boolean colorized) throws IOException
PdfType3Font
document
- the target document of the new font
colorized
- indicates whether the font will be colorized
IOException
- actually this exception is never thrown. This will be removed in 7.1.
public static PdfFont createRegisteredFont(String fontName, String encoding, boolean embedded, int style, boolean cached) throws IOException
PdfFont
based on registered FontProgram
's.
public static PdfFont createRegisteredFont(String fontName, String encoding, boolean embedded, boolean cached) throws IOException
PdfFont
based on registered FontProgram
's.
public static PdfFont createRegisteredFont(String fontName, String encoding, boolean embedded) throws IOException
PdfFont
based on registered FontProgram
's.
public static PdfFont createRegisteredFont(String fontName, String encoding, boolean embedded, int style) throws IOException
PdfFont
based on registered FontProgram
's.
public static PdfFont createRegisteredFont(String fontName, String encoding) throws IOException
PdfFont
based on registered FontProgram
's.
public static PdfFont createRegisteredFont(String fontName) throws IOException
PdfFont
based on registered FontProgram
's.
public static void registerFamily(String familyName, String fullName, String path)
familyName
- the font family
fullName
- the font name
path
- the font path
public static void register(String path)
path
- the path to a font file
public static void register(String path, String alias)
path
- the path to a font file
alias
- the alias you want to use for the font
public static int registerDirectory(String dirPath)
dirPath
- the directory path to be registered as a font directory path
public static int registerSystemDirectories()
public static Set<String> getRegisteredFonts()
public static Set<String> getRegisteredFamilies()
public static boolean isRegistered(String fontName)
fontName
- the name of the font that has to be checked.
true
if the font is found, false
otherwise
@Deprecated protected static boolean checkFontDictionary(PdfDictionary fontDic, PdfName fontType, boolean isException)
true
if the passed dictionary is a valid dictionary, false
otherwise
Copyright © 1998–2018 iText Group NV. All rights reserved.