From 3932bb2cb93be95d67fc56998423eb9ce047fdfa Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 9 Aug 2021 11:06:37 +0200 Subject: New source loading architecture --- src/export/pdf.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/export') 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]) -> Vec { @@ -33,19 +33,16 @@ pub fn pdf(ctx: &Context, frames: &[Rc]) -> Vec { struct PdfExporter<'a> { writer: PdfWriter, + refs: Refs, frames: &'a [Rc], - fonts: &'a FontCache, + fonts: &'a FontStore, + images: &'a ImageStore, font_map: Remapper, - images: &'a ImageCache, image_map: Remapper, - refs: Refs, } impl<'a> PdfExporter<'a> { fn new(ctx: &'a Context, frames: &'a [Rc]) -> 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, } -- cgit v1.2.3