Replace typst-based pdf creation with custom one#52
Conversation
There was a problem hiding this comment.
I think this works but it's pretty messy.
One thing that could help would be storing state in a struct and instead doing function calls as methods on this struct.
I think we can merge this and leave cleaning as an issue if we want, but there is definitely a lot that can be done to make this clearer to understand.
If we decide to merge I can circle back to cleaning thins up a bit in a week or so.
| let bold_italic_data: Arc<dyn AsRef<[u8]> + Send + Sync> = Arc::new(FONTS[3]); | ||
| let mut document = Document::new(); | ||
|
|
||
| let fonts = FontFamily { |
There was a problem hiding this comment.
We should set the FontFamily when creating the PdfExporter. In the future this can allow us to make it easy for a user to provide their own font.
There was a problem hiding this comment.
I think this is something we can look into in the future, but right now I think we should stay to this batteries included approach.
|
|
||
| /// The different ways to break a line into multiple lines. | ||
| #[derive(Debug, PartialEq, Eq, Clone, Hash)] | ||
| enum BreakType { |
There was a problem hiding this comment.
Perhaps this should move to its own file. Makes it easier if someone wants to re-use the logic for layouting.
| /// Appends a [`RichString`] to self. Will not merge the last [`Element`] of self, and the | ||
| /// first of the other even if they have the same style attributes. | ||
| pub fn append(&mut self, mut other: Self) { | ||
| self.elements.append(&mut other.elements); | ||
| } |
There was a problem hiding this comment.
I think this should merge last Element of self, and the first of other if they have the same style. This is an invariant of the RichString and it's nice to maintain it. Although, not crucial.
| } | ||
| } | ||
|
|
||
| impl Display for RichString { |
There was a problem hiding this comment.
I feel like it would be more accurate for Display to add back the delimiters to produce a String that can be parsed to the same RichString. Such that,
let a: RichString;
assert_eq!(a, RichString::from(&a.toString()))|
|
||
| /// An intermediate iterator which allows for seamless iteration over the [Chars] inside a | ||
| /// [`RichString`]. | ||
| pub struct RichIterator<'a> { |
There was a problem hiding this comment.
This should probably also return the Attributes affecting the given char.
There was a problem hiding this comment.
Attributes are not public, so I won't do this.
Co-authored-by: Emil Hultcrantz <90456354+Frequinzy@users.noreply.github.com>
Fixes #30. Replaces the typst-based pdf exporter with a krilla-based one, with an entirely custom built layout engine specifically built to create screenplays. This also removes the typst exporting option, as it was only ever really an intermediate step to create pdfs and I don't see any real argument to keeping it, now that the pdf generation no longer relies on it.
The new pdf generation works incredibly (blazing perhaps?) fast, and removing the typst dependency has also significantly reduced the number of dependencies we use, and thereby significantly reduced the build time for Rustwell.