From 237c696292b15cdd091a3d9d3fc96764c935a83d Mon Sep 17 00:00:00 2001 From: Laurenz Stampfl <47084093+LaurenzV@users.noreply.github.com> Date: Mon, 2 Dec 2024 23:46:01 +0100 Subject: [PATCH] Rename old files --- .../src/{catalog.rs => catalog_old.rs} | 6 +-- crates/typst-pdf/src/color_font.rs | 10 ++--- .../typst-pdf/src/{color.rs => color_old.rs} | 26 ++++++------ .../src/{content.rs => content_old.rs} | 6 +-- crates/typst-pdf/src/{extg.rs => extg_old.rs} | 0 crates/typst-pdf/src/{font.rs => font_old.rs} | 0 .../src/{gradient.rs => gradient_old.rs} | 22 +++++----- crates/typst-pdf/src/image_old.rs | 6 +-- crates/typst-pdf/src/lib.rs | 40 +++++++++---------- ...estination.rs => named_destination_old.rs} | 0 .../src/{outline.rs => outline_old.rs} | 0 crates/typst-pdf/src/{page.rs => page_old.rs} | 6 +-- crates/typst-pdf/src/paint.rs | 6 ++- .../src/{pattern.rs => pattern_old.rs} | 20 +++++----- .../src/{resources.rs => resources_old.rs} | 10 ++--- 15 files changed, 81 insertions(+), 77 deletions(-) rename crates/typst-pdf/src/{catalog.rs => catalog_old.rs} (98%) rename crates/typst-pdf/src/{color.rs => color_old.rs} (95%) rename crates/typst-pdf/src/{content.rs => content_old.rs} (99%) rename crates/typst-pdf/src/{extg.rs => extg_old.rs} (100%) rename crates/typst-pdf/src/{font.rs => font_old.rs} (100%) rename crates/typst-pdf/src/{gradient.rs => gradient_old.rs} (97%) rename crates/typst-pdf/src/{named_destination.rs => named_destination_old.rs} (100%) rename crates/typst-pdf/src/{outline.rs => outline_old.rs} (100%) rename crates/typst-pdf/src/{page.rs => page_old.rs} (98%) rename crates/typst-pdf/src/{pattern.rs => pattern_old.rs} (91%) rename crates/typst-pdf/src/{resources.rs => resources_old.rs} (98%) diff --git a/crates/typst-pdf/src/catalog.rs b/crates/typst-pdf/src/catalog_old.rs similarity index 98% rename from crates/typst-pdf/src/catalog.rs rename to crates/typst-pdf/src/catalog_old.rs index 1412afe63..d3cc6245c 100644 --- a/crates/typst-pdf/src/catalog.rs +++ b/crates/typst-pdf/src/catalog_old.rs @@ -11,8 +11,8 @@ use typst_library::text::Lang; use typst_syntax::Span; use xmp_writer::{DateTime, LangId, RenditionClass, Timezone, XmpWriter}; -use crate::page::PdfPageLabel; -use crate::{hash_base64, outline, TextStrExt, WithEverything}; +use crate::page_old::PdfPageLabel; +use crate::{hash_base64, outline_old, TextStrExt, WithEverything}; /// Write the document catalog. pub fn write_catalog( @@ -34,7 +34,7 @@ pub fn write_catalog( }; // Write the outline tree. - let outline_root_id = outline::write_outline(pdf, alloc, &ctx); + let outline_root_id = outline_old::write_outline(pdf, alloc, &ctx); // Write the page labels. let page_labels = write_page_labels(pdf, alloc, &ctx); diff --git a/crates/typst-pdf/src/color_font.rs b/crates/typst-pdf/src/color_font.rs index 1183e966e..cb2ca9492 100644 --- a/crates/typst-pdf/src/color_font.rs +++ b/crates/typst-pdf/src/color_font.rs @@ -18,9 +18,9 @@ use typst_library::layout::Em; use typst_library::text::color::glyph_frame; use typst_library::text::{Font, Glyph, TextItemView}; -use crate::font::{base_font_name, write_font_descriptor, CMAP_NAME, SYSTEM_INFO}; -use crate::resources::{Resources, ResourcesRefs}; -use crate::{content, EmExt, PdfChunk, PdfOptions, WithGlobalRefs}; +use crate::font_old::{base_font_name, write_font_descriptor, CMAP_NAME, SYSTEM_INFO}; +use crate::resources_old::{Resources, ResourcesRefs}; +use crate::{content_old, EmExt, PdfChunk, PdfOptions, WithGlobalRefs}; /// Write color fonts in the PDF document. /// @@ -190,7 +190,7 @@ pub struct ColorGlyph { /// The ID of the glyph. pub gid: u16, /// Instructions to draw the glyph. - pub instructions: content::Encoded, + pub instructions: content_old::Encoded, } impl ColorFontMap<()> { @@ -250,7 +250,7 @@ impl ColorFontMap<()> { let width = font.advance(glyph.id).unwrap_or(Em::new(0.0)).get() * font.units_per_em(); - let instructions = content::build( + let instructions = content_old::build( options, &mut self.resources, &frame, diff --git a/crates/typst-pdf/src/color.rs b/crates/typst-pdf/src/color_old.rs similarity index 95% rename from crates/typst-pdf/src/color.rs rename to crates/typst-pdf/src/color_old.rs index 7097c14a5..4afdbc6c6 100644 --- a/crates/typst-pdf/src/color.rs +++ b/crates/typst-pdf/src/color_old.rs @@ -6,7 +6,7 @@ use typst_library::diag::{bail, SourceResult}; use typst_library::visualize::{Color, ColorSpace, Paint}; use typst_syntax::Span; -use crate::{content, deflate, PdfChunk, PdfOptions, Renumber, WithResources}; +use crate::{content_old, deflate, PdfChunk, PdfOptions, Renumber, WithResources}; // The names of the color spaces. pub const SRGB: Name<'static> = Name(b"srgb"); @@ -198,26 +198,26 @@ pub(super) trait PaintEncode { /// Set the paint as the fill color. fn set_as_fill( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, on_text: bool, - transforms: content::Transforms, + transforms: content_old::Transforms, ) -> SourceResult<()>; /// Set the paint as the stroke color. fn set_as_stroke( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, on_text: bool, - transforms: content::Transforms, + transforms: content_old::Transforms, ) -> SourceResult<()>; } impl PaintEncode for Paint { fn set_as_fill( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, on_text: bool, - transforms: content::Transforms, + transforms: content_old::Transforms, ) -> SourceResult<()> { match self { Self::Solid(c) => c.set_as_fill(ctx, on_text, transforms), @@ -228,9 +228,9 @@ impl PaintEncode for Paint { fn set_as_stroke( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, on_text: bool, - transforms: content::Transforms, + transforms: content_old::Transforms, ) -> SourceResult<()> { match self { Self::Solid(c) => c.set_as_stroke(ctx, on_text, transforms), @@ -243,9 +243,9 @@ impl PaintEncode for Paint { impl PaintEncode for Color { fn set_as_fill( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, _: bool, - _: content::Transforms, + _: content_old::Transforms, ) -> SourceResult<()> { match self { Color::Luma(_) => { @@ -287,9 +287,9 @@ impl PaintEncode for Color { fn set_as_stroke( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, _: bool, - _: content::Transforms, + _: content_old::Transforms, ) -> SourceResult<()> { match self { Color::Luma(_) => { diff --git a/crates/typst-pdf/src/content.rs b/crates/typst-pdf/src/content_old.rs similarity index 99% rename from crates/typst-pdf/src/content.rs rename to crates/typst-pdf/src/content_old.rs index a6dc59608..ca28cebbe 100644 --- a/crates/typst-pdf/src/content.rs +++ b/crates/typst-pdf/src/content_old.rs @@ -25,11 +25,11 @@ use typst_library::visualize::{ use typst_syntax::Span; use typst_utils::{Deferred, Numeric, SliceExt}; -use crate::color::PaintEncode; +use crate::color_old::PaintEncode; use crate::color_font::ColorFontMap; -use crate::extg::ExtGState; +use crate::extg_old::ExtGState; use crate::image_old::deferred_image; -use crate::resources::Resources; +use crate::resources_old::Resources; use crate::{deflate_deferred, AbsExt, ContentExt, EmExt, PdfOptions, StrExt}; /// Encode a [`Frame`] into a content stream. diff --git a/crates/typst-pdf/src/extg.rs b/crates/typst-pdf/src/extg_old.rs similarity index 100% rename from crates/typst-pdf/src/extg.rs rename to crates/typst-pdf/src/extg_old.rs diff --git a/crates/typst-pdf/src/font.rs b/crates/typst-pdf/src/font_old.rs similarity index 100% rename from crates/typst-pdf/src/font.rs rename to crates/typst-pdf/src/font_old.rs diff --git a/crates/typst-pdf/src/gradient.rs b/crates/typst-pdf/src/gradient_old.rs similarity index 97% rename from crates/typst-pdf/src/gradient.rs rename to crates/typst-pdf/src/gradient_old.rs index 6cd4c1ae8..e89652260 100644 --- a/crates/typst-pdf/src/gradient.rs +++ b/crates/typst-pdf/src/gradient_old.rs @@ -13,10 +13,10 @@ use typst_library::visualize::{ }; use typst_utils::Numeric; -use crate::color::{ +use crate::color_old::{ self, check_cmyk_allowed, ColorSpaceExt, PaintEncode, QuantizedColor, }; -use crate::{content, deflate, transform_to_array, AbsExt, PdfChunk, WithGlobalRefs}; +use crate::{content_old, deflate, transform_to_array, AbsExt, PdfChunk, WithGlobalRefs}; /// A unique-transform-aspect-ratio combination that will be encoded into the /// PDF. @@ -69,7 +69,7 @@ pub fn write_gradients( let mut shading = shading_pattern.function_shading(); shading.shading_type(FunctionShadingType::Axial); - color::write( + color_old::write( color_space, shading.color_space(), &context.globals.color_functions, @@ -106,7 +106,7 @@ pub fn write_gradients( let mut shading = shading_pattern.function_shading(); shading.shading_type(FunctionShadingType::Radial); - color::write( + color_old::write( color_space, shading.color_space(), &context.globals.color_functions, @@ -136,7 +136,7 @@ pub fn write_gradients( let mut stream_shading = chunk.chunk.stream_shading(stream_shading_id, &vertices); - color::write( + color_old::write( color_space, stream_shading.color_space(), &context.globals.color_functions, @@ -251,9 +251,9 @@ fn single_gradient( impl PaintEncode for Gradient { fn set_as_fill( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, on_text: bool, - transforms: content::Transforms, + transforms: content_old::Transforms, ) -> SourceResult<()> { ctx.reset_fill_color_space(); @@ -268,9 +268,9 @@ impl PaintEncode for Gradient { fn set_as_stroke( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, on_text: bool, - transforms: content::Transforms, + transforms: content_old::Transforms, ) -> SourceResult<()> { ctx.reset_stroke_color_space(); @@ -286,10 +286,10 @@ impl PaintEncode for Gradient { /// Deduplicates a gradient to a named PDF resource. fn register_gradient( - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, gradient: &Gradient, on_text: bool, - mut transforms: content::Transforms, + mut transforms: content_old::Transforms, ) -> usize { // Edge cases for strokes. if transforms.size.x.is_zero() { diff --git a/crates/typst-pdf/src/image_old.rs b/crates/typst-pdf/src/image_old.rs index b3b1cd914..76b86bed2 100644 --- a/crates/typst-pdf/src/image_old.rs +++ b/crates/typst-pdf/src/image_old.rs @@ -10,7 +10,7 @@ use typst_library::visualize::{ }; use typst_utils::Deferred; -use crate::{color, deflate, PdfChunk, WithGlobalRefs}; +use crate::{color_old, deflate, PdfChunk, WithGlobalRefs}; /// Embed all used images into the PDF. #[typst_macros::time(name = "write images")] @@ -54,13 +54,13 @@ pub fn write_images( space.icc_based(id); icc_ref = Some(id); } else if *has_color { - color::write( + color_old::write( ColorSpace::Srgb, space, &context.globals.color_functions, ); } else { - color::write( + color_old::write( ColorSpace::D65Gray, space, &context.globals.color_functions, diff --git a/crates/typst-pdf/src/lib.rs b/crates/typst-pdf/src/lib.rs index 4b3091d9c..2477f3123 100644 --- a/crates/typst-pdf/src/lib.rs +++ b/crates/typst-pdf/src/lib.rs @@ -1,22 +1,22 @@ //! Exporting of Typst documents into PDFs. -mod catalog; -mod color; +mod catalog_old; +mod color_old; mod color_font; -mod content; -mod extg; -mod font; -mod gradient; +mod content_old; +mod extg_old; +mod font_old; +mod gradient_old; mod image; mod image_old; mod krilla; -mod named_destination; -mod outline; -mod page; +mod named_destination_old; +mod outline_old; +mod page_old; mod paint; -mod pattern; +mod pattern_old; mod primitive; -mod resources; +mod resources_old; use std::collections::HashMap; use std::fmt::{self, Debug, Formatter}; @@ -35,17 +35,17 @@ use typst_library::visualize::Image; use typst_syntax::Span; use typst_utils::Deferred; -use crate::catalog::write_catalog; -use crate::color::{alloc_color_functions_refs, ColorFunctionRefs}; +use crate::catalog_old::write_catalog; +use crate::color_old::{alloc_color_functions_refs, ColorFunctionRefs}; use crate::color_font::{write_color_fonts, ColorFontSlice}; -use crate::extg::{write_graphic_states, ExtGState}; -use crate::font::write_fonts; -use crate::gradient::{write_gradients, PdfGradient}; +use crate::extg_old::{write_graphic_states, ExtGState}; +use crate::font_old::write_fonts; +use crate::gradient_old::{write_gradients, PdfGradient}; use crate::image_old::write_images; -use crate::named_destination::{write_named_destinations, NamedDestinations}; -use crate::page::{alloc_page_refs, traverse_pages, write_page_tree, EncodedPage}; -use crate::pattern::{write_patterns, PdfPattern}; -use crate::resources::{ +use crate::named_destination_old::{write_named_destinations, NamedDestinations}; +use crate::page_old::{alloc_page_refs, traverse_pages, write_page_tree, EncodedPage}; +use crate::pattern_old::{write_patterns, PdfPattern}; +use crate::resources_old::{ alloc_resources_refs, write_resource_dictionaries, Resources, ResourcesRefs, }; diff --git a/crates/typst-pdf/src/named_destination.rs b/crates/typst-pdf/src/named_destination_old.rs similarity index 100% rename from crates/typst-pdf/src/named_destination.rs rename to crates/typst-pdf/src/named_destination_old.rs diff --git a/crates/typst-pdf/src/outline.rs b/crates/typst-pdf/src/outline_old.rs similarity index 100% rename from crates/typst-pdf/src/outline.rs rename to crates/typst-pdf/src/outline_old.rs diff --git a/crates/typst-pdf/src/page.rs b/crates/typst-pdf/src/page_old.rs similarity index 98% rename from crates/typst-pdf/src/page.rs rename to crates/typst-pdf/src/page_old.rs index 27daf6c95..648ea0dca 100644 --- a/crates/typst-pdf/src/page.rs +++ b/crates/typst-pdf/src/page_old.rs @@ -11,7 +11,7 @@ use typst_library::layout::{Abs, Page}; use typst_library::model::{Destination, Numbering}; use crate::{ - content, AbsExt, PdfChunk, PdfOptions, Resources, WithDocument, WithRefs, + content_old, AbsExt, PdfChunk, PdfOptions, Resources, WithDocument, WithRefs, WithResources, }; @@ -65,7 +65,7 @@ fn construct_page( page: &Page, ) -> SourceResult { Ok(EncodedPage { - content: content::build( + content: content_old::build( options, out, &page.frame, @@ -305,6 +305,6 @@ impl PdfPageLabelStyle { /// Data for an exported page. pub struct EncodedPage { - pub content: content::Encoded, + pub content: content_old::Encoded, pub label: Option, } diff --git a/crates/typst-pdf/src/paint.rs b/crates/typst-pdf/src/paint.rs index df4c431ab..27cd0a438 100644 --- a/crates/typst-pdf/src/paint.rs +++ b/crates/typst-pdf/src/paint.rs @@ -2,7 +2,7 @@ use krilla::geom::NormalizedF32; use typst_library::layout::Abs; -use typst_library::visualize::{ColorSpace, DashPattern, FillRule, FixedStroke, Paint}; +use typst_library::visualize::{ColorSpace, DashPattern, FillRule, FixedStroke, Paint, Pattern}; use crate::primitive::{linecap, linejoin}; use crate::AbsExt; @@ -62,3 +62,7 @@ fn fill_rule(fill_rule: FillRule) -> krilla::path::FillRule { FillRule::EvenOdd => krilla::path::FillRule::EvenOdd, } } + +fn pattern(pattern: &Pattern) -> krilla::paint::Pattern { + +} \ No newline at end of file diff --git a/crates/typst-pdf/src/pattern.rs b/crates/typst-pdf/src/pattern_old.rs similarity index 91% rename from crates/typst-pdf/src/pattern.rs rename to crates/typst-pdf/src/pattern_old.rs index ddc22fbd6..f6ec01d17 100644 --- a/crates/typst-pdf/src/pattern.rs +++ b/crates/typst-pdf/src/pattern_old.rs @@ -8,9 +8,9 @@ use typst_library::layout::{Abs, Ratio, Transform}; use typst_library::visualize::{Pattern, RelativeTo}; use typst_utils::Numeric; -use crate::color::PaintEncode; -use crate::resources::{Remapper, ResourcesRefs}; -use crate::{content, transform_to_array, PdfChunk, Resources, WithGlobalRefs}; +use crate::color_old::PaintEncode; +use crate::resources_old::{Remapper, ResourcesRefs}; +use crate::{content_old, transform_to_array, PdfChunk, Resources, WithGlobalRefs}; /// Writes the actual patterns (tiling patterns) to the PDF. /// This is performed once after writing all pages. @@ -80,10 +80,10 @@ pub struct PdfPattern { /// Registers a pattern with the PDF. fn register_pattern( - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, pattern: &Pattern, on_text: bool, - mut transforms: content::Transforms, + mut transforms: content_old::Transforms, ) -> SourceResult { let patterns = ctx .resources @@ -105,7 +105,7 @@ fn register_pattern( }; // Render the body. - let content = content::build( + let content = content_old::build( ctx.options, &mut patterns.resources, pattern.frame(), @@ -125,9 +125,9 @@ fn register_pattern( impl PaintEncode for Pattern { fn set_as_fill( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, on_text: bool, - transforms: content::Transforms, + transforms: content_old::Transforms, ) -> SourceResult<()> { ctx.reset_fill_color_space(); @@ -142,9 +142,9 @@ impl PaintEncode for Pattern { fn set_as_stroke( &self, - ctx: &mut content::Builder, + ctx: &mut content_old::Builder, on_text: bool, - transforms: content::Transforms, + transforms: content_old::Transforms, ) -> SourceResult<()> { ctx.reset_stroke_color_space(); diff --git a/crates/typst-pdf/src/resources.rs b/crates/typst-pdf/src/resources_old.rs similarity index 98% rename from crates/typst-pdf/src/resources.rs rename to crates/typst-pdf/src/resources_old.rs index 12aa87e6e..22e7e0f5b 100644 --- a/crates/typst-pdf/src/resources.rs +++ b/crates/typst-pdf/src/resources_old.rs @@ -4,7 +4,7 @@ //! a PDF reference. Each [content stream] is associated with a resource dictionary. //! The identifiers defined in the resources can then be used in content streams. //! -//! [content stream]: `crate::content` +//! [content stream]: `crate::content_old` use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; @@ -18,12 +18,12 @@ use typst_library::visualize::Image; use typst_syntax::Span; use typst_utils::Deferred; -use crate::color::ColorSpaces; +use crate::color_old::ColorSpaces; use crate::color_font::ColorFontMap; -use crate::extg::ExtGState; -use crate::gradient::PdfGradient; +use crate::extg_old::ExtGState; +use crate::gradient_old::PdfGradient; use crate::image_old::EncodedImage; -use crate::pattern::PatternRemapper; +use crate::pattern_old::PatternRemapper; use crate::{PdfChunk, Renumber, WithEverything, WithResources}; /// All the resources that have been collected when traversing the document.