From f105663037c44740b5aa02dea72a9b368bc003e0 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 20 Nov 2020 16:36:22 +0100 Subject: =?UTF-8?q?Basic=20image=20support=20=F0=9F=96=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [image] function - Image rendering in tests - Supports JPEG and PNG - No PDF export so far --- src/export/pdf.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/export') diff --git a/src/export/pdf.rs b/src/export/pdf.rs index 763cea8a..cb05dee0 100644 --- a/src/export/pdf.rs +++ b/src/export/pdf.rs @@ -148,6 +148,10 @@ impl<'a> PdfExporter<'a> { text = text.tm(1.0, 0.0, 0.0, 1.0, x as f32, y as f32); text = text.tj(&shaped.encode_glyphs_be()); } + + LayoutElement::Image(_image) => { + // TODO: Write image. + } } } @@ -280,12 +284,13 @@ fn remap_fonts(layouts: &[BoxLayout]) -> (HashMap, Vec) { // each text element to find out which face is uses. for layout in layouts { for (_, element) in &layout.elements { - let LayoutElement::Text(shaped) = element; - to_pdf.entry(shaped.face).or_insert_with(|| { - let next_id = to_layout.len(); - to_layout.push(shaped.face); - next_id - }); + if let LayoutElement::Text(shaped) = element { + to_pdf.entry(shaped.face).or_insert_with(|| { + let next_id = to_layout.len(); + to_layout.push(shaped.face); + next_id + }); + } } } -- cgit v1.2.3