Class FontUtils

java.lang.Object
be.quodlibet.boxable.utils.FontUtils

public final class FontUtils extends Object

Utility methods for fonts

Author:
hstimac, mkuehne
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addDefaultFonts(org.apache.pdfbox.pdmodel.font.PDFont font, org.apache.pdfbox.pdmodel.font.PDFont fontBold, org.apache.pdfbox.pdmodel.font.PDFont fontItalic, org.apache.pdfbox.pdmodel.font.PDFont fontBoldItalic)
     
    static float
    getAscent(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize)
    Calculate the font ascent distance.
    static Map<String,org.apache.pdfbox.pdmodel.font.PDFont>
     
    static float
    getDescent(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize)
    Calculate the font descent distance.
    static float
    getHeight(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize)
    Calculate the font height.
    static float
    getStringWidth(org.apache.pdfbox.pdmodel.font.PDFont font, String text, float fontSize)
    Retrieving String width depending on current font size.
    static final org.apache.pdfbox.pdmodel.font.PDType0Font
    loadFont(org.apache.pdfbox.pdmodel.PDDocument document, String fontPath)
    Loads the PDType0Font to be embedded in the specified PDDocument.
    static void
    setSansFontsAsDefault(org.apache.pdfbox.pdmodel.PDDocument document)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • loadFont

      public static final org.apache.pdfbox.pdmodel.font.PDType0Font loadFont(org.apache.pdfbox.pdmodel.PDDocument document, String fontPath)

      Loads the PDType0Font to be embedded in the specified PDDocument.

      Parameters:
      document - PDDocument where fonts will be loaded
      fontPath - font path which will be loaded
      Returns:
      The read PDType0Font
    • getStringWidth

      public static float getStringWidth(org.apache.pdfbox.pdmodel.font.PDFont font, String text, float fontSize)

      Retrieving String width depending on current font size. The width of the string in 1/1000 units of text space.

      Parameters:
      font - The font of text whose width will be retrieved
      text - The text whose width will be retrieved
      fontSize - The font size of text whose width will be retrieved
      Returns:
      text width
    • getAscent

      public static float getAscent(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize)

      Calculate the font ascent distance.

      Parameters:
      font - The font from which calculation will be applied
      fontSize - The font size from which calculation will be applied
      Returns:
      Positive font ascent distance
    • getDescent

      public static float getDescent(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize)

      Calculate the font descent distance.

      Parameters:
      font - The font from which calculation will be applied
      fontSize - The font size from which calculation will be applied
      Returns:
      Negative font descent distance
    • getHeight

      public static float getHeight(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize)

      Calculate the font height.

      Parameters:
      font - PDFont from which the height will be calculated.
      fontSize - font size for current PDFont.
      Returns:
      PDFont's height
    • addDefaultFonts

      public static void addDefaultFonts(org.apache.pdfbox.pdmodel.font.PDFont font, org.apache.pdfbox.pdmodel.font.PDFont fontBold, org.apache.pdfbox.pdmodel.font.PDFont fontItalic, org.apache.pdfbox.pdmodel.font.PDFont fontBoldItalic)
    • getDefaultfonts

      public static Map<String,org.apache.pdfbox.pdmodel.font.PDFont> getDefaultfonts()
    • setSansFontsAsDefault

      public static void setSansFontsAsDefault(org.apache.pdfbox.pdmodel.PDDocument document)