Class SVGGVTFont

java.lang.Object
org.apache.batik.bridge.SVGGVTFont
All Implemented Interfaces:
XMLConstants, GVTFont, CSSConstants, SVGConstants

public final class SVGGVTFont extends Object implements GVTFont, SVGConstants
Represents an SVG font.
  • Field Details

  • Constructor Details

    • 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 Details

    • 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.
      Specified by:
      getHKern in interface GVTFont
      Parameters:
      glyphCode1 - The id of the first glyph.
      glyphCode2 - The id of the second glyph.
      Returns:
      The horizontal kerning value.
    • 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.
      Specified by:
      getVKern in interface GVTFont
      Parameters:
      glyphCode1 - The id of the first glyph.
      glyphCode2 - The id of the second glyph.
      Returns:
      The vertical kerning value.
    • 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.
    • 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.
    • canDisplay

      public boolean canDisplay(char c)
      Indicates whether or not the specified character can be displayed by this font.
      Specified by:
      canDisplay in interface GVTFont
      Parameters:
      c - The character to check.
      Returns:
      true if the character 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.
      Specified by:
      canDisplayUpTo in interface GVTFont
      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.
      Specified by:
      canDisplayUpTo in interface GVTFont
      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.
      Specified by:
      canDisplayUpTo in interface GVTFont
      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.
      Specified by:
      createGlyphVector in interface GVTFont
      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.
      Specified by:
      createGlyphVector in interface GVTFont
      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.
      Specified by:
      createGlyphVector in interface GVTFont
      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.
      Specified by:
      createGlyphVector in interface GVTFont
      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.
      Specified by:
      deriveFont in interface GVTFont
      Parameters:
      size - The size of the new font.
      Returns:
      The new font object.
    • getFamilyName

      public String getFamilyName()
      Description copied from interface: GVTFont
      Returns the font family name of this font.
      Specified by:
      getFamilyName in interface GVTFont
    • 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.
      Specified by:
      getLineMetrics in interface GVTFont
      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.
      Specified by:
      getLineMetrics in interface GVTFont
      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.
      Specified by:
      getLineMetrics in interface GVTFont
      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.
      Specified by:
      getLineMetrics in interface GVTFont
      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.
      Specified by:
      getSize in interface GVTFont
      Returns:
      The font size.
    • toString

      public String toString()
      Returns a string representation of this font. This is for debugging purposes only.
      Specified by:
      toString in interface GVTFont
      Overrides:
      toString in class Object
      Returns:
      A string representation of this font.