Rename old files

This commit is contained in:
Laurenz Stampfl 2024-12-02 23:46:01 +01:00
parent 8490ee4ff4
commit 237c696292
15 changed files with 81 additions and 77 deletions

View File

@ -11,8 +11,8 @@ use typst_library::text::Lang;
use typst_syntax::Span; use typst_syntax::Span;
use xmp_writer::{DateTime, LangId, RenditionClass, Timezone, XmpWriter}; use xmp_writer::{DateTime, LangId, RenditionClass, Timezone, XmpWriter};
use crate::page::PdfPageLabel; use crate::page_old::PdfPageLabel;
use crate::{hash_base64, outline, TextStrExt, WithEverything}; use crate::{hash_base64, outline_old, TextStrExt, WithEverything};
/// Write the document catalog. /// Write the document catalog.
pub fn write_catalog( pub fn write_catalog(
@ -34,7 +34,7 @@ pub fn write_catalog(
}; };
// Write the outline tree. // 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. // Write the page labels.
let page_labels = write_page_labels(pdf, alloc, &ctx); let page_labels = write_page_labels(pdf, alloc, &ctx);

View File

@ -18,9 +18,9 @@ use typst_library::layout::Em;
use typst_library::text::color::glyph_frame; use typst_library::text::color::glyph_frame;
use typst_library::text::{Font, Glyph, TextItemView}; use typst_library::text::{Font, Glyph, TextItemView};
use crate::font::{base_font_name, write_font_descriptor, CMAP_NAME, SYSTEM_INFO}; use crate::font_old::{base_font_name, write_font_descriptor, CMAP_NAME, SYSTEM_INFO};
use crate::resources::{Resources, ResourcesRefs}; use crate::resources_old::{Resources, ResourcesRefs};
use crate::{content, EmExt, PdfChunk, PdfOptions, WithGlobalRefs}; use crate::{content_old, EmExt, PdfChunk, PdfOptions, WithGlobalRefs};
/// Write color fonts in the PDF document. /// Write color fonts in the PDF document.
/// ///
@ -190,7 +190,7 @@ pub struct ColorGlyph {
/// The ID of the glyph. /// The ID of the glyph.
pub gid: u16, pub gid: u16,
/// Instructions to draw the glyph. /// Instructions to draw the glyph.
pub instructions: content::Encoded, pub instructions: content_old::Encoded,
} }
impl ColorFontMap<()> { impl ColorFontMap<()> {
@ -250,7 +250,7 @@ impl ColorFontMap<()> {
let width = font.advance(glyph.id).unwrap_or(Em::new(0.0)).get() let width = font.advance(glyph.id).unwrap_or(Em::new(0.0)).get()
* font.units_per_em(); * font.units_per_em();
let instructions = content::build( let instructions = content_old::build(
options, options,
&mut self.resources, &mut self.resources,
&frame, &frame,

View File

@ -6,7 +6,7 @@ use typst_library::diag::{bail, SourceResult};
use typst_library::visualize::{Color, ColorSpace, Paint}; use typst_library::visualize::{Color, ColorSpace, Paint};
use typst_syntax::Span; 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. // The names of the color spaces.
pub const SRGB: Name<'static> = Name(b"srgb"); pub const SRGB: Name<'static> = Name(b"srgb");
@ -198,26 +198,26 @@ pub(super) trait PaintEncode {
/// Set the paint as the fill color. /// Set the paint as the fill color.
fn set_as_fill( fn set_as_fill(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
on_text: bool, on_text: bool,
transforms: content::Transforms, transforms: content_old::Transforms,
) -> SourceResult<()>; ) -> SourceResult<()>;
/// Set the paint as the stroke color. /// Set the paint as the stroke color.
fn set_as_stroke( fn set_as_stroke(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
on_text: bool, on_text: bool,
transforms: content::Transforms, transforms: content_old::Transforms,
) -> SourceResult<()>; ) -> SourceResult<()>;
} }
impl PaintEncode for Paint { impl PaintEncode for Paint {
fn set_as_fill( fn set_as_fill(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
on_text: bool, on_text: bool,
transforms: content::Transforms, transforms: content_old::Transforms,
) -> SourceResult<()> { ) -> SourceResult<()> {
match self { match self {
Self::Solid(c) => c.set_as_fill(ctx, on_text, transforms), Self::Solid(c) => c.set_as_fill(ctx, on_text, transforms),
@ -228,9 +228,9 @@ impl PaintEncode for Paint {
fn set_as_stroke( fn set_as_stroke(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
on_text: bool, on_text: bool,
transforms: content::Transforms, transforms: content_old::Transforms,
) -> SourceResult<()> { ) -> SourceResult<()> {
match self { match self {
Self::Solid(c) => c.set_as_stroke(ctx, on_text, transforms), Self::Solid(c) => c.set_as_stroke(ctx, on_text, transforms),
@ -243,9 +243,9 @@ impl PaintEncode for Paint {
impl PaintEncode for Color { impl PaintEncode for Color {
fn set_as_fill( fn set_as_fill(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
_: bool, _: bool,
_: content::Transforms, _: content_old::Transforms,
) -> SourceResult<()> { ) -> SourceResult<()> {
match self { match self {
Color::Luma(_) => { Color::Luma(_) => {
@ -287,9 +287,9 @@ impl PaintEncode for Color {
fn set_as_stroke( fn set_as_stroke(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
_: bool, _: bool,
_: content::Transforms, _: content_old::Transforms,
) -> SourceResult<()> { ) -> SourceResult<()> {
match self { match self {
Color::Luma(_) => { Color::Luma(_) => {

View File

@ -25,11 +25,11 @@ use typst_library::visualize::{
use typst_syntax::Span; use typst_syntax::Span;
use typst_utils::{Deferred, Numeric, SliceExt}; use typst_utils::{Deferred, Numeric, SliceExt};
use crate::color::PaintEncode; use crate::color_old::PaintEncode;
use crate::color_font::ColorFontMap; use crate::color_font::ColorFontMap;
use crate::extg::ExtGState; use crate::extg_old::ExtGState;
use crate::image_old::deferred_image; use crate::image_old::deferred_image;
use crate::resources::Resources; use crate::resources_old::Resources;
use crate::{deflate_deferred, AbsExt, ContentExt, EmExt, PdfOptions, StrExt}; use crate::{deflate_deferred, AbsExt, ContentExt, EmExt, PdfOptions, StrExt};
/// Encode a [`Frame`] into a content stream. /// Encode a [`Frame`] into a content stream.

View File

@ -13,10 +13,10 @@ use typst_library::visualize::{
}; };
use typst_utils::Numeric; use typst_utils::Numeric;
use crate::color::{ use crate::color_old::{
self, check_cmyk_allowed, ColorSpaceExt, PaintEncode, QuantizedColor, 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 /// A unique-transform-aspect-ratio combination that will be encoded into the
/// PDF. /// PDF.
@ -69,7 +69,7 @@ pub fn write_gradients(
let mut shading = shading_pattern.function_shading(); let mut shading = shading_pattern.function_shading();
shading.shading_type(FunctionShadingType::Axial); shading.shading_type(FunctionShadingType::Axial);
color::write( color_old::write(
color_space, color_space,
shading.color_space(), shading.color_space(),
&context.globals.color_functions, &context.globals.color_functions,
@ -106,7 +106,7 @@ pub fn write_gradients(
let mut shading = shading_pattern.function_shading(); let mut shading = shading_pattern.function_shading();
shading.shading_type(FunctionShadingType::Radial); shading.shading_type(FunctionShadingType::Radial);
color::write( color_old::write(
color_space, color_space,
shading.color_space(), shading.color_space(),
&context.globals.color_functions, &context.globals.color_functions,
@ -136,7 +136,7 @@ pub fn write_gradients(
let mut stream_shading = let mut stream_shading =
chunk.chunk.stream_shading(stream_shading_id, &vertices); chunk.chunk.stream_shading(stream_shading_id, &vertices);
color::write( color_old::write(
color_space, color_space,
stream_shading.color_space(), stream_shading.color_space(),
&context.globals.color_functions, &context.globals.color_functions,
@ -251,9 +251,9 @@ fn single_gradient(
impl PaintEncode for Gradient { impl PaintEncode for Gradient {
fn set_as_fill( fn set_as_fill(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
on_text: bool, on_text: bool,
transforms: content::Transforms, transforms: content_old::Transforms,
) -> SourceResult<()> { ) -> SourceResult<()> {
ctx.reset_fill_color_space(); ctx.reset_fill_color_space();
@ -268,9 +268,9 @@ impl PaintEncode for Gradient {
fn set_as_stroke( fn set_as_stroke(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
on_text: bool, on_text: bool,
transforms: content::Transforms, transforms: content_old::Transforms,
) -> SourceResult<()> { ) -> SourceResult<()> {
ctx.reset_stroke_color_space(); ctx.reset_stroke_color_space();
@ -286,10 +286,10 @@ impl PaintEncode for Gradient {
/// Deduplicates a gradient to a named PDF resource. /// Deduplicates a gradient to a named PDF resource.
fn register_gradient( fn register_gradient(
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
gradient: &Gradient, gradient: &Gradient,
on_text: bool, on_text: bool,
mut transforms: content::Transforms, mut transforms: content_old::Transforms,
) -> usize { ) -> usize {
// Edge cases for strokes. // Edge cases for strokes.
if transforms.size.x.is_zero() { if transforms.size.x.is_zero() {

View File

@ -10,7 +10,7 @@ use typst_library::visualize::{
}; };
use typst_utils::Deferred; use typst_utils::Deferred;
use crate::{color, deflate, PdfChunk, WithGlobalRefs}; use crate::{color_old, deflate, PdfChunk, WithGlobalRefs};
/// Embed all used images into the PDF. /// Embed all used images into the PDF.
#[typst_macros::time(name = "write images")] #[typst_macros::time(name = "write images")]
@ -54,13 +54,13 @@ pub fn write_images(
space.icc_based(id); space.icc_based(id);
icc_ref = Some(id); icc_ref = Some(id);
} else if *has_color { } else if *has_color {
color::write( color_old::write(
ColorSpace::Srgb, ColorSpace::Srgb,
space, space,
&context.globals.color_functions, &context.globals.color_functions,
); );
} else { } else {
color::write( color_old::write(
ColorSpace::D65Gray, ColorSpace::D65Gray,
space, space,
&context.globals.color_functions, &context.globals.color_functions,

View File

@ -1,22 +1,22 @@
//! Exporting of Typst documents into PDFs. //! Exporting of Typst documents into PDFs.
mod catalog; mod catalog_old;
mod color; mod color_old;
mod color_font; mod color_font;
mod content; mod content_old;
mod extg; mod extg_old;
mod font; mod font_old;
mod gradient; mod gradient_old;
mod image; mod image;
mod image_old; mod image_old;
mod krilla; mod krilla;
mod named_destination; mod named_destination_old;
mod outline; mod outline_old;
mod page; mod page_old;
mod paint; mod paint;
mod pattern; mod pattern_old;
mod primitive; mod primitive;
mod resources; mod resources_old;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
@ -35,17 +35,17 @@ use typst_library::visualize::Image;
use typst_syntax::Span; use typst_syntax::Span;
use typst_utils::Deferred; use typst_utils::Deferred;
use crate::catalog::write_catalog; use crate::catalog_old::write_catalog;
use crate::color::{alloc_color_functions_refs, ColorFunctionRefs}; use crate::color_old::{alloc_color_functions_refs, ColorFunctionRefs};
use crate::color_font::{write_color_fonts, ColorFontSlice}; use crate::color_font::{write_color_fonts, ColorFontSlice};
use crate::extg::{write_graphic_states, ExtGState}; use crate::extg_old::{write_graphic_states, ExtGState};
use crate::font::write_fonts; use crate::font_old::write_fonts;
use crate::gradient::{write_gradients, PdfGradient}; use crate::gradient_old::{write_gradients, PdfGradient};
use crate::image_old::write_images; use crate::image_old::write_images;
use crate::named_destination::{write_named_destinations, NamedDestinations}; use crate::named_destination_old::{write_named_destinations, NamedDestinations};
use crate::page::{alloc_page_refs, traverse_pages, write_page_tree, EncodedPage}; use crate::page_old::{alloc_page_refs, traverse_pages, write_page_tree, EncodedPage};
use crate::pattern::{write_patterns, PdfPattern}; use crate::pattern_old::{write_patterns, PdfPattern};
use crate::resources::{ use crate::resources_old::{
alloc_resources_refs, write_resource_dictionaries, Resources, ResourcesRefs, alloc_resources_refs, write_resource_dictionaries, Resources, ResourcesRefs,
}; };

View File

@ -11,7 +11,7 @@ use typst_library::layout::{Abs, Page};
use typst_library::model::{Destination, Numbering}; use typst_library::model::{Destination, Numbering};
use crate::{ use crate::{
content, AbsExt, PdfChunk, PdfOptions, Resources, WithDocument, WithRefs, content_old, AbsExt, PdfChunk, PdfOptions, Resources, WithDocument, WithRefs,
WithResources, WithResources,
}; };
@ -65,7 +65,7 @@ fn construct_page(
page: &Page, page: &Page,
) -> SourceResult<EncodedPage> { ) -> SourceResult<EncodedPage> {
Ok(EncodedPage { Ok(EncodedPage {
content: content::build( content: content_old::build(
options, options,
out, out,
&page.frame, &page.frame,
@ -305,6 +305,6 @@ impl PdfPageLabelStyle {
/// Data for an exported page. /// Data for an exported page.
pub struct EncodedPage { pub struct EncodedPage {
pub content: content::Encoded, pub content: content_old::Encoded,
pub label: Option<PdfPageLabel>, pub label: Option<PdfPageLabel>,
} }

View File

@ -2,7 +2,7 @@
use krilla::geom::NormalizedF32; use krilla::geom::NormalizedF32;
use typst_library::layout::Abs; 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::primitive::{linecap, linejoin};
use crate::AbsExt; use crate::AbsExt;
@ -62,3 +62,7 @@ fn fill_rule(fill_rule: FillRule) -> krilla::path::FillRule {
FillRule::EvenOdd => krilla::path::FillRule::EvenOdd, FillRule::EvenOdd => krilla::path::FillRule::EvenOdd,
} }
} }
fn pattern(pattern: &Pattern) -> krilla::paint::Pattern {
}

View File

@ -8,9 +8,9 @@ use typst_library::layout::{Abs, Ratio, Transform};
use typst_library::visualize::{Pattern, RelativeTo}; use typst_library::visualize::{Pattern, RelativeTo};
use typst_utils::Numeric; use typst_utils::Numeric;
use crate::color::PaintEncode; use crate::color_old::PaintEncode;
use crate::resources::{Remapper, ResourcesRefs}; use crate::resources_old::{Remapper, ResourcesRefs};
use crate::{content, transform_to_array, PdfChunk, Resources, WithGlobalRefs}; use crate::{content_old, transform_to_array, PdfChunk, Resources, WithGlobalRefs};
/// Writes the actual patterns (tiling patterns) to the PDF. /// Writes the actual patterns (tiling patterns) to the PDF.
/// This is performed once after writing all pages. /// This is performed once after writing all pages.
@ -80,10 +80,10 @@ pub struct PdfPattern {
/// Registers a pattern with the PDF. /// Registers a pattern with the PDF.
fn register_pattern( fn register_pattern(
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
pattern: &Pattern, pattern: &Pattern,
on_text: bool, on_text: bool,
mut transforms: content::Transforms, mut transforms: content_old::Transforms,
) -> SourceResult<usize> { ) -> SourceResult<usize> {
let patterns = ctx let patterns = ctx
.resources .resources
@ -105,7 +105,7 @@ fn register_pattern(
}; };
// Render the body. // Render the body.
let content = content::build( let content = content_old::build(
ctx.options, ctx.options,
&mut patterns.resources, &mut patterns.resources,
pattern.frame(), pattern.frame(),
@ -125,9 +125,9 @@ fn register_pattern(
impl PaintEncode for Pattern { impl PaintEncode for Pattern {
fn set_as_fill( fn set_as_fill(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
on_text: bool, on_text: bool,
transforms: content::Transforms, transforms: content_old::Transforms,
) -> SourceResult<()> { ) -> SourceResult<()> {
ctx.reset_fill_color_space(); ctx.reset_fill_color_space();
@ -142,9 +142,9 @@ impl PaintEncode for Pattern {
fn set_as_stroke( fn set_as_stroke(
&self, &self,
ctx: &mut content::Builder, ctx: &mut content_old::Builder,
on_text: bool, on_text: bool,
transforms: content::Transforms, transforms: content_old::Transforms,
) -> SourceResult<()> { ) -> SourceResult<()> {
ctx.reset_stroke_color_space(); ctx.reset_stroke_color_space();

View File

@ -4,7 +4,7 @@
//! a PDF reference. Each [content stream] is associated with a resource dictionary. //! 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. //! 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::collections::{BTreeMap, HashMap};
use std::hash::Hash; use std::hash::Hash;
@ -18,12 +18,12 @@ use typst_library::visualize::Image;
use typst_syntax::Span; use typst_syntax::Span;
use typst_utils::Deferred; use typst_utils::Deferred;
use crate::color::ColorSpaces; use crate::color_old::ColorSpaces;
use crate::color_font::ColorFontMap; use crate::color_font::ColorFontMap;
use crate::extg::ExtGState; use crate::extg_old::ExtGState;
use crate::gradient::PdfGradient; use crate::gradient_old::PdfGradient;
use crate::image_old::EncodedImage; use crate::image_old::EncodedImage;
use crate::pattern::PatternRemapper; use crate::pattern_old::PatternRemapper;
use crate::{PdfChunk, Renumber, WithEverything, WithResources}; use crate::{PdfChunk, Renumber, WithEverything, WithResources};
/// All the resources that have been collected when traversing the document. /// All the resources that have been collected when traversing the document.