getFonts static method

Future<List<CPDFFontName>> getFonts()

Retrieve the list of available fonts in the ComPDFKit SDK. Each font is represented by a CPDFFontName object containing the family name, PostScript names, and style names.

Example:

List<CPDFFontName> fonts = await ComPDFKit.getFonts();

Implementation

static Future<List<CPDFFontName>> getFonts() async {
  try {
    final dynamic fontsJson = await _methodChannel.invokeMethod('get_fonts');
    if (fontsJson is List) {
      return fontsJson
          .whereType<Map>()
          .map<CPDFFontName>((fontMap) =>
              CPDFFontName.fromJson(Map<String, dynamic>.from(fontMap)))
          .toList();
    }
  } catch (e) {
    debugPrint('getFonts error: $e');
  }
  return <CPDFFontName>[];
}