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, shortTag, toUnicode
DEFAULT_FONT_MATRIX, embedded, 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.
|
double[] |
getFontMatrix()
Gets the transformation matrix that defines relation between text and glyph spaces.
|
Glyph |
getGlyph(int unicode)
Get glyph by unicode
|
protected double |
getGlyphWidth(Glyph glyph)
Gets glyph width which us ready to be written to the output file.
|
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 |
setFontMatrix(double[] fontMatrix)
Deprecated.
will be made internal in next major release
|
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, writeText
addSubsetRange, compactRanges, getAscent, getAscent, getDescent, getDescent, getFontProgram, getPdfFontStream, getWidth, getWidth, getWidth, getWidth, isWrappedObjectMustBeIndirect, setSubset, splitString, toString, updateSubsetPrefix
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
public 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-units
public 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 vertical
public void setFontStretch(String fontWidth)
fontWidth
- FontStretches
.
public void setPdfFontFlags(int flags)
flags
- font descriptor flags.
FontDescriptorFlags
public Type3Glyph getType3Glyph(int unicode)
Type3Glyph
by unicode.
unicode
- glyph unicode
Type3Glyph
glyph, or null
if this font does not contain glyph for the unicode
public boolean isSubset()
PdfFont
public boolean isEmbedded()
isEmbedded
in class PdfFont
public double[] getFontMatrix()
PdfFont
getFontMatrix
in class PdfFont
@Deprecated public void setFontMatrix(double[] fontMatrix)
fontMatrix
- an array of six numbers specifying the font matrix, mapping glyph space to text space.
public 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 have
llx
- the X lower left corner of the glyph bounding box. If the colorize
option is true
the value is ignored
lly
- the Y lower left corner of the glyph bounding box. If the colorize
option is true
the value is ignored
urx
- the X upper right corner of the glyph bounding box. If the colorize
option is true
the value is ignored
ury
- the Y upper right corner of the glyph bounding box. If the colorize
option is true
the value is ignored
public Glyph getGlyph(int unicode)
PdfFont
public boolean containsGlyph(int unicode)
PdfFont
containsGlyph
in class PdfFont
unicode
- a unicode code point
public void flush()
PdfFont
PdfObject
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)
PdfSimpleFont
null
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()
protected double getGlyphWidth(Glyph glyph)
PdfSimpleFont
getGlyphWidth
in class PdfSimpleFont<Type3Font>
glyph
- the glyph which widths is required to be written to the output file
Copyright © 1998–2023 iText Group NV. All rights reserved.