Interface CharacterInfo

All Known Implementing Classes:
DefaultCharacter, SmallCaps

public interface CharacterInfo
Represents information about a character including its visual width.

This interface provides methods to retrieve the character itself and its associated length (which might be used for formatting or layout purposes).

Additionally, it offers a method to calculate the "bold" length, which takes into account an extra width for non-space characters.
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    Calculates the bold length of the character.
    char
    Retrieves the character represented by this instance.
    int
    Retrieves the base length associated with this character.
    of(char c, int i)
    Creates a new CharacterInfo instance with the specified character and length.
  • Method Details

    • getCharacter

      char getCharacter()
      Retrieves the character represented by this instance.
      Returns:
      the character
    • getLength

      int getLength()
      Retrieves the base length associated with this character.

      The length can be interpreted as the visual or logical width of the character.

      Returns:
      the length of the character
    • getBoldLength

      default int getBoldLength()
      Calculates the bold length of the character.

      This is computed as the base length plus an extra unit of length for non-space characters. For space characters, the bold length is equal to the base length.

      Returns:
      the bold length of the character
    • of

      static CharacterInfo of(char c, int i)
      Creates a new CharacterInfo instance with the specified character and length.

      This factory method provides a convenient way to obtain a CharacterInfo implementation without needing to explicitly create a new class.

      Parameters:
      c - the character
      i - the base length of the character
      Returns:
      a new CharacterInfo instance