Skip to content
Snippets Groups Projects
Verified Commit b542973e authored by Louis's avatar Louis :fire:
Browse files

Only save cached kttf image when using FileAssetIo

parent ca204896
No related branches found
No related tags found
No related merge requests found
......@@ -32,11 +32,9 @@ impl AssetLoader for TTFLoader {
load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<(), anyhow::Error>> {
Box::pin(async move {
#[cfg(not(target_family = "wasm"))]
let asset_io = load_context
.asset_io()
.downcast_ref::<FileAssetIo>()
.unwrap();
.downcast_ref::<FileAssetIo>();
let kttf: KTTF =
nanoserde::DeJson::deserialize_json(std::str::from_utf8(bytes).unwrap()).unwrap();
......@@ -196,9 +194,13 @@ impl AssetLoader for TTFLoader {
let image_bytes = if cache_image.is_err() {
#[cfg(not(target_family = "wasm"))]
image_builder
.save(asset_io.root_path().join(cache_path))
.unwrap();
{
if let Some(asset_io) = asset_io {
image_builder
.save(asset_io.root_path().join(cache_path))
.unwrap();
}
}
image_builder.as_bytes().to_vec()
} else {
let cache_image = cache_image.unwrap();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment