Minor improvements
This commit is contained in:
parent
82b893ec0e
commit
65f11dc364
@ -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)
|
||||
|
@ -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)?;
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
||||
---
|
||||
|
Loading…
x
Reference in New Issue
Block a user