org.foray.font
Class FreeStandingFont

java.lang.Object
  extended by org.foray.font.Font4a
      extended by org.foray.font.FreeStandingFont
All Implemented Interfaces:
org.axsl.font.Font
Direct Known Subclasses:
FSTrueTypeFont, FSType1Font

public abstract class FreeStandingFont
extends Font4a

Base class for all fonts that are registered independently of the operating system's font registration. Fonts that are not FreeStandingFonts are SystemFonts. Access to SystemFont capabilities is handled entirely through the parent Font class. However, FreeStandingFonts can be embedded, and this capability requires that more of the internals of the font be exposed to client applications.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.axsl.font.Font
org.axsl.font.Font.Baseline, org.axsl.font.Font.Complexity, org.axsl.font.Font.Embedding, org.axsl.font.Font.Format, org.axsl.font.Font.LineHeightAlgorithm, org.axsl.font.Font.SelectionStrategy, org.axsl.font.Font.Stretch, org.axsl.font.Font.Style, org.axsl.font.Font.Variant, org.axsl.font.Font.Weight, org.axsl.font.Font.WritingMode
 
Field Summary
 
Fields inherited from interface org.axsl.font.Font
INVALID_STRING, NORMAL_STRING
 
Constructor Summary
protected FreeStandingFont(RegisteredFont rf)
          Constructor.
 
Method Summary
 boolean allowsEmbedding()
          Indicates whether the font allows embedding.
 int extractBaseline(org.axsl.font.Font.WritingMode writingMode, org.axsl.font.Font.Baseline baselineType, int fontSize)
          Returns the font's explicit definition of the baseline, if possible.
 int getAscender(int fontSize)
           
 Font getAwtFont(int fontSize)
           FreeStandingFonts are never AWTFonts, so this always returns null.
 int getAWTFontFormat()
          Computes the corresponding Java AWT font format constant.
 int getCapHeight(int fontSize)
           
 org.axsl.ps.CharSet getCharSet()
          Returns the character set used by this font.
 int getDefaultWidth()
          Returns the default glyph width for this font.
 int getDescender(int fontSize)
           
 String getFamilyName()
           
 int getFlags()
          Returns the PS/PDF flags for this font.
abstract  int[] getFontBBox()
          Returns the bounding box for this font.
 org.axsl.font.Font.Complexity getFontComplexity()
           
protected  InputStream getFontInputStream()
          Returns the font content as a stream.
 String getFontName()
           
 org.axsl.ps.Encoding getInternalEncoding()
          Get the encoding scheme that should be used to embed this font in a PDF file.
 float getItalicAngle()
           
 Kerning getKerning()
          Returns the kerning information for this font.
 int getNumGlyphs()
          Returns the number of glyphs in this font.
 byte[] getPanose()
          
 Panose getPanoseInstance()
          Returns this font's Panose instance.
 String getPostscriptName()
          Returns the font's internal name, if given.
abstract  byte[] getRawFontFile(FontUse4a fontUse)
          Returns the font file contents in a byte array.
abstract  int getStemV()
          Returns the StemV value for this font, used in a PDF Font Descriptor, as defined in the PDF Reference, Second Edition, Section 5.7.
 short[] getWidths()
          Returns the widths of the glyphs in this font in an array.
 int getXHeight(int fontSize)
           
 boolean isEmbeddable()
          Tells the client application whether this font can be embedded or not.
 boolean isSubsettable()
           
 boolean kerningActive()
          Reports whether kerning information should be used for this font.
protected  void setAllowsEmbedding(boolean allowsEmbedding)
          Sets the allowsEmbedding.
protected  void setAscender(int ascender)
          Sets the ascender.
protected  void setCapHeight(int capHeight)
          Sets the cap height.
protected  void setCharSet(org.axsl.ps.CharSet charSet)
          Sets the character set for this font.
protected  void setDescender(int descender)
          Sets the descender.
protected  void setFamilyName(String familyName)
          Sets the family name for this font.
protected  void setFlags(int flags)
          Sets the flags.
 void setFontComplexity(org.axsl.font.Font.Complexity fontComplexity)
          Sets the complexity value for this font.
protected  void setFontName(String fontName)
          Sets the name of this font.
protected  void setInternalEncoding(org.axsl.ps.Encoding encoding)
          Sets the internal encoding for this font.
protected  void setItalicAngle(float italicAngle)
          Sets the italic angle.
protected  void setKerning(Kerning kerning)
          Sets the kerning for this font.
protected  void setMissingWidth(int missingWidth)
          Sets the missing width value.
protected  void setNumGlyphs(int numGlyphs)
          Sets the number of glyphs in this font.
protected  void setPanose(Panose panose)
          Sets the Panose value for this font.
protected  void setPostscriptName(String postscriptName)
          Sets the postscript name for this font.
protected  void setWidths(short[] width)
          Set the widths for this font.
protected  void setXHeight(int height)
          Sets the x-height.
 SystemFont systemFontManifestation()
          Returns the SystemFont manifestation of this font.
 boolean usableInPostScriptOutput()
          Indicates whether this font can be referenced within a PostScript file.
 
