Class SizedFont

java.lang.Object
com.teamten.font.SizedFont

public class SizedFont extends Object
The combination of a font and a size. Provides some Font-like methods that omit the font size, since it's already part of this object's state.
  • Constructor Details

    • SizedFont

      public SizedFont(Font font, double size)
  • Method Details

    • getFont

      public Font getFont()
      The font.
    • getSize

      public double getSize()
      The size in points.
    • withFont

      public SizedFont withFont(Font font)
      Create a new object, replacing the font.
    • withScaledSize

      public SizedFont withScaledSize(double scale)
      Create a new object, scaling the size.
    • getKerning

      public long getKerning(int leftChar, int rightChar)
      Get the kerning between the two code points. The result is in scaled points.
    • transformLigatures

      public String transformLigatures(String text)
      Replaces all ligatures (supported by this font) in the string.
    • getSpaceWidth

      public long getSpaceWidth()
      The width of a space in scaled points.
    • getCharacterMetrics

      public Font.Metrics getCharacterMetrics(int ch)
      Return the size of a code point in the specified font size.
    • draw

      public void draw(String text, long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) throws IOException
      Draw the text.
      Parameters:
      text - the text to draw.
      x - the left-hand edge of the text in scaled points.
      y - the baseline of the text in scaled points.
      contents - the stream to write to.
      Throws:
      IOException
    • getStringMetrics

      public Font.Metrics getStringMetrics(String text)
      Get the size of the text in the specified font size. Does not include kerning.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object