bytesFor method
Implementation
@override
Future<Uint8List> bytesFor(LLResolvedFont font) async {
final String cacheName = switch (font.kind) {
LLFontKind.file => '${_hex(font.contentHash!)}.${font.format ?? 'ttf'}',
LLFontKind.google => 'google-${_slug(font.family ?? '')}.ttf',
LLFontKind.none => throw StateError('no font to fetch'),
};
final Uint8List? cached = await _readCache(cacheName);
if (cached != null) return cached;
final String url = font.kind == LLFontKind.google
? await _resolveGoogleUrl(font.family!)
: font.url!;
final LLResponse response = await _fetch(url);
if (!response.ok) {
throw StateError('font request failed with HTTP ${response.status}');
}
await _writeCache(cacheName, response.bodyBytes);
return response.bodyBytes;
}