Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another approach to full bleed printing, paper/sheet size, and pdf refactoring #1853

Merged

Conversation

Omikhleia
Copy link
Member

@Omikhleia Omikhleia commented Aug 24, 2023

Freshly backported from Omikhleia/silex.sile#2 (you can see some new visuals there), proposed for inclusion upstream here1

This is a new take at #1439, reusing some of the ideas from my earlier attempt #1470 -- There are a few "slightly" breaking changes (notably on the cropmarks package), although nothing worse that in that previous attempt.

The main differences with the previous attempt are that the frames are not impacted in this solution, and the frames coordinates are de-correlated from those used by the outputter.

  • It's simpler and safer
  • After all, bleed and sheet size are output concepts2

Another (minor) differences is that I went for different base class options (which sound much better, I think, and less intrusive in the existing code base).

Achievements:

Other details and fixes:

  • Closes cropmarks package is broken #1285 - new working implementation of the cropmarks package (:warning: commands and behavior changed)
  • Closes Starts addressing Setup pdf package to work with other backends #902 - pdf package now delegates to the outputter3
    • Also refactored the url package so it doesn't have to check which outputter is used
  • Closes Refactor rotate package to move backend specific code into backend #916 - rotate package now delegates to the outputter
  • Updates the scalebox package to also delegate the lower-level pdf calls to the outputter
  • Fixes a bug in the typesetter when -d hboxes is used, the debug hbox could be misplaced
  • Fixes a bug in the pdf packages, the metadata and bookmarks do not need to be wrapped in a hbox (avoiding the box prevents side-effects with paragraph indents and spread / odd page opening logic...)

Other noteworthy comments:

Footnotes

  1. Is it a reasonable request to ask for it to be considered for 0.15? Note by the way the deprecation warning in the cropmarks package currently assuming it. I'd be happy if 0.15 could also bring some cool typography features (such as this one and the automated italic correction).

  2. In PDF, we may eventually want to consider filling the CropBox, TrimBox, BleedBox etc. properties (but the current libtexpdf wrappers only sets the MediaBox). In other outputters, the concept might not be meaningful and be ignored. In debug outputter, the frame coordinates remain unchanged, relative to the page, which is best IMHO.

  3. Except for the seldom used \pdf:literal command, I have annotated the rationale in the code.

  4. I have some understanding why the issue occurs, but this is far beyond my current reach to address it.

…g, cropmarks, background

Decorrelate frame cursor position from actual outputter cursor.
Add base class options (bleed, sheetsize)
Move most of the direct low-level libtexpdf call to the outputter.
@Omikhleia Omikhleia added the enhancement Software improvement or feature request label Sep 5, 2023
@Omikhleia Omikhleia added this to the v0.15.0 milestone Sep 5, 2023
@Omikhleia
Copy link
Member Author

Omikhleia commented Sep 21, 2023

Erm:

Fixes a bug in the pdf packages, the metadata and bookmarks do not need to be wrapped in a hbox (avoiding the box prevents side-effects with paragraph indents and spread / odd page opening logic...)

Perhaps a bad move, esp. for bookmarks. I'll revert that bit.

--> EDIT: Done

@Omikhleia Omikhleia marked this pull request as draft September 21, 2023 18:03
@Omikhleia Omikhleia force-pushed the feat-new-approach-refactor-pdf branch from d365af8 to 1d3d557 Compare October 5, 2023 18:13
@Omikhleia Omikhleia force-pushed the feat-new-approach-refactor-pdf branch from 1d3d557 to 6f8a022 Compare October 5, 2023 18:15
@Omikhleia Omikhleia marked this pull request as ready for review October 5, 2023 18:19
@Omikhleia Omikhleia mentioned this pull request Nov 18, 2023
3 tasks
@Omikhleia
Copy link
Member Author

Hey @jodros the conflicts here are due to the introduction of the landscape option. But with two or three page size related options in this proposal, I'm unsure how to interpret landscape, now... Your opinion on how to solve it would be welcome.

