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 { ...@@ -32,11 +32,9 @@ impl AssetLoader for TTFLoader {
load_context: &'a mut LoadContext, load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<(), anyhow::Error>> { ) -> BoxedFuture<'a, Result<(), anyhow::Error>> {
Box::pin(async move { Box::pin(async move {
#[cfg(not(target_family = "wasm"))]
let asset_io = load_context let asset_io = load_context
.asset_io() .asset_io()
.downcast_ref::<FileAssetIo>() .downcast_ref::<FileAssetIo>();
.unwrap();
let kttf: KTTF = let kttf: KTTF =
nanoserde::DeJson::deserialize_json(std::str::from_utf8(bytes).unwrap()).unwrap(); nanoserde::DeJson::deserialize_json(std::str::from_utf8(bytes).unwrap()).unwrap();
...@@ -196,9 +194,13 @@ impl AssetLoader for TTFLoader { ...@@ -196,9 +194,13 @@ impl AssetLoader for TTFLoader {
let image_bytes = if cache_image.is_err() { let image_bytes = if cache_image.is_err() {
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
image_builder {
.save(asset_io.root_path().join(cache_path)) if let Some(asset_io) = asset_io {
.unwrap(); image_builder
.save(asset_io.root_path().join(cache_path))
.unwrap();
}
}
image_builder.as_bytes().to_vec() image_builder.as_bytes().to_vec()
} else { } else {
let cache_image = cache_image.unwrap(); 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