org.apache.fop.afp.fonts

## Class AFPFont

- java.lang.Object
- - org.apache.fop.fonts.Typeface
  - - org.apache.fop.afp.fonts.AFPFont

- All Implemented Interfaces:
    FontMetrics
  Direct Known Subclasses:
    AbstractOutlineFont, RasterFont

      public abstract class AFPFont
      extends Typeface

  All implementations of AFP fonts should extend this base class, the object implements the FontMetrics information.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `name` The font name

    - ### Fields inherited from class org.apache.fop.fonts.Typeface

      `eventListener, NOT_FOUND`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AFPFont(String name, boolean embeddable)` Constructor for the base font requires the name.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract Rectangle` | `getBoundingBox(int glyphIndex, int size)` Returns the bounding box of the glyph at the given index, for the given font size.
    `abstract CharacterSet` | `getCharacterSet(int size)` Returns the character set for a given size
    `String` | `getEmbedFontName()` Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
    `Set<String>` | `getFamilyNames()` Returns the font's family names as a Set of Strings (Example: "Helvetica").
    `String` | `getFontName()` Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").
    `FontType` | `getFontType()` Returns the type of the font.
    `URI` | `getFontURI()` Returns the URI of the font file from which these metrics were loaded.
    `String` | `getFullName()` Returns the font's full name (Example: "Helvetica Bold Oblique").
    `Map<Integer,Map<Integer,Integer>>` | `getKerningInfo()` Returns the kerning map for the font.
    `int` | `getStrikeoutPosition(int size)` Returns the distance from the baseline to the center of the strikeout line (negative value indicates below baseline).
    `int` | `getStrikeoutThickness(int size)` Returns the thickness of the strikeout line.
    `int` | `getUnderlineThickness(int size)` Returns the thickness of the underline.
    `int[]` | `getWidths()` Return the array of widths.
    `boolean` | `hasKerningInfo()` Indicates if the font has kerning information.
    `boolean` | `isEmbeddable()` Indicates if this font may be embedded.
    `String` | `toString()`
    `protected static char` | `toUnicodeCodepoint(int character)` Maps mapped code points to Unicode code points.

    - ### Methods inherited from class org.apache.fop.fonts.Typeface

      `getEncodingName, getMaxAscent, hadMappingOperations, hasChar, hasFeature, isCID, isMultiByte, mapChar, notifyMapOperation, setEventListener, warnMissingGlyph`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.fop.fonts.FontMetrics

      `getAscender, getCapHeight, getDescender, getUnderlinePosition, getWidth, getXHeight`

- - ### Field Detail

    - #### name

          protected final String name

      The font name

  - ### Constructor Detail

    - #### AFPFont

          public AFPFont(String name,
                         boolean embeddable)

      Constructor for the base font requires the name.
      Parameters:
        `name` - the name of the font
        `embeddable` - whether this font is to be embedded

  - ### Method Detail

    - #### getFontURI

          public URI getFontURI()

      Returns the URI of the font file from which these metrics were loaded.
      Returns:
        the font file's URI

    - #### getFontName

          public String getFontName()

      Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").
      Returns:
        the font name

    - #### getEmbedFontName

          public String getEmbedFontName()

      Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
      Returns:
        the name for font embedding

    - #### getFullName

          public String getFullName()

      Returns the font's full name (Example: "Helvetica Bold Oblique").
      Returns:
        the font's full name

    - #### getFamilyNames

          public Set<String> getFamilyNames()

      Returns the font's family names as a Set of Strings (Example: "Helvetica").
      Returns:
        the font's family names (a Set of Strings)

    - #### getFontType

          public FontType getFontType()

      Returns the type of the font.
      Returns:
        the font type

    - #### hasKerningInfo

          public boolean hasKerningInfo()

      Indicates if the font has kerning information.
      Returns:
        True, if kerning is available.

    - #### getKerningInfo

          public Map<Integer,Map<Integer,Integer>> getKerningInfo()

      Returns the kerning map for the font.
      Returns:
        the kerning map

    - #### getCharacterSet

          public abstract CharacterSet getCharacterSet(int size)

      Returns the character set for a given size
      Parameters:
        `size` - the font size
      Returns:
        the character set object

    - #### isEmbeddable

          public boolean isEmbeddable()

      Indicates if this font may be embedded.
      Returns:
        True, if embedding is possible/permitted

    - #### toUnicodeCodepoint

          protected static final char toUnicodeCodepoint(int character)

      Maps mapped code points to Unicode code points.
      Parameters:
        `character` - the mapped code point
      Returns:
        the corresponding Unicode code point

    - #### getUnderlineThickness

          public int getUnderlineThickness(int size)

      Returns the thickness of the underline.
      Parameters:
        `size` - font size
      Returns:
        the thickness in 1/1000ths of the font size

    - #### getStrikeoutPosition

          public int getStrikeoutPosition(int size)

      Returns the distance from the baseline to the center of the strikeout line (negative value indicates below baseline).
      Parameters:
        `size` - font size
      Returns:
        the position in 1/1000ths of the font size

    - #### getStrikeoutThickness

          public int getStrikeoutThickness(int size)

      Returns the thickness of the strikeout line.
      Parameters:
        `size` - font size
      Returns:
        the thickness in 1/1000ths of the font size

    - #### getBoundingBox

          public abstract Rectangle getBoundingBox(int glyphIndex,
                                                   int size)

      Returns the bounding box of the glyph at the given index, for the given font size.
      Parameters:
        `glyphIndex` - glyph index
        `size` - font size
      Returns:
        the scaled bounding box scaled in 1/1000ths of the given size

    - #### getWidths

          public int[] getWidths()

      Return the array of widths.

      This is used to get an array for inserting in an output format. It should not be used for lookup.

      Returns:
        an array of widths

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Typeface`

Copyright © 2025 Apache Software Foundation. All rights reserved.