resolveFont method

Future<Font> resolveFont(
  1. String font,
  2. FontData fontData
)

Implementation

Future<pw.Font> resolveFont(String font, FontData fontData) async {
  switch (font) {
    case 'Courier':
      return pw.Font.courier();
    case 'Helvetica':
      return pw.Font.helvetica();
    case 'Times':
      return pw.Font.times();
    case 'ZapfDingbats':
      return pw.Font.zapfDingbats();
    case 'Symbol':
      return pw.Font.symbol();
    default:
      if (!fontData.ttfFonts.containsKey(font)) {
        throw Exception('Unsupported Font: $font');
      }
      return await resolveCustomFont(
          fontData.ttfFonts[font]!, fontData.assetBundle);
  }
}