Search packages, repositories and app categories

Package detailsv0.4.0

fontsource

Easily add Fontsource fonts to your flutter app. Includes a dart interface for the Fontsource API.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
59
Likes
12
Pub points
140

Install package

flutter pub add fontsource

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Fontsource is a Flutter/Dart package that simplifies the integration of Fontsource fonts into your application. It provides a Dart interface to the Fontsource API, enabling developers to easily include high-quality, open-source fonts across all supported platforms. The package streamlines font loading and management, ensuring consistent typography with minimal configuration. With support for Android, iOS, Web, macOS, Windows, and Linux, it's ideal for cross-platform apps requiring customizable and performant font rendering.

Use cases

  • Adding custom open-source fonts to Flutter apps
  • Cross-platform font consistency
  • Optimizing font loading performance
  • Integrating Google Fonts via Fontsource
  • Custom typography in web and mobile apps

Key features

  • Dart interface to Fontsource API
  • Support for multiple platforms
  • Easy integration via pub add
  • Pre-optimized font files
  • Automatic font family handling
  • Lightweight and fast

Suitable for

  • Flutter developers seeking open-source fonts
  • Apps needing consistent typography across platforms
  • Projects prioritizing performance and minimal setup
  • Designers working with custom typefaces
  • Web and mobile applications with branding-focused typography

Considerations

  • Requires internet access for initial font fetching
  • Limited to Fontsource-hosted font families
  • May increase app bundle size with large font sets
  • Not suitable for offline-only applications
  • Best used with font preloading strategies

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Fontsource for Flutter

Easily add Fontsource fonts to your flutter app. Includes a dart interface for the Fontsource API.

Getting started

To start, create a config in either your pubspec.yaml file under the fontsource key or in the fontsource.yaml file.

include: [my-package] # Defaults to all
fonts:
  alex-brush: # This can be any font id
    version: 4.5.3 # Defaults to latest
    subsets: [latin, latin-ext] # Defaults to all
    weights: [400] # Defaults to all
    styles: [normal] # Defaults to all

The config will tell fontsource what to download and bundle into your flutter app. To ensure everything is downloaded, execute dart run fontsource after your config is modified. Also, make sure to run it whenever your repository is cloned. This will generate a local package in the .fontsource directory.

You can then import the fontsource package:

import 'package:fontsource/fontsource.dart';

Use the FontsourceTextStyle class to use a Fontsource font:

const Text(
  'Hello world!',
  style: FontsourceTextStyle(fontFamily: 'Alex Brush', fontSize: 30),
),

FontsourceTextStyle extends the TextStyle class, so any styling properties can be used to change the way the text looks.

Use With Packages

To use this in a package, add a configuration like normal, but don't run the fontsource cli.

Packages with a fontsource configuration will automatically be included. To manually specify what packages should be scanned, provide an include key with a list of package names to scan.

Fontsource API

The Fontsource API also has a dart interface that can be accessed through fontsource/api.dart.

Categories

Dependencies

Dependency list 6 items

Source repository

Projects using this package

No data available yet.