SourceForge.net Logo
aXSL API 0.2

org.axsl.font
Interface Font


public interface Font

The Font interface exposes a font resource to the client application.


Nested Class Summary
static class Font.Complexity
          Enumeration of constants to describe the complexity of a font.
static class Font.Format
          Enumeration of constants to describe the format of a font.
static class Font.LineHeightAlgorithm
          Enumeration of possible algorithms that could be used to compute the line-height for a given font.
static class Font.SelectionStrategy
          Enumeration of constants needed to describe the various font selection strategies.
static class Font.Stretch
          Enumeration of constants needed to describe the "stretch" value of a font.
static class Font.Style
          Enumeration of constants needed to describe the style of a font.
static class Font.Variant
          Enumeration of constants needed to describe the variant of a font.
static class Font.Weight
          Enumeration of constants needed to describe the weight of a font.
static class Font.WritingMode
          Enumeration of possible writing-modes that a font might have.
 
Method Summary
 Baseline baseline(Iso15924 script)
          Determines which baseline should be used by this font for a specified script.
 int baselineOffset(AbsoluteAxis writingMode, Baseline baselineType, int fontSize)
          Returns the location of the specified baseline.
 int getAscender(int fontSize)
          Returns the Ascender value for this font, scaled to a specific point size.
 java.awt.Font getAwtFont(int fontSize)
          If this Font has a java.awt.Font associated with it, return it.
 int getCapHeight(int fontSize)
          Returns the CapHeight value for this font, scaled to a specific point size.
 int getDefaultWidth()
          Returns the default glyph width for this font.
 int getDescender(int fontSize)
          Returns the Descender value for this font, scaled to a specific point size.
 java.lang.String getFamilyName()
          Returns this font's font-family name.
 Font.Complexity getFontComplexity()
          Returns a value indicating whether this font is a simple or composite font.
 Font.Format getFontFormat()
          Returns a value indicating what format (e.g.
 java.lang.String getFontName()
          Returns this font's name.
 Encoding getInternalEncoding()
          Get the font's internal Encoding scheme.
 float getItalicAngle()
          Returns the ItalicAngle value for this font.
 byte[] getPanose()
          Returns the Panose array for this font.
 java.lang.String getPostscriptName()
          Returns the PostScript name of the font.
 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 getXHeight(int fontSize)
          Returns the XHeight value for this font, scaled to a specific point size.
 boolean isEmbeddable()
          Tells the client application whether this font can be embedded or not.
 boolean isPdfStandardFont()
          Indicates whether this font is one of the PDF Base-14 fonts.
 boolean isSubsettable()
          Tells the client application whether a subset of this font can be embedded.
 int kern(int char1, int char2)
          Computes the kerning needed between two glyphs in this font.
 float normalLineHeightFactor(Font.LineHeightAlgorithm algorithm)
          Returns a factor suitable for computing a "normal" line-height as defined in the CSS and XSL-FO standards.
 int overlinePosition(int fontSize)
          The recommended position of the bottom of the overline stroke, relative to the baseline, in millipoints.
 int overlineSize(int fontSize)
          The recommended thickness, in millipoints, of the overline stroke for this font.
 int strikeoutPosition(int fontSize)
          The recommended position of the top of the strikeout stroke, relative to the baseline, in millipoints.
 int strikeoutSize(int fontSize)
          The recommended thickness, in millipoints, of the strikeout stroke for this font.
 int subscriptShift(int fontSize)
          The amount by which the alphabetic baseline should be shifted when writing subscripts for this font.
 int superscriptShift(int fontSize)
          The amount by which the alphabetic baseline should be shifted when writing superscripts for this font.
 int underlinePosition(int fontSize)
          The recommended position of the top of the underline stroke, relative to the baseline, in millipoints.
 int underlineSize(int fontSize)
          The recommended thickness, in millipoints, of the underline stroke for this font.
 boolean usableInPostScriptOutput()
          Indicates whether this font can be referenced within a PostScript file.
 int width(java.lang.CharSequence chars, int fontSize, int letterSpacing, int wordSpacing)
          Calculates the width of a given String, considering letter spacing, word spacing, and kerning.
 int width(int codePoint, int fontSize)
          Returns the width of a Unicode character for this font, at a specified point size.
 int widthEstimate(int codePoint, int fontSize)
          Returns the estimated width of a Unicode character for this font, at a specified point size.
 

Method Detail

getAscender

int getAscender(int fontSize)
Returns the Ascender value for this font, scaled to a specific point size.

Parameters:
fontSize - The font size, in millipoints.
Returns:
The Ascender value, in millipoints.

getDescender

int getDescender(int fontSize)
Returns the Descender value for this font, scaled to a specific point size.

Parameters:
fontSize - The font size, in millipoints.
Returns:
The Descender value, in millipoints.

getCapHeight

int getCapHeight(int fontSize)
Returns the CapHeight value for this font, scaled to a specific point size.

Parameters:
fontSize - The font size, in millipoints.
Returns:
The CapHeight value, in millipoints.

getXHeight

int getXHeight(int fontSize)
Returns the XHeight value for this font, scaled to a specific point size.

Parameters:
fontSize - The font size, in millipoints.
Returns:
The XHeight value, in millipoints.

width

int width(int codePoint,
          int fontSize)
Returns the width of a Unicode character for this font, at a specified point size.

Parameters:
codePoint - The Unicode character for which the width should be returned.
fontSize - The size, in millipoints, of the font.
Returns:
The width, in millipoints, of the glyph in this font for codePoint, or Integer.MIN_VALUE if such a glyph is not found.

width

int width(java.lang.CharSequence chars,
          int fontSize,
          int letterSpacing,
          int wordSpacing)
Calculates the width of a given String, considering letter spacing, word spacing, and kerning.

Parameters:
chars - The String whose width should be computed.
fontSize - The size, in millipoints, of the font.
letterSpacing - The size, in millipoints, of any letter-spacing.
wordSpacing - The size, in millipoints, of any word-spacing.
Returns:
The width, in millipoints, of string. Letter-spacing and kerning are added between characters in string, but are not added either before or after. (Adding letter-spacing or kerning before or after would require making assumptions about the context of string, including whether it is at the beginning or end of the line, what fonts surround it, etc.) Word-spacing is added only to space characters (0x20). Any other whitespace characters that the client applications wishes to have considered as word-spacing must first be normalized to 0x20. If there is no glyph for a character in string , the width returned will be that of the "missing glyph".

widthEstimate

int widthEstimate(int codePoint,
                  int fontSize)
Returns the estimated width of a Unicode character for this font, at a specified point size. This method is implementation-dependent. It may attempt to estimate the size of characters such as hair spaces and em quads, which may not be available in the font, but which can be simulated in output if the size is known. Presumably, this method should be used only after width(int, int) has indicated that the font cannot return a true width.

Parameters:
codePoint - The Unicode character for which the width should be returned.
fontSize - The size, in millipoints, of the font.
Returns:
The width, in millipoints, of the estimated size of this glyph in this font for codePoint, or Integer.MIN_VALUE if the implementation cannot estimate such a width.

isEmbeddable

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

Returns:
True if this font can be embedded.

isSubsettable

boolean isSubsettable()
Tells the client application whether a subset of this font can be embedded.

Returns:
True if a subset of this font can be embedded.

getAwtFont

java.awt.Font getAwtFont(int fontSize)
If this Font has a java.awt.Font associated with it, return it.

Parameters:
fontSize - The font size, in millipoints.
Returns:
The related Font instance, if there is one, otherwise null.

usableInPostScriptOutput

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

Returns:
True if this font can be referenced within a PostScript file.

getFamilyName

java.lang.String getFamilyName()
Returns this font's font-family name. For example, a font named "Bitstream Charter Italic" in font-family "Bitstream Charter", with PostScript name "CharterBT-Italic", should return "Bitstream Charter".

Returns:
This font's font-family name.
See Also:
getFontName(), getPostscriptName()

getFontName

java.lang.String getFontName()
Returns this font's name. For example, a font named "Bitstream Charter Italic" in font-family "Bitstream Charter", with PostScript name "CharterBT-Italic", should return "Bitstream Charter Italic".

Returns:
This font's name.
See Also:
getFamilyName(), getPostscriptName()

getPostscriptName

java.lang.String getPostscriptName()
Returns the PostScript name of the font. For example, a font named "Bitstream Charter Italic" in font-family "Bitstream Charter", with PostScript name "CharterBT-Italic", should return "CharterBT-Italic".

Returns:
The PostScript name of the font.
See Also:
getFamilyName(), getFontName()

getInternalEncoding

Encoding getInternalEncoding()
Get the font's internal Encoding scheme. Note that this may be different from the Encoding scheme actually used to encode characters by the font.

Returns:
The font's internal Encoding scheme.
See Also:
FontUse.getEncoding()

getFontComplexity

Font.Complexity getFontComplexity()
Returns a value indicating whether this font is a simple or composite font.

Returns:
One of Font.Complexity.SIMPLE, or Font.Complexity.COMPOSITE.

getFontFormat

Font.Format getFontFormat()
Returns a value indicating what format (e.g. Type1, TrueType) this font is.

Returns:
One of Font.Format.TYPE1, or Font.Format.TRUETYPE.

kern

int kern(int char1,
         int char2)
Computes the kerning needed between two glyphs in this font.

Parameters:
char1 - The Unicode code point of the first (left in a left-to-right system) character.
char2 - The Unicode code point of the second (right in left-to-right system) character.
Returns:
The distance in 1/1000ths of a text space unit of the kerning. A positive amount means that the characters should be moved farther apart, and a negative amount means that they should be moved closer together.

getItalicAngle

float getItalicAngle()
Returns the ItalicAngle value for this font.

Returns:
The ItalicAngle value, expressed in degrees counterclockwise from vertical.

getStemV

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.

Returns:
The StemV value, in 1/1000ths of a text space unit.

getDefaultWidth

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

Returns:
The default glyph width for this font, expressed in 1/1000ths of a text space unit.

isPdfStandardFont

boolean isPdfStandardFont()
Indicates whether this font is one of the PDF Base-14 fonts.

Returns:
True if this font is one of the PDF Base-14 fonts.

normalLineHeightFactor

float normalLineHeightFactor(Font.LineHeightAlgorithm algorithm)

Returns a factor suitable for computing a "normal" line-height as defined in the CSS and XSL-FO standards. The line-height is the distance, including leading, between the baselines of stacked lines of text. The CSS and XSL-FO standards recommend that the "normal" value for line-height fall between 1.0 and 1.2. (see Section 7.15.4 of XSL-FO 1.0) This method attempts to find a suitable value based on the characteristics of the font itself.

Design Note 1: This method returns a float factor instead of a computation of the actual line-height to facilitate the handling of inheritance where that is required. For example, for CSS and XSL-FO, the factor is what is inherited instead of the computed line-height.

Parameters:
algorithm - The specifier of an algorithm that should be used to compute the factor. Valid values include Font.LineHeightAlgorithm.DEFAULT, which puts the implementation in complete control of the computation. Other algorithms may be added in the future.
Returns:
The factor to be applied to the font-size to compute the "normal" line-height. For example, if the font-size is 12 points, and this method returns 1.2, the computed "normal" line-height is 14.4 points.

baselineOffset

int baselineOffset(AbsoluteAxis writingMode,
                   Baseline baselineType,
                   int fontSize)
Returns the location of the specified baseline. For fonts with explicit baseline data, returns that value. For other fonts, estimates the value.

Parameters:
writingMode - Constant indicating the direction in which the script is being written. Valid values are AbsoluteAxis.HORIZONTAL and AbsoluteAxis.VERTICAL.
baselineType - Constant indicating which baseline is sought. Valid values are Baseline.ALPHABETIC, Baseline.IDEOGRAPHIC, Baseline.HANGING, Baseline.MATHEMATICAL, Baseline.CENTRAL, Baseline.MIDDLE, Baseline.TEXT_BEFORE_EDGE, and Baseline.TEXT_AFTER_EDGE.
fontSize - The size, in millipoints, at which the font is scaled.
Returns:
The distance, in millipoints, from the leading edge of the em-box, at which the specified baseline is located.

baseline

Baseline baseline(Iso15924 script)
Determines which baseline should be used by this font for a specified script.

Parameters:
script - The ISO 15924 script name for which a baseline is sought.
Returns:
One of Baseline.ALPHABETIC, Baseline.IDEOGRAPHIC, Baseline.HANGING, Baseline.MATHEMATICAL, Baseline.CENTRAL, Baseline.MIDDLE, Baseline.TEXT_BEFORE_EDGE, and Baseline.TEXT_AFTER_EDGE.

subscriptShift

int subscriptShift(int fontSize)
The amount by which the alphabetic baseline should be shifted when writing subscripts for this font. If the font does not contain such a value, a reasonable estimate is provided.

Parameters:
fontSize - The size, in millipoints, at which the font is scaled.
Returns:
The distance, in millipoints, by which the alphabetic baseline should be shifted when writing subscripts. A positive value shifts the baseline up, and a negative value shifts it down. Since subscripts are normally below the alphabetic baseline, the expected value is negative.

superscriptShift

int superscriptShift(int fontSize)
The amount by which the alphabetic baseline should be shifted when writing superscripts for this font. If the font does not contain such a value, a reasonable estimate is provided.

Parameters:
fontSize - The size, in millipoints, at which the font is scaled.
Returns:
The distance, in millipoints, by which the alphabetic baseline should be shifted when writing superscripts. A positive value shifts the baseline up, and a negative value shifts it down. Since superscripts are normally above the alphabetic baseline, the expected value is positive.

underlineSize

int underlineSize(int fontSize)
The recommended thickness, in millipoints, of the underline stroke for this font. If the font does not contain such a value, a reasonable estimate is provided.

Parameters:
fontSize - The font size for which the underline thickness should be computed.
Returns:
The underline thickness, in millipoints.

underlinePosition

int underlinePosition(int fontSize)
The recommended position of the top of the underline stroke, relative to the baseline, in millipoints. Positive values represent distances above the baseline, while negative values represent distances below the baseline. If the font does not contain such a value, a reasonable estimate is provided.

Parameters:
fontSize - The font size for which the underline position should be computed.
Returns:
The underline position, in millipoints.

overlineSize

int overlineSize(int fontSize)
The recommended thickness, in millipoints, of the overline stroke for this font. If the font does not contain such a value, a reasonable estimate is provided.

Parameters:
fontSize - The font size for which the overline thickness should be computed.
Returns:
The overline thickness, in millipoints.

overlinePosition

int overlinePosition(int fontSize)
The recommended position of the bottom of the overline stroke, relative to the baseline, in millipoints. Positive values represent distances above the baseline, while negative values represent distances below the baseline. If the font does not contain such a value, a reasonable estimate is provided.

Parameters:
fontSize - The font size for which the overline position should be computed.
Returns:
The overline position, in millipoints.

strikeoutSize

int strikeoutSize(int fontSize)
The recommended thickness, in millipoints, of the strikeout stroke for this font. If the font does not contain such a value, a reasonable estimate is provided.

Parameters:
fontSize - The font size for which the strikeout thickness should be computed.
Returns:
The strikout thickness, in millipoints.

strikeoutPosition

int strikeoutPosition(int fontSize)
The recommended position of the top of the strikeout stroke, relative to the baseline, in millipoints. Positive values represent distances above the baseline, while negative values represent distances below the baseline. If the font does not contain such a value, a reasonable estimate is provided.

Parameters:
fontSize - The font size for which the strikeout position should be computed.
Returns:
The strikeout position, in millipoints.

getPanose

byte[] getPanose()
Returns the Panose array for this font. This is typically a 10-element array.

Returns:
The Panose array for this font, or null if the array is not known.
See Also:
"http://www.w3.org/Printing/stevahn.html#references"

SourceForge.net Logo
aXSL API 0.2

This documentation was created August 8 2007 by The aXSL Group and may be freely copied. See license for details.