Compare commits

...

6 Commits

Author SHA1 Message Date
Laurenz Stampfl
5dcb1def0c
Merge 1a66c8ebe731946899a12d426ba180cc7826fe8e into b790c6d59ceaf7a809cc24b60c1f1509807470e2 2025-07-20 10:08:17 +00:00
Laurenz Stampfl
1a66c8ebe7 Bump deps 2025-07-20 10:52:12 +02:00
Laurenz Stampfl
c384f6b6c0 Use select_fallback as well 2025-07-20 10:06:33 +02:00
Erik
b790c6d59c
Add rust-analyzer to flake devShell (#6618) 2025-07-18 14:36:10 +00:00
Malo
b1c79b50d4
Fix documentation oneliners (#6608) 2025-07-18 13:25:17 +00:00
Patrick Massot
4629ede020
Mention Tinymist in README.md (#6601) 2025-07-18 13:21:36 +00:00
10 changed files with 67 additions and 42 deletions

15
Cargo.lock generated
View File

@ -967,7 +967,7 @@ dependencies = [
[[package]]
name = "hayro"
version = "0.1.0"
source = "git+https://github.com/LaurenzV/hayro?rev=d385360#d38536089c95b521b0b64080302d7a305344edbf"
source = "git+https://github.com/LaurenzV/hayro?rev=2b63dc8#2b63dc85b9447a815cc5b40c16338841c3780f7e"
dependencies = [
"bytemuck",
"hayro-interpret",
@ -980,7 +980,7 @@ dependencies = [
[[package]]
name = "hayro-font"
version = "0.1.0"
source = "git+https://github.com/LaurenzV/hayro?rev=d385360#d38536089c95b521b0b64080302d7a305344edbf"
source = "git+https://github.com/LaurenzV/hayro?rev=2b63dc8#2b63dc85b9447a815cc5b40c16338841c3780f7e"
dependencies = [
"log",
"phf",
@ -989,7 +989,7 @@ dependencies = [
[[package]]
name = "hayro-interpret"
version = "0.1.0"
source = "git+https://github.com/LaurenzV/hayro?rev=d385360#d38536089c95b521b0b64080302d7a305344edbf"
source = "git+https://github.com/LaurenzV/hayro?rev=2b63dc8#2b63dc85b9447a815cc5b40c16338841c3780f7e"
dependencies = [
"bitflags 2.9.1",
"hayro-font",
@ -1006,7 +1006,7 @@ dependencies = [
[[package]]
name = "hayro-syntax"
version = "0.0.1"
source = "git+https://github.com/LaurenzV/hayro?rev=d385360#d38536089c95b521b0b64080302d7a305344edbf"
source = "git+https://github.com/LaurenzV/hayro?rev=2b63dc8#2b63dc85b9447a815cc5b40c16338841c3780f7e"
dependencies = [
"flate2",
"kurbo",
@ -1019,7 +1019,7 @@ dependencies = [
[[package]]
name = "hayro-write"
version = "0.1.0"
source = "git+https://github.com/LaurenzV/hayro?rev=d385360#d38536089c95b521b0b64080302d7a305344edbf"
source = "git+https://github.com/LaurenzV/hayro?rev=2b63dc8#2b63dc85b9447a815cc5b40c16338841c3780f7e"
dependencies = [
"flate2",
"hayro-syntax",
@ -1430,7 +1430,7 @@ dependencies = [
[[package]]
name = "krilla"
version = "0.4.0"
source = "git+https://github.com/LaurenzV/krilla?rev=f7d753c3#f7d753c39e1fb7118fb1b774243a0720771f229f"
source = "git+https://github.com/LaurenzV/krilla?rev=1668ac2#1668ac2e64dc85572e6c62a2399e85acd39b619d"
dependencies = [
"base64",
"bumpalo",
@ -1460,7 +1460,7 @@ dependencies = [
[[package]]
name = "krilla-svg"
version = "0.1.0"
source = "git+https://github.com/LaurenzV/krilla?rev=f7d753c3#f7d753c39e1fb7118fb1b774243a0720771f229f"
source = "git+https://github.com/LaurenzV/krilla?rev=1668ac2#1668ac2e64dc85572e6c62a2399e85acd39b619d"
dependencies = [
"flate2",
"fontdb",
@ -2926,7 +2926,6 @@ dependencies = [
[[package]]
name = "typst-assets"
version = "0.13.1"
source = "git+https://github.com/typst/typst-assets?rev=edf0d64#edf0d648376e29738a05a933af9ea99bb81557b1"
[[package]]
name = "typst-cli"

View File

@ -32,7 +32,7 @@ typst-svg = { path = "crates/typst-svg", version = "0.13.1" }
typst-syntax = { path = "crates/typst-syntax", version = "0.13.1" }
typst-timing = { path = "crates/typst-timing", version = "0.13.1" }
typst-utils = { path = "crates/typst-utils", version = "0.13.1" }
typst-assets = { git = "https://github.com/typst/typst-assets", rev = "edf0d64" }
typst-assets = { path = "../typst-assets" }
typst-dev-assets = { git = "https://github.com/typst/typst-dev-assets", rev = "bfa947f" }
arrayvec = "0.7.4"
az = "1.2"
@ -61,8 +61,8 @@ fontdb = { version = "0.23", default-features = false }
fs_extra = "1.3"
glidesort = "0.1.2"
hayagriva = "0.8.1"
hayro-syntax = { git = "https://github.com/LaurenzV/hayro", rev = "d385360" }
hayro = { git = "https://github.com/LaurenzV/hayro", rev = "d385360" }
hayro-syntax = { git = "https://github.com/LaurenzV/hayro", rev = "2b63dc8" }
hayro = { git = "https://github.com/LaurenzV/hayro", rev = "2b63dc8" }
heck = "0.5"
hypher = "0.1.4"
icu_properties = { version = "1.4", features = ["serde"] }
@ -75,8 +75,8 @@ image = { version = "0.25.5", default-features = false, features = ["png", "jpeg
indexmap = { version = "2", features = ["serde"] }
infer = { version = "0.19.0", default-features = false }
kamadak-exif = "0.6"
krilla = { git = "https://github.com/LaurenzV/krilla", rev = "f7d753c3", default-features = false, features = ["raster-images", "comemo", "rayon", "pdf"] }
krilla-svg = { git = "https://github.com/LaurenzV/krilla", rev = "f7d753c3" }
krilla = { git = "https://github.com/LaurenzV/krilla", rev = "1668ac2", default-features = false, features = ["raster-images", "comemo", "rayon", "pdf"] }
krilla-svg = { git = "https://github.com/LaurenzV/krilla", rev = "1668ac2" }
kurbo = "0.11"
libfuzzer-sys = "0.4"
lipsum = "0.9"

View File

@ -173,8 +173,11 @@ typst help
typst help watch
```
If you prefer an integrated IDE-like experience with autocompletion and instant
preview, you can also check out [Typst's free web app][app].
If you prefer an integrated IDE-like experience with autocompletion and instant
preview, you can also check out our [free web app][app]. Alternatively, there is
a community-created language server called
[Tinymist](https://myriad-dreamin.github.io/tinymist/) which is integrated into
various editor extensions.
## Community
The main places where the community gathers are our [Forum][forum] and our

View File

@ -797,7 +797,9 @@ impl Color {
components
}
/// Returns the constructor function for this color's space:
/// Returns the constructor function for this color's space.
///
/// Returns one of:
/// - [`luma`]($color.luma)
/// - [`oklab`]($color.oklab)
/// - [`oklch`]($color.oklch)

View File

@ -7,6 +7,7 @@ use hayro_syntax::page::Page;
use hayro_syntax::Pdf;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
use typst_library::text::FontInfo;
struct DocumentRepr {
pdf: Arc<Pdf>,
@ -121,8 +122,9 @@ fn get_standard_fonts(world: Tracked<dyn World + '_>) -> Arc<StandardFonts> {
None
}
})
.or_else(|| book.select_fallback(None, variant, "A"))
.and_then(|i| world.font(i))
.map(|font| font.data().clone())
.map(|font| (font.data().clone(), font.index()))
};
let normal_variant = FontVariant::new(
@ -161,18 +163,17 @@ fn get_standard_fonts(world: Tracked<dyn World + '_>) -> Arc<StandardFonts> {
bold_italic: get_font("times", Some("liberation serif"), bold_italic_variant),
};
// TODO: Use Foxit fonts as fallback
let symbol = get_font("symbol", None, normal_variant);
let zapf_dingbats = get_font("zapf dingbats", None, normal_variant);
let symbol = Some(Bytes::new(typst_assets::pdf::SYMBOL));
let zapf_dingbats = Some(Bytes::new(typst_assets::pdf::DING_BATS));
Arc::new(StandardFonts { helvetica, courier, times, symbol, zapf_dingbats })
}
pub struct VariantFont {
pub normal: Option<Bytes>,
pub bold: Option<Bytes>,
pub italic: Option<Bytes>,
pub bold_italic: Option<Bytes>,
pub normal: Option<(Bytes, u32)>,
pub bold: Option<(Bytes, u32)>,
pub italic: Option<(Bytes, u32)>,
pub bold_italic: Option<(Bytes, u32)>,
}
pub struct StandardFonts {

View File

@ -110,7 +110,7 @@ fn build_texture(image: &Image, w: u32, h: u32) -> Option<Arc<sk::Pixmap>> {
fn build_pdf_texture(pdf: &PdfImage, w: u32, h: u32) -> Option<sk::Pixmap> {
let sf = pdf.standard_fonts().clone();
let select_standard_font = move |font: StandardFont| -> Option<FontData> {
let select_standard_font = move |font: StandardFont| -> Option<(FontData, u32)> {
let bytes = match font {
StandardFont::Helvetica => sf.helvetica.normal.clone(),
StandardFont::HelveticaBold => sf.helvetica.bold.clone(),
@ -124,14 +124,14 @@ fn build_pdf_texture(pdf: &PdfImage, w: u32, h: u32) -> Option<sk::Pixmap> {
StandardFont::TimesBold => sf.times.bold.clone(),
StandardFont::TimesItalic => sf.times.italic.clone(),
StandardFont::TimesBoldItalic => sf.times.bold_italic.clone(),
StandardFont::ZapfDingBats => sf.zapf_dingbats.clone(),
StandardFont::Symbol => sf.symbol.clone(),
StandardFont::ZapfDingBats => sf.zapf_dingbats.clone().map(|d| (d, 0)),
StandardFont::Symbol => sf.symbol.clone().map(|d| (d, 0)),
};
bytes.map(|d| {
let font_data: Arc<dyn AsRef<[u8]> + Send + Sync> = Arc::new(d.clone());
let font_data: Arc<dyn AsRef<[u8]> + Send + Sync> = Arc::new(d.0.clone());
font_data
(font_data, d.1)
})
};

View File

@ -102,7 +102,7 @@ pub fn convert_image_to_base64_url(image: &Image) -> EcoString {
fn pdf_to_png(pdf: &PdfImage, w: u32, h: u32) -> Vec<u8> {
let sf = pdf.standard_fonts().clone();
let select_standard_font = move |font: StandardFont| -> Option<FontData> {
let select_standard_font = move |font: StandardFont| -> Option<(FontData, u32)> {
let bytes = match font {
StandardFont::Helvetica => sf.helvetica.normal.clone(),
StandardFont::HelveticaBold => sf.helvetica.bold.clone(),
@ -116,14 +116,14 @@ fn pdf_to_png(pdf: &PdfImage, w: u32, h: u32) -> Vec<u8> {
StandardFont::TimesBold => sf.times.bold.clone(),
StandardFont::TimesItalic => sf.times.italic.clone(),
StandardFont::TimesBoldItalic => sf.times.bold_italic.clone(),
StandardFont::ZapfDingBats => sf.zapf_dingbats.clone(),
StandardFont::Symbol => sf.symbol.clone(),
StandardFont::ZapfDingBats => sf.zapf_dingbats.clone().map(|d| (d, 0)),
StandardFont::Symbol => sf.symbol.clone().map(|d| (d, 0)),
};
bytes.map(|d| {
let font_data: Arc<dyn AsRef<[u8]> + Send + Sync> = Arc::new(d.clone());
let font_data: Arc<dyn AsRef<[u8]> + Send + Sync> = Arc::new(d.0.clone());
font_data
(font_data, d.1)
})
};

View File

@ -242,7 +242,7 @@ fn category_page(resolver: &dyn Resolver, category: Category) -> PageModel {
items.push(CategoryItem {
name: group.name.clone(),
route: subpage.route.clone(),
oneliner: oneliner(docs).into(),
oneliner: oneliner(docs),
code: true,
});
children.push(subpage);
@ -296,7 +296,7 @@ fn category_page(resolver: &dyn Resolver, category: Category) -> PageModel {
items.push(CategoryItem {
name: name.into(),
route: subpage.route.clone(),
oneliner: oneliner(func.docs().unwrap_or_default()).into(),
oneliner: oneliner(func.docs().unwrap_or_default()),
code: true,
});
children.push(subpage);
@ -306,7 +306,7 @@ fn category_page(resolver: &dyn Resolver, category: Category) -> PageModel {
items.push(CategoryItem {
name: ty.short_name().into(),
route: subpage.route.clone(),
oneliner: oneliner(ty.docs()).into(),
oneliner: oneliner(ty.docs()),
code: true,
});
children.push(subpage);
@ -637,7 +637,7 @@ fn group_page(
let item = CategoryItem {
name: group.name.clone(),
route: model.route.clone(),
oneliner: oneliner(&group.details).into(),
oneliner: oneliner(&group.details),
code: false,
};
@ -772,8 +772,24 @@ pub fn urlify(title: &str) -> EcoString {
}
/// Extract the first line of documentation.
fn oneliner(docs: &str) -> &str {
docs.lines().next().unwrap_or_default()
fn oneliner(docs: &str) -> EcoString {
let paragraph = docs.split("\n\n").next().unwrap_or_default();
let mut depth = 0;
let mut period = false;
let mut end = paragraph.len();
for (i, c) in paragraph.char_indices() {
match c {
'(' | '[' | '{' => depth += 1,
')' | ']' | '}' => depth -= 1,
'.' if depth == 0 => period = true,
c if period && c.is_whitespace() && !docs[..i].ends_with("e.g.") => {
end = i;
break;
}
_ => period = false,
}
}
EcoString::from(&docs[..end]).replace("\r\n", " ").replace("\n", " ")
}
/// The order of types in the documentation.

View File

@ -86,7 +86,7 @@ pub struct FuncModel {
pub name: EcoString,
pub title: &'static str,
pub keywords: &'static [&'static str],
pub oneliner: &'static str,
pub oneliner: EcoString,
pub element: bool,
pub contextual: bool,
pub deprecation: Option<&'static str>,
@ -139,7 +139,7 @@ pub struct TypeModel {
pub name: &'static str,
pub title: &'static str,
pub keywords: &'static [&'static str],
pub oneliner: &'static str,
pub oneliner: EcoString,
pub details: Html,
pub constructor: Option<FuncModel>,
pub scope: Vec<FuncModel>,

View File

@ -127,6 +127,10 @@
checks = self'.checks;
inputsFrom = [ typst ];
buildInputs = with pkgs; [
rust-analyzer
];
packages = [
# A script for quickly running tests.
# See https://github.com/typst/typst/blob/main/tests/README.md#making-an-alias