public abstract class PdfSimpleFontFontProgram> extends PdfFont
Modifier and Type | Field and Description |
---|---|
protected FontEncoding |
fontEncoding |
protected boolean |
forceWidthsOutput
Forces the output of the width array.
|
protected byte[] |
shortTag
The array used with single byte encodings.
|
protected CMapToUnicode |
toUnicode
Currently only exists for the fonts that are parsed from the document.
|
DEFAULT_FONT_MATRIX, embedded, EMPTY_BYTES, fontProgram, newFont, notdefGlyphs, SIMPLE_FONT_MAX_CHAR_CODE_VALUE, subset, subsetRanges
Modifier | Constructor and Description |
---|---|
protected |
PdfSimpleFont() |
protected |
PdfSimpleFont(PdfDictionary fontDictionary) |
Modifier and Type | Method and Description |
---|---|
protected 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.
|
GlyphLine |
createGlyphLine(String content) |
String |
decode(PdfString content) |
GlyphLine |
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 or null if it is one of the 14 built in fonts.
|
FontEncoding |
getFontEncoding()
Get the font encoding.
|
protected double |
getGlyphWidth(Glyph glyph)
Deprecated.
This method was introduced to allow overriding of widths array entry writing to output file. It's now replaced by more specific
buildWidthsArray(int, int) in order to avoid confusion between this method and Glyph.getWidth() . This method will be removed in the next major release.
|
CMapToUnicode |
getToUnicode()
Get the mapping of character codes to unicode values based on /ToUnicode entry of font dictionary.
|
protected boolean |
isBuiltInFont()
Indicates that the font is built in, i.e.
|
boolean |
isBuiltWith(String fontProgram, String encoding)
Checks whether the PdfFont was built with corresponding fontProgram and encoding or CMAP.
|
boolean |
isForceWidthsOutput()
Gets the state of the property.
|
protected void |
setFontProgram(T fontProgram) |
void |
setForceWidthsOutput(boolean forceWidthsOutput)
Set to true to force the generation of the widths array.
|
void |
writeText(GlyphLine text, int from, int to, PdfOutputStream stream) |
void |
writeText(String text, PdfOutputStream stream) |
addSubsetRange, compactRanges, containsGlyph, flush, getAscent, getAscent, getDescent, getDescent, getFontMatrix, getFontProgram, getGlyph, getPdfFontStream, getWidth, getWidth, getWidth, getWidth, isEmbedded, isSubset, isWrappedObjectMustBeIndirect, setSubset, splitString, toString, updateSubsetPrefix
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
protected FontEncoding fontEncoding
protected boolean forceWidthsOutput
protected byte[] shortTag
protected CMapToUnicode toUnicode
protected PdfSimpleFont(PdfDictionary fontDictionary)
protected PdfSimpleFont()
public boolean isBuiltWith(String fontProgram, String encoding)
PdfFont
PdfFont
was built with corresponding fontProgram and encoding or CMAP. Default value is false unless overridden.
isBuiltWith
in class PdfFont
fontProgram
- a font name or path to a font program
encoding
- an encoding or CMAP
PdfDocument.findFont(String, String)
, FontProgram.isBuiltWith(String)
, FontEncoding.isBuiltWith(String)
, CMapEncoding.isBuiltWith(String)
public GlyphLine createGlyphLine(String content)
createGlyphLine
in class PdfFont
public int appendGlyphs(String text, int from, int to, List<Glyph> glyphs)
PdfFont
appendGlyphs
in class PdfFont
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.
public int appendAnyGlyph(String text, int from, List<Glyph> glyphs)
PdfFont
appendAnyGlyph
in class PdfFont
text
- String to convert to glyphs.
from
- from index of the text.
glyphs
- array for a new glyph, shall not be null.
public FontEncoding getFontEncoding()
FontEncoding
public CMapToUnicode getToUnicode()
CMapToUnicode
built based on /ToUnicode, or null if /ToUnicode is not available
public byte[] convertToBytes(String text)
PdfFont
convertToBytes
in class PdfFont
text
- the text to convert
public byte[] convertToBytes(GlyphLine glyphLine)
convertToBytes
in class PdfFont
public byte[] convertToBytes(Glyph glyph)
convertToBytes
in class PdfFont
public void writeText(GlyphLine text, int from, int to, PdfOutputStream stream)
public void writeText(String text, PdfOutputStream stream)
public GlyphLine decodeIntoGlyphLine(PdfString content)
GlyphLine
decodeIntoGlyphLine
in class PdfFont
content
- the string which is interpreted as a sequence of character codes. Note, that PdfString
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
GlyphLine
containing the glyphs encoded by the passed string
public boolean appendDecodedCodesToGlyphsList(List<Glyph> list, PdfString characterCodes)
appendDecodedCodesToGlyphsList
in class PdfFont
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, that PdfString
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
public float getContentWidth(PdfString content)
getContentWidth
in class PdfFont
public boolean isForceWidthsOutput()
public void setForceWidthsOutput(boolean forceWidthsOutput)
true
to force the generation of the widths array.
forceWidthsOutput
- true
to force the generation of the widths array
protected boolean isBuiltInFont()
true
in case the font is a Standard font and false
otherwise
protected PdfDictionary getFontDescriptor(String fontName)
null
if it is one of the 14 built in fonts.
getFontDescriptor
in class PdfFont
null
.
protected PdfArray buildWidthsArray(int firstChar, int lastChar)
protected abstract void addFontStream(PdfDictionary fontDescriptor)
protected void setFontProgram(T fontProgram)
@Deprecated protected double getGlyphWidth(Glyph glyph)
buildWidthsArray(int, int)
in order to avoid confusion between this method and Glyph.getWidth()
. This method will be removed in the next major release.
glyph
- the glyph which widths is required to be written to the output file
Copyright © 1998–2021 iText Group NV. All rights reserved.