org.apache.batik.bridge

Class SVGGVTFont

public final class SVGGVTFont extends Object implements GVTFont, SVGConstants

Represents an SVG font.
Field Summary
static AttributePAINT_INFO
Constructor Summary
SVGGVTFont(float fontSize, GVTFontFace fontFace, String[] glyphUnicodes, String[] glyphNames, String[] glyphLangs, String[] glyphOrientations, String[] glyphForms, BridgeContext ctx, Element[] glyphElements, Element missingGlyphElement, Element[] hkernElements, Element[] vkernElements, Element textElement)
Constructs a new SVGGVTFont of the specified size.
Method Summary
booleancanDisplay(char c)
Indicates whether or not the specified character can be displayed by this font.
booleancanDisplayGivenName(String name)
Indicates whether or not the specified glyph can be displayed by this font.
intcanDisplayUpTo(char[] text, int start, int limit)
Checks whether this Font can display the characters in the specified character array starting at start and ending at limit.
intcanDisplayUpTo(CharacterIterator iter, int start, int limit)
Checks whether this Font can display the characters in the specified character iterator starting at start and ending at limit.
intcanDisplayUpTo(String str)
Checks whether or not this font can display the characters in the specified String.
GVTGlyphVectorcreateGlyphVector(FontRenderContext frc, char[] chars)
Returns a new GVTGlyphVector object for the specified array of characters.
GVTGlyphVectorcreateGlyphVector(FontRenderContext frc, CharacterIterator ci)
Returns a new GVTGlyphVector object for the characters in the specified character iterator.
GVTGlyphVectorcreateGlyphVector(FontRenderContext frc, int[] glyphCodes, CharacterIterator ci)
Returns a new GVTGlyphVector object for the glyphs in the the glyph code array.
GVTGlyphVectorcreateGlyphVector(FontRenderContext frc, String str)
Returns a new GVTGlyphVector object for the specified String.
GVTFontderiveFont(float size)
Creates a new GVTFont object by replicating this font object and applying a new size to it.
StringgetFamilyName()
int[]getGlyphCodesForName(String name)
Returns an array of glyph codes (unique ids) of the glyphs with the specified name (there may be more than one).
int[]getGlyphCodesForUnicode(String unicode)
Returns an array of glyph codes (unique ids) of the glyphs with the specified unicode value (there may be more than one).
floatgetHKern(int glyphCode1, int glyphCode2)
Returns the horizontal kerning value for the specified glyph pair.
protected GVTLineMetricsgetLineMetrics(int beginIndex, int limit)
GVTLineMetricsgetLineMetrics(char[] chars, int beginIndex, int limit, FontRenderContext frc)
Returns the line metrics for the specified text.
GVTLineMetricsgetLineMetrics(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc)
Returns the line metrics for the specified text.
GVTLineMetricsgetLineMetrics(String str, FontRenderContext frc)
Returns the line metrics for the specified text.
GVTLineMetricsgetLineMetrics(String str, int beginIndex, int limit, FontRenderContext frc)
Returns the line metrics for the specified text.
floatgetSize()
Returns the size of this font.
floatgetVKern(int glyphCode1, int glyphCode2)
Returns the vertical kerning value for the specified glyph pair.
StringtoString()
Returns a string representation of this font.

Field Detail

PAINT_INFO

public static final Attribute PAINT_INFO

Constructor Detail

SVGGVTFont

public SVGGVTFont(float fontSize, GVTFontFace fontFace, String[] glyphUnicodes, String[] glyphNames, String[] glyphLangs, String[] glyphOrientations, String[] glyphForms, BridgeContext ctx, Element[] glyphElements, Element missingGlyphElement, Element[] hkernElements, Element[] vkernElements, Element textElement)
Constructs a new SVGGVTFont of the specified size.

Parameters: fontSize The size of the font to create. fontFace The font face that describes the font. glyphUnicodes An array containing the unicode values for all the glyphs this font can display. glyphNames An array containing the names of all the glyphs this font can display. ctx The bridge context. glyphElements An array containing the children glyph elements of the SVG font. missingGlyphElement The missing glyph element for this font. hkernElements An array containing all hkern elements for this font. vkernElements An array containing all vkern elements for this font. textElement The text element that contains the text to be rendered using this font.

Method Detail

canDisplay

public boolean canDisplay(char c)
Indicates whether or not the specified character can be displayed by this font.

Parameters: c The character to check.

Returns: true if the character can be displayed.

canDisplayGivenName

public boolean canDisplayGivenName(String name)
Indicates whether or not the specified glyph can be displayed by this font.

Parameters: name The name of the glyph to check.

Returns: true if the glyph can be displayed.

canDisplayUpTo

public int canDisplayUpTo(char[] text, int start, int limit)
Checks whether this Font can display the characters in the specified character array starting at start and ending at limit.