(Let's admit it, the most important option for me is bleed -- because when going to use POD services such as Lulu.com, a 0.25in bleed is ideally requested.)

@Omikhleia
Copy link
Member Author

BTW, I did mention #1892 that it would break here. I asked there for a discussion that never came. Thats's ok, but how do we move forward? I've no idea :)

@jodros
Copy link
Contributor

jodros commented Nov 23, 2023

Hey @jodros the conflicts here are due to the introduction of the landscape option. But with two or three page size related options in this proposal, I'm unsure how to interpret landscape, now... Your opinion on how to solve it would be welcome.

Hello, I took a brief look at your code, mostly the base class, so I'd like to know whether there are others conflicting parts besides the class:setOptions?

@Omikhleia
Copy link
Member Author

Hello, I took a brief look at your code, mostly the base class, so I'd like to know whether there are others conflicting parts besides the class:setOptions?

Well besides the coding, the question is that the PR proposes sheetsize and bleed in addition to papersize -- the sheet size defaults to the paper size plus possibly the bleed, and can be set to a specified size again augmented by the bleed if needed. For instance,

  • papersize=6in x 9in, bleed=0.25in is what I'd use for a US trade book sent to Lulu POD
  • papersize=6in x 9in, papersize=a4 is what I'd use (likely with cropmarks) for a pre-print on my home printer.

With a single landscape=true option now, I wonder how it should be interpreted. Would it apply to the paper size, or both the paper size and sheet size? Consider for instance papersize=a6, landscape=true, sheetsize=a4... There would be no need for the sheet size to be in landscape.

@jodros
Copy link
Contributor

jodros commented Nov 26, 2023

Well, I'm not sure whether I understood the problem, but here is what I tested right now:

Consider for instance papersize=a6, landscape=true, sheetsize=a4... There would be no need for the sheet size to be in landscape.

In your example indeed there would be no need for that, as we can see:

изображение

But what if the user just want to have this document with an a5 paper size as well? We'd have the following:

изображение

But if we add the landscape option to sheet size

SILE.documentState.sheetSize = SILE.papersize(size, self.options.landscape)

We'd have:

изображение

This last one matches better with your purpose, right?

@jodros
Copy link
Contributor

jodros commented Nov 26, 2023

BTW, I did mention #1892 that it would break here. I asked there for a discussion that never came.

I apologize about that, #1892 was my first PR ever so I was too much focused in merging it that didn't paid attention to this point at the time.

@Omikhleia
Copy link
Member Author

Well, I'm not sure whether I understood the problem, but here is what I tested right now

Can you possibly post your diff? I could try and check.

@jodros
Copy link
Contributor

jodros commented Nov 27, 2023

Can you possibly post your diff? I could try and check.

diff --git a/classes/base.lua b/classes/base.lua
index d73b5ac6..d013a579 100644
--- a/classes/base.lua
+++ b/classes/base.lua
@@ -85,9 +85,8 @@ function class:setOptions (options)
   options.landscape = nil
   self.options.papersize = options.papersize or "a4"
   options.papersize = nil
-  options.papersize = options.papersize or "a4"
   options.bleed = options.bleed or "0"
-  
+
   for option, value in pairs(options) do
     self.options[option] = value
   end
@@ -152,7 +151,8 @@ function class:declareOptions ()
   self:declareOption("sheetsize", function (_, size)
     if size then
       self.sheetsize = size
-      SILE.documentState.sheetSize = SILE.papersize(size)
+      -- SILE.documentState.sheetSize = SILE.papersize(size)
+      SILE.documentState.sheetSize = SILE.papersize(size, self.options.landscape)
     end
     return self.sheetsize
   end)

@alerque alerque changed the base branch from master to develop December 6, 2023 12:30
packages/cropmarks/init.lua Outdated Show resolved Hide resolved
@alerque alerque force-pushed the feat-new-approach-refactor-pdf branch from d7c491b to ff5f86f Compare December 13, 2023 12:26
@alerque
Copy link
Member

alerque commented Dec 13, 2023

I just took a stab at ⓐ resolving the merge conflicts to integrate the landscape option and ⓑ cleaning up a few tidbits I noticed in review. How are we looking?

@alerque alerque force-pushed the feat-new-approach-refactor-pdf branch from ff5f86f to 8fd8be5 Compare December 16, 2023 22:48
@alerque
Copy link
Member

alerque commented Jan 4, 2024

This does not actually close #902, but it does start down that road. I'm working on finishing that up in another branch.

@Omikhleia
Copy link
Member Author

Omikhleia commented Jan 4, 2024

This does not actually close #902, but it does start down that road. I'm working on finishing that up in another branch.

It should have, i had rotate, links etc. working in my "draft" HTML outputter with no problem. If I can help, let me know, perhaps indeed I didn't address the debug backend?

Copy link
Member

@alerque alerque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks like a good start. There is some more refactoring I want to do to add hooks to the outputters so packages can do more, but also move more backend specific logic out of packages. But in messing with it I think it makes sense to just start with this and move on rather than trying to refactor these commits.

@alerque alerque merged commit 9ef72e4 into sile-typesetter:develop Jan 6, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Software improvement or feature request
Projects
None yet
3 participants