Font Class Documentation

class Font

Namespace:com::datalogics::PDFL

Detailed Description

Represents a font.Defines the typeface, size, style (bold, italic), Unicode values, and other details. The Font class represents a font installed on the system.

Constructor & Destructor Documentation

Font

Font(String fontName)

Parameters

fontName: String

the name of the font to find and create

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

Font(String fontName, java.util.EnumSet< FontCreateFlags > createFlags)

Parameters

fontName: String

the name of the font to create

createFlags: java.util.EnumSet< FontCreateFlags >

flags specifying embedding and other options for the use of a font in the document

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

Font(String fontName, java.util.EnumSet< FontCreateFlags > createFlags, WritingMode wrMode)

Parameters

fontName: String

the name of the font to create

createFlags: java.util.EnumSet< FontCreateFlags >

flags specifying embedding and other options for the use of a font in the document

wrMode: WritingMode

determines whether text will be printed horizontally or vertically

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).

Member Function Documentation

delete

synchronized void delete(Boolean disposing)

Parameters

disposing: Boolean

Returns:

synchronized void

delete

synchronized void delete()

Returns:

synchronized void

Destructor.

embedNow

void embedNow(Document doc)

Parameters

doc: Document

the Document the Font is embedded into

Returns:

void

Embeds the Font.

finalize

void finalize()

Returns:

void

Destructor.

findIndexOfFirstUnrepresentableChar

long findIndexOfFirstUnrepresentableChar(String text)

Parameters

text: String

the text to check

Returns:

long

The index of the first character that cannot be represented in this font.

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.

getAscent

double getAscent()

Returns:

double

The Ascent value of the font in glyph space units.

the Ascent value from the font descriptor. This is the maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.

getAvgWidth

double getAvgWidth()

Returns:

double

The AvgWidth value of the font in glyph space units, or 0 if not defined.

the AvgWidth value from the font descriptor. This is the average width of glyphs in the font, or 0 if the value is not defined in the font descriptor.

getBBox

Rect getBBox()

Returns:

Rect

The bounding box of the font as a Rect, in glyph space units.

The Bounding Box rectangle of the font.

getCapHeight

double getCapHeight()

Returns:

double

The CapHeight value of the font in glyph space units, or 0 if not defined.

the CapHeight value from the font descriptor. This is the vertical coordinate of the top of flat capital letters, measured from the baseline, or 0 if the value is not defined in the font descriptor.

getCidFontType

String getCidFontType()

Returns:

String

The CID font type, or an empty string if not a CID font.

Get the CID font type of the font.

getDescent

double getDescent()

Returns:

double

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

the Descent value from the font descriptor. This is the maximum depth below the baseline reached by glyphs in this font. The value is a negative number.

getEmbedded

boolean getEmbedded()

Returns:

boolean

true if the font is embedded, false if it is not.

Tests whether the font is embedded in the document it was created for.

getEncoding

String getEncoding()

Returns:

String

The encoding of the font, eg:
WinAnsiEncoding

MacRomanEncoding

Return the encoding of the font.

getEncodingInfo

EncodingInfo getEncodingInfo()

Returns:

EncodingInfo

The EncodingInfo object containing encoding details for this font.

Get the populated CEncodingInfo object.

getFlags

java.util.EnumSet< FontFlags > getFlags()

Returns:

java.util.EnumSet< FontFlags >

The font descriptor flags as a CFontFlags bitmask.

Get the font flags for a font.

getFullName

String getFullName()

Returns:

String

The Full Name of the font. Note: This method only returns a meaningful result for TrueType-based technology fonts.

Get the Full Name of the font.

getItalicAngle

double getItalicAngle()

Returns:

double

The ItalicAngle value of the font in degrees.

the ItalicAngle value from the font descriptor. This is the angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font, defined in the font descriptor.

getLeading

double getLeading()

Returns:

double

The leading value of the font, or 0 if not present.

the Leading value from the font descriptor. This is the spacing between baselines of consecutive lines of text, or 0 if the value is not defined in the font descriptor.

getMaxWidth

double getMaxWidth()

Returns:

double

The MaxWidth value of the font in glyph space units, or 0 if not present.

the MaxWidth value from the font descriptor. This is the maximum glyph width present in the font, or 0 if the value is not defined in the font descriptor.

getMissingWidth

double getMissingWidth()

Returns:

double

The MissingWidth value of the font in glyph space units, or 0 if not present.

the MissingWidth value from the font descriptor. This is the width given to characters that do not have corresponding glyphs defined in the font, or 0 if the value is not defined in the font descriptor.

getName

String getName()

Returns:

String

The name of the font.

Get the name of the font.

getPDFDict

PDFDict getPDFDict()

Returns:

PDFDict

The PDFDict for this font's COS dictionary object.

Retrieve the PDFDict representation of this font.

getStemH

double getStemH()

Returns:

double

The StemH value of the font in glyph space units, or 0 if not present.

the StemH value from the font descriptor. This is the vertical thickness of the dominant horizontal stems of the font's glyphs, or 0 if the value is not defined in the font descriptor.

getStemV

double getStemV()

Returns:

double

The StemV value of the font in glyph space units, or 0 if not present.

the StemV value from the font descriptor. This is the horizontal thickness of the dominant vertical stems of the font's glyphs, or 0 if the value is not defined in the font descriptor.

getType

String getType()

Returns:

String

The type of the font.
Type0

Type1

MMType1

TrueType

Get the type of the font.

getWritingMode

WritingMode getWritingMode()

Returns:

WritingMode

The WritingMode of the font.

Get the writing mode of the font. The writing mode of the fontwhether it will place glyphs horizontally or vertically. Text written with this font will run in the direction of the writing mode.

getXHeight

double getXHeight()

Returns:

double

The XHeight value of the font in glyph space units, or 0 if not present.

the XHeight value from the font descriptor. This is the vertical coordinate of the top of flat nonascending lowercase letters in fonts that have Latin characters, as measured from the baseline, or 0 if the value is not defined in the font descriptor.

isFromDoc

boolean isFromDoc()

Returns:

boolean

true if the font was loaded from a document, false if it was created from a system font.

Determine whether this font was obtained from an existing document rather than the system.

isTextRepresentable

boolean isTextRepresentable(String text)

Parameters

text: String

the text to check

Returns:

boolean

true if all characters in the text have corresponding glyphs in this font.

Is this text representable in this font?

measureTextWidth

double measureTextWidth(String text, double fontSize)

Parameters

text: String

the Text to be measured

fontSize: double

the Font size to be used

Returns:

double

The width of the text in points.

Measures the width of the specified text in points, using the Font at the specified size.