Class FontFile

java.lang.Object
com.mta.tehreer.font.FontFile

public final class FontFile extends Object
A FontFile object represents the file of a specific font format.
  • Constructor Details

    • FontFile

      public FontFile(@NonNull AssetManager assetManager, @NonNull String filePath)
      Constructs a font file instance representing the specified asset. The data of the asset is not copied to an in-memory buffer. Rather, it is directly read from a stream of the asset when needed. So the typefaces obtained from resulting font file might be slower and should be used with caution.
      Parameters:
      assetManager - The application's asset manager.
      filePath - The path of the font in the assets directory.
      Throws:
      NullPointerException - if assetManager or filePath is null.
      RuntimeException - if an error occurred while initialization.
    • FontFile

      public FontFile(@NonNull File file)
      Constructs a font file instance representing the specified file path. The data of the font is directly read from a stream of the file when needed.
      Parameters:
      file - The file describing the path of the font.
      Throws:
      NullPointerException - if file is null.
      RuntimeException - if an error occurred while initialization.
    • FontFile

      public FontFile(@NonNull InputStream stream)
      Constructs a font file instance from the specified input stream by copying its data into a native memory buffer. It may take time to create the instance if the stream holds larger data.
      Parameters:
      stream - The input stream that contains the data of the font.
      Throws:
      NullPointerException - if stream is null.
      RuntimeException - if an error occurred while initialization.
  • Method Details

    • getTypefaces

      public List<Typeface> getTypefaces()
      Returns named typefaces of this font file.
      Returns:
      Named typefaces of this font file.