mirror of
https://github.com/typst/typst
synced 2025-08-15 15:38:33 +08:00
more changes
This commit is contained in:
parent
eed3c0dfea
commit
bb7efcccec
@ -47,7 +47,7 @@ pub fn convert(
|
|||||||
cmyk_profile: None,
|
cmyk_profile: None,
|
||||||
configuration,
|
configuration,
|
||||||
enable_tagging: false,
|
enable_tagging: false,
|
||||||
render_svg_glyph_fn: render_svg_glyph
|
render_svg_glyph_fn: render_svg_glyph,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut document = Document::new_with(settings);
|
let mut document = Document::new_with(settings);
|
||||||
@ -304,7 +304,6 @@ pub(crate) fn handle_group(
|
|||||||
.clip
|
.clip
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|p| {
|
.and_then(|p| {
|
||||||
|
|
||||||
let mut builder = PathBuilder::new();
|
let mut builder = PathBuilder::new();
|
||||||
convert_path(p, &mut builder);
|
convert_path(p, &mut builder);
|
||||||
builder.finish()
|
builder.finish()
|
||||||
|
@ -190,9 +190,12 @@ fn convert_gradient(
|
|||||||
cx: radial.center.x.get() as f32,
|
cx: radial.center.x.get() as f32,
|
||||||
cy: radial.center.y.get() as f32,
|
cy: radial.center.y.get() as f32,
|
||||||
cr: radial.radius.get() as f32,
|
cr: radial.radius.get() as f32,
|
||||||
transform: base_transform.pre_concat(
|
transform: base_transform
|
||||||
Transform::scale(Ratio::new(size.x.to_f32() as f64), Ratio::new(size.y.to_f32() as f64)),
|
.pre_concat(Transform::scale(
|
||||||
).to_krilla(),
|
Ratio::new(size.x.to_f32() as f64),
|
||||||
|
Ratio::new(size.y.to_f32() as f64),
|
||||||
|
))
|
||||||
|
.to_krilla(),
|
||||||
spread_method: SpreadMethod::Pad,
|
spread_method: SpreadMethod::Pad,
|
||||||
stops: stops.into(),
|
stops: stops.into(),
|
||||||
anti_alias: gradient.anti_alias(),
|
anti_alias: gradient.anti_alias(),
|
||||||
|
@ -31,7 +31,8 @@ pub(crate) fn handle_shape(
|
|||||||
shape.geometry.bbox_size(),
|
shape.geometry.bbox_size(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
surface.fill_path(&path, fill);
|
surface.set_fill(fill);
|
||||||
|
surface.fill_path(&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
let stroke = shape.stroke.as_ref().and_then(|stroke| {
|
let stroke = shape.stroke.as_ref().and_then(|stroke| {
|
||||||
@ -52,7 +53,8 @@ pub(crate) fn handle_shape(
|
|||||||
shape.geometry.bbox_size(),
|
shape.geometry.bbox_size(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
surface.stroke_path(&path, stroke);
|
surface.set_stroke(stroke);
|
||||||
|
surface.stroke_path(&path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ use std::ops::Range;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use bytemuck::TransparentWrapper;
|
use bytemuck::TransparentWrapper;
|
||||||
use krilla::font::{GlyphId, GlyphUnits};
|
use krilla::font::GlyphId;
|
||||||
use krilla::surface::{Location, Surface};
|
use krilla::surface::{Location, Surface};
|
||||||
use typst_library::diag::{bail, SourceResult};
|
use typst_library::diag::{bail, SourceResult};
|
||||||
use typst_library::layout::Size;
|
use typst_library::layout::{Abs, 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;
|
||||||
@ -37,14 +37,13 @@ pub(crate) fn handle_text(
|
|||||||
let glyphs: &[PdfGlyph] = TransparentWrapper::wrap_slice(t.glyphs.as_slice());
|
let glyphs: &[PdfGlyph] = TransparentWrapper::wrap_slice(t.glyphs.as_slice());
|
||||||
|
|
||||||
surface.push_transform(&fc.state().transform().to_krilla());
|
surface.push_transform(&fc.state().transform().to_krilla());
|
||||||
|
surface.set_fill(fill);
|
||||||
surface.fill_glyphs(
|
surface.fill_glyphs(
|
||||||
krilla::geom::Point::from_xy(0.0, 0.0),
|
krilla::geom::Point::from_xy(0.0, 0.0),
|
||||||
fill,
|
|
||||||
glyphs,
|
glyphs,
|
||||||
font.clone(),
|
font.clone(),
|
||||||
text,
|
text,
|
||||||
size.to_f32(),
|
size.to_f32(),
|
||||||
GlyphUnits::Normalized,
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -55,14 +54,14 @@ pub(crate) fn handle_text(
|
|||||||
{
|
{
|
||||||
let stroke = stroke?;
|
let stroke = stroke?;
|
||||||
|
|
||||||
|
surface.set_stroke(stroke);
|
||||||
surface.stroke_glyphs(
|
surface.stroke_glyphs(
|
||||||
krilla::geom::Point::from_xy(0.0, 0.0),
|
krilla::geom::Point::from_xy(0.0, 0.0),
|
||||||
stroke,
|
|
||||||
glyphs,
|
glyphs,
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
size.to_f32(),
|
size.to_f32(),
|
||||||
GlyphUnits::Normalized,
|
// TODO: What if only stroke?
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -110,19 +109,19 @@ impl krilla::font::Glyph for PdfGlyph {
|
|||||||
self.0.range.start as usize..self.0.range.end as usize
|
self.0.range.start as usize..self.0.range.end as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
fn x_advance(&self) -> f32 {
|
fn x_advance(&self, size: f32) -> f32 {
|
||||||
self.0.x_advance.get() as f32
|
self.0.x_advance.at(Abs::raw(size as f64)).to_raw() as f32
|
||||||
}
|
}
|
||||||
|
|
||||||
fn x_offset(&self) -> f32 {
|
fn x_offset(&self, size: f32) -> f32 {
|
||||||
self.0.x_offset.get() as f32
|
self.0.x_offset.at(Abs::raw(size as f64)).to_raw() as f32
|
||||||
}
|
}
|
||||||
|
|
||||||
fn y_offset(&self) -> f32 {
|
fn y_offset(&self, _: f32) -> f32 {
|
||||||
0.0
|
0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn y_advance(&self) -> f32 {
|
fn y_advance(&self, _: f32) -> f32 {
|
||||||
0.0
|
0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user