-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move fonts folder, add RawTypstAsset
- Loading branch information
1 parent
9a2c224
commit 87c58fd
Showing
50 changed files
with
81 additions
and
92 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use bevy::{ | ||
asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext}, | ||
prelude::*, | ||
utils::{ | ||
thiserror::{self, Error}, | ||
BoxedFuture, | ||
}, | ||
}; | ||
|
||
pub struct TypstAssetPlugin; | ||
|
||
impl Plugin for TypstAssetPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.init_asset::<RawTypstAsset>() | ||
.init_asset_loader::<RawTypstAssetLoader>(); | ||
} | ||
} | ||
|
||
#[derive(Asset, TypePath)] | ||
pub struct RawTypstAsset(String); | ||
|
||
impl RawTypstAsset { | ||
pub fn content(&self) -> &str { | ||
&self.0 | ||
} | ||
} | ||
|
||
#[derive(Default)] | ||
struct RawTypstAssetLoader; | ||
|
||
impl AssetLoader for RawTypstAssetLoader { | ||
type Asset = RawTypstAsset; | ||
|
||
type Settings = (); | ||
|
||
type Error = RawTypstAssetLoaderError; | ||
|
||
fn load<'a>( | ||
&'a self, | ||
reader: &'a mut Reader, | ||
_settings: &'a Self::Settings, | ||
_load_context: &'a mut LoadContext, | ||
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> { | ||
Box::pin(async move { | ||
let mut string = String::new(); | ||
reader.read_to_string(&mut string).await?; | ||
Ok(RawTypstAsset(string)) | ||
}) | ||
} | ||
|
||
fn extensions(&self) -> &[&str] { | ||
&["typ"] | ||
} | ||
} | ||
|
||
/// Possible errors that can be produced by [`BvhAssetLoader`] | ||
#[non_exhaustive] | ||
#[derive(Debug, Error)] | ||
pub enum RawTypstAssetLoaderError { | ||
/// An [Io](std::io) Error | ||
#[error("Could not load typst file: {0}")] | ||
Io(#[from] std::io::Error), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters