Skip to content

Commit

Permalink
fix: use Abs::pt instead of Abs::raw
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Oct 29, 2024
1 parent c52a054 commit f97342d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
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

0 comments on commit f97342d

Please sign in to comment.