fontFromAssetBundle function

Future<TtfFont> fontFromAssetBundle(
  1. String key, {
  2. AssetBundle? bundle,
  3. bool cache = true,
  4. PdfBaseCache? pdfCache,
  5. bool protect = false,
})

Loads a font from an asset bundle key. If used multiple times with the same font name, it will be included multiple times in the pdf file

Implementation

Future<TtfFont> fontFromAssetBundle(
  String key, {
  AssetBundle? bundle,
  bool cache = true,
  PdfBaseCache? pdfCache,
  bool protect = false,
}) async {
  bundle ??= rootBundle;
  final bytes = await bundle.load(key);
  return TtfFont(bytes, protect: protect);
}