summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/text
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-01-08 11:57:56 +0100
committerGitHub <noreply@github.com>2025-01-08 10:57:56 +0000
commitdacd6acd5e73d35c6e7a7a3b144f16ae70d03daa (patch)
treeca75ce7d4d5365fbe2424a356cefe9cb223d429f /crates/typst-library/src/text
parent0a374d238016c0101d11cbc3f4bc621f3895ad36 (diff)
More flexible and efficient `Bytes` representation (#5670)
Diffstat (limited to 'crates/typst-library/src/text')
-rw-r--r--crates/typst-library/src/text/font/color.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/typst-library/src/text/font/color.rs b/crates/typst-library/src/text/font/color.rs
index 08f6fe0a..e3183e88 100644
--- a/crates/typst-library/src/text/font/color.rs
+++ b/crates/typst-library/src/text/font/color.rs
@@ -7,6 +7,7 @@ use typst_syntax::Span;
use usvg::tiny_skia_path;
use xmlwriter::XmlWriter;
+use crate::foundations::Bytes;
use crate::layout::{Abs, Frame, FrameItem, Point, Size};
use crate::text::{Font, Glyph};
use crate::visualize::{FixedStroke, Geometry, Image, RasterFormat, VectorFormat};
@@ -101,8 +102,12 @@ fn draw_raster_glyph(
upem: Abs,
raster_image: ttf_parser::RasterGlyphImage,
) -> Option<()> {
- let image =
- Image::new(raster_image.data.into(), RasterFormat::Png.into(), None).ok()?;
+ let image = Image::new(
+ Bytes::new(raster_image.data.to_vec()),
+ RasterFormat::Png.into(),
+ None,
+ )
+ .ok()?;
// Apple Color emoji doesn't provide offset information (or at least
// not in a way ttf-parser understands), so we artificially shift their
@@ -175,7 +180,7 @@ fn draw_colr_glyph(
let data = svg.end_document().into_bytes();
- let image = Image::new(data.into(), VectorFormat::Svg.into(), None).ok()?;
+ let image = Image::new(Bytes::new(data), VectorFormat::Svg.into(), None).ok()?;
let y_shift = Abs::pt(upem.to_pt() - y_max);
let position = Point::new(Abs::pt(x_min), y_shift);
@@ -251,7 +256,7 @@ fn draw_svg_glyph(
);
let image =
- Image::new(wrapper_svg.into_bytes().into(), VectorFormat::Svg.into(), None)
+ Image::new(Bytes::new(wrapper_svg.into_bytes()), VectorFormat::Svg.into(), None)
.ok()?;
let position = Point::new(Abs::pt(left), Abs::pt(top) + upem);