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
FieldsModifier and TypeFieldDescriptionprotected FontEncodingprotected booleanForces the output of the width array.protected CMapToUnicodeCurrently 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddFontStream(PdfDictionary fontDescriptor) intappendAnyGlyph(String text, int from, List<Glyph> glyphs) Append any single glyph, even notdef.booleanappendDecodedCodesToGlyphsList(List<Glyph> list, PdfString characterCodes) Decodes sequence of character codes (e.g.intappendGlyphs(String text, int from, int to, List<Glyph> glyphs) Append all supported glyphs and return number of processed chars.protected PdfArraybuildWidthsArray(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 voidflushFontData(String fontName, PdfName subtype) floatgetContentWidth(PdfString content) protected PdfDictionarygetFontDescriptor(String fontName) Generates the font descriptor for this font ornullif 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 booleanIndicates that the font is built in, i.e.booleanisBuiltWith(String fontProgram, String encoding) Checks whether thePdfFontwas built with corresponding fontProgram and encoding or CMAP.booleanGets the state of the property.protected voidsetFontProgram(T fontProgram) voidsetForceWidthsOutput(boolean forceWidthsOutput) Set totrueto force the generation of the widths array.voidwriteText(GlyphLine text, int from, int to, PdfOutputStream stream) voidwriteText(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, updateSubsetPrefixMethods 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:PdfFontChecks whether thePdfFontwas built with corresponding fontProgram and encoding or CMAP. Default value is false unless overridden.- Overrides:
-
isBuiltWithin 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:
-
createGlyphLinein classPdfFont
-
appendGlyphs
Description copied from class:PdfFontAppend all supported glyphs and return number of processed chars. Composite font supports surrogate pairs.- Specified by:
-
appendGlyphsin 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:PdfFontAppend any single glyph, even notdef. Returns number of processed chars: 2 in case surrogate pair, otherwise 1.- Specified by:
-
appendAnyGlyphin 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
CMapToUnicodebuilt based on /ToUnicode, or null if /ToUnicode is not available
-
convertToBytes
Description copied from class:PdfFontConverts 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:
-
convertToBytesin classPdfFont - Parameters:
-
text- the text to convert - Returns:
- the conversion
-
convertToBytes
- Specified by:
-
convertToBytesin classPdfFont
-
convertToBytes
- Specified by:
-
convertToBytesin classPdfFont
-
writeText
-
writeText
-
decode
-
decodeIntoGlyphLine
Decodes sequence of character codes (e.g. from content stream) into aGlyphLine- Specified by:
-
decodeIntoGlyphLinein classPdfFont - Parameters:
-
content- the string which is interpreted as a sequence of character codes. Note, thatPdfStringacts 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
GlyphLinecontaining 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:
-
appendDecodedCodesToGlyphsListin 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, thatPdfStringacts 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:
-
getContentWidthin classPdfFont
-
isForceWidthsOutput
public boolean isForceWidthsOutput()Gets the state of the property.- Returns:
- value of property forceWidthsOutput
-
setForceWidthsOutput
public void setForceWidthsOutput(boolean forceWidthsOutput) Set totrueto force the generation of the widths array.- Parameters:
-
forceWidthsOutput-trueto 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:
-
truein case the font is a Standard font andfalseotherwise
-
getFontDescriptor
Generates the font descriptor for this font ornullif it is one of the 14 built in fonts.- Specified by:
-
getFontDescriptorin classPdfFont - Returns:
-
the PdfDictionary containing the font descriptor or
null.
-
buildWidthsArray
-
addFontStream
-
setFontProgram
-