Package com.itextpdf.kernel.font
Class PdfSimpleFontFontProgram>
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.kernel.font.PdfFont
com.itextpdf.kernel.font.PdfSimpleFont
- Direct Known Subclasses:
-
PdfTrueTypeFont
,PdfType1Font
,PdfType3Font
-
Field Summary
Modifier and TypeFieldDescriptionprotected FontEncoding
protected boolean
Forces the output of the width array.protected CMapToUnicode
Currently only exists for the fonts that are parsed from the document.protected byte[]
The array used with single byte encodings.Fields inherited from class com.itextpdf.kernel.font.PdfFont
embedded, EMPTY_BYTES, fontProgram, newFont, notdefGlyphs, SIMPLE_FONT_MAX_CHAR_CODE_VALUE, subset, subsetRanges
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addFontStream
(PdfDictionary fontDescriptor) int
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.protected PdfArray
buildWidthsArray
(int firstChar, int lastChar) 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 content) Decodes sequence of character codes (e.g.protected void
flushFontData
(String fontName, PdfName subtype) float
getContentWidth
(PdfString content) protected PdfDictionary
getFontDescriptor
(String fontName) Generates the font descriptor for this font ornull
if it is one of the 14 built in fonts.Get the font encoding.Get the mapping of character codes to unicode values based on /ToUnicode entry of font dictionary.protected boolean
Indicates that the font is built in, i.e.boolean
isBuiltWith
(String fontProgram, String encoding) Checks whether thePdfFont
was built with corresponding fontProgram and encoding or CMAP.boolean
Gets the state of the property.protected void
setFontProgram
(T fontProgram) void
setForceWidthsOutput
(boolean forceWidthsOutput) Set totrue
to force the generation of the widths array.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, containsGlyph, flush, getAscent, getAscent, getDescent, getDescent, getFontProgram, getGlyph, 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
-
fontEncoding
-
forceWidthsOutput
protected boolean forceWidthsOutputForces the output of the width array. Only matters for the 14 built-in fonts. -
usedGlyphs
protected byte[] usedGlyphsThe array used with single byte encodings. -
toUnicode
Currently only exists for the fonts that are parsed from the document. In the future, we might provide possibility to add custom mappings after a font has been created from a font file.
-
-
Constructor Details
-
PdfSimpleFont
-
PdfSimpleFont
protected PdfSimpleFont()
-
-
Method Details
-
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:
-
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
-
getFontEncoding
Get the font encoding.- Returns:
-
the
FontEncoding
-
getToUnicode
Get the mapping of character codes to unicode values based on /ToUnicode entry of font dictionary.- Returns:
-
the
CMapToUnicode
built based on /ToUnicode, or null if /ToUnicode is not available
-
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
-
decode
-
decodeIntoGlyphLine
Decodes sequence of character codes (e.g. from content stream) into aGlyphLine
- Specified by:
-
decodeIntoGlyphLine
in classPdfFont
- Parameters:
-
content
- 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
-
isForceWidthsOutput
public boolean isForceWidthsOutput()Gets the state of the property.- Returns:
- value of property forceWidthsOutput
-
setForceWidthsOutput
public void setForceWidthsOutput(boolean forceWidthsOutput) Set totrue
to force the generation of the widths array.- Parameters:
-
forceWidthsOutput
-true
to force the generation of the widths array
-
flushFontData
-
isBuiltInFont
protected boolean isBuiltInFont()Indicates that the font is built in, i.e. it is one of the 14 Standard fonts- Returns:
-
true
in case the font is a Standard font andfalse
otherwise
-
getFontDescriptor
Generates the font descriptor for this font ornull
if it is one of the 14 built in fonts.- Specified by:
-
getFontDescriptor
in classPdfFont
- Returns:
-
the PdfDictionary containing the font descriptor or
null
.
-
buildWidthsArray
-
addFontStream
-
setFontProgram
-