FontFileEntry
class FontFileEntry( val key: String, val path: String, val byteCount: Long, val header: ByteArray, val contentLength: Long? = null ) /** * Outcome of resolving one font role's [FontSpec] into something the platform can render with. * * Never a bare null, so the SDKs can log *why* they are falling back to Lato: * - [Loaded] - a validated font file is on disk * - [System] - a font name to look up on the device; nothing was downloaded * - [Unusable] - the clip can never work as it stands: no ttf/otf asset, no family name, * unparsable json, or bytes that arrived and are not a font (empty, no sfnt * magic, too short to hold an sfnt header). Also the verdict for a cleared * role. Retrying will not help; fall back to Lato and stop asking. * - [Unavailable] - the answer never arrived, or not all of it: the clip json could not be * fetched, the font file download failed or timed out, fewer bytes arrived than * the server declared, resolution timed out, no file store was wired up (yet), * or a platform implementation threw. The font itself may be perfectly fine. * Fall back to Lato now, worth retrying later. * * The dividing line is *what was learned*, not *how far it got*: a 404 on the font file is * [Unavailable] because the next request may well answer, while an error page served in its place * is [Unusable] because those bytes will never be a font. */ sealed class FontResolution
What a FontFileStoreInterface knows about one cached file.
[header] carries the first bytes of the file so the shared module can do the sfnt check without reading the whole file back into memory: 4 bytes cover the magic, 6 are enough for the declared table count and 28 cover the whole offset table plus one table record. iOS hands over 28 today, so the table-count check runs there; Android hands over 4, so it is skipped and only the magic and the byte count are judged. More is never wrong - the shared module reads what it needs and ignores the rest. [contentLength] is the value the server declared, or null when it did not.
NB: [header] is a [ByteArray], so the generated equals/hashCode compare it by identity.
Compare the fields you care about, not whole entries.
Properties
path
val path: String get()
Path of the font file on disk, for the platform's font registration call.