Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use Abs::pt instead of Abs::raw #597

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/conversion/typst2vec/src/pass/glyph2vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl ConvertInnerImpl {
let ascender = font
.metrics()
.ascender
.at(typst::layout::Abs::raw(font.metrics().units_per_em))
.at(typst::layout::Abs::pt(font.metrics().units_per_em))
.to_f32();

Some(Arc::new(ir::ImageGlyphItem {
Expand Down Expand Up @@ -293,7 +293,7 @@ impl ConvertInnerImpl {

let w = glyph_image.width();
let h = glyph_image.height();
let sz = Size::new(typst::layout::Abs::raw(w), typst::layout::Abs::raw(h));
let sz = Size::new(typst::layout::Abs::pt(w), typst::layout::Abs::pt(h));

let image = ir::ImageItem {
image: Arc::new(glyph_image.into_typst()),
Expand All @@ -307,7 +307,7 @@ impl ConvertInnerImpl {
// let adjusted = font.metrics().ascender;

let adjusted = adjusted
.at(typst::layout::Abs::raw(font.metrics().units_per_em))
.at(typst::layout::Abs::pt(font.metrics().units_per_em))
.to_f32();

let ts = sk::Transform::from_scale(upem / w as f32, -upem / h as f32);
Expand Down Expand Up @@ -404,7 +404,7 @@ impl ConvertInnerImpl {
// > ` <svg> <defs> <use #glyph{id}> </svg>`
// See: <https://learn.microsoft.com/en-us/typography/opentype/spec/svg#glyph-identifiers>

let upem = typst::layout::Abs::raw(font.units_per_em());
let upem = typst::layout::Abs::pt(font.units_per_em());
let (width, height) = (upem.to_f32(), upem.to_f32());
let origin_ascender = font_metrics.ascender.at(upem).to_f32();

Expand Down Expand Up @@ -458,8 +458,8 @@ impl ConvertInnerImpl {
.ok()?;

let sz = Size::new(
typst::layout::Abs::raw(glyph_image.width()),
typst::layout::Abs::raw(glyph_image.height()),
typst::layout::Abs::pt(glyph_image.width()),
typst::layout::Abs::pt(glyph_image.height()),
);

Some(ir::ImageItem {
Expand Down
1 change: 1 addition & 0 deletions fuzzers/corpora/viewers/emoji.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#emoji.beer
Loading