Repository navigation
Description
Imported from dnfield/flutter_svg#680
Original report by @FetFrumos on Mar 11, 2022
I have svg image(export from Adobe Xd). For the correct display of this file, I need to install an additional font in the system(MAC or Windows) - then the picture is displayed correctly, without this font it is incorrect. but I need to display this drawing in application. I using flutter_svg plugin. I download ttf of font, add in assets and pubspec. But after that it doesn't work either. how add custom font for svg image(with flutter_svg)?
Comment by @dnfield on Mar 13, 2022
I'd find it helpful if you shared a small but complete example of the issue.
Some places where this could possibly go wrong:
- The font isn't getting included in the pubspec correctly (see https://docs.flutter.dev/cookbook/design/fonts).
- The font is getting included as a plain asset and you need to use font loading API to load it (https://api.flutter.dev/flutter/dart-ui/loadFontFromList.html).
- For some reason the SVG is getting parsed and rendered to a picture before the font is loaded.
- The SVG is not specifying the correct font family information to resolve to your custom font.
- The flutter_svg package is not making the right use of font rendering attributes to get the custom font to be used.
Obviously if it's that last point, there's a bug in this package. A reproduction case would be able to narrow this down.
Comment by @L4hibYoussef on Mar 15, 2023
Is there any updates on this. I am appearing to have the same issue. Font is loaded before image is rendered and font is available for use in the app. I am building the app for web using canvaskit.
Comment by @devalev on Jul 12, 2023
Is there any updates on this. I am appearing to have the same issue. Font is loaded before image is rendered and font is available for use in the app. I am building the app for web using canvaskit.
You need to load the font when executing the application.
void main() async {
runApp(const MyApp());
}
void loadFont() async {
var fontLoader = FontLoader("FontName");
fontLoader.addFont(rootBundle.load('fonts/FontName.ttf'));
await fontLoader.load();
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
loadFont();
return Container();
}
}
Please note that sometimes the font-family is specified in extra quotes in the svg file
font-family="FontName"
and
font-family="'FontName'"
these are different things, and, accordingly, you need to import different fonts
var fontLoader = FontLoader("FontName");
var fontLoader = FontLoader("'FontName'");
Activity
darshankawar commentedon Nov 28, 2025
I'll close this based on the solution given above. If anybody still sees this as an issue with latest plugin and stable version, please file new issue with relevant details using issue template.
/cc @FetFrumos and @L4hibYoussef
github-actions commentedon Dec 12, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.