QuestPDF / QuestPDF

QuestPDF is a modern open-source .NET library for PDF document generation. Offering comprehensive layout engine powered by concise and discoverable C# Fluent API. Easily generate PDF reports, invoices, exports, etc.
https://www.questpdf.com
Other
11.95k stars 630 forks source link

Lineheight is not respected when generated in linux #243

Open koo9 opened 2 years ago

koo9 commented 2 years ago

Describe the bug Lineheight is not respected when running in linux

To Reproduce Compare the generated pdf in windows and linux.

Expected behavior Lineheight should be the same when generated in linux

Screenshots https://1drv.ms/u/s!Atfkc5kdKg4AokWlPcMTN_CVliZs?e=c3dw8g

Additional context running the app in kubernetes container in linux

kyugoa commented 2 years ago

Turned out the lineheight ratio is treated differently in linux and windows. if LineHeight = 1.2f in widows, it's approximately 1.4f in linux. so the pdf generated in linux does not look the same as that in windows. (great library for genrating pdf BTW).

MarcinZiabek commented 2 years ago

@kyugoa This is strange... I am using the SkiaSharp API to extract the LineHeight property from the font file. I suspect that fonts registered within operating systems (Linux vs Windows) have different values for LineHeight property. And this is the root cause of the not consistent results.

What you can try: include the font file with your project (as a separate file or as an embedded resource) and then load the file using the FontManager API.

koo9 commented 2 years ago

that's what I did, I include the font files and register them on startup. seeing different lineheights from windows and linux. could it be the two operating systems treat lineheight differently from the font file?

MarcinZiabek commented 2 years ago

If you have loaded the font from a specific file, I doubt that this is connected to the operating system. This looks like a SkiaSharp bug. Notice: SkiaSharp uses different native assets dependending on the OS. Maybe there are some subtle differences?

kyugoa commented 2 years ago

that make sense. will find out if there is an existing bug logged on Skiasharp. thx

MarcinZiabek commented 2 years ago

There is one more active issue with very similar problem. This is the proof that we are not mad 😅

If the newest SkiaSharp version (2.88.x) does not work, would you like to create a bug report on the SkiaSharp repository?

kyugoa commented 2 years ago

do you mean this issue? https://github.com/mono/SkiaSharp/issues/838 looks like it's logged a few years back but it's still not addressed.

ingridlarssen commented 1 year ago

Did you find a solution to this problem? Having the same problem with mac vs Linux @kyugoa

kyugoa commented 1 year ago

no, looks like the bug is not addressed, what you can do is to adjust the line height with a ratio for Linux (by trial and error)