diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-09 11:06:37 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-09 11:26:41 +0200 |
| commit | 3932bb2cb93be95d67fc56998423eb9ce047fdfa (patch) | |
| tree | c36bd4df1d2c74f8ae100d2f3bd3a0b232b797f5 /src/export/pdf.rs | |
| parent | 3c92bad9a7cd6b880de197806443ffcce2cac9d8 (diff) | |
New source loading architecture
Diffstat (limited to 'src/export/pdf.rs')
| -rw-r--r-- | src/export/pdf.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/export/pdf.rs b/src/export/pdf.rs index bfd36421..d4b3ac25 100644 --- a/src/export/pdf.rs +++ b/src/export/pdf.rs @@ -14,17 +14,17 @@ use pdf_writer::{ use ttf_parser::{name_id, GlyphId}; use crate::color::Color; -use crate::font::{Em, FaceId, FontCache}; +use crate::font::{Em, FaceId, FontStore}; use crate::geom::{self, Length, Size}; -use crate::image::{Image, ImageCache, ImageId}; +use crate::image::{Image, ImageId, ImageStore}; use crate::layout::{Element, Frame, Geometry, Paint}; use crate::Context; /// Export a collection of frames into a PDF document. /// /// This creates one page per frame. In addition to the frames, you need to pass -/// in the cache used during compilation such that things like fonts and images -/// can be included in the PDF. +/// in the context used during compilation such that things like fonts and +/// images can be included in the PDF. /// /// Returns the raw bytes making up the PDF document. pub fn pdf(ctx: &Context, frames: &[Rc<Frame>]) -> Vec<u8> { @@ -33,19 +33,16 @@ pub fn pdf(ctx: &Context, frames: &[Rc<Frame>]) -> Vec<u8> { struct PdfExporter<'a> { writer: PdfWriter, + refs: Refs, frames: &'a [Rc<Frame>], - fonts: &'a FontCache, + fonts: &'a FontStore, + images: &'a ImageStore, font_map: Remapper<FaceId>, - images: &'a ImageCache, image_map: Remapper<ImageId>, - refs: Refs, } impl<'a> PdfExporter<'a> { fn new(ctx: &'a Context, frames: &'a [Rc<Frame>]) -> Self { - let mut writer = PdfWriter::new(1, 7); - writer.set_indent(2); - let mut font_map = Remapper::new(); let mut image_map = Remapper::new(); let mut alpha_masks = 0; @@ -66,14 +63,15 @@ impl<'a> PdfExporter<'a> { } } - let refs = Refs::new(frames.len(), font_map.len(), image_map.len(), alpha_masks); + let mut writer = PdfWriter::new(1, 7); + writer.set_indent(2); Self { writer, + refs: Refs::new(frames.len(), font_map.len(), image_map.len(), alpha_masks), frames, fonts: &ctx.fonts, images: &ctx.images, - refs, font_map, image_map, } |
