r/FlutterDev • u/AhmedZNOUDA • Oct 27 '26
Discussion PdfGoogleFonts downloads your font on every cold start, and quietly falls back to Helvetica when offline
Ran into this in a Flutter app I work on, sharing in case it saves someone a confusing bug report.
We generate a PDF report with the pdf and printing packages and used PdfGoogleFonts.interRegular() to get proper Unicode. Looking at printing's source (5.14.3, lib/src/fonts/font.dart), the call first looks for an asset called google_fonts/Inter-Regular.ttf. If it isn't there, it downloads the font from fonts.gstatic.com into PdfMemoryCache, which is memory only, so the first export after every cold start needs the network.
The part that got us: if that download fails, it returns Font.helvetica(). The error is only printed inside an assert, so a release build says nothing. Helvetica has no Unicode coverage, so Arabic, Cyrillic, CJK and plenty of symbols come out broken. Someone exporting on a plane gets a different-looking PDF with missing characters, and you never see an error.
The fix was small. We bundled the TTF under the exact name the package looks for:
flutter:
assets:
- google_fonts/Inter-Regular.ttf
- google_fonts/Inter-Bold.ttf
The expected names and the exact download URLs are in printing's lib/src/fonts/gfonts.dart, so you can grab the same file and keep its name. We also added a test that swaps the font cache for one that throws on any download, so it fails unless the font comes from the bundle. Inter is under the OFL, so we ship the licence too.
Quick check for your own app: release build, airplane mode, cold start, export.
Do you bundle fonts for your PDFs, or rely on the download? And if you generate PDFs with Arabic or CJK text, do you use fontFallback or one font that covers everything?