updateImportFontDir static method
Updates the font directory and configures whether to include system fonts. This method is primarily used to dynamically update the font directory after initializing the SDK.
- Parameters:
- dirPath: The directory path where the font files are stored.
- addSysFont: Whether to include system fonts. Default is
true, which will show system fonts in the font list.
Note: If you have loaded a document using CPDFReaderWidget, and there are annotations or content edits that use fonts not imported, the text may not display correctly. After updating the font directory with this method, you need to reload the document to see the updated font list using the CPDFReaderWidgetController.reloadPages2() method.
Example:
ComPDFKit.updateImportFontDir('path/to/your/font', addSysFont: true);
Returns:
A Future that resolves to true if the font directory was successfully updated, or false if an error occurred.
Implementation
static Future<bool> updateImportFontDir(String dirPath,
{bool addSysFont = true}) async {
try {
return await _methodChannel.invokeMethod('update_import_font_directory',
{'dir_path': dirPath, 'add_sys_font': addSysFont});
} catch (e) {
debugPrint("updateImportFontDir error: $e");
return false;
}
}