Package com.adobe.fontengine.font
This package and its subpackages contain classes that represent individual fonts.
Implementations of Font
provide client
access to basic font functionality. This includes access to data used to generate
pdfs.
The following font formats are supported:
- OpenType
- Windows legacy TrueType fonts
- Non-multiple-master Windows and Unix legacy Type1 fonts
- Non-sfnt cid and name-keyed cff fonts
How to Generate PDF Font objects.
AFE provides access to information that helps create PDF Font objects, PDF Font Descriptor
objects, and PDF font streams. In particular,
Font.getPDFFontDescription
can be used
to fetch a PDFFontDescription
, which returns
names and metrics that are needed to build these objects.
AFE interprets embedding permissions for its clients, but it does NOT perform gatekeeping. That is,
it does not prevent clients from embedding fonts which they must not embed. The current AFE API only
exposes whether a font can be used for print-and-preview use. If other uses are required, the AFE API
will need to be expanded. Clients can determine if fonts are allowed
to be embedded for print-and-preview use by calling
Font.canEmbedForPrintAndPreview
. If
this method returns true, print-and-preview clients can call
Font.subsetAndStream
to embed fonts. If it returns
false, clients MUST NOT embed the font.
When Font.subsetAndStream
generates fonts to be put in a PDF Font Stream,
it generates fonts appropriate for use in PDF Composite fonts.
How to Generate PDF Content streams and encodings with embedded fonts.
The most reliable PDFs are those that contain all of the fonts used. For this reason, when
allowed, clients should embed fonts. In that case, an Identity-H encoding must be used unless
PDFFontDescription.getROS
returns non-null.
Even in that case, Identity-H can be used and is generally the easiest encoding to use. If
getROS returns null, the codepoints used in the content stream must be the subset glyphIDs
(returned from
Subset.getSubsetGid
). If getROS returns
non-null, the codepoints will depend on the setting of the preserveROS parameter to
Font.subsetAndStream
.
How to Generate PDF Content streams and encodings with unembedded fonts.
When fonts can't be embedded, generating encodings is much more difficult. If
PDFFontDescription.getROS
returns
non-null, composite fonts must be created and Identity-H can be used safely.
In that case, codepoints must be CIDs in the ROS returned.
PDFFontDescription.getGlyphCid
returns CIDs in this case.
In all other cases, Identity-H can not be used portably. In those cases, if
PDFFontDescription.pdfFontIsTrueType
returns false, a simple font must be created.
PDFFontDescription.getGlyphName
will
always return a valid name. Those names should be used to build up the encoding.
If
PDFFontDescription.pdfFontIsTrueType
returns true, generating encodings is more complicated. The following algorithm is one possible way encodings
can be generated:
- Fetch all of the glyph names for the glyphs in the subset using
PDFFontDescription.getGlyphName
. - If all of the glyph names are in winansi or macroman, simple fonts can be created using the enclosing encoding.
- Otherwise, a
PDFEncodingBuilder
can be created. If it returns a non-null encoding fromPDFEncodingBuilder.getEncoding
for every glyph in the subset, then one or more composite fonts can be created (one for each unique encoding returned fromPDFEncodingBuilder.getEncoding
). The returned encodings can be mapped to CMaps that can be used as encodings for the composite fonts. If a given CMap is not allowed to be used because it is not compatible with the pdf version being generated, the client can attempt to convert encodings. If a given glyph either does not have an associated encoding or if it has an encoding but that encoding is not acceptable and attempts to translate fail, the client should go to the next step. Otherwise, composite fonts are ideal and should be used. - Otherwise, if all of the glyphs have names according to
PDFFontDescription.getGlyphName
, a simple font should be created and a differences array built. - Otherwise, a completely portable pdf cannot be created. Glyphs that can be covered by one of the above steps should be handled in that way. For the remaining glyphs, an identity encoding is the best that can be done. This pdf will not work if the exact font is not available to the rendering software.
-
Interface Summary Interface Description BitmapConsumer Receives events for bitmaps.Font The basic interface for all public font interaction.GlyphBBoxCalculator HintedOutlineConsumer Receives information about a parsed hinted charstring.OutlineConsumer Receives events for unhinted beziers representing glyphs.OutlineConsumer2 Receives events for outlines.Scaler A scaler provides access to font data dependent on a size and target device.ScalerDebugger Receives events during the process of hinting and rasterizing glyphs.ScanConverter A scan converter turns outlines into bitmaps.Subset Represent a subset of a font.SWFFontDescription This interface contains methods that allow for the construction of a SWF DefineFont2 or DefineFont3 tag. -
Class Summary Class Description Base14 PDF Base 14 fonts.BitmapConsumerBaseImpl An implementation of BitmapConsumer that does nothing.CatalogDescription The elements of a font useful for cataloguing.CodePage Enumeration representing some CoolType codepages Currently we don't do them all, just the six that are required for XDC That's why the class isn't called CoolTypeCodePageCoolTypeScript Enumeration representing the CoolType scripts (which map to Macintosh script codes)CScan Scan conversion by center scan.EmbeddingPermission Constants for embedding permissions.EmbeddingPermission.OutlineRestriction EmbeddingPermission.SubsettingRestriction FontByteArray A sequence of bytes in an OpenType font file, with methods to access the basic types.FontData The base class for all FontData objects.FontDescription This class is the base class used for any description of a font.FontImpl The base class for all Font objects.FontInputStream GlyphBBoxOutlineConsumer A bezier consumer used to calculate the glyph bbox.LineMetrics The line metrics of a font.Matrix A 2x3 "Postscript style" coordinate matrix (a 2D transformation and shift).OrigFontType OutlineConsumer2BaseImpl A base class for OutlineConsumer2 implementations.OutlineConsumerAdapter Wraps anOutlineConsumer2
as anOutlineConsumer
.PDFEncodingBuilder An object that aids in creation of composite fonts for nonembeddable fonts with pdf.PDFEncodingBuilder.Encoding PDFFontDescription A helper class useful for building pdf font objects.Permission Describes the usage rights associated with a font.Point A 2-D point.QReducer Scan conversion by overscanning.Rect A bounding box.ROS A Registry/Ordering/Supplement tuple.StemFinder Given unhinted cubic Beziers, derive a primary stem value.SubsetDefaultImpl A default implementation for theSubset
interface.SubsetSimpleTrueType SubsetSimpleType1 SWFFont4Description Fetch the data needed to create a DefineFont4 tag in SWF.SWFFont4Description.FTESubsetCompletionIterator Expands the characters in an iteration set to include those that are needed by TLE/CTS.SWFFont4Description.TLFSubsetCompletionIterator Expands the characters in an iteration set to include those that may be added by TLF.TTScan Scan conversion by center scan.UnderlineMetrics The metrics for underlining.WrapperFontData XDCFontDescription A PDFFontDescription plus a codepages mechanism for XDC This class is immutable after contruction and contains no mutable static data. -
Exception Summary Exception Description FontException Generally thrown when a font is incorrect in a way that cannot be worked around.FontLoadingException Generally thrown when the data representing the font is unable to be loaded or reloaded.InvalidFontException Generally thrown when a font is incorrect in a way that cannot be worked around.InvalidGlyphException The charstring associated with the glyph cannot be interpreted.UnsupportedFontException Generally thrown when the major version number of a table is not supported or when the font contains unsupported operators that make it unusable.