From 4e3036afcbdf2814889030413ffa81c8cc697341 Mon Sep 17 00:00:00 2001 From: Martin Haug Date: Tue, 31 May 2022 22:56:08 +0200 Subject: Sub- and superscripts Fixes to PDF export I guess Also improved rendition for non-Latin scripts --- src/export/pdf.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src/export/pdf.rs') diff --git a/src/export/pdf.rs b/src/export/pdf.rs index 46f3d389..aa7acd41 100644 --- a/src/export/pdf.rs +++ b/src/export/pdf.rs @@ -521,17 +521,18 @@ impl<'a> PageExporter<'a> { } fn write_text(&mut self, x: f32, y: f32, text: &Text) { + *self.languages.entry(text.lang).or_insert(0) += text.glyphs.len(); self.glyphs .entry(text.face_id) .or_default() .extend(text.glyphs.iter().map(|g| g.id)); - self.content.begin_text(); - self.set_font(text.face_id, text.size); - self.set_fill(text.fill); - let face = self.fonts.get(text.face_id); + self.set_fill(text.fill); + self.set_font(text.face_id, text.size); + self.content.begin_text(); + // Position the text. self.content.set_text_matrix([1.0, 0.0, 0.0, -1.0, x, y]); @@ -568,11 +569,6 @@ impl<'a> PageExporter<'a> { items.show(Str(&encoded)); } - self.languages - .entry(text.lang) - .and_modify(|x| *x += text.glyphs.len()) - .or_insert_with(|| text.glyphs.len()); - items.finish(); positioned.finish(); self.content.end_text(); @@ -583,6 +579,14 @@ impl<'a> PageExporter<'a> { return; } + if let Some(fill) = shape.fill { + self.set_fill(fill); + } + + if let Some(stroke) = shape.stroke { + self.set_stroke(stroke); + } + match shape.geometry { Geometry::Rect(size) => { let w = size.x.to_f32(); @@ -606,14 +610,6 @@ impl<'a> PageExporter<'a> { } } - if let Some(fill) = shape.fill { - self.set_fill(fill); - } - - if let Some(stroke) = shape.stroke { - self.set_stroke(stroke); - } - match (shape.fill, shape.stroke) { (None, None) => unreachable!(), (Some(_), None) => self.content.fill_nonzero(), -- cgit v1.2.3