Parameters: text An array containing the characters to check. start The index of the first character to check. limit The index of the last character to check.

Returns: The index of the first character it can't display or -1 if it can display the whole string.

canDisplayUpTo

public int canDisplayUpTo(CharacterIterator iter, int start, int limit)
Checks whether this Font can display the characters in the specified character iterator starting at start and ending at limit.

Parameters: iter The iterator containing the characters to check. start The index of the first character to check. limit The index of the last character to check.

Returns: The index of the first character it can't display or -1 if it can display the whole string.

canDisplayUpTo

public int canDisplayUpTo(String str)
Checks whether or not this font can display the characters in the specified String.

Parameters: str The string containing the characters to check.

Returns: The index of the first character it can't display or -1 if it can display the whole string.

createGlyphVector

public GVTGlyphVector createGlyphVector(FontRenderContext frc, char[] chars)
Returns a new GVTGlyphVector object for the specified array of characters.

Parameters: frc The current font render context. chars The array of chars that the glyph vector will represent.

Returns: The new glyph vector.

createGlyphVector

public GVTGlyphVector createGlyphVector(FontRenderContext frc, CharacterIterator ci)
Returns a new GVTGlyphVector object for the characters in the specified character iterator.

Parameters: frc The current font render context. ci The character iterator that the glyph vector will represent.

Returns: The new glyph vector.

createGlyphVector

public GVTGlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes, CharacterIterator ci)
Returns a new GVTGlyphVector object for the glyphs in the the glyph code array.

Parameters: frc The current font render context. glyphCodes An array containin the ids of the glyphs that the glyph vector will represent.

Returns: The new glyph vector.

createGlyphVector

public GVTGlyphVector createGlyphVector(FontRenderContext frc, String str)
Returns a new GVTGlyphVector object for the specified String.

Parameters: frc The current font render context. str The string that the glyph vector will represent.

Returns: The new glyph vector.

deriveFont

public GVTFont deriveFont(float size)
Creates a new GVTFont object by replicating this font object and applying a new size to it.

Parameters: size The size of the new font.

Returns: The new font object.

getFamilyName

public String getFamilyName()

getGlyphCodesForName

public int[] getGlyphCodesForName(String name)
Returns an array of glyph codes (unique ids) of the glyphs with the specified name (there may be more than one).

Parameters: name The name of the glyph.

Returns: An array of matching glyph codes. This may be empty.

getGlyphCodesForUnicode

public int[] getGlyphCodesForUnicode(String unicode)
Returns an array of glyph codes (unique ids) of the glyphs with the specified unicode value (there may be more than one).

Parameters: unicode The unicode value of the glyph.

Returns: An array of matching glyph codes. This may be empty.

getHKern

public float getHKern(int glyphCode1, int glyphCode2)
Returns the horizontal kerning value for the specified glyph pair. This will be zero if there is no explicit horizontal kerning value for this particular glyph pair.

Parameters: glyphCode1 The id of the first glyph. glyphCode2 The id of the second glyph.

Returns: The horizontal kerning value.

getLineMetrics

protected GVTLineMetrics getLineMetrics(int beginIndex, int limit)

getLineMetrics

public GVTLineMetrics getLineMetrics(char[] chars, int beginIndex, int limit, FontRenderContext frc)
Returns the line metrics for the specified text.

Parameters: chars The character array containing the text. beginIndex The index of the first character. limit The limit of characters. frc The current font render context.

Returns: The new GVTLineMetrics object.

getLineMetrics

public GVTLineMetrics getLineMetrics(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc)
Returns the line metrics for the specified text.

Parameters: ci The character iterator containing the text. beginIndex The index of the first character. limit The limit of characters. frc The current font render context.

Returns: The new GVTLineMetrics object.

getLineMetrics

public GVTLineMetrics getLineMetrics(String str, FontRenderContext frc)
Returns the line metrics for the specified text.

Parameters: str The string containing the text. frc The current font render context.

Returns: The new GVTLineMetrics object.

getLineMetrics

public GVTLineMetrics getLineMetrics(String str, int beginIndex, int limit, FontRenderContext frc)
Returns the line metrics for the specified text.

Parameters: str The string containing the text. beginIndex The index of the first character. limit The limit of characters. frc The current font render context.

Returns: The new GVTLineMetrics object.

getSize

public float getSize()
Returns the size of this font.

Returns: The font size.

getVKern

public float getVKern(int glyphCode1, int glyphCode2)
Returns the vertical kerning value for the specified glyph pair. This will be zero if there is no explicit vertical kerning value for for this particular glyph pair.

Parameters: glyphCode1 The id of the first glyph. glyphCode2 The id of the second glyph.

Returns: The vertical kerning value.

toString

public String toString()
Returns a string representation of this font. This is for debugging purposes only.

Returns: A string representation of this font.

Copyright B) 2008 Apache Software Foundation. All Rights Reserved.