web_font_loader 0.0.1 web_font_loader: ^0.0.1 copied to clipboard
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));
}