resolveCustomFont method

Future<Font> resolveCustomFont(
  1. String ttfFontPath,
  2. AssetBundle assetBundle
)

Implementation

Future<pw.Font> resolveCustomFont(
    String ttfFontPath, AssetBundle assetBundle) async {
  final bytes = await assetBundle.load(ttfFontPath);
  if (bytes.buffer.asInt8List().isEmpty) {
    throw Exception('Font file $ttfFontPath is empty');
  }
  return pw.Font.ttf(bytes);
}