Closed jhoncke2 closed 3 months ago
Are you using the google_fonts package?
Or are you using a custom Lato font which you added as a font asset to the projects pubspec.yml
?
I added it as a font asset to the projects pybspec.yaml
El vie, 2 ago 2024 a la(s) 11:44 a.m., Joseph Grabinger ( @.***) escribió:
Are you using the google_fonts https://pub.dev/packages/google_fonts package?
Or are you using a custom Lato font which you added as a font asset to the projects pubspec.yml ?
— Reply to this email directly, view it on GitHub https://github.com/joseph-grabinger/flutter_to_pdf/issues/80#issuecomment-2265776574, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMIA2KJ65LL3IUME2ONVTTZPOZPNAVCNFSM6AAAAABL252RV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRVG43TMNJXGQ . You are receiving this because you authored the thread.Message ID: @.***>
The error you're experiencing is hinting your ExportDelegate
dosen't know the font 'lato'
(Note: this is case sensitive).
This error is explicitly thrown when a provided custom font name is not registered in the ExportDelegate
's fontData
(see https://github.com/joseph-grabinger/flutter_to_pdf/blob/main/lib/args/text_style.dart#L66).
Did you register the font (in this case lato
) when instantiating the ExportDelegate
like the following?
final ExportDelegate myExportDelegate = ExportDelegate(
ttfFonts: {
'lato': 'assets/fonts/Lato-Regular.ttf', // Path can differ but should point to the correct location of the ttf-file
},
);
Furthermore, you must then use the same ExportDelegate
to export the frame containing the fonts.
final pdf = await myExportDelegate.exportToPdfDocument('someFrameID');
Thank you for the help. Which version of the flutterToPdf package do i have to use? I have in my pubspec.yaml the version 0.1.1 and the constructor of ExportDelegate has just the parameter "options" which type is ExportOptions.
El sáb, 3 ago 2024 a la(s) 1:10 p.m., Joseph Grabinger ( @.***) escribió:
Did you register the font (in this case lato) when instantiating the ExportDelegate like the following?
final ExportDelegate myExportDelegate = ExportDelegate( ttfFonts: { 'lato': 'assets/fonts/Lato-Regular.ttf', // Path can differ but should point to the correct location of the ttf-file }, );
Furthermore, you must then use the same ExportDelegate to export the frame containing the fonts.
final pdf = await myExportDelegate.exportToPdfDocument('someFrameID');
— Reply to this email directly, view it on GitHub https://github.com/joseph-grabinger/flutter_to_pdf/issues/80#issuecomment-2267090757, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMIA2K65MD55YKOCQ2WCBDZPUMLDAVCNFSM6AAAAABL252RV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRXGA4TANZVG4 . You are receiving this because you authored the thread.Message ID: @.***>
I have solved the problem by updating the package version to 0.2.0 and applying your solution. Thank you so much.
El lun, 5 ago 2024 a la(s) 2:49 p.m., Jhonatan Andrés Amórtegui García ( @.***) escribió:
Thank you for the help. Which version of the flutterToPdf package do i have to use? I have in my pubspec.yaml the version 0.1.1 and the constructor of ExportDelegate has just the parameter "options" which type is ExportOptions.
El sáb, 3 ago 2024 a la(s) 1:10 p.m., Joseph Grabinger ( @.***) escribió:
Did you register the font (in this case lato) when instantiating the ExportDelegate like the following?
final ExportDelegate myExportDelegate = ExportDelegate( ttfFonts: { 'lato': 'assets/fonts/Lato-Regular.ttf', // Path can differ but should point to the correct location of the ttf-file }, );
Furthermore, you must then use the same ExportDelegate to export the frame containing the fonts.
final pdf = await myExportDelegate.exportToPdfDocument('someFrameID');
— Reply to this email directly, view it on GitHub https://github.com/joseph-grabinger/flutter_to_pdf/issues/80#issuecomment-2267090757, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMIA2K65MD55YKOCQ2WCBDZPUMLDAVCNFSM6AAAAABL252RV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRXGA4TANZVG4 . You are receiving this because you authored the thread.Message ID: @.***>
I am converting a widget in to pdf with the function ExportDelegate.exportToPdfDocument(frameId). But, the method throws the error Unsupported Font: lato. Lato is a font that i added from google fonts to the project in pubspec.yalm. And, i am using this font into the widget that i am converting to pdf. Please, help me.
This is the stacktrace:
I/flutter ( 4678): Exception: Unsupported Font: lato I/flutter ( 4678): #0 TextStyleConverter.resolveFont (package:flutter_to_pdf/args/text_style.dart:61:9) I/flutter ( 4678): #1 TextStyleConverter.toPdfTextStyle (package:flutter_to_pdf/args/text_style.dart:36:36) I/flutter ( 4678): #2 TextConverter.toPdfWidget (package:flutter_to_pdf/widgets/text.dart:21:23) I/flutter ( 4678): #3 ExportInstance.matchWidget (package:flutter_to_pdf/export_instance.dart:173:34) I/flutter ( 4678): #4 ExportInstance._visit (package:flutter_to_pdf/export_instance.dart:55:29) I/flutter ( 4678):
I/flutter ( 4678): #5 ExportInstance.matchWidget (package:flutter_to_pdf/export_instance.dart:226:48)
I/flutter ( 4678):
I/flutter ( 4678): #6 ExportInstance._visit (package:flutter_to_pdf/export_instance.dart:55:23)
I/flutter ( 4678):
I/flutter ( 4678): #7 ExportInstance.matchWidget (package:flutter_to_pdf/export_instance.dart:84:31)
I/flutter ( 4678):
I/flutter ( 4678): #8 ExportInstance._visit (package:flutter_to_pdf/export_instance.dart:55:23)
I/flutter ( 4678):
I/flutter ( 4678): #9 ExportInstance.matchWidget (package:flutter_to_pdf/export_instance.dart:150:31)
I/flutter ( 4678):
I/flutter ( 4678): #10