web_font_loader 0.0.1 copy "web_font_loader: ^0.0.1" to clipboard
web_font_loader: ^0.0.1 copied to clipboard

Platformweb

A Dart interface to Web Font Loader along with Angular service and directive

Web Font Loader #

You can use the interface directly:

import 'package:web_font_loader/web_font_loader.dart';

void main() {
  load(Options(
      google: GoogleFonts(families: [
        'Lato'
      ])));
}

Use the service:

class MyComponent {
  MyComponent(this._font);
  
  final FontService _font;
  
  void main() {
    final family = GoogleFontFamilyImpl('Lato')
    ..styles.add(FontStyleImpl(family, 'Regular 400', 
        FontWeight.regular));
    
    // can safely be called multiple times without
    // downloading the fonts more than once
    _font.use(family).then((ev) {
      print('Font loaded!');
    });
  }
}

There is also a directive:

@Component(
  //...
  template: '<div [font-loader]="family">hello</div>',
  directives: [FontLoaderComponent]
)
class MyComponent {
  final family = GoogleFontFamilyImpl('Lato')
    ..styles.add(FontStyleImpl(family, 'Regular 400',
        FontWeight.regular));
}
0
likes
100
pub points
0%
popularity

Publisher

unverified uploader

A Dart interface to Web Font Loader along with Angular service and directive

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (LICENSE)

Dependencies

angular, animejs, js, js_interop

More

Packages that depend on web_font_loader