toApiFilenamePart method

String toApiFilenamePart()
inherited

Converts this GoogleFontsVariant to a Google Fonts API specific filename part.

A Filename part is the part of the filename that does not include the font family. For example: for the filename "Lato-Regular.ttf", the filename part is "Regular".

The following table shows how these GoogleFontsVariants convert: weight: 400, style: normal -> 'Regular' weight: 400, style: italic -> 'Italic' weight: 700, style: normal -> 'Bold' weight: 700, style: italic -> 'BoldItalic'

See GoogleFontsVariant.fromApiFilenamePart for the inverse function.

Implementation

String toApiFilenamePart() {
  final weightPrefix = _fontWeightToFilenameWeightParts[fontWeight] ??
      _fontWeightToFilenameWeightParts[FontWeight.w400]!;
  final italicSuffix = fontStyle == FontStyle.italic ? 'Italic' : '';
  if (weightPrefix == 'Regular') {
    return italicSuffix == '' ? weightPrefix : italicSuffix;
  }
  return '$weightPrefix$italicSuffix';
}