public class PdfType3Font extends PdfSimpleFont<Type3Font>
In Type 3 fonts, glyphs are defined by streams of PDF graphics operators. These streams are associated with character names. A separate encoding entry maps character codes to the appropriate character names for the glyphs.
Note, that this class operates in a special way with glyph space units.
In the code when working with fonts, iText expects that 1000 units of glyph-space correspond
to 1 unit of text space. For Type3 fonts this is not always the case and depends on FontMatrix.
That's why in PdfType3Font the font matrix and all font metrics in glyph space units
are "normalized" in such way, that 1 to 1000 relation is preserved. This is done on
Type3 font initialization, and is reverted back on font flushing, because the actual content
streams of type3 font glyphs are left with original coordinates based on original font matrix.
See also ISO-32000-2, 9.2.4 "Glyph positioning and metrics":
"The glyph coordinate system is the space in which an individual character’s glyph is defined. All path coordinates and metrics shall be interpreted in glyph space. For all font types except Type 3, the units of glyph space are one-thousandth of a unit of text space; for a Type 3 font, the transformation from glyph space to text space shall be defined by a font matrix specified in an explicit FontMatrix entry in the font."
Note, that because of this when processing Type3 glyphs content streams either process them completely independent from this class or take this normalization into account.
To be able to be wrapped with this PdfObjectWrapper the PdfObject
must be indirect.
fontEncoding, forceWidthsOutput, toUnicode, usedGlyphsembedded, EMPTY_BYTES, fontProgram, newFont, notdefGlyphs, SIMPLE_FONT_MAX_CHAR_CODE_VALUE, subset, subsetRanges| Modifier and Type | Method and Description |
|---|---|
protected void |
addFontStream(PdfDictionary fontDescriptor) |
Type3Glyph |
addGlyph(char c,
int wx,
int llx,
int lly,
int urx,
int ury)
Defines a glyph.
|
protected PdfArray |
buildWidthsArray(int firstChar,
int lastChar) |
boolean |
containsGlyph(int unicode)
Check whether font contains glyph with specified unicode.
|
void |
flush()
To manually flush a
PdfObject behind this wrapper, you have to ensure
that this object is added to the document, i.e. |
protected PdfDocument |
getDocument() |
protected PdfDictionary |
getFontDescriptor(String fontName)
Generates the font descriptor for this font or
null if it is one of the 14 built in fonts. |
Glyph |
getGlyph(int unicode)
Get glyph by unicode
|
int |
getNumberOfGlyphs()
Gets count of glyphs in Type 3 font.
|
Type3Glyph |
getType3Glyph(int unicode)
Returns a
Type3Glyph by unicode. |
boolean |
isEmbedded() |
boolean |
isSubset()
Indicates if all the glyphs and widths for that particular
encoding should be included in the document.
|
void |
setCapHeight(int capHeight)
Sets cap height.
|
void |
setFontFamily(String fontFamily)
Sets a preferred font family name.
|
void |
setFontName(String fontName)
Sets the PostScript name of the font.
|
void |
setFontStretch(String fontWidth)
Sets font width in css notation (font-stretch property)
|
void |
setFontWeight(int fontWeight)
Sets font weight.
|
void |
setItalicAngle(int italicAngle)
Sets the PostScript italic angle.
|
void |
setPdfFontFlags(int flags)
Sets Font descriptor flags.
|
appendAnyGlyph, appendDecodedCodesToGlyphsList, appendGlyphs, convertToBytes, convertToBytes, convertToBytes, createGlyphLine, decode, decodeIntoGlyphLine, flushFontData, getContentWidth, getFontEncoding, getToUnicode, isBuiltInFont, isBuiltWith, isForceWidthsOutput, setFontProgram, setForceWidthsOutput, writeText, writeTextaddSubsetRange, getAscent, getAscent, getDescent, getDescent, getFontProgram, getPdfFontStream, getWidth, getWidth, getWidth, getWidth, isWrappedObjectMustBeIndirect, setSubset, splitString, toString, updateSubsetPrefixensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidReleasepublic void setFontName(String fontName)
fontName - the PostScript name of the font, shall not be null or empty.public void setFontFamily(String fontFamily)
fontFamily - a preferred font family name.public void setFontWeight(int fontWeight)
fontWeight - integer form 100 to 900. See FontWeights.public void setCapHeight(int capHeight)
capHeight - integer in glyph-space 1000-unitspublic void setItalicAngle(int italicAngle)
Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward).
italicAngle - in counter-clockwise degrees from the verticalpublic void setFontStretch(String fontWidth)
fontWidth - FontStretches.public void setPdfFontFlags(int flags)
flags - font descriptor flags.FontDescriptorFlagspublic Type3Glyph getType3Glyph(int unicode)
Type3Glyph by unicode.unicode - glyph unicodeType3Glyph glyph, or null if this font does not contain glyph for the unicodepublic boolean isSubset()
PdfFontpublic boolean isEmbedded()
isEmbedded in class PdfFontpublic int getNumberOfGlyphs()
public Type3Glyph addGlyph(char c, int wx, int llx, int lly, int urx, int ury)
c - the character to match this glyph.wx - the advance this character will havellx - the X lower left corner of the glyph bounding box. If the colorize option is
true the value is ignoredlly - the Y lower left corner of the glyph bounding box. If the colorize option is
true the value is ignoredurx - the X upper right corner of the glyph bounding box. If the colorize option is
true the value is ignoredury - the Y upper right corner of the glyph bounding box. If the colorize option is
true the value is ignoredpublic Glyph getGlyph(int unicode)
PdfFontpublic boolean containsGlyph(int unicode)
PdfFontcontainsGlyph in class PdfFontunicode - a unicode code pointpublic void flush()
PdfFontPdfObject 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 call PdfObjectWrapper.makeIndirect(PdfDocument).
For example: wrapperInstance.makeIndirect(document).flush();
Note that not every wrapper require this, only those that have such warning in documentation.protected PdfDictionary getFontDescriptor(String fontName)
PdfSimpleFontnull if it is one of the 14 built in fonts.getFontDescriptor in class PdfSimpleFont<Type3Font>null.protected PdfArray buildWidthsArray(int firstChar, int lastChar)
buildWidthsArray in class PdfSimpleFont<Type3Font>protected void addFontStream(PdfDictionary fontDescriptor)
addFontStream in class PdfSimpleFont<Type3Font>protected PdfDocument getDocument()
Copyright © 1998–2024 Apryse Group NV. All rights reserved.