buildFont method Null safety

  1. @protected
PdfFont buildFont(
  1. PdfDocument pdfDocument
)

Implementation

@protected
PdfFont buildFont(PdfDocument pdfDocument) {
  return pdfDocument.fonts.firstWhere(
    (PdfFont font) => font.subtype == '/Type1' && font.fontName == fontName,
    orElse: () {
      switch (font) {
        case Type1Fonts.courier:
          return PdfFont.courier(pdfDocument);
        case Type1Fonts.courierBold:
          return PdfFont.courierBold(pdfDocument);
        case Type1Fonts.courierBoldOblique:
          return PdfFont.courierBoldOblique(pdfDocument);
        case Type1Fonts.courierOblique:
          return PdfFont.courierOblique(pdfDocument);
        case Type1Fonts.helvetica:
          return PdfFont.helvetica(pdfDocument);
        case Type1Fonts.helveticaBold:
          return PdfFont.helveticaBold(pdfDocument);
        case Type1Fonts.helveticaBoldOblique:
          return PdfFont.helveticaBoldOblique(pdfDocument);
        case Type1Fonts.helveticaOblique:
          return PdfFont.helveticaOblique(pdfDocument);
        case Type1Fonts.times:
          return PdfFont.times(pdfDocument);
        case Type1Fonts.timesBold:
          return PdfFont.timesBold(pdfDocument);
        case Type1Fonts.timesBoldItalic:
          return PdfFont.timesBoldItalic(pdfDocument);
        case Type1Fonts.timesItalic:
          return PdfFont.timesItalic(pdfDocument);
        case Type1Fonts.symbol:
          return PdfFont.symbol(pdfDocument);
        case Type1Fonts.zapfDingbats:
          return PdfFont.zapfDingbats(pdfDocument);
        case null:
          return PdfFont.helvetica(pdfDocument);
      }
    },
  );
}