Methods inherited from class org.foray.font.Font4a
baseline, baselineOffset, estimateBaseline, getEstimatedOverlinePosition, getEstimatedOverlineSize, getEstimatedStrikeoutPosition, getEstimatedStrikeoutSize, getEstimatedUnderlinePosition, getEstimatedUnderlineSize, getFontFormat, getLogger, getRegisteredFont, getUnitsPerTextSpaceUnit, glyphAvailable, isPdfStandardFont, kern, kerningAvailable, metricIndex, normalLineHeightFactor, subscriptShift, superscriptShift, supportsUnicode, width, widthEstimate, widthUndefinedGlyph
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.axsl.font.Font
overlinePosition, overlineSize, strikeoutPosition, strikeoutSize, underlinePosition, underlineSize, width
 

Constructor Detail

FreeStandingFont

protected FreeStandingFont(RegisteredFont rf)
Constructor.

Parameters:
rf - The parent registered font.
Method Detail

getInternalEncoding

public org.axsl.ps.Encoding getInternalEncoding()
Get the encoding scheme that should be used to embed this font in a PDF file.

Specified by:
getInternalEncoding in interface org.axsl.font.Font
Specified by:
getInternalEncoding in class Font4a
Returns:
The name of the encoding that should be used in the PDF file, or null if the font-intrinsic encoding should be used.

getFontName

public String getFontName()

getFamilyName

public String getFamilyName()

getPostscriptName

public String getPostscriptName()
Returns the font's internal name, if given. Otherwise, returns the configured name.

Returns:
The name of the font.

getAscender

public int getAscender(int fontSize)
Specified by:
getAscender in interface org.axsl.font.Font
Specified by:
getAscender in class Font4a

getDescender

public int getDescender(int fontSize)
Specified by:
getDescender in interface org.axsl.font.Font
Specified by:
getDescender in class Font4a

getCapHeight

public int getCapHeight(int fontSize)
Specified by:
getCapHeight in interface org.axsl.font.Font
Specified by:
getCapHeight in class Font4a

getXHeight

public int getXHeight(int fontSize)
Specified by:
getXHeight in interface org.axsl.font.Font
Specified by:
getXHeight in class Font4a

getFontBBox

public abstract int[] getFontBBox()
Returns the bounding box for this font.

Returns:
The bounding box for this font.

getFlags

public int getFlags()
Returns the PS/PDF flags for this font.

Returns:
the PS/PDF flags for this font.

getItalicAngle

public float getItalicAngle()
Specified by:
getItalicAngle in interface org.axsl.font.Font
Specified by:
getItalicAngle in class Font4a

getStemV

public abstract int getStemV()
Returns the StemV value for this font, used in a PDF Font Descriptor, as defined in the PDF Reference, Second Edition, Section 5.7.

Specified by:
getStemV in interface org.axsl.font.Font
Specified by:
getStemV in class Font4a
Returns:
The StemV value, in 1/1000ths of a text space unit.

getDefaultWidth

public int getDefaultWidth()
Returns the default glyph width for this font.

Specified by:
getDefaultWidth in interface org.axsl.font.Font
Specified by:
getDefaultWidth in class Font4a
Returns:
The default glyph width for this font, expressed in 1/1000ths of a text space unit.

getKerning

public final Kerning getKerning()
Returns the kerning information for this font.

Specified by:
getKerning in class Font4a
Returns:
The kerning information for this font.

isEmbeddable

public boolean isEmbeddable()
Tells the client application whether this font can be embedded or not.

Specified by:
isEmbeddable in interface org.axsl.font.Font
Specified by:
isEmbeddable in class Font4a
Returns:
True if this font can be embedded.

isSubsettable

public boolean isSubsettable()
Specified by:
isSubsettable in interface org.axsl.font.Font
Specified by:
isSubsettable in class Font4a

getFontInputStream

protected InputStream getFontInputStream()
                                  throws org.axsl.font.FontException
Returns the font content as a stream.

Returns:
The font content as a stream.
Throws:
org.axsl.font.FontException - For errors opening the input stream.

getRawFontFile

public abstract byte[] getRawFontFile(FontUse4a fontUse)
                               throws IOException,
                                      org.axsl.font.FontException
Returns the font file contents in a byte array.

Parameters:
fontUse - The specific font use, which is needed to get encoding and subsetting information.
Returns:
The font file contents.
Throws:
IOException - For I/O errors.
org.axsl.font.FontException - For errors parsing the font.

getAwtFont

public Font getAwtFont(int fontSize)
FreeStandingFonts are never AWTFonts, so this always returns null.

Specified by:
getAwtFont in interface org.axsl.font.Font
Specified by:
getAwtFont in class Font4a

getAWTFontFormat

public int getAWTFontFormat()
Computes the corresponding Java AWT font format constant.

Returns:
If the font is a TrueType font, returns: Font.TRUETYPE_FONT. If the font is a Type1 font, returns: Font.TYPE1_FONT. If the font is any other format: -1.

usableInPostScriptOutput

