Package 

Object FontHelper.Companion

    • Method Detail

      • getSystemFonts

        @Deprecated(message = Use getSystemFontList() instead. Map approach can lose unnamed families with colliding first font names., replaceWith = @ReplaceWith(imports = {}, expression = getSystemFontList()), level = DeprecationLevel.WARNING) final Map<String, Fonts.Family> getSystemFonts()

        Retrieves a map of all system fonts available.

        DEPRECATED: Use getSystemFontList instead for more reliable handling of unnamed font families. This method can lose data when multiple unnamed families have fonts with the same filename as their first font.

        This function attempts to find a valid XML configuration file from a set of possible paths and parses it to a map of font families.

      • getSystemFontList

         final List<Fonts.Family> getSystemFontList()

        Retrieves a list of all system fonts available.

        This is the preferred method for accessing system fonts as it preserves all font families, including multiple unnamed families that might have the same first font filename. The Map-based approach (getSystemFonts) can lose data due to key collisions in such cases.

      • getFallbackFont

         final Fonts.Font getFallbackFont(Fonts.FontOpts opts)

        Retrieves a fallback font based on optional font preferences.

        This function searches through the system's available fonts and selects a font that matches the provided options. If no options are provided, it uses the default settings (i.e. Fonts.FontOpts.DEFAULT)

        Parameters:
        opts - Optional Fonts.FontOpts specifying the desired font characteristics.
      • getFallbackFonts

         final List<Fonts.Font> getFallbackFonts(Fonts.FontOpts opts)

        Retrieves a list of fallback fonts based on optional font preferences.

        This function searches through the system's available fonts and returns a list of fonts that match the provided options, ordered by priority with named fonts first, followed by unnamed fallback fonts.

        Parameters:
        opts - Optional Fonts.FontOpts specifying the desired font characteristics.
      • getFontFile

         final File getFontFile(Fonts.Font font)

        Retrieves the file for a specified font from the system's font paths.

        Searches through predefined system font paths to find the file corresponding to the specified font.

        Parameters:
        font - The Fonts.Font object representing the font whose file is being sought.
      • getFontBytes

         final ByteArray getFontBytes(Fonts.Font font)

        Reads and returns the bytes of a font file for a specified font.

        This function uses getFontFile to find the font file and reads its bytes into a ByteArray.

        Parameters:
        font - The Fonts.Font object representing the font to be read.
      • getFallbackFontBytes

         final ByteArray getFallbackFontBytes(Fonts.FontOpts opts)

        Retrieves the byte array of a fallback font specified by optional font options.

        This function combines the functionality of getFallbackFont and getFontBytes to fetch the bytes of a font that matches the provided options. If no specific options are provided, default settings are used. This is useful when direct byte-level access to a font file is required, such as for sending font data over a network or loading it into a custom rendering system.

        Parameters:
        opts - Optional Fonts.FontOpts specifying the desired font characteristics.