summaryrefslogtreecommitdiff
path: root/src/export
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2022-05-31 22:56:08 +0200
committerMartin Haug <mhaug@live.de>2022-05-31 22:56:08 +0200
commit4e3036afcbdf2814889030413ffa81c8cc697341 (patch)
tree5a40018bb0fc39e726640184d988dcb0f2d3f86b /src/export
parent97858e5992a52459dd8a34be7a6b4786952b491a (diff)
Sub- and superscripts
Fixes to PDF export I guess Also improved rendition for non-Latin scripts
Diffstat (limited to 'src/export')
-rw-r--r--src/export/pdf.rs30
1 files changed, 13 insertions, 17 deletions
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(),