Class Font
-
Constructor Summary
ConstructorsConstructorDescriptionFind a font with the specified name, and construct a Font object from it.Font(String fontName, EnumSet<FontCreateFlags> createFlags) Find a font with the specified name, and construct a Font object from it.Font(String fontName, EnumSet<FontCreateFlags> createFlags, WritingMode wrMode) Find a font with the specified name, and construct a Font object from it. -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete()Destructor.voidEmbeds the Font.longFind the index of the first character that cannot be represented in this font.doubledoublegetBBox()The Bounding Box rectangle of the font.doubledoublebooleanTests that Font is embedded in the document it was created for returns true if the font is embedded and returns false if it is notReturn the encoding of the font.Get the populated CEncoding object.getFlags()Get the font flags for a font.Get a list of available fonts.Get the Full Name of the font.doubledoubledoubledoublegetName()Get the name of the font.Retrieve the PDFDict representation of this objectdoublegetStemH()doublegetStemV()getType()Get the type of the font.doublebooleanbooleanisTextRepresentable(String text) Is this text representable in this font?doublemeasureTextWidth(String text, double fontSize) Measures the width of the specified text in points, using the Font at the specified size.
-
Constructor Details
-
Font
Find a font with the specified name, and construct a Font object from it. Otherwise, it makes a font with the default encoding (MacRomanEncoding on Macs, WinAnsiEncoding elsewhere, or for symbol fonts, their own custom encoding). There is not a way to specify another encoding for the font.When setting text, it checks to see if the text is representable in the font's encoding. If it is not, then DLE makes a "unicode font" with an Identity-H encoding and uses that to set the text. For non-Type0 fonts, this may result in two versions of a font in the output document.
PDFL enforces the following requirements on fonts:
-
TrueTypes used as CID fonts must be embedded.
-
All CID fonts that are embedded must be subsetted.
-
CID fonts that are marked as embedded get their DoNotEmbed flag turned off (or else PDFL won't make a PDEFont from the SysFont).
-
-
Font
Find a font with the specified name, and construct a Font object from it. Otherwise, it makes a font with the default encoding (MacRomanEncoding on Macs, WinAnsiEncoding elsewhere, or for symbol fonts, their own custom encoding). There is not a way to specify another encoding for the font.When setting text, it checks to see if the text is representable in the font's encoding. If it is not, then DLE makes a "unicode font" with an Identity-H encoding and uses that to set the text. For non-Type0 fonts, this may result in two versions of a font in the output document.
PDFL enforces the following requirements on fonts:
-
TrueTypes used as CID fonts must be embedded.
-
All CID fonts that are embedded must be subsetted.
-
CID fonts that are marked as embedded get their DoNotEmbed flag turned off (or else PDFL won't make a PDEFont from the SysFont).
- Parameters:
fontName- the name of the font to createcreateFlags- flags specifying embedding and other options for the use of a font in the document
-
-
Font
Find a font with the specified name, and construct a Font object from it. Otherwise, it makes a font with the default encoding (MacRomanEncoding on Macs, WinAnsiEncoding elsewhere, or for symbol fonts, their own custom encoding). There is not a way to specify another encoding for the font.When setting text, it checks to see if the text is representable in the font's encoding. If it is not, then DLE makes a "unicode font" with an Identity-H or Identity-V encoding and uses that to set the text. For non-Type0 fonts, this may result in two versions of a font in the output document.
PDFL enforces the following requirements on fonts:
-
TrueTypes used as CID fonts must be embedded.
-
All CID fonts that are embedded must be subsetted.
-
CID fonts that are marked as embedded get their DoNotEmbed flag turned off (or else PDFL won't make a PDEFont from the SysFont).
- Parameters:
fontName- the name of the font to createcreateFlags- flags specifying embedding and other options for the use of a font in the documentwrMode- determines whether text will be printed horizontally or vertically
-
-
-
Method Details
-
delete
public void delete()Destructor. -
getFontList
Get a list of available fonts.- Returns:
- The list of available fonts.
-
getAscent
public double getAscent()- Returns:
- The Ascent value of the font in glyph space units.
-
getAvgWidth
public double getAvgWidth()- Returns:
- The AvgWidth value of the font in glyph space units, or 0 if not defined.
-
getCapHeight
public double getCapHeight()- Returns:
- The CapHeight value of the font in glyph space units, or 0 if not defined.
-
getDescent
public double getDescent()- Returns:
- The descent value of the font. \\xrefitem pdelayer_apis "PDE Layer" "PDE Layer" PDSysFont PDSysFontGetAttrs \\xrefitem pdelayer_apis "PDE Layer" "PDE Layer" PDEFont PDEFontGetAttrs \\xrefitem pdlayer_apis "PD Layer" "PD Layer" PDFont PDFontGetMetrics
-
getEncoding
Return the encoding of the font.- Returns:
- The encoding of the font, eg:
-
WinAnsiEncoding
-
MacRomanEncoding
-
-
getItalicAngle
public double getItalicAngle()- Returns:
- The ItalicAngle value of the font in degrees.
-
getLeading
public double getLeading()- Returns:
- The leading value of the font, or 0 if not present.
-
getMaxWidth
public double getMaxWidth()- Returns:
- The MaxWidth value of the font in glyph space units, or 0 if not present.
-
getMissingWidth
public double getMissingWidth()- Returns:
- The MissingWidth value of the font in glyph space units, or 0 if not present.
-
getBBox
The Bounding Box rectangle of the font. -
getName
Get the name of the font.- Returns:
- The name of the font.
-
getFullName
Get the Full Name of the font.- Returns:
- The Full Name of the font. Note: This method only returns a meaningful result for TrueType-based technology fonts.
-
getStemH
public double getStemH()- Returns:
- The StemH value of the font in glyph space units, or 0 if not present.
-
getStemV
public double getStemV()- Returns:
- The StemV value of the font in glyph space units, or 0 if not present.
-
getType
Get the type of the font.- Returns:
- The type of the font.
-
Type0
-
Type1
-
MMType1
-
TrueType
-
-
getCidFontType
-
getXHeight
public double getXHeight()- Returns:
- The XHeight value of the font in glyph space units, or 0 if not present.
-
getFlags
Get the font flags for a font. -
getEncodingInfo
Get the populated CEncoding object. -
getWritingMode
- Returns:
- The WritingMode of the font.
-
isTextRepresentable
Is this text representable in this font?- Parameters:
text- the text to check
-
findIndexOfFirstUnrepresentableChar
Find the index of the first character that cannot be represented in this font. This will return the index of the first character in the string for which the font has no glyph. If all characters can be represented (i.e. if IsTextRepresentable() would return true), this will return the length of the string.- Parameters:
text- the text to check- Returns:
- The index of the first character that cannot be represented in this font.
-
getPDFDict
Retrieve the PDFDict representation of this object -
isFromDoc
public boolean isFromDoc() -
getEmbedded
public boolean getEmbedded()Tests that Font is embedded in the document it was created for returns true if the font is embedded and returns false if it is not -
embedNow
Embeds the Font.- Parameters:
doc- the Document the Font is embedded into
-
measureTextWidth
Measures the width of the specified text in points, using the Font at the specified size.- Parameters:
text- the Text to be measuredfontSize- the Font size to be used
-