copyFonts method
Implementation
void copyFonts(
List<String> fontFiles, String fontFamily, String outputDirPath) {
final outputDir = Directory(outputDirPath);
if (!outputDir.existsSync()) {
outputDir.createSync(recursive: true);
}
if (fontFiles.isNotEmpty) {
for (var fontFile in fontFiles) {
final file = File(fontFile);
if (!file.existsSync()) {
print("\n✖ Font file `$fontFile` not found");
continue;
}
final destination =
path.join(outputDir.path, path.basename(fontFile)).fixPath;
print(AnsiStyles.blueBright(
"- Copying font file `${fontFile.split('/').last}` to `$destination`"));
try {
file.copySync(destination);
} catch (e) {
if (e is PathExistsException) {
/// Cannot create a file when that file already exists.
throw CopierException('${e.message}.\n'
'${AnsiStyles.italic("Cannot create a file when that file already exists.")}');
} else if (e is PathNotFoundException) {
/// The system cannot find the path specified.
throw CopierException('${e.message}.\n'
'${AnsiStyles.italic("-help: The system cannot find the path specified.")}');
} else {
throw CopierException(e.toString());
}
}
}
} else {
print(AnsiStyles.blueBright(
'\nWe\'re sorry, `$fontFamily` font is not yet available for fontresoft!'));
/// SEND MSG TO DEVELOPER TO ADD FONT
}
}