mirror of
https://github.com/typst/typst
synced 2025-08-15 15:38:33 +08:00
Add more typst-timing annotations
This commit is contained in:
parent
986f8b2456
commit
067478a520
@ -34,6 +34,7 @@ use crate::text::handle_text;
|
|||||||
use crate::util::{convert_path, display_font, AbsExt, TransformExt};
|
use crate::util::{convert_path, display_font, AbsExt, TransformExt};
|
||||||
use crate::PdfOptions;
|
use crate::PdfOptions;
|
||||||
|
|
||||||
|
#[typst_macros::time(name = "convert document")]
|
||||||
pub fn convert(
|
pub fn convert(
|
||||||
typst_document: &PagedDocument,
|
typst_document: &PagedDocument,
|
||||||
options: &PdfOptions,
|
options: &PdfOptions,
|
||||||
@ -247,6 +248,7 @@ impl<'a> GlobalContext<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[typst_macros::time(name = "handle page")]
|
||||||
pub(crate) fn handle_frame(
|
pub(crate) fn handle_frame(
|
||||||
fc: &mut FrameContext,
|
fc: &mut FrameContext,
|
||||||
frame: &Frame,
|
frame: &Frame,
|
||||||
@ -322,6 +324,7 @@ pub(crate) fn handle_group(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[typst_macros::time(name = "finish export")]
|
||||||
/// Finish a krilla document and handle export errors.
|
/// Finish a krilla document and handle export errors.
|
||||||
fn finish(
|
fn finish(
|
||||||
document: Document,
|
document: Document,
|
||||||
|
@ -16,6 +16,7 @@ use typst_syntax::Span;
|
|||||||
use crate::convert::{FrameContext, GlobalContext};
|
use crate::convert::{FrameContext, GlobalContext};
|
||||||
use crate::util::{SizeExt, TransformExt};
|
use crate::util::{SizeExt, TransformExt};
|
||||||
|
|
||||||
|
#[typst_macros::time(name = "handle image")]
|
||||||
pub(crate) fn handle_image(
|
pub(crate) fn handle_image(
|
||||||
gc: &mut GlobalContext,
|
gc: &mut GlobalContext,
|
||||||
fc: &mut FrameContext,
|
fc: &mut FrameContext,
|
||||||
|
@ -8,6 +8,7 @@ use crate::convert::{FrameContext, GlobalContext};
|
|||||||
use crate::paint;
|
use crate::paint;
|
||||||
use crate::util::{convert_path, AbsExt, TransformExt};
|
use crate::util::{convert_path, AbsExt, TransformExt};
|
||||||
|
|
||||||
|
#[typst_macros::time(name = "handle shape")]
|
||||||
pub(crate) fn handle_shape(
|
pub(crate) fn handle_shape(
|
||||||
fc: &mut FrameContext,
|
fc: &mut FrameContext,
|
||||||
shape: &Shape,
|
shape: &Shape,
|
||||||
|
@ -5,7 +5,7 @@ use bytemuck::TransparentWrapper;
|
|||||||
use krilla::surface::{Location, Surface};
|
use krilla::surface::{Location, Surface};
|
||||||
use krilla::text::GlyphId;
|
use krilla::text::GlyphId;
|
||||||
use typst_library::diag::{bail, SourceResult};
|
use typst_library::diag::{bail, SourceResult};
|
||||||
use typst_library::layout::{Abs, Size};
|
use typst_library::layout::Size;
|
||||||
use typst_library::text::{Font, Glyph, TextItem};
|
use typst_library::text::{Font, Glyph, TextItem};
|
||||||
use typst_library::visualize::FillRule;
|
use typst_library::visualize::FillRule;
|
||||||
use typst_syntax::Span;
|
use typst_syntax::Span;
|
||||||
@ -14,6 +14,7 @@ use crate::convert::{FrameContext, GlobalContext};
|
|||||||
use crate::paint;
|
use crate::paint;
|
||||||
use crate::util::{display_font, AbsExt, TransformExt};
|
use crate::util::{display_font, AbsExt, TransformExt};
|
||||||
|
|
||||||
|
#[typst_macros::time(name = "handle text")]
|
||||||
pub(crate) fn handle_text(
|
pub(crate) fn handle_text(
|
||||||
fc: &mut FrameContext,
|
fc: &mut FrameContext,
|
||||||
t: &TextItem,
|
t: &TextItem,
|
||||||
@ -96,26 +97,34 @@ fn build_font(typst_font: Font) -> SourceResult<krilla::text::Font> {
|
|||||||
struct PdfGlyph(Glyph);
|
struct PdfGlyph(Glyph);
|
||||||
|
|
||||||
impl krilla::text::Glyph for PdfGlyph {
|
impl krilla::text::Glyph for PdfGlyph {
|
||||||
|
#[inline(always)]
|
||||||
fn glyph_id(&self) -> GlyphId {
|
fn glyph_id(&self) -> GlyphId {
|
||||||
GlyphId::new(self.0.id as u32)
|
GlyphId::new(self.0.id as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn text_range(&self) -> Range<usize> {
|
fn text_range(&self) -> Range<usize> {
|
||||||
self.0.range.start as usize..self.0.range.end as usize
|
self.0.range.start as usize..self.0.range.end as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn x_advance(&self, size: f32) -> f32 {
|
fn x_advance(&self, size: f32) -> f32 {
|
||||||
self.0.x_advance.at(Abs::raw(size as f64)).to_raw() as f32
|
// Don't use `Em::at`, because it contains an expensive check whether the result is finite.
|
||||||
|
self.0.x_advance.get() as f32 * size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn x_offset(&self, size: f32) -> f32 {
|
fn x_offset(&self, size: f32) -> f32 {
|
||||||
self.0.x_offset.at(Abs::raw(size as f64)).to_raw() as f32
|
// Don't use `Em::at`, because it contains an expensive check whether the result is finite.
|
||||||
|
self.0.x_offset.get() as f32 * size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn y_offset(&self, _: f32) -> f32 {
|
fn y_offset(&self, _: f32) -> f32 {
|
||||||
0.0
|
0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn y_advance(&self, _: f32) -> f32 {
|
fn y_advance(&self, _: f32) -> f32 {
|
||||||
0.0
|
0.0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user