setImportFontDir static method

Future<bool> setImportFontDir(
  1. String dirPath, {
  2. bool addSysFont = true,
})

Import font directory and configure whether to include system fonts.

  • Parameters:
    • dirPath: The directory path where the font files are stored. The imported fonts will be available for selection in text annotations and content editing, resolving issues with missing text in certain languages.
    • addSysFont: Whether to include system fonts. Default is true, which will show system fonts in the font list.

Note: This method must be called before ComPDFKit.init or ComPDFKit.initialize, otherwise the settings will have no effect.

Example:

ComPDFKit.setImportFontDir('path/to/your/font', addSysFont: true);
ComPDF

Implementation

static Future<bool> setImportFontDir(String dirPath,
    {bool addSysFont = true}) async {
  try {
    return await _methodChannel.invokeMethod('set_import_font_directory',
        {'dir_path': dirPath, 'add_sys_font': addSysFont});
  } catch (e) {
    debugPrint("setImportFontDir error: $e");
    return false;
  }
}