Open moriro opened 11 months ago
Hi, thanks for reporting ! I have dug a little bit into this...
I found the issue to be that the baseline of the pango layout is slightly different when exporting to PDF (why, I do not know). Xournal++ does not align text on the baseline, so it is shifted up when the baseline is lower (lower pango y = closer to the top) than usual.
https://github.com/xournalpp/xournalpp/blob/0abf8a8f26d008299f9d06ed48a78894400a54aa/src/core/view/TextView.cpp#L21-L27
This is where the change to the baseline happens: calling pango_layout_get_baseline(layout.get())
before and after pango_cairo_update_layout(cr, layout.get())
will return different results.
Now simply removing this call to pango_cairo_update_layout()
works and resolves the issue, but doesn't feel like the correct way to do it. I think it could lead to imperfections in the rendering, but I do not know much about this.
Ideally, the font would be aligned on the baseline, such that we would always subtract the baseline from the translation, but that would move existing text. Instead we can correct for the baseline change we observe.
Operating System
Windows
(Linux only) Distribution
No response
(Linux only) Desktop Environment
No response
(Linux Only) Display Server
None
Installation Method
Official release
Xournal++ Version
1.2.2
libgtk Version
GTK: 3.24.39
Bug Description
The font size(or style? or line spacing?) will be changed in multi-line texts. I have experimented with various fonts, and it appears to be a consistent issue. This results in an offset between the text and the ink.
However, this issue does not occur when exporting to PNG/SVG or input the text via LaTeX. The problem seems to be associated with the system's PDF export method, and I have been unable to find a solution online.
Expected Behaviour
The font size(or style? or line spacing?) will be changed and offset.
Steps to Reproduce
Additional Context
Windows11 23H2 22631.2861