fschutt / printpdf

An easy-to-use library for writing PDF in Rust
https://docs.rs/printpdf/
MIT License
777 stars 95 forks source link

[Feature suggestion]Vertical text #139

Open JustFrederik opened 1 year ago

JustFrederik commented 1 year ago

Will you implement vertical text. I dont mean rotate, but like the example: Example

I know it could be acieved by creating for each char a new line and create a new text section for every line, but this would be tedious.

fschutt commented 1 year ago

No, this is easier: positioning characters in PDF is done on a character-by-character basis, so you just need to figure out the correct x and y positions and decode them from the font shaper (allsorts). I don't know how to do that however.

JustFrederik commented 1 year ago

Yeah that’s right, but be a useful feature the set the text orientation. Vertical and horizontal alignment would be a useful addition.

JustFrederik commented 1 year ago

azul-text-layout could be used to calculate the the positions of each char

JustFrederik commented 1 year ago

there is actually this in font.rs

let w = {
            if self.vertical_writing {
                ("W2", Array(widths_list))
            } else {
                ("W", Array(widths_list))
            }
        };

its on line 492 and it seems like vertical writing is implemented or an attempt of that, but no way to set that vertical writing to true and alignment is already planed(after readme)