Compare commits

..

3 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
5 changed files with 31 additions and 31 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

@ -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)
})
};