FontSelector (Apache FOP Core 2.11 API)
Date: 2025-04-24

org.apache.fop.fonts

## Class FontSelector

- java.lang.Object
- - org.apache.fop.fonts.FontSelector

-     public final class FontSelector
      extends Object

  Helper class for automatic font selection.

  TODO: Check if this could be merged with another font class, such as `FontManager`.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Font` | `selectFontForCharacter(Character fobj, PercentBaseContext context)` Selects a font which is able to display the given character.
    `static Font` | `selectFontForCharacterInText(char c, FOText text, PercentBaseContext context)` Selects a font which is able to display the given character.
    `static Font` | `selectFontForCharactersInText(CharSequence charSeq, int firstIndex, int breakIndex, FOText text, PercentBaseContext context)` Selects a font which is able to display the most of the given characters.

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

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

- - ### Method Detail

    - #### selectFontForCharacter

          public static Font selectFontForCharacter(Character fobj,
                                                    PercentBaseContext context)

      Selects a font which is able to display the given character.
      Parameters:
        `fobj` - a Character object containing the character and its attributes.
        `context` - the Percent-based context needed for creating the actual font.
      Returns:
        a Font object.

    - #### selectFontForCharacterInText

          public static Font selectFontForCharacterInText(char c,
                                                          FOText text,
                                                          PercentBaseContext context)

      Selects a font which is able to display the given character.
      Parameters:
        `c` - character to find.
        `text` - the text object which contains the character
        `context` - the Percent-based context needed for creating the actual font.
      Returns:
        a Font object.

    - #### selectFontForCharactersInText

          public static Font selectFontForCharactersInText(CharSequence charSeq,
                                                           int firstIndex,
                                                           int breakIndex,
                                                           FOText text,
                                                           PercentBaseContext context)

      Selects a font which is able to display the most of the given characters.
      Parameters:
        `charSeq` - Text to go through
        `firstIndex` - first index within text.
        `breakIndex` - last index +1 within text.
        `text` - the text object which contains the character
        `context` - the Percent-based context needed for creating the actual font.
      Returns:
        a Font object.

Copyright © 2025 Apache Software Foundation. All rights reserved.