flyingsaucerproject / flyingsaucer

XML/XHTML and CSS 2.1 renderer in pure Java
Other
1.95k stars 549 forks source link

Underline text decoration with Liberation Sans too thick #319

Open smfukaya opened 2 months ago

smfukaya commented 2 months ago

Hi,

Flying Saucer 9.7.2 is producing a very thick underline text decoration from an HTML with a "underline" element (<u></u>) using Liberation Sans (it has a underline thickness of 150 — tested with 2.00.5 and 2.1.5 that I built myself).

20240505_124856-Flying Saucer 9 7 2 - Liberation Sans - very thick underline

I compared it to Open HTML to PDF 1.0.10 and found out that it hard codes the underline thickness to 50 in order to produce a more pleasant decoration.

20240505_124911-Open HTML to PDF 1 0 10 - hard-coded underline thickness

Could you please confirm if the Flying Saucer behavior is expected and if so could you advise me on any workaround.

Best regards, Sergio

asolntsev commented 2 months ago

@smfukaya I don't the background of underline sickness, but I see "50" is hardcoded in FS code:

image

Also, I see that FS can read this number from the font definition (*.ttf files).

smfukaya commented 2 months ago

Hi @asolntsev ,

Thank you for your quick reply. The problem is that, at runtime, the default thickness value is being overridden by Liberation Sans 150 value for thickness.

FontForge: Liberation Sans 2.00.5

20240505_134753-FontForge - Liberation Sans v2 00 5 - Underline Thickness

FontForge: Liberation Sans 2.1.5

20240505_135005-FontForge - Liberation Sans v2 1 5 - Underline Thickness

Best Regards, Sergio