fetchFontFile function

Future<Uint8List> fetchFontFile(
  1. String fontId,
  2. String subset,
  3. int weight,
  4. String style,
  5. FontFormat format, [
  6. String? version,
])

Fetch specified variant of a font file.

Implementation

Future<Uint8List> fetchFontFile(
    String fontId, String subset, int weight, String style, FontFormat format,
    [String? version]) async {
  String ext = '';
  switch (format) {
    case FontFormat.ttf:
      ext = 'ttf';
      break;
    case FontFormat.woff:
      ext = 'woff';
      break;
    case FontFormat.woff2:
      ext = 'woff2';
      break;
    default:
  }
  final response = await http.get(Uri.parse(
      '$apiUrl/v1/fonts/$fontId/$subset-$weight-$style.$ext${version == null ? '' : '?version=$version'}'));

  return response.bodyBytes;
}