Class FontFamily

java.lang.Object
com.github.tadukoo.view.font.FontFamily
All Implemented Interfaces:
FontConstants

public class FontFamily extends Object implements FontConstants
Represents a single font family. This can be a logical font, a proprietary font for which we have no files (but can specify an alternate), or an open source font where we have the actual files and can specify a local path to them.
Version:
Alpha v.0.2
Author:
Logan Ferree (Tadukoo)
  • Field Details

    • name

      private final String name
      The name of the font
    • directory

      private final String directory
      The font directory - may be null for non-open source fonts
    • files

      private final List<String> files
      The font files (includes all variants, such as bold, italic, etc.) - may be null for non-open source fonts
    • alternate

      private final FontFamily alternate
      The open source alternative font that can be substituted - may be null for open source fonts
  • Constructor Details

    • FontFamily

      FontFamily(String name)
      This constructor is used for the logical fonts provided by Java.
      Parameters:
      name - The name of the logical Font
    • FontFamily

      FontFamily(String name, String directory, List<String> files)
      This constructor is used for open sources fonts included in a project. These fonts can be found in the TadukooFonts project.
      Parameters:
      name - The name of the font
      directory - The font directory
      files - The font files (includes all variants, such as bold, italic, etc.)
    • FontFamily

      FontFamily(String name, FontFamily alternate)
      This constructor is used for proprietary fonts, and provides an open source alternative.
      Parameters:
      name - The name of the font
      alternate - The open source alternative font that can be substituted
  • Method Details

    • stdFileStr

      public static String stdFileStr(String name, String type, String extension)
      Constructs a string in the form {name}-{type}.{extension} (which appears to be a common filename for a lot of fonts - .e.g Arimo-Regular.ttf, Gelasio-Medium.ttf, etc.)
      Parameters:
      name - The name of the font
      type - The type of font (e.g. Regular, Bold, Italic, etc.)
      extension - The extension of the font (e.g. ttf)
      Returns:
      A string of the form {name}-{type}.{extension}
    • makeRegularList

      public static List<String> makeRegularList(String name, String extension)
      Creates a List of font filenames that just contains {name}-Regular.{extension} (a common occurrence).
      Parameters:
      name - The name of the font
      extension - The extension of the font file (e.g. ttf)
      Returns:
      A List containing just {name}-Regular.{extension}
    • makeStandardList

      public static List<String> makeStandardList(String name, String extension)
      Creates a list of font filenames containing the following:
      • {name}-Regular.{extension}
      • {name}-Bold.{extension}
      • {name}-Italic.{extension}
      • {name}-BoldItalic.{extension}
      This appears to be the most common list of filenames for fonts.
      Parameters:
      name - The name of the font
      extension - The extension of the font files (e.g. ttf)
      Returns:
      A List of the 4 standard font filenames
    • makeStandardListWithAdditions

      public static List<String> makeStandardListWithAdditions(String name, String extension, List<String> additions)
      Creates a list of font filenames containing the 4 standard ones (by calling makeStandardList), plus additional ones specified in the format {name}-{addition}.{extension}
      Parameters:
      name - The name of the font
      extension - The extension of the font files (e.g. ttf)
      additions - The additional types to be used (e.g. Medium, Semibold, etc.)
      Returns:
      A List of the standard font filenames plus the additional ones
    • getName

      public String getName()
      Returns:
      The name of the font
    • getDirectory

      public String getDirectory()
      Returns:
      The font directory - may be null for non-open source fonts
    • getFiles

      public List<String> getFiles()
      Returns:
      The font files (includes all variants, such as bold, italic, etc.) - may be null for non-open source fonts
    • getAlternate

      public FontFamily getAlternate()
      Returns:
      The open source alternative font that can be substituted - may be null for open source fonts