feat: forbid weird embedded font uses and make toml dep optional (#1701)

* cg

* fix: forbid weird embedded

* feat: optional toml
This commit is contained in:
Myriad-Dreamin 2025-04-25 17:56:17 +08:00 committed by GitHub
parent 2b3eb252f0
commit 042fc2a477
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 18 deletions

View file

@ -31,7 +31,7 @@ tinymist-world = { workspace = true }
tinymist-std = { workspace = true, features = ["typst"] }
tinymist-derive.workspace = true
tinymist-l10n.workspace = true
toml.workspace = true
toml = { workspace = true, optional = true }
typst.workspace = true
typst-assets.workspace = true
notify.workspace = true
@ -40,7 +40,7 @@ notify.workspace = true
fonts = ["typst-assets/fonts"]
no-content-hint = ["tinymist-task/no-content-hint"]
lsp = ["system"]
lsp = ["system", "toml"]
system = ["tinymist-std/system", "tinymist-world/system"]

View file

@ -53,7 +53,7 @@ web-sys = { workspace = true, optional = true, features = ["console"] }
[features]
default = []
browser-embedded-fonts = ["typst-assets/fonts"]
fonts = ["typst-assets/fonts"]
http-registry = ["reqwest"]
web = [
"chrono",

View file

@ -371,13 +371,7 @@ pub struct BrowserFontSearcher {
impl BrowserFontSearcher {
/// Create a new, empty browser searcher.
pub fn new() -> Self {
let mut searcher = Self { fonts: vec![] };
if cfg!(feature = "browser-embedded-fonts") {
searcher.add_embedded();
}
searcher
Self { fonts: vec![] }
}
/// Create a new browser searcher with fonts in a FontResolverImpl.
@ -435,6 +429,7 @@ impl BrowserFontSearcher {
impl BrowserFontSearcher {
/// Add fonts that are embedded in the binary.
#[cfg(feature = "fonts")]
pub fn add_embedded(&mut self) {
for font_data in typst_assets::fonts() {
let buffer = Bytes::new(font_data);

View file

@ -204,14 +204,12 @@
}
context if shiroa-sys-target() == "html" {
html.elem(
"style",
```css
.pseudo-image svg {
width: 100%
}
```.text,
)
show raw: it => html.elem("style", it.text)
```css
.pseudo-image svg {
width: 100%
}
```
}
show <typst-raw-func>: it => {