public boolean usableInPostScriptOutput()
Indicates whether this font can be referenced within a PostScript file.

Specified by:
usableInPostScriptOutput in interface org.axsl.font.Font
Specified by:
usableInPostScriptOutput in class Font4a
Returns:
True if this font can be referenced within a PostScript file.

kerningActive

public boolean kerningActive()
Description copied from class: Font4a
Reports whether kerning information should be used for this font.

Specified by:
kerningActive in class Font4a
Returns:
True if both 1) kerning is available for this font, and 2) the font configuration has kerning="yes" for this font; false otherwise.

systemFontManifestation

public SystemFont systemFontManifestation()
Returns the SystemFont manifestation of this font.

Returns:
The SystemFont manifestation of this FreeStandingFont. If there is none, return null.

getWidths

public short[] getWidths()
Returns the widths of the glyphs in this font in an array.

Returns:
The widths of the glyphs in this font.

getCharSet

public org.axsl.ps.CharSet getCharSet()
Description copied from class: Font4a
Returns the character set used by this font.

Specified by:
getCharSet in class Font4a
Returns:
The character set for this font.

extractBaseline

public int extractBaseline(org.axsl.font.Font.WritingMode writingMode,
                           org.axsl.font.Font.Baseline baselineType,
                           int fontSize)
Description copied from class: Font4a
Returns the font's explicit definition of the baseline, if possible.

Specified by:
extractBaseline in class Font4a
Parameters:
writingMode - Same as for Font.baselineOffset(Font.WritingMode, Baseline, int).
baselineType - Same as for Font.baselineOffset(Font.WritingMode, Baseline, int).
fontSize - Same as for Font.baselineOffset(Font.WritingMode, Baseline, int).
Returns:
The extracted Baseline, as described for Font.baselineOffset(Font.WritingMode, Baseline, int), if it exists. Otherwise, returns Integer.MIN_VALUE.

getNumGlyphs

public int getNumGlyphs()
Description copied from class: Font4a
Returns the number of glyphs in this font.

Specified by:
getNumGlyphs in class Font4a
Returns:
The number of glyphs in this font.

setNumGlyphs

protected void setNumGlyphs(int numGlyphs)
Sets the number of glyphs in this font.

Parameters:
numGlyphs - The numGlyphs to set.

setCharSet

protected void setCharSet(org.axsl.ps.CharSet charSet)
Sets the character set for this font.

Parameters:
charSet - The character set to set.

allowsEmbedding

public boolean allowsEmbedding()
Indicates whether the font allows embedding.

Returns:
True iff the font allows embedding.

setAllowsEmbedding

protected void setAllowsEmbedding(boolean allowsEmbedding)
Sets the allowsEmbedding.

Parameters:
allowsEmbedding - True if the font allows embedding, false otherwise.

setInternalEncoding

protected void setInternalEncoding(org.axsl.ps.Encoding encoding)
Sets the internal encoding for this font.

Parameters:
encoding - The encoding to set.

setWidths

protected void setWidths(short[] width)
Set the widths for this font.

Parameters:
width - The width array to set.

setMissingWidth

protected void setMissingWidth(int missingWidth)
Sets the missing width value.

Parameters:
missingWidth - The width to set.

setItalicAngle

protected void setItalicAngle(float italicAngle)
Sets the italic angle.

Parameters:
italicAngle - The italic angle to set.

setAscender

protected void setAscender(int ascender)
Sets the ascender.

Parameters:
ascender - The ascender to set.

setCapHeight

protected void setCapHeight(int capHeight)
Sets the cap height.

Parameters:
capHeight - The capHeight to set.

setDescender

protected void setDescender(int descender)
Sets the descender.

Parameters:
descender - The descender to set.

setFlags

protected void setFlags(int flags)
Sets the flags.

Parameters:
flags - The flags to set.

setXHeight

protected void setXHeight(int height)
Sets the x-height.

Parameters:
height - The xHeight to set.

setFamilyName

protected void setFamilyName(String familyName)
Sets the family name for this font.

Parameters:
familyName - The familyName to set.

setFontName

protected void setFontName(String fontName)
Sets the name of this font.

Parameters:
fontName - The fontName to set.

setKerning

protected void setKerning(Kerning kerning)
Sets the kerning for this font.

Parameters:
kerning - The kerning to set.

setPostscriptName

protected void setPostscriptName(String postscriptName)
Sets the postscript name for this font.

Parameters:
postscriptName - The postscriptName to set.

setPanose

protected void setPanose(Panose panose)
Sets the Panose value for this font.

Parameters:
panose - The new Panose value.

getPanoseInstance

public Panose getPanoseInstance()
Returns this font's Panose instance.

Returns:
The Panose instance for this font.
See Also:
getPanose()

getPanose

public byte[] getPanose()

See Also:
getPanoseInstance()

getFontComplexity

public org.axsl.font.Font.Complexity getFontComplexity()

setFontComplexity

public void setFontComplexity(org.axsl.font.Font.Complexity fontComplexity)
Sets the complexity value for this font.

Parameters:
fontComplexity - The complexity level to set.


Copyright © 2017. All rights reserved.