搜索插件、代码仓与 APP 分类

插件详情v0.4.0

fontsource

轻松将 Fontsource 字体添加到您的 Flutter 应用中。包含 Fontsource API 的 Dart 接口。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
59
喜欢数
12
Pub 分数
140

安装插件

flutter pub add fontsource

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Fontsource 是一个 Flutter/Dart 包,可简化将 Fontsource 字体集成到您的应用程序中的过程。它提供了对 Fontsource API 的 Dart 接口,使开发者能够轻松地在所有支持的平台上包含高质量的开源字体。该包简化了字体加载和管理,确保以最少的配置实现一致的排版效果。支持 Android、iOS、Web、macOS、Windows 和 Linux,非常适合需要可自定义且高性能字体渲染的跨平台应用。

适合场景

  • 向Flutter应用添加自定义开源字体
  • 跨平台字体一致性
  • 优化字体加载性能
  • 通过 Fontsource 集成 Google 字体
  • 网页和移动应用中的自定义字体

主要特点

  • Dart 接口用于 Fontsource API
  • 对多平台的支持
  • 通过 pub add 轻松集成
  • 预优化的字体文件
  • 自动字体族处理
  • 轻量且快速

适合对象

  • 寻求开源字体的Flutter开发者
  • 需要在跨平台保持一致排版的应用程序
  • 优先考虑性能和最小化设置的项目
  • 设计师使用自定义字型
  • 带有品牌导向排版的网页和移动应用

使用建议

  • 需要互联网访问以获取初始字体
  • 仅限 Fontsource 托管的字体系列
  • 使用大型字体集可能会增加应用包大小
  • 不适用于仅离线的应用程序
  • 最好与字体预加载策略一起使用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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.

所属分类

依赖

依赖清单 6 项

源码仓库

使用此插件的项目

暂无相关数据。