summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/meta/counter.rs4
-rw-r--r--library/src/meta/reference.rs2
-rw-r--r--src/export/render.rs28
-rw-r--r--src/ide/analyze.rs1
-rw-r--r--tests/typ/compiler/hint.typ2
5 files changed, 27 insertions, 10 deletions
diff --git a/library/src/meta/counter.rs b/library/src/meta/counter.rs
index 4825bc65..9a223b32 100644
--- a/library/src/meta/counter.rs
+++ b/library/src/meta/counter.rs
@@ -634,8 +634,8 @@ impl Show for DisplayElem {
.numbering()
.or_else(|| {
let CounterKey::Selector(Selector::Elem(func, _)) = counter.0 else {
- return None;
- };
+ return None;
+ };
if func == HeadingElem::func() {
HeadingElem::numbering_in(styles)
diff --git a/library/src/meta/reference.rs b/library/src/meta/reference.rs
index c39f8ca0..5bd04431 100644
--- a/library/src/meta/reference.rs
+++ b/library/src/meta/reference.rs
@@ -189,7 +189,7 @@ impl Show for RefElem {
)
})
.hint(eco_format!(
- "you can enable heading numbering with `#set {}(numbering: \"1.\")`?",
+ "you can enable heading numbering with `#set {}(numbering: \"1.\")`",
elem.func().name()
))
.at(span)?;
diff --git a/src/export/render.rs b/src/export/render.rs
index ef0fc9f2..d8115b12 100644
--- a/src/export/render.rs
+++ b/src/export/render.rs
@@ -5,12 +5,14 @@ use std::sync::Arc;
use image::imageops::FilterType;
use image::{GenericImageView, Rgba};
+use pixglyph::Bitmap;
use resvg::FitTo;
use tiny_skia as sk;
use ttf_parser::{GlyphId, OutlineBuilder};
use usvg::{NodeExt, TreeParsing};
use crate::doc::{Frame, FrameItem, GroupItem, Meta, TextItem};
+use crate::font::Font;
use crate::geom::{
self, Abs, Color, Geometry, LineCap, LineJoin, Paint, PathItem, Shape, Size, Stroke,
Transform,
@@ -297,10 +299,26 @@ fn render_outline_glyph(
}
// Rasterize the glyph with `pixglyph`.
+ #[comemo::memoize]
+ fn rasterize(
+ font: &Font,
+ id: GlyphId,
+ x: u32,
+ y: u32,
+ size: u32,
+ ) -> Option<Arc<Bitmap>> {
+ let glyph = pixglyph::Glyph::load(font.ttf(), id)?;
+ Some(Arc::new(glyph.rasterize(
+ f32::from_bits(x),
+ f32::from_bits(y),
+ f32::from_bits(size),
+ )))
+ }
+
// Try to retrieve a prepared glyph or prepare it from scratch if it
// doesn't exist, yet.
- let glyph = pixglyph::Glyph::load(text.font.ttf(), id)?;
- let bitmap = glyph.rasterize(ts.tx, ts.ty, ppem);
+ let bitmap =
+ rasterize(&text.font, id, ts.tx.to_bits(), ts.ty.to_bits(), ppem.to_bits())?;
// If we have a clip mask we first render to a pixmap that we then blend
// with our canvas
@@ -333,8 +351,6 @@ fn render_outline_glyph(
sk::Transform::identity(),
mask,
);
-
- Some(())
} else {
let cw = canvas.width() as i32;
let ch = canvas.height() as i32;
@@ -372,9 +388,9 @@ fn render_outline_glyph(
pixels[pi] = blend_src_over(applied, pixels[pi]);
}
}
-
- Some(())
}
+
+ Some(())
}
/// Render a geometrical shape into the canvas.
diff --git a/src/ide/analyze.rs b/src/ide/analyze.rs
index 55ec8281..dad466c1 100644
--- a/src/ide/analyze.rs
+++ b/src/ide/analyze.rs
@@ -89,6 +89,7 @@ pub fn analyze_labels(
let Some(label) = elem.label().cloned() else { continue };
let details = elem
.field("caption")
+ .or_else(|| elem.field("body"))
.and_then(|field| match field {
Value::Content(content) => Some(content),
_ => None,
diff --git a/tests/typ/compiler/hint.typ b/tests/typ/compiler/hint.typ
index fdd5f59b..6b60eafb 100644
--- a/tests/typ/compiler/hint.typ
+++ b/tests/typ/compiler/hint.typ
@@ -25,7 +25,7 @@
= Heading <intro>
// Error: 1:20-1:26 cannot reference heading without numbering
-// Hint: 1:20-1:26 you can enable heading numbering with `#set heading(numbering: "1.")`?
+// Hint: 1:20-1:26 you can enable heading numbering with `#set heading(numbering: "1.")`
Can not be used as @intro
---