org.faceless.pdf2
Class OpenTypeFont

java.lang.Object
  extended byorg.faceless.pdf2.PDFObject
      extended byorg.faceless.pdf2.PDFMap
          extended byorg.faceless.pdf2.PDFFont
              extended byorg.faceless.pdf2.OpenTypeFont
All Implemented Interfaces:
Cloneable

public final class OpenTypeFont
extends PDFFont

A subclass of PDFFont that represents an OpenType font. OpenType fonts are a superset of TrueType fonts, but also include fonts where the glyphs are defined using Adobes "Compact Font" format (which are supported since version 2.3 of the library).

OpenType fonts can be stored by reference only (the font is not embedded into the file), or can be embedded using either one or two bytes per glyph. One byte is only really suitable when the font is using a subset of the ASCII character set - eg. western european characters only. If the font is going to be used to display non-roman characters, two bytes should be used.

Since:
2.0 (prior to 2.0 this class was called TrueTypeFont)


Constructor Summary
OpenTypeFont(InputStream in, int bytesperglyph)
          Create a new OpenTypeFont from the specified InputStream.
 
Method Summary
 float getAscender()
          Get the Ascender for the font (the maximum height above the baseline the font extends), as a proportion of the point size.
 String getBaseName()
          Return the Base Font Name for this font.
 float getDefaultLeading()
           Get the default leading for this font - the preferred distance between two successive baselines of text.
 float getDescender()
          Get the Descender for the font (the maximum height below the baseline the font extends), as a proportion of the point size.
 int getKerning(int c1, int c2)
          Get the horizontal character-to-character (or "pair-wise") kerning in this font for the specified characters, in millipoints.
 float getStrikeoutPosition()
          Get the strikeout position, as a proportion of the font size.
 float getStrikeoutThickness()
          Get the strikeout thickness, as a proportion of the font size.
 float getSubscriptPosition()
           Get the recommended position of a sub-script version of this font, as a proportion of the sub-scripted font size.
 float getSubscriptSize()
           Get the recommended size of a super/sub script version of this font, as a proportion of the normal font size.
 float getSuperscriptPosition()
           Get the recommended position of a super-script version of this font, as a proportion of the sub-scripted font size.
 float getUnderlinePosition()
          Get the underline position, as a proportion of the font size.
 float getUnderlineThickness()
          Get the underline thickness, as a proportion of the font size.
 boolean isDefined(int s)
          Return true if the specified Unicode character is defined in the font.
 boolean isMonospace()
          Return true if every character has the same width (like Courier), false if every character is potentially a different width (like Times-Roman)
 void setEmbed(boolean embed)
          Whether to embed the font.
 void setSubset(boolean subset)
          Whether to subset the font.
 
Methods inherited from class org.faceless.pdf2.PDFFont
equals, getBottom, getCharWidth, getCharWidth, getKerning, getLeft, getRight, getTop, isDefined, isHorizontal, ligaturize, ligaturize, requote, requote, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OpenTypeFont

public OpenTypeFont(InputStream in,
                    int bytesperglyph)
             throws IOException,
                    IllegalArgumentException
Create a new OpenTypeFont from the specified InputStream. The InputStream is closed after use.

Parameters:
in - the InputStream to read the font from.
bytesperglyph - the number of bytes to use for each glyph. Must be 1 or 2. Thanks to compression there is surprisingly little difference in terms of size in the resulting file, so if in doubt, use 2.
Since:
2.0
Method Detail

setSubset

public void setSubset(boolean subset)
Whether to subset the font. Default is true.


setEmbed

public void setEmbed(boolean embed)
Whether to embed the font. Default is true. Note 2-byte fonts are always embedded


getBaseName

public String getBaseName()
Description copied from class: PDFFont
Return the Base Font Name for this font.

Overrides:
getBaseName in class PDFFont

isDefined

public boolean isDefined(int s)
Description copied from class: PDFFont
Return true if the specified Unicode character is defined in the font. This method is identical to PDFFont.isDefined(char) but takes an int, to cater for the new Unicode 4.0 codepoints added in Java 1.5.

Overrides:
isDefined in class PDFFont
Parameters:
s - a Unicode codepoint between U+0000 and U+10FFFD

getKerning

public int getKerning(int c1,
                      int c2)
Description copied from class: PDFFont
Get the horizontal character-to-character (or "pair-wise") kerning in this font for the specified characters, in millipoints. This method is identical to PDFFont.getKerning(char,char) but takes ints, to handle the new Unicode 4.0 characters defined in Java 1.5

Specified by:
getKerning in class PDFFont
Parameters:
c1 - a Unicode codepoint between U+0000 and U+10FFFD
c2 - a Unicode codepoint between U+0000 and U+10FFFD

getDefaultLeading

public float getDefaultLeading()
Description copied from class: PDFFont

Get the default leading for this font - the preferred distance between two successive baselines of text. Values are a ratio of the font size, and are typically between 1 and 1.3

Note that the values of the different spacing-between-lines methods have changed - in versions 1.0.4 and earlier this routine normally returned 1 and the spacing was set by the PDFStyle.setTextLineSpacing(float) method. Since 1.1, the values for these two methods are effectively reversed. See the relevant method comments in the PDFStyle class for more information.

Specified by:
getDefaultLeading in class PDFFont

getDescender

public float getDescender()
Description copied from class: PDFFont
Get the Descender for the font (the maximum height below the baseline the font extends), as a proportion of the point size. The returned value is usually negative.

Specified by:
getDescender in class PDFFont

getAscender

public float getAscender()
Description copied from class: PDFFont
Get the Ascender for the font (the maximum height above the baseline the font extends), as a proportion of the point size.

Specified by:
getAscender in class PDFFont

getUnderlinePosition

public float getUnderlinePosition()
Description copied from class: PDFFont
Get the underline position, as a proportion of the font size. Like the getDescender() method, the returned value is almost always negative, indicating below the baseline.

Specified by:
getUnderlinePosition in class PDFFont

getUnderlineThickness

public float getUnderlineThickness()
Description copied from class: PDFFont
Get the underline thickness, as a proportion of the font size.

Specified by:
getUnderlineThickness in class PDFFont

getStrikeoutPosition

public float getStrikeoutPosition()
Description copied from class: PDFFont
Get the strikeout position, as a proportion of the font size.

Specified by:
getStrikeoutPosition in class PDFFont

getStrikeoutThickness

public float getStrikeoutThickness()
Description copied from class: PDFFont
Get the strikeout thickness, as a proportion of the font size.

Specified by:
getStrikeoutThickness in class PDFFont

getSuperscriptPosition

public float getSuperscriptPosition()
Description copied from class: PDFFont

Get the recommended position of a super-script version of this font, as a proportion of the sub-scripted font size. Value is always positive.

For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.

Specified by:
getSuperscriptPosition in class PDFFont

getSubscriptPosition

public float getSubscriptPosition()
Description copied from class: PDFFont

Get the recommended position of a sub-script version of this font, as a proportion of the sub-scripted font size. Value is almost always zero or negative.

For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.

Specified by:
getSubscriptPosition in class PDFFont

getSubscriptSize

public float getSubscriptSize()
Description copied from class: PDFFont

Get the recommended size of a super/sub script version of this font, as a proportion of the normal font size. Typical value is around 0.6.

For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.

Specified by:
getSubscriptSize in class PDFFont

isMonospace

public boolean isMonospace()
Description copied from class: PDFFont
Return true if every character has the same width (like Courier), false if every character is potentially a different width (like Times-Roman)

Specified by:
isMonospace in class PDFFont


Copyright © 2001-2004 Big Faceless Organization