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 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);

View File

@ -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,

View File

@ -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(_) => {

View File

@ -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.

View File

@ -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() {

View File

@ -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,

View File

@ -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,
};

View File

@ -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<EncodedPage> {
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<PdfPageLabel>,
}

View File

@ -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 {
}

View File

@ -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<usize> {
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();

View File

@ -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.