Package com.adobe.fontengine.font.cff
Class NameKeyedFont
- java.lang.Object
-
- com.adobe.fontengine.font.FontData
-
- com.adobe.fontengine.font.cff.CFFFont
-
- com.adobe.fontengine.font.cff.NameKeyedFont
-
public final class NameKeyedFont extends CFFFont
Represents a name-keyed font.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNameKeyedFont.GlyphNameFetcher
-
Constructor Summary
Constructors Constructor Description NameKeyedFont(com.adobe.fontengine.font.cff.StringIndex stringIndex, CharStrings globalSubrs, java.lang.String name, Dict topDict, com.adobe.fontengine.font.cff.CFFByteArray data, byte[] digest)Construct aNameKeyedFont.NameKeyedFont(java.lang.String fontName, Dict topDict, CharStrings charStrings, Dict privateDict)Create a somewhat lobotimized name keyed font for subsetting a type1 font to CFFNameKeyedFont(java.lang.String fontName, Dict topDict, CharStrings charStrings, Dict privateDict, CharStrings lSubrs, CharStrings gSubrs)Create an extended lobotimized name keyed font for subsetting a TrueType font to CFF with subroutines
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcharCode2gid(int charCode)SubsetcreateSubset()Create a subset for this font.LineMetricsgetCoolTypeLineMetrics()Emulates the CoolType API CTFontDict:GetHorizontalMetrics CoolType API.RectgetCoolTypeRawFontBBox()PermissiongetEmbeddingPermission(boolean wasEmbedded)intgetFirstChar()RectgetFontBBox()MatrixgetFontMatrix()intgetGlyphCid(int glyphID)Get the CID associated with glyphglyphID.intgetGlyphForChar(int usv)Return the glyph to use to display a character.java.lang.StringgetGlyphName(int gid)Return the name of glyphgid.voidgetGlyphOutline(int gid, OutlineConsumer consumer)Get the outline of glyphgid.doublegetHorizontalAdvance(int gid)Get the horizontal advance of a glyph.intgetLastChar()intgetNumGlyphs()Return the number of glyphs in this font.voidgetOutline(int gid, Type2OutlineParser parser, OutlineConsumer consumer)Get the outline of glyphgid, using a specified parser.PDFFontDescriptiongetPDFFontDescription(Font font)ROSgetROS()Get the ROS associated with this font.doublegetStemVForGlyph(int gid)XDCFontDescriptiongetXDCFontDescription(Font font)intglyphName2gid(java.lang.String glyphName)voidstream(java.io.OutputStream out, java.lang.Integer fsType)voidstream(java.io.OutputStream out, java.lang.Integer fsType, NameKeyedFont.GlyphNameFetcher fetcher)voidsubsetAndStream(Subset subset, java.io.OutputStream out, boolean preserveROS, java.lang.Integer fsType)Subset and stream this font for PDF use.voidsubsetAndStream(Subset subset, java.io.OutputStream out, boolean preserveROS, java.lang.Integer fsType, boolean enableSubrizer)Added new subsetAndStream method as part of changes to force DF4 output to be Identity-CID always.voidsubsetAndStream(Subset subset, java.io.OutputStream out, java.lang.Integer fsType, boolean rebuildCharstrings, NameKeyedFont.GlyphNameFetcher fetcher)Create a subset name-keyed cff based on the given parametersvoidsubsetAndStream(Subset subset, java.io.OutputStream out, java.lang.Integer fsType, boolean rebuildCharstrings, NameKeyedFont.GlyphNameFetcher fetcher, boolean enableSubrizer)-
Methods inherited from class com.adobe.fontengine.font.cff.CFFFont
getCacheSupportInfo, getCoolTypeIcfBox, getCoolTypeIdeoEmBox, getCoolTypeProportionalRomanFromFontProperties, getCoolTypeScript, getCoolTypeUnderlineMetrics, getCoolTypeUnderlineMetrics, getCSSFamilyNames, getCSSStretchValue, getCSSWeight, getFXGFontDescription, getGlyphBBox, getName, getPlatformFontDescription, getPostscriptFontDescription, getPreferredCSSFamilyName, getScaler, getSelectionDescription, getSWFFont4Description, getSWFFontDescription, getUnitsPerEmX, getUnitsPerEmY, isCSSStyleItalic, isCSSStyleNormal, isCSSStyleOblique, isCSSVariantNormal, isCSSVariantSmallCaps, isFixedPitch, subsetAndStream
-
Methods inherited from class com.adobe.fontengine.font.FontData
getContainerFingerprint, getCoolTypeCapHeight, getCoolTypeFontBBox, getCoolTypeGlyphBBox, getCoolTypeGlyphForChar, getCoolTypeUnitsPerEm, getCoolTypeXHeight, getCSS20FontDescription, getLineMetrics, getPointSizeRange, getPreferredCSS20FontDescription, getScaler, hasCoolTypeProportionalRoman, isSymbolic
-
-
-
-
Constructor Detail
-
NameKeyedFont
public NameKeyedFont(com.adobe.fontengine.font.cff.StringIndex stringIndex, CharStrings globalSubrs, java.lang.String name, Dict topDict, com.adobe.fontengine.font.cff.CFFByteArray data, byte[] digest) throws java.io.IOException, InvalidFontException, UnsupportedFontExceptionConstruct aNameKeyedFont.- Parameters:
stringIndex- the StringIndex for this fontglobalSubrs- the global subroutines for this fontname- the name of this fonttopDict- the topDictof this font.data- the underlying bytes from which the structures pointed by the top dict will be parseddigest- the digest for the container of this font- Throws:
java.io.IOExceptionInvalidFontExceptionUnsupportedFontException
-
NameKeyedFont
public NameKeyedFont(java.lang.String fontName, Dict topDict, CharStrings charStrings, Dict privateDict) throws InvalidFontException, UnsupportedFontExceptionCreate a somewhat lobotimized name keyed font for subsetting a type1 font to CFF
-
NameKeyedFont
public NameKeyedFont(java.lang.String fontName, Dict topDict, CharStrings charStrings, Dict privateDict, CharStrings lSubrs, CharStrings gSubrs) throws InvalidFontException, UnsupportedFontExceptionCreate an extended lobotimized name keyed font for subsetting a TrueType font to CFF with subroutines
-
-
Method Detail
-
getNumGlyphs
public int getNumGlyphs()
Description copied from class:FontDataReturn the number of glyphs in this font.- Specified by:
getNumGlyphsin classFontData
-
glyphName2gid
public int glyphName2gid(java.lang.String glyphName) throws InvalidFontException, UnsupportedFontException
-
charCode2gid
public int charCode2gid(int charCode) throws InvalidFontException, UnsupportedFontException
-
getGlyphName
public java.lang.String getGlyphName(int gid) throws InvalidFontException, UnsupportedFontExceptionReturn the name of glyphgid.- Specified by:
getGlyphNamein classCFFFont- Throws:
InvalidFontExceptionUnsupportedFontException
-
getROS
public ROS getROS()
Description copied from class:CFFFontGet the ROS associated with this font. If the font does not have an ROS, return null.
-
getGlyphCid
public int getGlyphCid(int glyphID)
Description copied from class:CFFFontGet the CID associated with glyphglyphID. Returns -1 if getROS() returns null.- Specified by:
getGlyphCidin classCFFFont- Returns:
- the CID in the ROS associated with the font.
-
getGlyphOutline
public void getGlyphOutline(int gid, OutlineConsumer consumer) throws InvalidFontException, UnsupportedFontExceptionGet the outline of glyphgid.- Specified by:
getGlyphOutlinein classCFFFont- Parameters:
gid- the glyph id of the glyphconsumer- the OutlineConsumer to receive the outline- Throws:
InvalidFontExceptionUnsupportedFontException
-
getOutline
public void getOutline(int gid, Type2OutlineParser parser, OutlineConsumer consumer) throws InvalidFontException, UnsupportedFontExceptionGet the outline of glyphgid, using a specified parser.- Specified by:
getOutlinein classCFFFont- Parameters:
gid- the glyph id of the glyphparser- the Type2OutlineParser parser to useconsumer- the OutlineConsumer to receive the outline- Throws:
InvalidFontExceptionUnsupportedFontException
-
getStemVForGlyph
public double getStemVForGlyph(int gid)
- Specified by:
getStemVForGlyphin classCFFFont
-
getHorizontalAdvance
public double getHorizontalAdvance(int gid) throws InvalidFontException, UnsupportedFontExceptionDescription copied from class:FontDataGet the horizontal advance of a glyph. The returned value is in metric space.- Specified by:
getHorizontalAdvancein classCFFFont- Throws:
InvalidFontExceptionUnsupportedFontException
-
getFontMatrix
public Matrix getFontMatrix()
- Specified by:
getFontMatrixin classCFFFont
-
getFontBBox
public Rect getFontBBox() throws InvalidFontException, UnsupportedFontException
- Specified by:
getFontBBoxin classFontData- Throws:
InvalidFontExceptionUnsupportedFontException
-
getCoolTypeRawFontBBox
public Rect getCoolTypeRawFontBBox() throws InvalidFontException, UnsupportedFontException
-
getCoolTypeLineMetrics
public LineMetrics getCoolTypeLineMetrics() throws UnsupportedFontException, InvalidFontException
Emulates the CoolType API CTFontDict:GetHorizontalMetrics CoolType API.The metrics are expressed in the design space of the font, i.e. they need to be converted through the metrics matrix.
This methods never returns null.
See also the
FontData.getLineMetrics()method.- Specified by:
getCoolTypeLineMetricsin classFontData- Throws:
UnsupportedFontExceptionInvalidFontException
-
getFirstChar
public int getFirstChar() throws InvalidFontException, UnsupportedFontException
-
getLastChar
public int getLastChar() throws InvalidFontException, UnsupportedFontException
-
getGlyphForChar
public int getGlyphForChar(int usv) throws InvalidFontException, UnsupportedFontExceptionReturn the glyph to use to display a character. Depending on the layout technology of the font, the returned gid may be further processed.- Specified by:
getGlyphForCharin classCFFFont- Parameters:
usv- the Unicode scalar value of the character; (by definition, surrogate code points are not Unicode scalar values).- Returns:
- the gid of the glyph to use
- Throws:
InvalidFontExceptionUnsupportedFontException
-
getEmbeddingPermission
public Permission getEmbeddingPermission(boolean wasEmbedded)
- Specified by:
getEmbeddingPermissionin classFontData
-
subsetAndStream
public void subsetAndStream(Subset subset, java.io.OutputStream out, boolean preserveROS, java.lang.Integer fsType) throws InvalidFontException, UnsupportedFontException, java.io.IOException
Subset and stream this font for PDF use. The stream is a CID-keyed CFF stream.- Specified by:
subsetAndStreamin classCFFFont- Parameters:
out- the OutputStream to which the bytes are streamedfsType- if non-null an integer as described in technote 5147 http://partners.adobe.com/public/developer/en/acrobat/sdk/FontPolicies.pdf "Font Embedding Guidelines for Adobe Third-party Developers".- Throws:
InvalidFontExceptionUnsupportedFontExceptionjava.io.IOException
-
subsetAndStream
public void subsetAndStream(Subset subset, java.io.OutputStream out, boolean preserveROS, java.lang.Integer fsType, boolean enableSubrizer) throws InvalidFontException, UnsupportedFontException, java.io.IOException
Added new subsetAndStream method as part of changes to force DF4 output to be Identity-CID always.- Throws:
InvalidFontExceptionUnsupportedFontExceptionjava.io.IOException
-
stream
public void stream(java.io.OutputStream out, java.lang.Integer fsType) throws InvalidFontException, UnsupportedFontException, java.io.IOException- Specified by:
streamin classCFFFont- Throws:
InvalidFontExceptionUnsupportedFontExceptionjava.io.IOException
-
stream
public void stream(java.io.OutputStream out, java.lang.Integer fsType, NameKeyedFont.GlyphNameFetcher fetcher) throws InvalidFontException, UnsupportedFontException, java.io.IOException- Throws:
InvalidFontExceptionUnsupportedFontExceptionjava.io.IOException
-
subsetAndStream
public void subsetAndStream(Subset subset, java.io.OutputStream out, java.lang.Integer fsType, boolean rebuildCharstrings, NameKeyedFont.GlyphNameFetcher fetcher) throws InvalidFontException, UnsupportedFontException, java.io.IOException
Create a subset name-keyed cff based on the given parameters- Parameters:
subset- The set of glyphs to include in the subsetout- The OutputStream to which we will write the new fontfsType- The fsType to include in the new fontrebuildCharstrings- Tells if the charstrings in the current font already take into account the Subset. If they do, then we don't need to recreate the charstrings. Otherwise, we do.fetcher- Provides a way to get from gid to glyphName for cases where there is no charset (for example, because this NameKeyedFont is a temporary font converted from Type1). Can be null if this's charset and string index are valid.- Throws:
InvalidFontExceptionUnsupportedFontExceptionjava.io.IOException
-
subsetAndStream
public void subsetAndStream(Subset subset, java.io.OutputStream out, java.lang.Integer fsType, boolean rebuildCharstrings, NameKeyedFont.GlyphNameFetcher fetcher, boolean enableSubrizer) throws InvalidFontException, UnsupportedFontException, java.io.IOException
- Throws:
InvalidFontExceptionUnsupportedFontExceptionjava.io.IOException
-
getPDFFontDescription
public PDFFontDescription getPDFFontDescription(Font font) throws UnsupportedFontException, InvalidFontException
- Specified by:
getPDFFontDescriptionin classFontData- Throws:
UnsupportedFontExceptionInvalidFontException
-
getXDCFontDescription
public XDCFontDescription getXDCFontDescription(Font font) throws UnsupportedFontException, InvalidFontException
- Specified by:
getXDCFontDescriptionin classFontData- Throws:
UnsupportedFontExceptionInvalidFontException
-
createSubset
public Subset createSubset() throws InvalidFontException, UnsupportedFontException
Create a subset for this font.- Specified by:
createSubsetin classFontData- Throws:
InvalidFontExceptionUnsupportedFontException
-
-