Package com.itextpdf.kernel.font
Class PdfType0Font
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.kernel.font.PdfFont
com.itextpdf.kernel.font.PdfType0Font
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
CIDFont Type0 (Type1 outlines).protected static final int
CIDFont Type2 (TrueType outlines).protected int
protected CMapEncoding
protected char[]
protected boolean
Fields inherited from class com.itextpdf.kernel.font.PdfFont
embedded, EMPTY_BYTES, fontProgram, newFont, notdefGlyphs, SIMPLE_FONT_MAX_CHAR_CODE_VALUE, subset, subsetRanges
-
Method Summary
Modifier and TypeMethodDescriptionint
appendAnyGlyph
(String text, int from, List<Glyph> glyphs) Append any single glyph, even notdef.boolean
appendDecodedCodesToGlyphsList
(List<Glyph> list, PdfString characterCodes) Decodes sequence of character codes (e.g.int
appendGlyphs
(String text, int from, int to, List<Glyph> glyphs) Append all supported glyphs and return number of processed chars.boolean
containsGlyph
(int unicode) Check whether font contains glyph with specified unicode.byte[]
convertToBytes
(Glyph glyph) byte[]
convertToBytes
(GlyphLine glyphLine) byte[]
convertToBytes
(String text) Converts the text into bytes to be placed in the document.createGlyphLine
(String content) decodeIntoGlyphLine
(PdfString characterCodes) Decodes sequence of character codes (e.g.void
flush()
To manually flush aPdfObject
behind this wrapper, you have to ensure that this object is added to the document, i.e.protected PdfDictionary
getCidFont
(PdfDictionary fontDescriptor, String fontName, boolean isType2) Generates the CIDFontType2 dictionary.getCmap()
Gets CMAP associated with the Pdf Font.float
getContentWidth
(PdfString content) protected PdfDictionary
getFontDescriptor
(String fontName) getGlyph
(int unicode) Get glyph by unicodeCreates a ToUnicode CMap to allow copy and paste from Acrobat.static String
getUniMapFromOrdering
(String ordering) Deprecated.static String
getUniMapFromOrdering
(String ordering, boolean horizontal) Get Unicode mapping name from ordering.boolean
isBuiltWith
(String fontProgram, String encoding) Checks whether thePdfFont
was built with corresponding fontProgram and encoding or CMAP.void
writeText
(GlyphLine text, int from, int to, PdfOutputStream stream) void
writeText
(String text, PdfOutputStream stream) Methods inherited from class com.itextpdf.kernel.font.PdfFont
addSubsetRange, getAscent, getAscent, getDescent, getDescent, getFontProgram, getPdfFontStream, getWidth, getWidth, getWidth, getWidth, isEmbedded, isSubset, isWrappedObjectMustBeIndirect, setSubset, splitString, toString, updateSubsetPrefix
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Field Details
-
CID_FONT_TYPE_0
protected static final int CID_FONT_TYPE_0CIDFont Type0 (Type1 outlines).- See Also:
-
CID_FONT_TYPE_2
protected static final int CID_FONT_TYPE_2CIDFont Type2 (TrueType outlines).- See Also:
-
vertical
protected boolean vertical -
cmapEncoding
-
usedGlyphs
-
cidFontType
protected int cidFontType -
specificUnicodeDifferences
protected char[] specificUnicodeDifferences
-
-
Method Details
-
getUniMapFromOrdering
Get Unicode mapping name from ordering.- Parameters:
-
ordering
- the text ordering to base to unicode mapping on -
horizontal
- identifies whether the encoding is horizontal or vertical - Returns:
- Unicode mapping name
-
getUniMapFromOrdering
Deprecated.Replaced bygetUniMapFromOrdering(String, boolean)
for proper handling of IDENTITY_V encoding.Get Unicode mapping name from ordering.- Parameters:
-
ordering
- the text ordering to base to unicode mapping on - Returns:
- Unicode mapping name
-
getGlyph
Description copied from class:PdfFont
Get glyph by unicode -
containsGlyph
public boolean containsGlyph(int unicode) Description copied from class:PdfFont
Check whether font contains glyph with specified unicode.- Overrides:
-
containsGlyph
in classPdfFont
- Parameters:
-
unicode
- a unicode code point - Returns:
- true if font contains glyph, represented with the unicode code point, otherwise false.
-
convertToBytes
Description copied from class:PdfFont
Converts the text into bytes to be placed in the document. The conversion is done according to the font and the encoding and the characters used are stored.- Specified by:
-
convertToBytes
in classPdfFont
- Parameters:
-
text
- the text to convert - Returns:
- the conversion
-
convertToBytes
- Specified by:
-
convertToBytes
in classPdfFont
-
convertToBytes
- Specified by:
-
convertToBytes
in classPdfFont
-
writeText
-
writeText
-
createGlyphLine
- Specified by:
-
createGlyphLine
in classPdfFont
-
appendGlyphs
Description copied from class:PdfFont
Append all supported glyphs and return number of processed chars. Composite font supports surrogate pairs.- Specified by:
-
appendGlyphs
in classPdfFont
- Parameters:
-
text
- String to convert to glyphs. -
from
- from index of the text. -
to
- to index of the text. -
glyphs
- array for a new glyphs, shall not be null. - Returns:
- number of processed chars from text.
-
appendAnyGlyph
Description copied from class:PdfFont
Append any single glyph, even notdef. Returns number of processed chars: 2 in case surrogate pair, otherwise 1.- Specified by:
-
appendAnyGlyph
in classPdfFont
- Parameters:
-
text
- String to convert to glyphs. -
from
- from index of the text. -
glyphs
- array for a new glyph, shall not be null. - Returns:
- number of processed chars: 2 in case surrogate pair, otherwise 1
-
decode
-
decodeIntoGlyphLine
Decodes sequence of character codes (e.g. from content stream) into aGlyphLine
- Specified by:
-
decodeIntoGlyphLine
in classPdfFont
- Parameters:
-
characterCodes
- the string which is interpreted as a sequence of character codes. Note, thatPdfString
acts as a storage for char code values specific to given font, therefore individual character codes must not be interpreted as code units of the UTF-16 encoding - Returns:
-
the
GlyphLine
containing the glyphs encoded by the passed string
-
appendDecodedCodesToGlyphsList
Decodes sequence of character codes (e.g. from content stream) to sequence of glyphs and appends them to the passed list.- Overrides:
-
appendDecodedCodesToGlyphsList
in classPdfFont
- Parameters:
-
list
- the list to the end of which decoded glyphs are to be added -
characterCodes
- the string which is interpreted as a sequence of character codes. Note, thatPdfString
acts as a storage for char code values specific to given font, therefore individual character codes must not be interpreted as code units of the UTF-16 encoding - Returns:
- true if all codes where successfully decoded, false otherwise
-
getContentWidth
- Specified by:
-
getContentWidth
in classPdfFont
-
isBuiltWith
Description copied from class:PdfFont
Checks whether thePdfFont
was built with corresponding fontProgram and encoding or CMAP. Default value is false unless overridden.- Overrides:
-
isBuiltWith
in classPdfFont
- Parameters:
-
fontProgram
- a font name or path to a font program -
encoding
- an encoding or CMAP - Returns:
- true, if the PdfFont was built with the fontProgram and encoding. Otherwise false.
- See Also:
-
flush
public void flush()Description copied from class:PdfFont
To manually flush aPdfObject
behind this wrapper, you have to ensure that this object is added to the document, i.e. it has an indirect reference. Basically this means that before flushing you need to explicitly callPdfObjectWrapper.makeIndirect(PdfDocument)
. For example: wrapperInstance.makeIndirect(document).flush(); Note that not every wrapper require this, only those that have such warning in documentation. -
getCmap
Gets CMAP associated with the Pdf Font.- Returns:
- CMAP
- See Also:
-
getFontDescriptor
- Specified by:
-
getFontDescriptor
in classPdfFont
-
getCidFont
Generates the CIDFontType2 dictionary.- Parameters:
-
fontDescriptor
- the font descriptor dictionary -
fontName
- a name of the font -
isType2
- true, if the font is CIDFontType2 (TrueType glyphs), otherwise false, i.e. CIDFontType0 (Type1/CFF glyphs) - Returns:
- fully initialized CIDFont
-
getToUnicode
Creates a ToUnicode CMap to allow copy and paste from Acrobat.- Returns:
-
the stream representing this CMap or
null
-
getUniMapFromOrdering(String, boolean)
for proper handling of IDENTITY_V encoding.