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

♻️ Decouple layout from PDF lib types #52

Merged
merged 1 commit into from
Jun 18, 2023
Merged

♻️ Decouple layout from PDF lib types #52

merged 1 commit into from
Jun 18, 2023

Conversation

ralfstx
Copy link
Member

@ralfstx ralfstx commented May 28, 2023

The layout phase relied on the pdf-lib types PDFFont and PDFImage. In preparation of loading font and image resources on demand, this commit decouples the layout process from these PDF lib types and uses only Font and Image during layout.

Fonts are now only loaded, i.e. the fontkit font is being created before layout, since we need fontkit to calculate sizes. In the render phase, the fonts are embedded into the PDF. Likewise, images are loaded before layout to get their size, and embedded into the PDF in the render phase. During render, the PDF ref is attached to the Font and Image instances.

@ralfstx ralfstx force-pushed the decouple-layout branch 3 times, most recently from fafbe45 to 0e7af3b Compare June 18, 2023 12:55
The layout phase relied on the `pdf-lib` types `PDFFont` and `PDFImage`.
These types can only be created by embedding a font or an image into the
PDF. In preparation of loading font and image resources on demand, this
commit decouples the layout process from these `pdf-lib` types and uses
only `Font` and `Image` during layout.

Before layout, fonts are now only *loaded*, i.e. the `fontkit` font is
being created. To calculate text sizes, the layout now relies only on
`fontkit` instead of a `PDFFont` instance. The fonts are embedded into
the PDF only in the render phase.

Likewise, images are loaded before layout and embedded into the PDF in
the render phase. They need to be loaded in advance to get their size.
@ralfstx ralfstx merged commit cadc751 into main Jun 18, 2023
@ralfstx ralfstx deleted the decouple-layout branch June 18, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant