org.foray.font
Class FSTrueTypeFont

java.lang.Object
  extended by org.foray.font.Font4a
      extended by org.foray.font.FreeStandingFont
          extended by org.foray.font.FSTrueTypeFont
All Implemented Interfaces:
org.axsl.font.Font

public class FSTrueTypeFont
extends FreeStandingFont

High-level representation of a TrueType font.


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
static int DEFAULT_UNITS_PER_TEXT_SPACE
          Constant indicating the default units per text-space unit used by TrueType fonts.
 
Fields inherited from interface org.axsl.font.Font
INVALID_STRING, NORMAL_STRING
 
Constructor Summary
FSTrueTypeFont(RegisteredFont rf)
          Construct an instance.
 
Method Summary
 TrueTypeFont getFont()
          Returns the encapsulated font.
 int[] getFontBBox()
          Returns the bounding box for this font.
 org.axsl.font.Font.Format getFontFormat()
           
 byte[] getRawFontFile(FontUse4a fontUse)
          Returns the font file contents in a byte array.
 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.
 int getUnitsPerTextSpaceUnit()
          Returns the units per text-space unit that is used in this font for internal font measurements.
 boolean glyphAvailable(int c)
          Reports on the availability of a glyph in this font, without regard to encoding issues.
 boolean isPdfStandardFont()
           Always returns false as all standard PDF fonts are Type 1 fonts.
 int metricIndex(int codePoint)
          For a given Unicode code point index, returns the metric index.
 int overlinePosition(int fontSize)
           
 int overlineSize(int fontSize)
           
 void parseFont()
          Parses the font contents for needed information.
 int strikeoutPosition(int fontSize)
           
 int strikeoutSize(int fontSize)
           
 boolean supportsUnicode()
          Indicates whether this font has the ability to map Unicode characters to font glyphs.
 int underlinePosition(int fontSize)
           
 int underlineSize(int fontSize)
           
 int width(int c, int fontSize)
           
 int widthUndefinedGlyph(int fontSize)
          Returns the width of the undefined or missing glyph.
 
Methods inherited from class org.foray.font.FreeStandingFont
allowsEmbedding, extractBaseline, getAscender, getAwtFont, getAWTFontFormat, getCapHeight, getCharSet, getDefaultWidth, getDescender, getFamilyName, getFlags, getFontComplexity, getFontInputStream, getFontName, getInternalEncoding, getItalicAngle, getKerning, getNumGlyphs, getPanose, getPanoseInstance, getPostscriptName, getWidths, getXHeight, isEmbeddable, isSubsettable, kerningActive, setAllowsEmbedding, setAscender, setCapHeight, setCharSet, setDescender, setFamilyName, setFlags, setFontComplexity, setFontName, setInternalEncoding, setItalicAngle, setKerning, setMissingWidth, setNumGlyphs, setPanose, setPostscriptName, setWidths, setXHeight, systemFontManifestation, usableInPostScriptOutput
 
Methods inherited from class org.foray.font.Font4a
baseline, baselineOffset, estimateBaseline, getEstimatedOverlinePosition, getEstimatedOverlineSize, getEstimatedStrikeoutPosition, getEstimatedStrikeoutSize, getEstimatedUnderlinePosition, getEstimatedUnderlineSize, getLogger, getRegisteredFont, kern, kerningAvailable, normalLineHeightFactor, subscriptShift, superscriptShift, width, widthEstimate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_UNITS_PER_TEXT_SPACE

public static final int DEFAULT_UNITS_PER_TEXT_SPACE
Constant indicating the default units per text-space unit used by TrueType fonts.

See Also:
Constant Field Values
Constructor Detail

FSTrueTypeFont

public FSTrueTypeFont(RegisteredFont rf)
               throws org.axsl.font.FontException,
                      IOException
Construct an instance.

Parameters:
rf - The RegisteredFont that should be used to create this font.
Throws:
org.axsl.font.FontException - For errors parsing the font.
IOException - For errors reading content.
Method Detail

getRawFontFile

public byte[] getRawFontFile(FontUse4a fontUse)
                      throws IOException,
                             org.axsl.font.FontException
Description copied from class: FreeStandingFont
Returns the font file contents in a byte array.

Specified by:
getRawFontFile in class FreeStandingFont
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.

parseFont

public void parseFont()
               throws org.axsl.font.FontException,
                      IOException
Parses the font contents for needed information.

Throws:
org.axsl.font.FontException - For errors parsing the font.
IOException - For errors reading content.

getFontBBox

public int[] getFontBBox()
Description copied from class: FreeStandingFont
Returns the bounding box for this font.

Specified by:
getFontBBox in class FreeStandingFont
Returns:
The bounding box for this font.

getStemV

public int getStemV()
Description copied from class: FreeStandingFont
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 FreeStandingFont
Returns:
The StemV value, in 1/1000ths of a text space unit.

getFontFormat

public org.axsl.font.Font.Format getFontFormat()
Specified by:
getFontFormat in interface org.axsl.font.Font
Specified by:
getFontFormat in class Font4a

width

public int width(int c,
                 int fontSize)

widthUndefinedGlyph

public int widthUndefinedGlyph(int fontSize)
Description copied from class: Font4a
Returns the width of the undefined or missing glyph.

Specified by:
widthUndefinedGlyph in class Font4a
Parameters:
fontSize - The font size at which the width should be computed.
Returns:
The width, in millipoints, of the undefined glyph at the specified point size.

isPdfStandardFont

public boolean isPdfStandardFont()
Always returns false as all standard PDF fonts are Type 1 fonts.

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

glyphAvailable

public boolean glyphAvailable(int c)
Description copied from class: Font4a
Reports on the availability of a glyph in this font, without regard to encoding issues.

Specified by:
glyphAvailable in class Font4a
Parameters:
c - The Unicode code point to be tested.
Returns:
True iff this font can paint a glyph for c.

strikeoutSize

public int strikeoutSize(int fontSize)

strikeoutPosition

public int strikeoutPosition(int fontSize)

underlineSize

public int underlineSize(int fontSize)

underlinePosition

public int underlinePosition(int fontSize)

overlineSize

public int overlineSize(int fontSize)

overlinePosition

public int overlinePosition(int fontSize)

getUnitsPerTextSpaceUnit

public int getUnitsPerTextSpaceUnit()
Description copied from class: Font4a
Returns the units per text-space unit that is used in this font for internal font measurements. For PostScript Type 1 fonts, this is 1000. For TrueType fonts, it is usually 2048, but can be specified in the font itself.

Specified by:
getUnitsPerTextSpaceUnit in class Font4a
Returns:
The units per text-space unit used by this font.

supportsUnicode

public boolean supportsUnicode()
Description copied from class: Font4a
Indicates whether this font has the ability to map Unicode characters to font glyphs.

Specified by:
supportsUnicode in class Font4a
Returns:
True iff this font can map Unicode characters to font glyphs.

getFont

public TrueTypeFont getFont()
Returns the encapsulated font.

Returns:
The encapsulated font.

metricIndex

public int metricIndex(int codePoint)
Description copied from class: Font4a
For a given Unicode code point index, returns the metric index.

Specified by:
metricIndex in class Font4a
Parameters:
codePoint - The Unicode code point to be converted.
Returns:
The metric index.


Copyright © 2017. All rights reserved.